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" 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 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 # ----------------------------------------------------------------------------
322 CHECK_MODULE(gtk+-2.0 HAVE_GTK)
323 CHECK_MODULE(gthread-2.0 HAVE_GTHREAD)
325 CHECK_MODULE(gtkglext-1.0 HAVE_GTKGLEXT)
327 find_package(OpenGL QUIET)
330 set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES})
331 include_directories(${OPENGL_INCLUDE_DIR})
337 set(HAVE_GTHREAD FALSE)
340 CHECK_MODULE(gstreamer-base-0.10 HAVE_GSTREAMER)
341 CHECK_MODULE(gstreamer-app-0.10 HAVE_GSTREAMER)
342 CHECK_MODULE(gstreamer-video-0.10 HAVE_GSTREAMER)
344 set(HAVE_GSTREAMER FALSE)
349 CHECK_MODULE(libunicap HAVE_UNICAP_)
350 CHECK_MODULE(libucil HAVE_UNICAP_UCIL)
351 if(HAVE_UNICAP_ AND HAVE_UNICAP_UCIL)
355 set(HAVE_UNICAP FALSE)
359 find_path(PVAPI_INCLUDE_PATH "PvApi.h"
360 PATHS "/usr/local/include" "/usr/include"
361 DOC "The path to PvAPI header")
362 if(PVAPI_INCLUDE_PATH)
369 CHECK_MODULE(libavcodec HAVE_FFMPEG_CODEC)
370 CHECK_MODULE(libavformat HAVE_FFMPEG_FORMAT)
371 CHECK_MODULE(libavutil HAVE_FFMPEG_UTIL)
372 CHECK_MODULE(libswscale HAVE_FFMPEG_SWSCALE)
373 CHECK_INCLUDE_FILE(libavformat/avformat.h HAVE_GENTOO_FFMPEG)
374 CHECK_INCLUDE_FILE(ffmpeg/avformat.h HAVE_FFMPEG_FFMPEG)
375 if(NOT HAVE_GENTOO_FFMPEG AND NOT HAVE_FFMPEG_FFMPEG)
376 if(EXISTS /usr/include/ffmpeg/libavformat/avformat.h OR HAVE_FFMPEG_SWSCALE)
377 set(HAVE_GENTOO_FFMPEG 1)
380 if(HAVE_FFMPEG_CODEC AND HAVE_FFMPEG_FORMAT AND HAVE_FFMPEG_UTIL)
381 if(HAVE_FFMPEG_SWSCALE OR NOT HAVE_GENTOO_FFMPEG)
385 # Find the bzip2 library because it is required on some systems
386 FIND_LIBRARY(BZIP2_LIBRARIES NAMES bz2 bzip2)
387 if(NOT BZIP2_LIBRARIES)
389 FIND_FILE(BZIP2_LIBRARIES NAMES libbz2.so.1 PATHS /lib)
394 CHECK_MODULE(libdc1394-2 HAVE_DC1394_2)
395 if(NOT HAVE_DC1394_2)
396 CHECK_MODULE(libdc1394 HAVE_DC1394)
399 set(HAVE_DC1394_2 FALSE)
400 set(HAVE_DC1394 FALSE)
404 CHECK_INCLUDE_FILE(alloca.h HAVE_ALLOCA_H)
405 CHECK_FUNCTION_EXISTS(alloca HAVE_ALLOCA)
406 CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
407 CHECK_INCLUDE_FILE(pthread.h HAVE_LIBPTHREAD)
410 CHECK_MODULE(libxine HAVE_XINE)
415 CHECK_MODULE(libv4l1 HAVE_LIBV4L)
416 CHECK_INCLUDE_FILE(linux/videodev.h HAVE_CAMV4L)
417 CHECK_INCLUDE_FILE(linux/videodev2.h HAVE_CAMV4L2)
419 set(HAVE_LIBV4L FALSE)
420 set(HAVE_CAMV4L FALSE)
421 set(HAVE_CAMV4L2 FALSE)
425 set(OPENCV_LINKER_LIBS dl m log)
426 elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
427 set(OPENCV_LINKER_LIBS m pthread)
429 set(OPENCV_LINKER_LIBS dl m pthread rt)
432 add_definitions(-DHAVE_ALLOCA -DHAVE_ALLOCA_H -DHAVE_LIBPTHREAD -DHAVE_UNISTD_H)
437 include(cmake/OpenCVIOLibs.cmake REQUIRED)
439 #################### LATEX for dpf documentation ##################
441 include(cmake/OpenCVFindLATEX.cmake REQUIRED)
444 ########################## Python Support #########################
445 include(cmake/OpenCVDetectPython.cmake REQUIRED)
447 ########################### Java Support ##########################
448 # current implementation of Java wrappers generator requires python at build time
449 if((NOT DEFINED BUILD_opencv_java OR BUILD_opencv_java) AND PYTHON_EXECUTABLE)
451 include(cmake/OpenCVDetectAndroidSDK.cmake REQUIRED)
453 include(cmake/OpenCVDetectApacheAnt.cmake REQUIRED)
455 if(ANDROID_EXECUTABLE AND ANT_EXECUTABLE AND (ANT_VERSION VERSION_GREATER 1.7) AND (ANDROID_SDK_TARGET_LEVEL GREATER 7))
456 SET(CAN_BUILD_ANDROID_PROJECTS TRUE)
458 SET(CAN_BUILD_ANDROID_PROJECTS FALSE)
462 if(BUILD_ANDROID_EXAMPLES AND NOT CAN_BUILD_ANDROID_PROJECTS)
464 message(WARNING "Android examples are chosen for build, but required SDK tools are not found.")
466 unset(BUILD_ANDROID_EXAMPLES CACHE)
469 ############################### QT ################################
471 set(HAVE_QT_OPENGL 0)
477 add_definitions(-DHAVE_QT) #We need to define te macro this way, using cvconfig.h.cmake does not work
480 find_package (OpenGL QUIET)
481 if(QT_QTOPENGL_FOUND AND OPENGL_FOUND)
483 set(HAVE_QT_OPENGL 1)
484 add_definitions(-DHAVE_QT_OPENGL)
485 set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES})
491 ############################### TBB ################################
493 include(cmake/OpenCVDetectTBB.cmake REQUIRED)
496 ############################ Intel IPP #############################
500 include(cmake/OpenCVFindIPP.cmake)
504 add_definitions(-DHAVE_IPP)
505 include_directories(${IPP_INCLUDE_DIRS})
506 link_directories(${IPP_LIBRARY_DIRS})
507 set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${IPP_LIBRARIES})
510 ############################### CUDA ################################
512 include(cmake/OpenCVDetectCUDA.cmake REQUIRED)
515 ############################### OpenNI ################################
516 set(HAVE_OPENNI FALSE)
517 set(HAVE_OPENNI_PRIME_SENSOR_MODULE FALSE)
520 include(cmake/OpenCVFindOpenNI.cmake)
523 ############################### XIMEA ################################
524 set(HAVE_XIMEA FALSE)
527 include(cmake/OpenCVFindXimea.cmake)
534 ############################## Eigen ##############################
536 find_path(EIGEN_INCLUDE_PATH "Eigen/Core"
537 PATHS "/usr/local/include/eigen2" "/opt/include/eigen2" "/usr/include/eigen2"
538 "/usr/local/include/eigen3" "/opt/include/eigen3" "/usr/include/eigen3"
539 DOC "The path to Eigen2/Eigen3 headers")
540 if(EIGEN_INCLUDE_PATH)
541 include_directories(${EIGEN_INCLUDE_PATH})
546 ################## Extra HighGUI libs on Windows ###################
548 set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} comctl32 gdi32 ole32)
551 set(HAVE_VIDEOINPUT 1)
555 set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} vfw32)
560 set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} msvfw32 avifil32 avicap32 winmm)
562 set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} vfw32 winmm)
566 if(WITH_OPENGL AND NOT HAVE_QT_OPENGL)
567 find_package(OpenGL QUIET)
571 set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES})
572 include_directories(${OPENGL_INCLUDE_DIR})
578 # ----------------------------------------------------------------------------
580 # ----------------------------------------------------------------------------
581 if(ENABLE_SOLUTION_FOLDERS)
582 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
583 set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
586 # Extra OpenCV targets: uninstall, package_source, perf, etc.
587 include(cmake/OpenCVExtraTargets.cmake REQUIRED)
590 # ----------------------------------------------------------------------------
591 # Process subdirectories
592 # ----------------------------------------------------------------------------
594 # opencv.hpp and legacy headers
595 add_subdirectory(include)
598 add_subdirectory(modules)
600 # Generate targets for documentation
601 add_subdirectory(doc)
603 # various data that is used by cv libraries and/or demo applications.
604 add_subdirectory(data)
606 # 3rdparty libraries on-board
607 add_subdirectory(3rdparty)
610 add_subdirectory(apps)
613 if(BUILD_EXAMPLES OR BUILD_ANDROID_EXAMPLES OR INSTALL_PYTHON_EXAMPLES)
614 add_subdirectory(samples)
618 # ----------------------------------------------------------------------------
619 # Finalization: generate configuration-based files
620 # ----------------------------------------------------------------------------
621 ocv_track_build_dependencies()
623 # Generate platform-dependent and configuration-dependent headers
624 include(cmake/OpenCVGenHeaders.cmake REQUIRED)
626 # Generate opencv.pc for pkg-config command
627 include(cmake/OpenCVGenPkgconfig.cmake REQUIRED)
629 # Generate OpenCV.mk for ndk-build (Android build tool)
630 include(cmake/OpenCVGenAndroidMK.cmake REQUIRED)
632 # Generate OpenCVŠ”onfig.cmake and OpenCVConfig-version.cmake for cmake projects
633 include(cmake/OpenCVGenConfig.cmake REQUIRED)
636 # ----------------------------------------------------------------------------
638 # ----------------------------------------------------------------------------
640 status("General configuration for OpenCV ${OPENCV_VERSION} =====================================")
645 status(" Host:" ${CMAKE_HOST_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_VERSION} ${CMAKE_HOST_SYSTEM_PROCESSOR})
646 status(" Target:" ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION} ${CMAKE_SYSTEM_PROCESSOR})
647 status(" CMake:" ${CMAKE_VERSION})
648 status(" CMake generator:" ${CMAKE_GENERATOR})
649 status(" CMake build tool:" ${CMAKE_BUILD_TOOL})
651 status(" MSVC:" ${MSVC_VERSION})
653 if(CMAKE_GENERATOR MATCHES Xcode)
654 status(" Xcode:" ${XCODE_VERSION})
660 status(" Built as dynamic libs?:" BUILD_SHARED_LIBS THEN YES ELSE NO)
661 status(" C++ Compiler:" CMAKE_COMPILER THEN "${CMAKE_COMPILER}" ELSE "${CMAKE_CXX_COMPILER}")
662 status(" C++ flags (Release):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE})
663 status(" C++ flags (Debug):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG})
665 status(" Linker flags (Release):" ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_RELEASE})
666 status(" Linker flags (Debug):" ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_DEBUG})
668 status(" Linker flags (Release):" ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_RELEASE})
669 status(" Linker flags (Debug):" ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_DEBUG})
674 status(" OpenCV modules:")
675 string(REPLACE "opencv_" "" OPENCV_MODULES_BUILD_ST "${OPENCV_MODULES_BUILD}")
676 string(REPLACE "opencv_" "" OPENCV_MODULES_DISABLED_USER_ST "${OPENCV_MODULES_DISABLED_USER}")
677 string(REPLACE "opencv_" "" OPENCV_MODULES_DISABLED_AUTO_ST "${OPENCV_MODULES_DISABLED_AUTO}")
678 string(REPLACE "opencv_" "" OPENCV_MODULES_DISABLED_FORCE_ST "${OPENCV_MODULES_DISABLED_FORCE}")
679 status(" To be built:" OPENCV_MODULES_BUILD THEN ${OPENCV_MODULES_BUILD_ST} ELSE "-")
680 status(" Disabled by user:" OPENCV_MODULES_DISABLED_USER THEN ${OPENCV_MODULES_DISABLED_USER_ST} ELSE "-")
681 status(" Disabled by dependency:" OPENCV_MODULES_DISABLED_AUTO THEN ${OPENCV_MODULES_DISABLED_AUTO_ST} ELSE "-")
682 status(" Unavailable:" OPENCV_MODULES_DISABLED_FORCE THEN ${OPENCV_MODULES_DISABLED_FORCE_ST} ELSE "-")
688 status(" Android ABI:" ${ANDROID_ABI})
689 status(" Native API level:" android-${ANDROID_NATIVE_API_LEVEL})
690 status(" SDK target:" "${ANDROID_SDK_TARGET}")
691 if(BUILD_WITH_ANDROID_NDK)
692 status(" Android NDK:" "${ANDROID_NDK} (toolchain: ${ANDROID_TOOLCHAIN_NAME})")
693 elseif(BUILD_WITH_STANDALONE_TOOLCHAIN)
694 status(" Android toolchain:" "${ANDROID_STANDALONE_TOOLCHAIN}")
696 status(" android tool:" ANDROID_EXECUTABLE THEN "${ANDROID_EXECUTABLE} (${ANDROID_TOOLS_Pkg_Desc})" ELSE NO)
697 status(" ant:" ANT_EXECUTABLE THEN "${ANT_EXECUTABLE} (ver ${ANT_VERSION})" ELSE NO)
705 status(" QT 4.x:" HAVE_QT THEN YES ELSE NO)
706 status(" QT OpenGL support:" HAVE_QT_OPENGL THEN YES ELSE NO)
709 status(" Win32 UI:" YES)
713 status(" Carbon:" YES)
715 status(" Cocoa:" YES)
718 status(" GTK+ 2.x:" HAVE_GTK THEN YES ELSE NO)
719 status(" GThread :" HAVE_GTHREAD THEN YES ELSE NO)
720 status(" GtkGlExt:" HAVE_GTKGLEXT THEN YES ELSE NO)
725 status(" OpenGL support:" HAVE_OPENGL THEN YES ELSE NO)
729 status(" Media I/O: ")
730 status(" ZLib:" ZLIB_FOUND THEN "${ZLIB_LIBRARY}" ELSE build)
733 status(" JPEG:" JPEG_FOUND THEN "${JPEG_LIBRARY}" ELSE build)
735 status(" JPEG:" "NO")
738 status(" PNG:" PNG_FOUND THEN "${PNG_LIBRARY}" ELSE build)
743 status(" TIFF:" TIFF_FOUND THEN "${TIFF_LIBRARY}" ELSE build)
745 status(" TIFF:" "NO")
748 status(" JPEG 2000:" JASPER_FOUND THEN "${JASPER_LIBRARY}" ELSE build)
750 status(" JPEG 2000:" "NO")
753 status(" OpenEXR:" WITH_OPENEXR AND OPENEXR_FOUND THEN YES ELSE NO)
754 status(" OpenNI:" HAVE_OPENNI THEN YES ELSE NO)
755 status(" OpenNI PrimeSensor Modules:"
756 HAVE_OPENNI_PRIME_SENSOR_MODULE THEN YES ELSE NO)
758 status(" XIMEA:" HAVE_XIMEA THEN YES ELSE NO)
763 if(UNIX AND NOT APPLE)
764 status(" Video I/O:")
765 status(" DC1394 1.x:" HAVE_DC1394 THEN YES ELSE NO)
766 status(" DC1394 2.x:" HAVE_DC1394_2 THEN YES ELSE NO)
767 status(" FFMPEG:" HAVE_FFMPEG THEN YES ELSE NO)
768 status(" codec:" HAVE_FFMPEG_CODEC THEN YES ELSE NO)
769 status(" format:" HAVE_FFMPEG_FORMAT THEN YES ELSE NO)
770 status(" util:" HAVE_FFMPEG_UTIL THEN YES ELSE NO)
771 status(" swscale:" HAVE_FFMPEG_SWSCALE THEN YES ELSE NO)
772 status(" gentoo-style:" HAVE_GENTOO_FFMPEG THEN YES ELSE NO)
773 status(" GStreamer:" HAVE_GSTREAMER THEN YES ELSE NO)
774 status(" UniCap:" HAVE_UNICAP THEN YES ELSE NO)
775 status(" PvAPI:" HAVE_PVAPI THEN YES ELSE NO)
776 status(" V4L/V4L2:" HAVE_LIBV4L THEN "Using libv4l" ELSE ${HAVE_CAMV4L}/${HAVE_CAMV4L2})
777 status(" Xine:" HAVE_XINE THEN YES ELSE NO)
780 if(HAVE_opencv_androidcamera)
781 status(" AndroidNativeCamera:" BUILD_ANDROID_CAMERA_WRAPPER THEN "YES, build for Android ${ANDROID_VERSION}" ELSE "YES, use prebuilt libraries")
783 status(" AndroidNativeCamera:" "NO (native camera requires Android API level 8 or higher)")
788 status(" Video I/O:" WITH_QUICKTIME THEN QuickTime ELSE QTKit)
790 status(" Video I/O: AVFoundation")
793 status(" Video I/O:" HAVE_VIDEOINPUT THEN DirectShow ELSE NO)
796 # Other third-party libraries
798 status(" Other third-party libraries:")
800 if(WITH_IPP AND IPP_FOUND)
801 status(" Use IPP:" "${IPP_LATEST_VERSION_STR} [${IPP_LATEST_VERSION_MAJOR}.${IPP_LATEST_VERSION_MINOR}.${IPP_LATEST_VERSION_BUILD}]")
802 status(" at:" "${IPP_ROOT_DIR}")
804 status(" Use IPP:" WITH_IPP AND NOT IPP_FOUND THEN "IPP not found" ELSE NO)
807 status(" Use TBB:" HAVE_TBB THEN YES ELSE NO)
808 status(" Use Cuda:" HAVE_CUDA THEN YES ELSE NO)
809 status(" Use Eigen:" HAVE_EIGEN THEN YES ELSE NO)
812 status(" Python interpreter:" PYTHON_EXECUTABLE THEN "${PYTHON_EXECUTABLE} (ver ${PYTHON_VERSION_MAJOR_MINOR})" ELSE NO)
813 # interfaces to other languages
815 status(" Interfaces:")
816 status(" Python:" HAVE_opencv_python THEN YES ELSE NO)
817 status(" Python numpy:" PYTHON_USE_NUMPY THEN YES ELSE "NO (Python wrappers will not be generated)")
819 status(" Java:" HAVE_opencv_java THEN YES ELSE NO)
824 status(" Documentation:")
825 status(" Sphinx:" HAVE_SPHINX THEN "${SPHINX_BUILD} (ver ${SPHINX_VERSION})" ELSE NO)
826 status(" PdfLaTeX compiler:" PDFLATEX_COMPILER THEN "${PDFLATEX_COMPILER}" ELSE NO)
827 if(BUILD_DOCS AND HAVE_SPHINX)
828 status(" Build Documentation:" PDFLATEX_COMPILER THEN YES ELSE "YES (only HTML without math expressions)")
830 status(" Build Documentation:" NO)
835 status(" Tests and samples:")
836 status(" Tests:" BUILD_TESTS THEN YES ELSE NO)
837 status(" Performance tests:" BUILD_PERF_TESTS THEN YES ELSE NO)
838 status(" Examples:" BUILD_EXAMPLES THEN YES ELSE NO)
841 status(" Android tests:" BUILD_TESTS AND CAN_BUILD_ANDROID_PROJECTS THEN YES ELSE NO)
842 status(" Android examples:" BUILD_ANDROID_EXAMPLES THEN YES ELSE NO)
847 status(" Install path:" "${CMAKE_INSTALL_PREFIX}")
849 status(" cvconfig.h is in:" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}")
850 status("-----------------------------------------------------------------")
853 # ----------------------------------------------------------------------------
854 # Warn in the case of in-source build
855 # ----------------------------------------------------------------------------
856 if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
857 message(WARNING "The source directory is the same as binary directory. \"make clean\" may damage the source tree")