1 # ----------------------------------------------------------------------------
2 # Root CMake file for OpenCV
4 # From the off-tree build directory, invoke:
5 # $ cmake <PATH_TO_OPENCV_ROOT>
8 # - OCT-2008: Initial version <joseluisblancoc@gmail.com>
10 # ----------------------------------------------------------------------------
12 set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
14 # --------------------------------------------------------------
15 # Indicate CMake 2.7 and above that we don't want to mix relative
16 # and absolute paths in linker lib lists.
17 # Run "cmake --help-policy CMP0003" for more information.
18 # --------------------------------------------------------------
19 if(COMMAND cmake_policy)
20 cmake_policy(SET CMP0003 NEW)
23 # Following block can broke build in case of cross-compilng
24 # but CMAKE_CROSSCOMPILING variable will be set only on project(OpenCV) command
25 # so we will try to detect crosscompiling by presense of CMAKE_TOOLCHAIN_FILE
26 if(NOT CMAKE_TOOLCHAIN_FILE)
27 # it _must_ go before project(OpenCV) in order to work
29 set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory")
31 set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation Directory")
35 set(CMAKE_USE_RELATIVE_PATHS ON CACHE INTERNAL "" FORCE)
37 else(NOT CMAKE_TOOLCHAIN_FILE)
38 #Android: set output folder to ${CMAKE_BINARY_DIR}
39 set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_BINARY_DIR} CACHE PATH "root for library output, set this to change where android libs are compiled to" )
40 endif(NOT CMAKE_TOOLCHAIN_FILE)
42 # --------------------------------------------------------------
43 # Top level OpenCV project
44 # --------------------------------------------------------------
46 cmake_minimum_required(VERSION 2.6.3)
48 cmake_minimum_required(VERSION 2.8)
53 set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE)
54 if(DEFINED CMAKE_BUILD_TYPE AND CMAKE_VERSION VERSION_GREATER "2.8")
55 set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES} )
58 set(CMAKE_C_FLAGS_MINSIZEREL "" CACHE INTERNAL "" FORCE)
59 set(CMAKE_C_FLAGS_RELWITHDEBINFO "" CACHE INTERNAL "" FORCE)
60 set(CMAKE_CXX_FLAGS_MINSIZEREL "" CACHE INTERNAL "" FORCE)
61 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "" CACHE INTERNAL "" FORCE)
62 set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "" CACHE INTERNAL "" FORCE)
63 set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "" CACHE INTERNAL "" FORCE)
64 set(CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL "" CACHE INTERNAL "" FORCE)
65 set(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "" CACHE INTERNAL "" FORCE)
66 set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "" CACHE INTERNAL "" FORCE)
67 set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "" CACHE INTERNAL "" FORCE)
69 include(cmake/OpenCVUtils.cmake REQUIRED)
71 # ----------------------------------------------------------------------------
72 # Detect compiler and target platform architecture
73 # ----------------------------------------------------------------------------
74 include(cmake/OpenCVDetectCXXCompiler.cmake REQUIRED)
76 # Add these standard paths to the search paths for FIND_LIBRARY
77 # to find libraries from these locations first
78 if(UNIX AND NOT ANDROID)
79 if(X86_64 OR CMAKE_SIZEOF_VOID_P EQUAL 8)
81 list(APPEND CMAKE_LIBRARY_PATH /lib64)
83 list(APPEND CMAKE_LIBRARY_PATH /lib)
86 list(APPEND CMAKE_LIBRARY_PATH /usr/lib64)
88 list(APPEND CMAKE_LIBRARY_PATH /usr/lib)
90 elseif(X86 OR CMAKE_SIZEOF_VOID_P EQUAL 4)
92 list(APPEND CMAKE_LIBRARY_PATH /lib32)
94 list(APPEND CMAKE_LIBRARY_PATH /lib)
97 list(APPEND CMAKE_LIBRARY_PATH /usr/lib32)
99 list(APPEND CMAKE_LIBRARY_PATH /usr/lib)
105 # ----------------------------------------------------------------------------
106 # OpenCV cmake options
107 # ----------------------------------------------------------------------------
109 # Optional 3rd party components
110 # ===================================================
111 OCV_OPTION(WITH_1394 "Include IEEE1394 support" ON IF (UNIX AND NOT ANDROID AND NOT IOS) )
112 OCV_OPTION(WITH_AVFOUNDATION "Use AVFoundation for Video I/O" ON IF IOS)
113 OCV_OPTION(WITH_CARBON "Use Carbon for UI instead of Cocoa" OFF IF APPLE )
114 OCV_OPTION(WITH_CUBLAS "Include NVidia Cuda Basic Linear Algebra Subprograms (BLAS) library support" OFF IF (CMAKE_VERSION VERSION_GREATER "2.8" AND NOT ANDROID AND NOT IOS) )
115 OCV_OPTION(WITH_CUDA "Include NVidia Cuda Runtime support" ON IF (CMAKE_VERSION VERSION_GREATER "2.8" AND NOT ANDROID AND NOT IOS) )
116 OCV_OPTION(WITH_CUFFT "Include NVidia Cuda Fast Fourier Transform (FFT) library support" ON IF (CMAKE_VERSION VERSION_GREATER "2.8" AND NOT ANDROID AND NOT IOS) )
117 OCV_OPTION(WITH_EIGEN "Include Eigen2/Eigen3 support" ON)
118 OCV_OPTION(WITH_FFMPEG "Include FFMPEG support" ON IF (UNIX AND NOT ANDROID AND NOT IOS) )
119 OCV_OPTION(WITH_GSTREAMER "Include Gstreamer support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS) )
120 OCV_OPTION(WITH_GTK "Include GTK support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS) )
121 OCV_OPTION(WITH_IPP "Include Intel IPP support" OFF IF (MSVC OR X86 OR X86_64) )
122 OCV_OPTION(WITH_JASPER "Include JPEG2K support" ON IF (NOT IOS) )
123 OCV_OPTION(WITH_JPEG "Include JPEG support" ON IF (NOT IOS) )
124 OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ON IF (NOT IOS) )
125 OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF IF (NOT ANDROID AND NOT IOS) )
126 OCV_OPTION(WITH_OPENNI "Include OpenNI support" OFF IF (NOT ANDROID AND NOT IOS) )
127 OCV_OPTION(WITH_PNG "Include PNG support" ON IF (NOT IOS) )
128 OCV_OPTION(WITH_PVAPI "Include Prosilica GigE support" ON IF (UNIX AND NOT ANDROID AND NOT IOS) )
129 OCV_OPTION(WITH_QT "Build with Qt Backend support" OFF IF (NOT ANDROID AND NOT IOS) )
130 OCV_OPTION(WITH_QUICKTIME "Use QuickTime for Video I/O insted of QTKit" OFF IF APPLE )
131 OCV_OPTION(WITH_TBB "Include Intel TBB support" OFF IF (NOT IOS) )
132 OCV_OPTION(WITH_TIFF "Include TIFF support" ON IF (NOT IOS) )
133 OCV_OPTION(WITH_UNICAP "Include Unicap support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS) )
134 OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS) )
135 OCV_OPTION(WITH_VIDEOINPUT "Build HighGUI with DirectShow support" ON IF WIN32 )
136 OCV_OPTION(WITH_XIMEA "Include XIMEA cameras support" OFF IF WIN32 )
137 OCV_OPTION(WITH_XINE "Include Xine support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS) )
139 # OpenCV build components
140 # ===================================================
141 OCV_OPTION(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" NOT (ANDROID OR IOS) )
142 OCV_OPTION(BUILD_ANDROID_EXAMPLES "Build examples for Android platform" ON IF ANDROID )
143 OCV_OPTION(BUILD_DOCS "Create build rules for OpenCV Documentation" ON )
144 OCV_OPTION(BUILD_EXAMPLES "Build all examples" OFF )
145 OCV_OPTION(BUILD_PACKAGE "Enables 'make package_source' command" ON )
146 OCV_OPTION(BUILD_PERF_TESTS "Build performance tests" ON IF (NOT IOS) )
147 OCV_OPTION(BUILD_TESTS "Build accuracy & regression tests" ON IF (NOT IOS) )
148 OCV_OPTION(BUILD_WITH_DEBUG_INFO "Include debug info into debug libs (not MSCV only)" ON )
149 OCV_OPTION(BUILD_WITH_STATIC_CRT "Enables use of staticaly linked CRT for staticaly linked OpenCV" ON IF MSVC )
152 OCV_OPTION(BUILD_ZLIB "Build zlib from source" WIN32 OR IOS )
153 OCV_OPTION(BUILD_TIFF "Build libtiff from source" WIN32 OR IOS OR ANDROID )
154 OCV_OPTION(BUILD_JASPER "Build libjasper from source" WIN32 OR IOS OR ANDROID )
155 OCV_OPTION(BUILD_JPEG "Build libjpeg from source" WIN32 OR IOS OR ANDROID )
156 OCV_OPTION(BUILD_PNG "Build libpng from source" WIN32 OR IOS OR ANDROID )
158 # OpenCV installation options
159 # ===================================================
160 OCV_OPTION(INSTALL_C_EXAMPLES "Install C examples" OFF )
161 OCV_OPTION(INSTALL_PYTHON_EXAMPLES "Install Python examples" OFF )
162 OCV_OPTION(INSTALL_ANDROID_EXAMPLES "Install Android examples" OFF IF ANDROID )
163 OCV_OPTION(INSTALL_TO_MANGLED_PATHS "Enables mangled install paths, that help with side by side installs." OFF IF (UNIX AND NOT ANDROID AND NOT IOS AND BUILD_SHARED_LIBS) )
165 # OpenCV build options
166 # ===================================================
167 OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" ON IF (NOT IOS) )
168 OCV_OPTION(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" OFF IF (CMAKE_VERSION VERSION_GREATER "2.8.0") )
169 OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add flags: -g -pg)" OFF IF CMAKE_COMPILER_IS_GNUCXX )
170 OCV_OPTION(ENABLE_OMIT_FRAME_POINTER "Enable -fomit-frame-pointer for GCC" ON IF CMAKE_COMPILER_IS_GNUCXX )
171 OCV_OPTION(ENABLE_POWERPC "Enable PowerPC for GCC" ON IF (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES powerpc.*) )
172 OCV_OPTION(ENABLE_FAST_MATH "Enable -ffast-math (not recommended for GCC 4.6.x)" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
173 OCV_OPTION(ENABLE_SSE "Enable SSE instructions" ON IF (MSVC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
174 OCV_OPTION(ENABLE_SSE2 "Enable SSE2 instructions" ON IF (MSVC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
175 OCV_OPTION(ENABLE_SSE3 "Enable SSE3 instructions" OFF IF (CV_ICC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
176 OCV_OPTION(ENABLE_SSSE3 "Enable SSSE3 instructions" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
177 OCV_OPTION(ENABLE_SSE41 "Enable SSE4.1 instructions" OFF IF (CV_ICC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
178 OCV_OPTION(ENABLE_SSE42 "Enable SSE4.2 instructions" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
179 OCV_OPTION(OPENCV_WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF )
181 # uncategorized options
182 # ===================================================
183 OCV_OPTION(CMAKE_VERBOSE "Verbose mode" OFF )
185 # backward compatibility
186 # ===================================================
187 include(cmake/OpenCVLegacyOptions.cmake OPTIONAL)
190 # ----------------------------------------------------------------------------
191 # Get actual OpenCV version number from sources
192 # ----------------------------------------------------------------------------
193 include(cmake/OpenCVVersion.cmake REQUIRED)
196 # ----------------------------------------------------------------------------
197 # Build & install layouts
198 # ----------------------------------------------------------------------------
200 # Save libs and executables in the same place
201 set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib" CACHE PATH "Output directory for libraries" )
202 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin" CACHE PATH "Output directory for applications" )
205 set(OPENCV_DOC_INSTALL_PATH doc)
206 elseif(INSTALL_TO_MANGLED_PATHS)
207 set(OPENCV_DOC_INSTALL_PATH share/OpenCV-${OPENCV_VERSION}/doc)
209 set(OPENCV_DOC_INSTALL_PATH share/OpenCV/doc)
213 set(OPENCV_LIB_INSTALL_PATH libs/${ANDROID_NDK_ABI_NAME})
215 set(OPENCV_LIB_INSTALL_PATH lib${LIB_SUFFIX})
218 set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${OPENCV_LIB_INSTALL_PATH}")
219 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
221 set(OPENCV_INCLUDE_PREFIX include)
222 if(INSTALL_TO_MANGLED_PATHS)
223 set(OPENCV_INCLUDE_PREFIX include/opencv-${OPENCV_VERSION})
228 set(OPENCV_DLLVERSION "${OPENCV_VERSION_MAJOR}${OPENCV_VERSION_MINOR}${OPENCV_VERSION_PATCH}")
229 set(OPENCV_DEBUG_POSTFIX d)
232 set(OPENCV_DLLVERSION "")
233 set(OPENCV_DEBUG_POSTFIX "")
236 if(DEFINED CMAKE_DEBUG_POSTFIX)
237 set(OPENCV_DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
241 set(CMAKE_VERBOSE_MAKEFILE 1)
245 # ----------------------------------------------------------------------------
246 # Path for build/platform -specific headers
247 # ----------------------------------------------------------------------------
248 set(OPENCV_CONFIG_FILE_INCLUDE_DIR "${CMAKE_BINARY_DIR}/" CACHE PATH "Where to create the platform-dependant cvconfig.h")
249 add_definitions(-DHAVE_CVCONFIG_H)
250 ocv_include_directories(${OPENCV_CONFIG_FILE_INCLUDE_DIR})
253 # ----------------------------------------------------------------------------
254 # Use statically or dynamically linked CRT?
256 # ----------------------------------------------------------------------------
258 include(cmake/OpenCVCRTLinkage.cmake REQUIRED)
262 # ----------------------------------------------------------------------------
263 # Autodetect if we are in a SVN repository
264 # ----------------------------------------------------------------------------
265 find_host_program(SVNVERSION_PATH svnversion)
266 mark_as_advanced(force SVNVERSION_PATH)
268 message(STATUS "Extracting svn version, please wait...")
269 execute_process(COMMAND ${SVNVERSION_PATH} -n ${OpenCV_SOURCE_DIR} OUTPUT_VARIABLE SVNVERSION_RESULT)
271 if(SVNVERSION_RESULT MATCHES "exported")
272 # This is NOT a svn repository:
273 set(OPENCV_SVNVERSION "")
274 message(STATUS "SVNVERSION: exported")
276 set(OPENCV_SVNVERSION " svn:${SVNVERSION_RESULT}")
277 message(STATUS "SVNVERSION: ${OPENCV_SVNVERSION}")
280 # We don't have svnversion:
281 set(OPENCV_SVNVERSION "")
285 # ----------------------------------------------------------------------------
286 # OpenCV compiler and linker options
287 # ----------------------------------------------------------------------------
288 include(cmake/OpenCVCompilerOptions.cmake REQUIRED)
290 # In case of Makefiles if the user does not setup CMAKE_BUILD_TYPE, assume it's Release:
291 if(CMAKE_GENERATOR MATCHES "Makefiles" AND "${CMAKE_BUILD_TYPE}" STREQUAL "")
292 set(CMAKE_BUILD_TYPE Release)
296 # ----------------------------------------------------------------------------
297 # CHECK FOR SYSTEM LIBRARIES, OPTIONS, ETC..
298 # ----------------------------------------------------------------------------
300 include(cmake/OpenCVFindPkgConfig.cmake OPTIONAL)
301 include(CheckFunctionExists)
302 include(CheckIncludeFile)
305 include(cmake/OpenCVPCHSupport.cmake REQUIRED)
306 include(cmake/OpenCVModule.cmake REQUIRED)
309 include(cmake/OpenCVAndroidProject.cmake REQUIRED)
313 # ----------------------------------------------------------------------------
314 # Detect 3rd-party tools and libraries
315 # ----------------------------------------------------------------------------
318 include(cmake/OpenCVIOLibs.cmake REQUIRED)
325 CHECK_MODULE(gtk+-2.0 HAVE_GTK)
326 CHECK_MODULE(gthread-2.0 HAVE_GTHREAD)
328 CHECK_MODULE(gtkglext-1.0 HAVE_GTKGLEXT)
330 find_package(OpenGL QUIET)
333 set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES})
334 ocv_include_directories(${OPENGL_INCLUDE_DIR})
340 set(HAVE_GTHREAD FALSE)
343 CHECK_MODULE(gstreamer-base-0.10 HAVE_GSTREAMER)
344 CHECK_MODULE(gstreamer-app-0.10 HAVE_GSTREAMER)
345 CHECK_MODULE(gstreamer-video-0.10 HAVE_GSTREAMER)
347 set(HAVE_GSTREAMER FALSE)
352 CHECK_MODULE(libunicap HAVE_UNICAP_)
353 CHECK_MODULE(libucil HAVE_UNICAP_UCIL)
354 if(HAVE_UNICAP_ AND HAVE_UNICAP_UCIL)
358 set(HAVE_UNICAP FALSE)
362 find_path(PVAPI_INCLUDE_PATH "PvApi.h"
363 PATHS "/usr/local/include" "/usr/include"
364 DOC "The path to PvAPI header")
365 if(PVAPI_INCLUDE_PATH)
372 CHECK_MODULE(libavcodec HAVE_FFMPEG_CODEC)
373 CHECK_MODULE(libavformat HAVE_FFMPEG_FORMAT)
374 CHECK_MODULE(libavutil HAVE_FFMPEG_UTIL)
375 CHECK_MODULE(libswscale HAVE_FFMPEG_SWSCALE)
376 CHECK_INCLUDE_FILE(libavformat/avformat.h HAVE_GENTOO_FFMPEG)
377 CHECK_INCLUDE_FILE(ffmpeg/avformat.h HAVE_FFMPEG_FFMPEG)
378 if(NOT HAVE_GENTOO_FFMPEG AND NOT HAVE_FFMPEG_FFMPEG)
379 if(EXISTS /usr/include/ffmpeg/libavformat/avformat.h OR HAVE_FFMPEG_SWSCALE)
380 set(HAVE_GENTOO_FFMPEG 1)
383 if(HAVE_FFMPEG_CODEC AND HAVE_FFMPEG_FORMAT AND HAVE_FFMPEG_UTIL)
384 if(HAVE_FFMPEG_SWSCALE OR NOT HAVE_GENTOO_FFMPEG)
389 # Find the bzip2 library because it is required on some systems
390 FIND_LIBRARY(BZIP2_LIBRARIES NAMES bz2 bzip2)
391 if(NOT BZIP2_LIBRARIES)
393 FIND_FILE(BZIP2_LIBRARIES NAMES libbz2.so.1 PATHS /lib)
398 CHECK_MODULE(libavformat>=53 NEW_FFMPEG)
402 CHECK_MODULE(libdc1394-2 HAVE_DC1394_2)
403 if(NOT HAVE_DC1394_2)
404 CHECK_MODULE(libdc1394 HAVE_DC1394)
407 set(HAVE_DC1394_2 FALSE)
408 set(HAVE_DC1394 FALSE)
412 CHECK_INCLUDE_FILE(alloca.h HAVE_ALLOCA_H)
413 CHECK_FUNCTION_EXISTS(alloca HAVE_ALLOCA)
414 CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
415 CHECK_INCLUDE_FILE(pthread.h HAVE_LIBPTHREAD)
418 CHECK_MODULE(libxine HAVE_XINE)
423 CHECK_MODULE(libv4l1 HAVE_LIBV4L)
424 CHECK_INCLUDE_FILE(linux/videodev.h HAVE_CAMV4L)
425 CHECK_INCLUDE_FILE(linux/videodev2.h HAVE_CAMV4L2)
427 set(HAVE_LIBV4L FALSE)
428 set(HAVE_CAMV4L FALSE)
429 set(HAVE_CAMV4L2 FALSE)
433 set(OPENCV_LINKER_LIBS dl m log)
434 elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
435 set(OPENCV_LINKER_LIBS m pthread)
437 set(OPENCV_LINKER_LIBS dl m pthread rt)
440 add_definitions(-DHAVE_ALLOCA -DHAVE_ALLOCA_H -DHAVE_LIBPTHREAD -DHAVE_UNISTD_H)
444 #################### LATEX for dpf documentation ##################
446 include(cmake/OpenCVFindLATEX.cmake REQUIRED)
449 ########################## Python Support #########################
450 include(cmake/OpenCVDetectPython.cmake REQUIRED)
452 ########################### Java Support ##########################
453 # current implementation of Java wrappers generator requires python at build time
454 if((NOT DEFINED BUILD_opencv_java OR BUILD_opencv_java) AND PYTHON_EXECUTABLE)
456 include(cmake/OpenCVDetectAndroidSDK.cmake REQUIRED)
458 include(cmake/OpenCVDetectApacheAnt.cmake REQUIRED)
460 if(ANDROID_EXECUTABLE AND ANT_EXECUTABLE AND (ANT_VERSION VERSION_GREATER 1.7) AND (ANDROID_SDK_TARGET_LEVEL GREATER 7))
461 SET(CAN_BUILD_ANDROID_PROJECTS TRUE)
463 SET(CAN_BUILD_ANDROID_PROJECTS FALSE)
467 if(BUILD_ANDROID_EXAMPLES AND NOT CAN_BUILD_ANDROID_PROJECTS)
469 message(WARNING "Android examples are chosen for build, but required SDK tools are not found.")
471 unset(BUILD_ANDROID_EXAMPLES CACHE)
474 ############################### QT ################################
476 set(HAVE_QT_OPENGL 0)
482 add_definitions(-DHAVE_QT) #We need to define te macro this way, using cvconfig.h.cmake does not work
485 find_package (OpenGL QUIET)
486 if(QT_QTOPENGL_FOUND AND OPENGL_FOUND)
488 set(HAVE_QT_OPENGL 1)
489 add_definitions(-DHAVE_QT_OPENGL)
490 set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES})
496 ############################### TBB ################################
498 include(cmake/OpenCVDetectTBB.cmake REQUIRED)
501 ############################ Intel IPP #############################
505 include(cmake/OpenCVFindIPP.cmake)
509 add_definitions(-DHAVE_IPP)
510 ocv_include_directories(${IPP_INCLUDE_DIRS})
511 link_directories(${IPP_LIBRARY_DIRS})
512 set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${IPP_LIBRARIES})
515 ############################### CUDA ################################
517 include(cmake/OpenCVDetectCUDA.cmake REQUIRED)
520 ############################### OpenNI ################################
521 set(HAVE_OPENNI FALSE)
522 set(HAVE_OPENNI_PRIME_SENSOR_MODULE FALSE)
525 include(cmake/OpenCVFindOpenNI.cmake)
528 ############################### XIMEA ################################
529 set(HAVE_XIMEA FALSE)
532 include(cmake/OpenCVFindXimea.cmake)
539 ############################## Eigen ##############################
541 find_path(EIGEN_INCLUDE_PATH "Eigen/Core"
542 PATHS "/usr/local/include/eigen2" "/opt/include/eigen2" "/usr/include/eigen2"
543 "/usr/local/include/eigen3" "/opt/include/eigen3" "/usr/include/eigen3"
544 DOC "The path to Eigen2/Eigen3 headers")
545 if(EIGEN_INCLUDE_PATH)
546 ocv_include_directories(${EIGEN_INCLUDE_PATH})
551 ################## Extra HighGUI libs on Windows ###################
553 set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} comctl32 gdi32 ole32)
556 set(HAVE_VIDEOINPUT 1)
560 set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} vfw32)
565 set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} msvfw32 avifil32 avicap32 winmm)
567 set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} vfw32 winmm)
571 if(WITH_OPENGL AND NOT HAVE_QT_OPENGL)
572 find_package(OpenGL QUIET)
576 set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES})
577 ocv_include_directories(${OPENGL_INCLUDE_DIR})
583 # ----------------------------------------------------------------------------
585 # ----------------------------------------------------------------------------
586 if(ENABLE_SOLUTION_FOLDERS)
587 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
588 set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
591 # Extra OpenCV targets: uninstall, package_source, perf, etc.
592 include(cmake/OpenCVExtraTargets.cmake REQUIRED)
595 # ----------------------------------------------------------------------------
596 # Process subdirectories
597 # ----------------------------------------------------------------------------
599 # opencv.hpp and legacy headers
600 add_subdirectory(include)
603 add_subdirectory(modules)
605 # Generate targets for documentation
606 add_subdirectory(doc)
608 # various data that is used by cv libraries and/or demo applications.
609 add_subdirectory(data)
612 add_subdirectory(apps)
615 if(BUILD_EXAMPLES OR BUILD_ANDROID_EXAMPLES OR INSTALL_PYTHON_EXAMPLES)
616 add_subdirectory(samples)
620 # ----------------------------------------------------------------------------
621 # Finalization: generate configuration-based files
622 # ----------------------------------------------------------------------------
623 ocv_track_build_dependencies()
625 # Generate platform-dependent and configuration-dependent headers
626 include(cmake/OpenCVGenHeaders.cmake REQUIRED)
628 # Generate opencv.pc for pkg-config command
629 include(cmake/OpenCVGenPkgconfig.cmake REQUIRED)
631 # Generate OpenCV.mk for ndk-build (Android build tool)
632 include(cmake/OpenCVGenAndroidMK.cmake REQUIRED)
634 # Generate OpenCVСonfig.cmake and OpenCVConfig-version.cmake for cmake projects
635 include(cmake/OpenCVGenConfig.cmake REQUIRED)
638 # ----------------------------------------------------------------------------
640 # ----------------------------------------------------------------------------
642 status("General configuration for OpenCV ${OPENCV_VERSION} =====================================")
647 status(" Host:" ${CMAKE_HOST_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_VERSION} ${CMAKE_HOST_SYSTEM_PROCESSOR})
648 status(" Target:" ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION} ${CMAKE_SYSTEM_PROCESSOR})
649 status(" CMake:" ${CMAKE_VERSION})
650 status(" CMake generator:" ${CMAKE_GENERATOR})
651 status(" CMake build tool:" ${CMAKE_BUILD_TOOL})
653 status(" MSVC:" ${MSVC_VERSION})
655 if(CMAKE_GENERATOR MATCHES Xcode)
656 status(" Xcode:" ${XCODE_VERSION})
662 status(" Built as dynamic libs?:" BUILD_SHARED_LIBS THEN YES ELSE NO)
663 status(" C++ Compiler:" CMAKE_COMPILER THEN "${CMAKE_COMPILER}" ELSE "${CMAKE_CXX_COMPILER}")
664 status(" C++ flags (Release):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE})
665 status(" C++ flags (Debug):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG})
667 status(" Linker flags (Release):" ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_RELEASE})
668 status(" Linker flags (Debug):" ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_DEBUG})
670 status(" Linker flags (Release):" ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_RELEASE})
671 status(" Linker flags (Debug):" ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_DEBUG})
676 status(" OpenCV modules:")
677 string(REPLACE "opencv_" "" OPENCV_MODULES_BUILD_ST "${OPENCV_MODULES_BUILD}")
678 string(REPLACE "opencv_" "" OPENCV_MODULES_DISABLED_USER_ST "${OPENCV_MODULES_DISABLED_USER}")
679 string(REPLACE "opencv_" "" OPENCV_MODULES_DISABLED_AUTO_ST "${OPENCV_MODULES_DISABLED_AUTO}")
680 string(REPLACE "opencv_" "" OPENCV_MODULES_DISABLED_FORCE_ST "${OPENCV_MODULES_DISABLED_FORCE}")
681 status(" To be built:" OPENCV_MODULES_BUILD THEN ${OPENCV_MODULES_BUILD_ST} ELSE "-")
682 status(" Disabled by user:" OPENCV_MODULES_DISABLED_USER THEN ${OPENCV_MODULES_DISABLED_USER_ST} ELSE "-")
683 status(" Disabled by dependency:" OPENCV_MODULES_DISABLED_AUTO THEN ${OPENCV_MODULES_DISABLED_AUTO_ST} ELSE "-")
684 status(" Unavailable:" OPENCV_MODULES_DISABLED_FORCE THEN ${OPENCV_MODULES_DISABLED_FORCE_ST} ELSE "-")
690 status(" Android ABI:" ${ANDROID_ABI})
691 status(" Native API level:" android-${ANDROID_NATIVE_API_LEVEL})
692 status(" SDK target:" "${ANDROID_SDK_TARGET}")
693 if(BUILD_WITH_ANDROID_NDK)
694 status(" Android NDK:" "${ANDROID_NDK} (toolchain: ${ANDROID_TOOLCHAIN_NAME})")
695 elseif(BUILD_WITH_STANDALONE_TOOLCHAIN)
696 status(" Android toolchain:" "${ANDROID_STANDALONE_TOOLCHAIN}")
698 status(" android tool:" ANDROID_EXECUTABLE THEN "${ANDROID_EXECUTABLE} (${ANDROID_TOOLS_Pkg_Desc})" ELSE NO)
699 status(" ant:" ANT_EXECUTABLE THEN "${ANT_EXECUTABLE} (ver ${ANT_VERSION})" ELSE NO)
707 status(" QT 4.x:" HAVE_QT THEN YES ELSE NO)
708 status(" QT OpenGL support:" HAVE_QT_OPENGL THEN YES ELSE NO)
711 status(" Win32 UI:" YES)
715 status(" Carbon:" YES)
717 status(" Cocoa:" YES)
720 status(" GTK+ 2.x:" HAVE_GTK THEN YES ELSE NO)
721 status(" GThread :" HAVE_GTHREAD THEN YES ELSE NO)
722 status(" GtkGlExt:" HAVE_GTKGLEXT THEN YES ELSE NO)
727 status(" OpenGL support:" HAVE_OPENGL THEN YES ELSE NO)
731 status(" Media I/O: ")
732 status(" ZLib:" ZLIB_FOUND THEN "${ZLIB_LIBRARY}" ELSE build)
735 status(" JPEG:" JPEG_FOUND THEN "${JPEG_LIBRARY}" ELSE build)
737 status(" JPEG:" "NO")
740 status(" PNG:" PNG_FOUND THEN "${PNG_LIBRARY}" ELSE build)
745 status(" TIFF:" TIFF_FOUND THEN "${TIFF_LIBRARY}" ELSE build)
747 status(" TIFF:" "NO")
750 status(" JPEG 2000:" JASPER_FOUND THEN "${JASPER_LIBRARY}" ELSE build)
752 status(" JPEG 2000:" "NO")
755 status(" OpenEXR:" WITH_OPENEXR AND OPENEXR_FOUND THEN YES ELSE NO)
756 status(" OpenNI:" HAVE_OPENNI THEN YES ELSE NO)
757 status(" OpenNI PrimeSensor Modules:"
758 HAVE_OPENNI_PRIME_SENSOR_MODULE THEN YES ELSE NO)
760 status(" XIMEA:" HAVE_XIMEA THEN YES ELSE NO)
765 if(UNIX AND NOT APPLE)
766 status(" Video I/O:")
767 status(" DC1394 1.x:" HAVE_DC1394 THEN YES ELSE NO)
768 status(" DC1394 2.x:" HAVE_DC1394_2 THEN YES ELSE NO)
769 status(" FFMPEG:" HAVE_FFMPEG THEN YES ELSE NO)
770 status(" codec:" HAVE_FFMPEG_CODEC THEN YES ELSE NO)
771 status(" format:" HAVE_FFMPEG_FORMAT THEN YES ELSE NO)
772 status(" util:" HAVE_FFMPEG_UTIL THEN YES ELSE NO)
773 status(" swscale:" HAVE_FFMPEG_SWSCALE THEN YES ELSE NO)
774 status(" gentoo-style:" HAVE_GENTOO_FFMPEG THEN YES ELSE NO)
775 status(" GStreamer:" HAVE_GSTREAMER THEN YES ELSE NO)
776 status(" UniCap:" HAVE_UNICAP THEN YES ELSE NO)
777 status(" PvAPI:" HAVE_PVAPI THEN YES ELSE NO)
778 status(" V4L/V4L2:" HAVE_LIBV4L THEN "Using libv4l" ELSE ${HAVE_CAMV4L}/${HAVE_CAMV4L2})
779 status(" Xine:" HAVE_XINE THEN YES ELSE NO)
782 if(HAVE_opencv_androidcamera)
783 status(" AndroidNativeCamera:" BUILD_ANDROID_CAMERA_WRAPPER THEN "YES, build for Android ${ANDROID_VERSION}" ELSE "YES, use prebuilt libraries")
785 status(" AndroidNativeCamera:" "NO (native camera requires Android API level 8 or higher)")
790 status(" Video I/O:" WITH_QUICKTIME THEN QuickTime ELSE QTKit)
792 status(" Video I/O: AVFoundation")
795 status(" Video I/O:" HAVE_VIDEOINPUT THEN DirectShow ELSE NO)
798 # Other third-party libraries
800 status(" Other third-party libraries:")
802 if(WITH_IPP AND IPP_FOUND)
803 status(" Use IPP:" "${IPP_LATEST_VERSION_STR} [${IPP_LATEST_VERSION_MAJOR}.${IPP_LATEST_VERSION_MINOR}.${IPP_LATEST_VERSION_BUILD}]")
804 status(" at:" "${IPP_ROOT_DIR}")
806 status(" Use IPP:" WITH_IPP AND NOT IPP_FOUND THEN "IPP not found" ELSE NO)
809 status(" Use TBB:" HAVE_TBB THEN YES ELSE NO)
810 status(" Use Cuda:" HAVE_CUDA THEN YES ELSE NO)
811 status(" Use Eigen:" HAVE_EIGEN THEN YES ELSE NO)
814 status(" Python interpreter:" PYTHON_EXECUTABLE THEN "${PYTHON_EXECUTABLE} (ver ${PYTHON_VERSION_MAJOR_MINOR})" ELSE NO)
815 # interfaces to other languages
817 status(" Interfaces:")
818 status(" Python:" HAVE_opencv_python THEN YES ELSE NO)
819 status(" Python numpy:" PYTHON_USE_NUMPY THEN YES ELSE "NO (Python wrappers can not be generated)")
821 status(" Java:" HAVE_opencv_java THEN YES ELSE NO)
826 status(" Documentation:")
827 status(" Sphinx:" HAVE_SPHINX THEN "${SPHINX_BUILD} (ver ${SPHINX_VERSION})" ELSE NO)
828 status(" PdfLaTeX compiler:" PDFLATEX_COMPILER THEN "${PDFLATEX_COMPILER}" ELSE NO)
829 if(BUILD_DOCS AND HAVE_SPHINX)
830 status(" Build Documentation:" PDFLATEX_COMPILER THEN YES ELSE "YES (only HTML without math expressions)")
832 status(" Build Documentation:" NO)
837 status(" Tests and samples:")
838 status(" Tests:" BUILD_TESTS THEN YES ELSE NO)
839 status(" Performance tests:" BUILD_PERF_TESTS THEN YES ELSE NO)
840 status(" Examples:" BUILD_EXAMPLES THEN YES ELSE NO)
843 status(" Android tests:" BUILD_TESTS AND CAN_BUILD_ANDROID_PROJECTS THEN YES ELSE NO)
844 status(" Android examples:" BUILD_ANDROID_EXAMPLES THEN YES ELSE NO)
849 status(" Install path:" "${CMAKE_INSTALL_PREFIX}")
851 status(" cvconfig.h is in:" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}")
852 status("-----------------------------------------------------------------")
855 # ----------------------------------------------------------------------------
856 # Warn in the case of in-source build
857 # ----------------------------------------------------------------------------
858 if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
859 message(WARNING "The source directory is the same as binary directory. \"make clean\" may damage the source tree")