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)
51 set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE)
52 if(DEFINED CMAKE_BUILD_TYPE AND CMAKE_VERSION VERSION_GREATER "2.8")
53 set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES} )
58 include(cmake/OpenCVUtils.cmake REQUIRED)
60 # ----------------------------------------------------------------------------
61 # Detect compiler and target platform architecture
62 # ----------------------------------------------------------------------------
63 include(cmake/OpenCVDetectCXXCompiler.cmake REQUIRED)
65 # Add these standard paths to the search paths for FIND_LIBRARY
66 # to find libraries from these locations first
67 if(UNIX AND NOT ANDROID)
68 if(X86_64 OR CMAKE_SIZEOF_VOID_P EQUAL 8)
70 list(APPEND CMAKE_LIBRARY_PATH /lib64)
72 list(APPEND CMAKE_LIBRARY_PATH /lib)
75 list(APPEND CMAKE_LIBRARY_PATH /usr/lib64)
77 list(APPEND CMAKE_LIBRARY_PATH /usr/lib)
79 elseif(X86 OR CMAKE_SIZEOF_VOID_P EQUAL 4)
81 list(APPEND CMAKE_LIBRARY_PATH /lib32)
83 list(APPEND CMAKE_LIBRARY_PATH /lib)
86 list(APPEND CMAKE_LIBRARY_PATH /usr/lib32)
88 list(APPEND CMAKE_LIBRARY_PATH /usr/lib)
94 # ----------------------------------------------------------------------------
95 # OpenCV cmake options
96 # ----------------------------------------------------------------------------
98 # Optional 3rd party components
99 # ===================================================
100 OCV_OPTION(WITH_1394 "Include IEEE1394 support" ON IF (UNIX AND NOT ANDROID AND NOT IOS) )
101 OCV_OPTION(WITH_AVFOUNDATION "Use AVFoundation for Video I/O" ON IF IOS)
102 OCV_OPTION(WITH_CARBON "Use Carbon for UI instead of Cocoa" OFF IF APPLE )
103 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) )
104 OCV_OPTION(WITH_CUDA "Include NVidia Cuda Runtime support" ON IF (CMAKE_VERSION VERSION_GREATER "2.8" AND NOT ANDROID AND NOT IOS) )
105 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) )
106 OCV_OPTION(WITH_EIGEN "Include Eigen2/Eigen3 support" ON)
107 OCV_OPTION(WITH_FFMPEG "Include FFMPEG support" ON IF (UNIX AND NOT ANDROID AND NOT IOS) )
108 OCV_OPTION(WITH_GSTREAMER "Include Gstreamer support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS) )
109 OCV_OPTION(WITH_GTK "Include GTK support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS) )
110 OCV_OPTION(WITH_IPP "Include Intel IPP support" OFF IF (MSVC OR X86 OR X86_64) )
111 OCV_OPTION(WITH_JASPER "Include JPEG2K support" ON IF (NOT IOS) )
112 OCV_OPTION(WITH_JPEG "Include JPEG support" ON IF (NOT IOS) )
113 OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ON IF (NOT IOS) )
114 OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF IF (NOT ANDROID AND NOT IOS) )
115 OCV_OPTION(WITH_OPENNI "Include OpenNI support" OFF IF (NOT ANDROID AND NOT IOS) )
116 OCV_OPTION(WITH_PNG "Include PNG support" ON IF (NOT IOS) )
117 OCV_OPTION(WITH_PVAPI "Include Prosilica GigE support" ON IF (UNIX AND NOT ANDROID AND NOT IOS) )
118 OCV_OPTION(WITH_QT "Build with Qt Backend support" OFF IF (NOT ANDROID AND NOT IOS) )
119 OCV_OPTION(WITH_QUICKTIME "Use QuickTime for Video I/O insted of QTKit" OFF IF APPLE )
120 OCV_OPTION(WITH_TBB "Include Intel TBB support" OFF IF (NOT IOS) )
121 OCV_OPTION(WITH_TIFF "Include TIFF support" ON IF (NOT IOS) )
122 OCV_OPTION(WITH_UNICAP "Include Unicap support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS) )
123 OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS) )
124 OCV_OPTION(WITH_VIDEOINPUT "Build HighGUI with DirectShow support" ON IF WIN32 )
125 OCV_OPTION(WITH_XIMEA "Include XIMEA cameras support" OFF IF WIN32 )
126 OCV_OPTION(WITH_XINE "Include Xine support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS) )
128 # OpenCV build components
129 # ===================================================
130 OCV_OPTION(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" NOT (ANDROID OR IOS) )
131 OCV_OPTION(BUILD_ANDROID_EXAMPLES "Build examples for Android platform" ON IF ANDROID )
132 OCV_OPTION(BUILD_DOCS "Create build rules for OpenCV Documentation" ON )
133 OCV_OPTION(BUILD_EXAMPLES "Build all examples" OFF )
134 OCV_OPTION(BUILD_PACKAGE "Enables 'make package_source' command" ON )
135 OCV_OPTION(BUILD_PERF_TESTS "Build performance tests" ON IF (NOT IOS) )
136 OCV_OPTION(BUILD_TESTS "Build accuracy & regression tests" ON IF (NOT IOS) )
137 OCV_OPTION(BUILD_WITH_DEBUG_INFO "Include debug info into debug libs (not MSCV only)" ON )
138 OCV_OPTION(BUILD_WITH_STATIC_CRT "Enables use of staticaly linked CRT for staticaly linked OpenCV" ON IF MSVC )
139 OCV_OPTION(BUILD_FAT_JAVA_LIB "Create fat java wrapper containing the whole OpenCV library" ON IF ANDROID AND NOT BUILD_SHARED_LIBS AND CMAKE_COMPILER_IS_GNUCXX )
142 OCV_OPTION(BUILD_ZLIB "Build zlib from source" WIN32 OR IOS )
143 OCV_OPTION(BUILD_TIFF "Build libtiff from source" WIN32 OR IOS OR ANDROID )
144 OCV_OPTION(BUILD_JASPER "Build libjasper from source" WIN32 OR IOS OR ANDROID )
145 OCV_OPTION(BUILD_JPEG "Build libjpeg from source" WIN32 OR IOS OR ANDROID )
146 OCV_OPTION(BUILD_PNG "Build libpng from source" WIN32 OR IOS OR ANDROID )
148 # OpenCV installation options
149 # ===================================================
150 OCV_OPTION(INSTALL_C_EXAMPLES "Install C examples" OFF )
151 OCV_OPTION(INSTALL_PYTHON_EXAMPLES "Install Python examples" OFF )
152 OCV_OPTION(INSTALL_ANDROID_EXAMPLES "Install Android examples" OFF IF ANDROID )
153 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) )
155 # OpenCV build options
156 # ===================================================
157 OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" ON IF (NOT IOS) )
158 OCV_OPTION(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" MSVC_IDE IF (CMAKE_VERSION VERSION_GREATER "2.8.0") )
159 OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add flags: -g -pg)" OFF IF CMAKE_COMPILER_IS_GNUCXX )
160 OCV_OPTION(ENABLE_OMIT_FRAME_POINTER "Enable -fomit-frame-pointer for GCC" ON IF CMAKE_COMPILER_IS_GNUCXX )
161 OCV_OPTION(ENABLE_POWERPC "Enable PowerPC for GCC" ON IF (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES powerpc.*) )
162 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)) )
163 OCV_OPTION(ENABLE_SSE "Enable SSE instructions" ON IF (MSVC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
164 OCV_OPTION(ENABLE_SSE2 "Enable SSE2 instructions" ON IF (MSVC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
165 OCV_OPTION(ENABLE_SSE3 "Enable SSE3 instructions" OFF IF (CV_ICC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
166 OCV_OPTION(ENABLE_SSSE3 "Enable SSSE3 instructions" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
167 OCV_OPTION(ENABLE_SSE41 "Enable SSE4.1 instructions" OFF IF (CV_ICC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
168 OCV_OPTION(ENABLE_SSE42 "Enable SSE4.2 instructions" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
169 OCV_OPTION(OPENCV_WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF )
171 # uncategorized options
172 # ===================================================
173 OCV_OPTION(CMAKE_VERBOSE "Verbose mode" OFF )
175 # backward compatibility
176 # ===================================================
177 include(cmake/OpenCVLegacyOptions.cmake OPTIONAL)
180 # ----------------------------------------------------------------------------
181 # Get actual OpenCV version number from sources
182 # ----------------------------------------------------------------------------
183 include(cmake/OpenCVVersion.cmake REQUIRED)
186 # ----------------------------------------------------------------------------
187 # Build & install layouts
188 # ----------------------------------------------------------------------------
190 # Save libs and executables in the same place
191 set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib" CACHE PATH "Output directory for libraries" )
192 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin" CACHE PATH "Output directory for applications" )
195 set(OPENCV_DOC_INSTALL_PATH doc)
196 elseif(INSTALL_TO_MANGLED_PATHS)
197 set(OPENCV_DOC_INSTALL_PATH share/OpenCV-${OPENCV_VERSION}/doc)
199 set(OPENCV_DOC_INSTALL_PATH share/OpenCV/doc)
203 set(OPENCV_LIB_INSTALL_PATH libs/${ANDROID_NDK_ABI_NAME})
205 set(OPENCV_LIB_INSTALL_PATH lib${LIB_SUFFIX})
208 set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${OPENCV_LIB_INSTALL_PATH}")
209 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
211 set(OPENCV_INCLUDE_PREFIX include)
212 if(INSTALL_TO_MANGLED_PATHS)
213 set(OPENCV_INCLUDE_PREFIX include/opencv-${OPENCV_VERSION})
218 set(OPENCV_DLLVERSION "${OPENCV_VERSION_MAJOR}${OPENCV_VERSION_MINOR}${OPENCV_VERSION_PATCH}")
219 set(OPENCV_DEBUG_POSTFIX d)
222 set(OPENCV_DLLVERSION "")
223 set(OPENCV_DEBUG_POSTFIX "")
226 if(DEFINED CMAKE_DEBUG_POSTFIX)
227 set(OPENCV_DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
231 set(CMAKE_VERBOSE_MAKEFILE 1)
235 # ----------------------------------------------------------------------------
236 # Path for build/platform -specific headers
237 # ----------------------------------------------------------------------------
238 set(OPENCV_CONFIG_FILE_INCLUDE_DIR "${CMAKE_BINARY_DIR}/" CACHE PATH "Where to create the platform-dependant cvconfig.h")
239 add_definitions(-DHAVE_CVCONFIG_H)
240 ocv_include_directories(${OPENCV_CONFIG_FILE_INCLUDE_DIR})
243 # ----------------------------------------------------------------------------
244 # Use statically or dynamically linked CRT?
246 # ----------------------------------------------------------------------------
248 include(cmake/OpenCVCRTLinkage.cmake REQUIRED)
252 # ----------------------------------------------------------------------------
253 # Autodetect if we are in a SVN repository
254 # ----------------------------------------------------------------------------
255 find_host_program(SVNVERSION_PATH svnversion)
256 mark_as_advanced(force SVNVERSION_PATH)
258 message(STATUS "Extracting svn version, please wait...")
259 execute_process(COMMAND ${SVNVERSION_PATH} -n ${OpenCV_SOURCE_DIR} OUTPUT_VARIABLE SVNVERSION_RESULT)
261 if(SVNVERSION_RESULT MATCHES "exported")
262 # This is NOT a svn repository:
263 set(OPENCV_SVNVERSION "")
264 message(STATUS "SVNVERSION: exported")
266 set(OPENCV_SVNVERSION " svn:${SVNVERSION_RESULT}")
267 message(STATUS "SVNVERSION: ${OPENCV_SVNVERSION}")
270 # We don't have svnversion:
271 set(OPENCV_SVNVERSION "")
275 # ----------------------------------------------------------------------------
276 # OpenCV compiler and linker options
277 # ----------------------------------------------------------------------------
278 include(cmake/OpenCVCompilerOptions.cmake REQUIRED)
280 # In case of Makefiles if the user does not setup CMAKE_BUILD_TYPE, assume it's Release:
281 if(CMAKE_GENERATOR MATCHES "Makefiles" AND "${CMAKE_BUILD_TYPE}" STREQUAL "")
282 set(CMAKE_BUILD_TYPE Release)
286 # ----------------------------------------------------------------------------
287 # CHECK FOR SYSTEM LIBRARIES, OPTIONS, ETC..
288 # ----------------------------------------------------------------------------
290 include(cmake/OpenCVFindPkgConfig.cmake OPTIONAL)
291 include(CheckFunctionExists)
292 include(CheckIncludeFile)
295 include(cmake/OpenCVPCHSupport.cmake REQUIRED)
296 include(cmake/OpenCVModule.cmake REQUIRED)
299 include(cmake/OpenCVAndroidProject.cmake REQUIRED)
303 # ----------------------------------------------------------------------------
304 # Detect 3rd-party tools and libraries
305 # ----------------------------------------------------------------------------
308 include(cmake/OpenCVIOLibs.cmake REQUIRED)
315 CHECK_MODULE(gtk+-2.0 HAVE_GTK)
316 CHECK_MODULE(gthread-2.0 HAVE_GTHREAD)
318 CHECK_MODULE(gtkglext-1.0 HAVE_GTKGLEXT)
320 find_package(OpenGL QUIET)
323 set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES})
324 ocv_include_directories(${OPENGL_INCLUDE_DIR})
330 set(HAVE_GTHREAD FALSE)
333 CHECK_MODULE(gstreamer-base-0.10 HAVE_GSTREAMER)
334 CHECK_MODULE(gstreamer-app-0.10 HAVE_GSTREAMER)
335 CHECK_MODULE(gstreamer-video-0.10 HAVE_GSTREAMER)
337 set(HAVE_GSTREAMER FALSE)
342 CHECK_MODULE(libunicap HAVE_UNICAP_)
343 CHECK_MODULE(libucil HAVE_UNICAP_UCIL)
344 if(HAVE_UNICAP_ AND HAVE_UNICAP_UCIL)
348 set(HAVE_UNICAP FALSE)
352 find_path(PVAPI_INCLUDE_PATH "PvApi.h"
353 PATHS "/usr/local/include" "/usr/include"
354 DOC "The path to PvAPI header")
355 if(PVAPI_INCLUDE_PATH)
362 CHECK_MODULE(libavcodec HAVE_FFMPEG_CODEC)
363 CHECK_MODULE(libavformat HAVE_FFMPEG_FORMAT)
364 CHECK_MODULE(libavutil HAVE_FFMPEG_UTIL)
365 CHECK_MODULE(libswscale HAVE_FFMPEG_SWSCALE)
366 CHECK_INCLUDE_FILE(libavformat/avformat.h HAVE_GENTOO_FFMPEG)
367 CHECK_INCLUDE_FILE(ffmpeg/avformat.h HAVE_FFMPEG_FFMPEG)
368 if(NOT HAVE_GENTOO_FFMPEG AND NOT HAVE_FFMPEG_FFMPEG)
369 if(EXISTS /usr/include/ffmpeg/libavformat/avformat.h OR HAVE_FFMPEG_SWSCALE)
370 set(HAVE_GENTOO_FFMPEG 1)
373 if(HAVE_FFMPEG_CODEC AND HAVE_FFMPEG_FORMAT AND HAVE_FFMPEG_UTIL)
374 if(HAVE_FFMPEG_SWSCALE OR NOT HAVE_GENTOO_FFMPEG)
379 # Find the bzip2 library because it is required on some systems
380 FIND_LIBRARY(BZIP2_LIBRARIES NAMES bz2 bzip2)
381 if(NOT BZIP2_LIBRARIES)
383 FIND_FILE(BZIP2_LIBRARIES NAMES libbz2.so.1 PATHS /lib)
388 CHECK_MODULE(libavformat>=52.111.0 NEW_FFMPEG)
392 CHECK_MODULE(libdc1394-2 HAVE_DC1394_2)
393 if(NOT HAVE_DC1394_2)
394 CHECK_MODULE(libdc1394 HAVE_DC1394)
397 set(HAVE_DC1394_2 FALSE)
398 set(HAVE_DC1394 FALSE)
402 CHECK_INCLUDE_FILE(alloca.h HAVE_ALLOCA_H)
403 CHECK_FUNCTION_EXISTS(alloca HAVE_ALLOCA)
404 CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
405 CHECK_INCLUDE_FILE(pthread.h HAVE_LIBPTHREAD)
408 CHECK_MODULE(libxine HAVE_XINE)
413 CHECK_MODULE(libv4l1 HAVE_LIBV4L)
414 CHECK_INCLUDE_FILE(linux/videodev.h HAVE_CAMV4L)
415 CHECK_INCLUDE_FILE(linux/videodev2.h HAVE_CAMV4L2)
417 set(HAVE_LIBV4L FALSE)
418 set(HAVE_CAMV4L FALSE)
419 set(HAVE_CAMV4L2 FALSE)
423 set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} dl m log)
424 elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
425 set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} m pthread)
427 set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} dl m pthread rt)
430 add_definitions(-DHAVE_ALLOCA -DHAVE_ALLOCA_H -DHAVE_LIBPTHREAD -DHAVE_UNISTD_H)
434 #################### LATEX for dpf documentation ##################
436 include(cmake/OpenCVFindLATEX.cmake REQUIRED)
439 ########################## Python Support #########################
440 include(cmake/OpenCVDetectPython.cmake REQUIRED)
442 ########################### Java Support ##########################
443 # current implementation of Java wrappers generator requires python at build time
444 if((NOT DEFINED BUILD_opencv_java OR BUILD_opencv_java) AND PYTHON_EXECUTABLE)
446 include(cmake/OpenCVDetectAndroidSDK.cmake REQUIRED)
447 if(NOT ANDROID_TOOLS_Pkg_Revision GREATER 13)
448 message(WARNING "OpenCV requires Android SDK tool revision 14 or newer. Otherwise tests and samples will no be compiled.")
451 include(cmake/OpenCVDetectApacheAnt.cmake REQUIRED)
453 if(ANDROID_EXECUTABLE AND ANT_EXECUTABLE AND (ANT_VERSION VERSION_GREATER 1.7) AND (ANDROID_TOOLS_Pkg_Revision GREATER 13))
454 SET(CAN_BUILD_ANDROID_PROJECTS TRUE)
456 SET(CAN_BUILD_ANDROID_PROJECTS FALSE)
460 ############################### QT ################################
462 set(HAVE_QT_OPENGL 0)
468 add_definitions(-DHAVE_QT) #We need to define te macro this way, using cvconfig.h.cmake does not work
471 find_package (OpenGL QUIET)
472 if(QT_QTOPENGL_FOUND AND OPENGL_FOUND)
474 set(HAVE_QT_OPENGL 1)
475 add_definitions(-DHAVE_QT_OPENGL)
476 set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES})
482 ############################### TBB ################################
484 include(cmake/OpenCVDetectTBB.cmake REQUIRED)
487 ############################ Intel IPP #############################
491 include(cmake/OpenCVFindIPP.cmake)
495 add_definitions(-DHAVE_IPP)
496 ocv_include_directories(${IPP_INCLUDE_DIRS})
497 link_directories(${IPP_LIBRARY_DIRS})
498 set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${IPP_LIBRARIES})
501 ############################### CUDA ################################
503 include(cmake/OpenCVDetectCUDA.cmake REQUIRED)
506 ############################### OpenNI ################################
507 set(HAVE_OPENNI FALSE)
508 set(HAVE_OPENNI_PRIME_SENSOR_MODULE FALSE)
511 include(cmake/OpenCVFindOpenNI.cmake)
514 ############################### XIMEA ################################
515 set(HAVE_XIMEA FALSE)
518 include(cmake/OpenCVFindXimea.cmake)
525 ############################## Eigen ##############################
527 find_path(EIGEN_INCLUDE_PATH "Eigen/Core"
528 PATHS "/usr/local/include/eigen2" "/opt/include/eigen2" "/usr/include/eigen2"
529 "/usr/local/include/eigen3" "/opt/include/eigen3" "/usr/include/eigen3"
530 DOC "The path to Eigen2/Eigen3 headers")
531 if(EIGEN_INCLUDE_PATH)
532 ocv_include_directories(${EIGEN_INCLUDE_PATH})
537 ################## Extra HighGUI libs on Windows ###################
539 set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} comctl32 gdi32 ole32)
542 set(HAVE_VIDEOINPUT 1)
546 set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} vfw32)
551 set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} msvfw32 avifil32 avicap32 winmm)
553 set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} vfw32 winmm)
557 if(WITH_OPENGL AND NOT HAVE_QT_OPENGL)
558 find_package(OpenGL QUIET)
562 set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES})
563 ocv_include_directories(${OPENGL_INCLUDE_DIR})
569 # ----------------------------------------------------------------------------
571 # ----------------------------------------------------------------------------
572 if(ENABLE_SOLUTION_FOLDERS)
573 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
574 set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
577 # Extra OpenCV targets: uninstall, package_source, perf, etc.
578 include(cmake/OpenCVExtraTargets.cmake REQUIRED)
581 # ----------------------------------------------------------------------------
582 # Process subdirectories
583 # ----------------------------------------------------------------------------
585 # opencv.hpp and legacy headers
586 add_subdirectory(include)
589 add_subdirectory(modules)
591 # Generate targets for documentation
592 add_subdirectory(doc)
594 # various data that is used by cv libraries and/or demo applications.
595 add_subdirectory(data)
598 add_subdirectory(apps)
601 if(BUILD_EXAMPLES OR BUILD_ANDROID_EXAMPLES OR INSTALL_PYTHON_EXAMPLES)
602 add_subdirectory(samples)
606 # ----------------------------------------------------------------------------
607 # Finalization: generate configuration-based files
608 # ----------------------------------------------------------------------------
609 ocv_track_build_dependencies()
611 # Generate platform-dependent and configuration-dependent headers
612 include(cmake/OpenCVGenHeaders.cmake REQUIRED)
614 # Generate opencv.pc for pkg-config command
615 include(cmake/OpenCVGenPkgconfig.cmake REQUIRED)
617 # Generate OpenCV.mk for ndk-build (Android build tool)
618 include(cmake/OpenCVGenAndroidMK.cmake REQUIRED)
620 # Generate OpenCVСonfig.cmake and OpenCVConfig-version.cmake for cmake projects
621 include(cmake/OpenCVGenConfig.cmake REQUIRED)
624 # ----------------------------------------------------------------------------
626 # ----------------------------------------------------------------------------
628 status("General configuration for OpenCV ${OPENCV_VERSION} =====================================")
633 status(" Host:" ${CMAKE_HOST_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_VERSION} ${CMAKE_HOST_SYSTEM_PROCESSOR})
634 status(" Target:" ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION} ${CMAKE_SYSTEM_PROCESSOR})
635 status(" CMake:" ${CMAKE_VERSION})
636 status(" CMake generator:" ${CMAKE_GENERATOR})
637 status(" CMake build tool:" ${CMAKE_BUILD_TOOL})
639 status(" MSVC:" ${MSVC_VERSION})
641 if(CMAKE_GENERATOR MATCHES Xcode)
642 status(" Xcode:" ${XCODE_VERSION})
648 status(" Built as dynamic libs?:" BUILD_SHARED_LIBS THEN YES ELSE NO)
649 status(" C++ Compiler:" CMAKE_COMPILER THEN "${CMAKE_COMPILER}" ELSE "${CMAKE_CXX_COMPILER}")
650 status(" C++ flags (Release):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE})
651 status(" C++ flags (Debug):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG})
653 status(" Linker flags (Release):" ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_RELEASE})
654 status(" Linker flags (Debug):" ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_DEBUG})
656 status(" Linker flags (Release):" ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_RELEASE})
657 status(" Linker flags (Debug):" ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_DEBUG})
662 status(" OpenCV modules:")
663 string(REPLACE "opencv_" "" OPENCV_MODULES_BUILD_ST "${OPENCV_MODULES_BUILD}")
664 string(REPLACE "opencv_" "" OPENCV_MODULES_DISABLED_USER_ST "${OPENCV_MODULES_DISABLED_USER}")
665 string(REPLACE "opencv_" "" OPENCV_MODULES_DISABLED_FORCE_ST "${OPENCV_MODULES_DISABLED_FORCE}")
666 set(OPENCV_MODULES_DISABLED_AUTO_ST "")
667 foreach(m ${OPENCV_MODULES_DISABLED_AUTO})
669 foreach(d ${OPENCV_MODULE_${m}_DEPS})
670 if(d MATCHES "^opencv_" AND NOT HAVE_${d})
671 list(APPEND __mdeps ${d})
674 list(APPEND OPENCV_MODULES_DISABLED_AUTO_ST "${m}(deps: ${__mdeps})")
676 string(REPLACE "opencv_" "" OPENCV_MODULES_DISABLED_AUTO_ST "${OPENCV_MODULES_DISABLED_AUTO_ST}")
678 status(" To be built:" OPENCV_MODULES_BUILD THEN ${OPENCV_MODULES_BUILD_ST} ELSE "-")
679 status(" Disabled by user:" OPENCV_MODULES_DISABLED_USER THEN ${OPENCV_MODULES_DISABLED_USER_ST} ELSE "-")
680 status(" Disabled by dependency:" OPENCV_MODULES_DISABLED_AUTO THEN ${OPENCV_MODULES_DISABLED_AUTO_ST} ELSE "-")
681 status(" Unavailable:" OPENCV_MODULES_DISABLED_FORCE THEN ${OPENCV_MODULES_DISABLED_FORCE_ST} ELSE "-")
687 status(" Android ABI:" ${ANDROID_ABI})
688 status(" Native API level:" android-${ANDROID_NATIVE_API_LEVEL})
689 status(" SDK target:" "${ANDROID_SDK_TARGET}")
690 if(BUILD_WITH_ANDROID_NDK)
691 status(" Android NDK:" "${ANDROID_NDK} (toolchain: ${ANDROID_TOOLCHAIN_NAME})")
692 elseif(BUILD_WITH_STANDALONE_TOOLCHAIN)
693 status(" Android toolchain:" "${ANDROID_STANDALONE_TOOLCHAIN}")
695 status(" android tool:" ANDROID_EXECUTABLE THEN "${ANDROID_EXECUTABLE} (${ANDROID_TOOLS_Pkg_Desc})" ELSE NO)
696 status(" ant:" ANT_EXECUTABLE THEN "${ANT_EXECUTABLE} (ver ${ANT_VERSION})" ELSE NO)
704 status(" QT 4.x:" HAVE_QT THEN YES ELSE NO)
705 status(" QT OpenGL support:" HAVE_QT_OPENGL THEN YES ELSE NO)
708 status(" Win32 UI:" YES)
712 status(" Carbon:" YES)
714 status(" Cocoa:" YES)
717 status(" GTK+ 2.x:" HAVE_GTK THEN YES ELSE NO)
718 status(" GThread :" HAVE_GTHREAD THEN YES ELSE NO)
719 status(" GtkGlExt:" HAVE_GTKGLEXT THEN YES ELSE NO)
724 status(" OpenGL support:" HAVE_OPENGL THEN YES ELSE NO)
728 status(" Media I/O: ")
729 status(" ZLib:" ZLIB_FOUND THEN "${ZLIB_LIBRARY}" ELSE build)
732 status(" JPEG:" JPEG_FOUND THEN "${JPEG_LIBRARY}" ELSE build)
734 status(" JPEG:" "NO")
737 status(" PNG:" PNG_FOUND THEN "${PNG_LIBRARY}" ELSE build)
742 status(" TIFF:" TIFF_FOUND THEN "${TIFF_LIBRARY}" ELSE build)
744 status(" TIFF:" "NO")
747 status(" JPEG 2000:" JASPER_FOUND THEN "${JASPER_LIBRARY}" ELSE build)
749 status(" JPEG 2000:" "NO")
752 status(" OpenEXR:" WITH_OPENEXR AND OPENEXR_FOUND THEN YES ELSE NO)
753 status(" OpenNI:" HAVE_OPENNI THEN YES ELSE NO)
754 status(" OpenNI PrimeSensor Modules:"
755 HAVE_OPENNI_PRIME_SENSOR_MODULE THEN YES ELSE NO)
757 status(" XIMEA:" HAVE_XIMEA THEN YES ELSE NO)
762 if(UNIX AND NOT APPLE)
763 status(" Video I/O:")
764 status(" DC1394 1.x:" HAVE_DC1394 THEN YES ELSE NO)
765 status(" DC1394 2.x:" HAVE_DC1394_2 THEN YES ELSE NO)
766 status(" FFMPEG:" HAVE_FFMPEG THEN YES ELSE NO)
767 status(" codec:" HAVE_FFMPEG_CODEC THEN YES ELSE NO)
768 status(" format:" HAVE_FFMPEG_FORMAT THEN YES ELSE NO)
769 status(" util:" HAVE_FFMPEG_UTIL THEN YES ELSE NO)
770 status(" swscale:" HAVE_FFMPEG_SWSCALE THEN YES ELSE NO)
771 status(" gentoo-style:" HAVE_GENTOO_FFMPEG THEN YES ELSE NO)
772 status(" GStreamer:" HAVE_GSTREAMER THEN YES ELSE NO)
773 status(" UniCap:" HAVE_UNICAP THEN YES ELSE NO)
774 status(" PvAPI:" HAVE_PVAPI THEN YES ELSE NO)
775 status(" V4L/V4L2:" HAVE_LIBV4L THEN "Using libv4l" ELSE ${HAVE_CAMV4L}/${HAVE_CAMV4L2})
776 status(" Xine:" HAVE_XINE THEN YES ELSE NO)
779 if(HAVE_opencv_androidcamera)
780 status(" AndroidNativeCamera:" BUILD_ANDROID_CAMERA_WRAPPER THEN "YES, build for Android ${ANDROID_VERSION}" ELSE "YES, use prebuilt libraries")
782 status(" AndroidNativeCamera:" "NO (native camera requires Android API level 8 or higher)")
787 status(" Video I/O:" WITH_QUICKTIME THEN QuickTime ELSE QTKit)
789 status(" Video I/O: AVFoundation")
792 status(" Video I/O:" HAVE_VIDEOINPUT THEN DirectShow ELSE NO)
795 # Other third-party libraries
797 status(" Other third-party libraries:")
799 if(WITH_IPP AND IPP_FOUND)
800 status(" Use IPP:" "${IPP_LATEST_VERSION_STR} [${IPP_LATEST_VERSION_MAJOR}.${IPP_LATEST_VERSION_MINOR}.${IPP_LATEST_VERSION_BUILD}]")
801 status(" at:" "${IPP_ROOT_DIR}")
803 status(" Use IPP:" WITH_IPP AND NOT IPP_FOUND THEN "IPP not found" ELSE NO)
806 status(" Use TBB:" HAVE_TBB THEN YES ELSE NO)
807 status(" Use Cuda:" HAVE_CUDA THEN YES ELSE NO)
808 status(" Use Eigen:" HAVE_EIGEN THEN YES ELSE NO)
811 status(" Python interpreter:" PYTHON_EXECUTABLE THEN "${PYTHON_EXECUTABLE} (ver ${PYTHON_VERSION_MAJOR_MINOR})" ELSE NO)
812 # interfaces to other languages
814 status(" Interfaces:")
815 status(" Python:" HAVE_opencv_python THEN YES ELSE NO)
816 status(" Python numpy:" PYTHON_USE_NUMPY THEN YES ELSE "NO (Python wrappers can not be generated)")
818 status(" Java:" HAVE_opencv_java THEN YES ELSE NO)
823 status(" Documentation:")
824 status(" Sphinx:" HAVE_SPHINX THEN "${SPHINX_BUILD} (ver ${SPHINX_VERSION})" ELSE NO)
825 status(" PdfLaTeX compiler:" PDFLATEX_COMPILER THEN "${PDFLATEX_COMPILER}" ELSE NO)
826 if(BUILD_DOCS AND HAVE_SPHINX)
827 status(" Build Documentation:" PDFLATEX_COMPILER THEN YES ELSE "YES (only HTML without math expressions)")
829 status(" Build Documentation:" NO)
834 status(" Tests and samples:")
835 status(" Tests:" BUILD_TESTS AND HAVE_opencv_ts THEN YES ELSE NO)
836 status(" Performance tests:" BUILD_PERF_TESTS AND HAVE_opencv_ts THEN YES ELSE NO)
837 status(" Examples:" BUILD_EXAMPLES THEN YES ELSE NO)
840 status(" Android tests:" BUILD_TESTS AND CAN_BUILD_ANDROID_PROJECTS THEN YES ELSE NO)
841 status(" Android examples:" BUILD_ANDROID_EXAMPLES THEN YES ELSE NO)
846 status(" Install path:" "${CMAKE_INSTALL_PREFIX}")
848 status(" cvconfig.h is in:" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}")
849 status("-----------------------------------------------------------------")
852 # ----------------------------------------------------------------------------
853 # Warn in the case of in-source build
854 # ----------------------------------------------------------------------------
855 if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
856 message(WARNING "The source directory is the same as binary directory. \"make clean\" may damage the source tree")