added background subtraction sample for gpu module
[profile/ivi/opencv.git] / CMakeLists.txt
1 # ----------------------------------------------------------------------------
2 #  Root CMake file for OpenCV
3 #
4 #    From the off-tree build directory, invoke:
5 #      $ cmake <PATH_TO_OPENCV_ROOT>
6 #
7 #
8 #   - OCT-2008: Initial version <joseluisblancoc@gmail.com>
9 #
10 # ----------------------------------------------------------------------------
11
12 set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
13
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)
21 endif()
22
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
28   if(WIN32)
29     set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory")
30   else()
31     set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation Directory")
32   endif()
33
34   if(MSVC)
35     set(CMAKE_USE_RELATIVE_PATHS ON CACHE INTERNAL "" FORCE)
36   endif()
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)
41
42 # --------------------------------------------------------------
43 # Top level OpenCV project
44 # --------------------------------------------------------------
45 if(CMAKE_GENERATOR MATCHES Xcode AND XCODE_VERSION VERSION_GREATER 4.3)
46   cmake_minimum_required(VERSION 2.8.8)
47 elseif(IOS)
48   cmake_minimum_required(VERSION 2.8.0)
49 else()
50   cmake_minimum_required(VERSION 2.6.3)
51 endif()
52
53 # must go before the project command
54 set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE)
55 if(DEFINED CMAKE_BUILD_TYPE AND CMAKE_VERSION VERSION_GREATER "2.8")
56   set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES} )
57 endif()
58
59 project(OpenCV CXX C)
60
61 include(cmake/OpenCVUtils.cmake REQUIRED)
62
63 # ----------------------------------------------------------------------------
64 # Break in case of popular CMake configuration mistakes
65 # ----------------------------------------------------------------------------
66 if(NOT CMAKE_SIZEOF_VOID_P GREATER 0)
67   message(FATAL_ERROR "CMake fails to deterimine the bitness of target platform.
68   Please check your CMake and compiler installation. If you are crosscompiling then ensure that your CMake toolchain file correctly sets the compiler details.")
69 endif()
70
71 # ----------------------------------------------------------------------------
72 # Detect compiler and target platform architecture
73 # ----------------------------------------------------------------------------
74 include(cmake/OpenCVDetectCXXCompiler.cmake REQUIRED)
75
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)
80     if(EXISTS /lib64)
81       list(APPEND CMAKE_LIBRARY_PATH /lib64)
82     else()
83       list(APPEND CMAKE_LIBRARY_PATH /lib)
84     endif()
85     if(EXISTS /usr/lib64)
86       list(APPEND CMAKE_LIBRARY_PATH /usr/lib64)
87     else()
88       list(APPEND CMAKE_LIBRARY_PATH /usr/lib)
89     endif()
90   elseif(X86 OR CMAKE_SIZEOF_VOID_P EQUAL 4)
91     if(EXISTS /lib32)
92       list(APPEND CMAKE_LIBRARY_PATH /lib32)
93     else()
94       list(APPEND CMAKE_LIBRARY_PATH /lib)
95     endif()
96     if(EXISTS /usr/lib32)
97       list(APPEND CMAKE_LIBRARY_PATH /usr/lib32)
98     else()
99       list(APPEND CMAKE_LIBRARY_PATH /usr/lib)
100     endif()
101   endif()
102 endif()
103
104
105 # ----------------------------------------------------------------------------
106 # OpenCV cmake options
107 # ----------------------------------------------------------------------------
108
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 (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_IMAGEIO        "ImageIO support for OS X"                    OFF  IF APPLE)
122 OCV_OPTION(WITH_IPP            "Include Intel IPP support"                   OFF  IF (MSVC OR X86 OR X86_64) )
123 OCV_OPTION(WITH_JASPER         "Include JPEG2K support"                      ON   IF (NOT IOS) )
124 OCV_OPTION(WITH_JPEG           "Include JPEG support"                        ON   IF (NOT IOS) )
125 OCV_OPTION(WITH_OPENEXR        "Include ILM support via OpenEXR"             ON   IF (NOT IOS) )
126 OCV_OPTION(WITH_OPENGL         "Include OpenGL support"                      OFF  IF (NOT ANDROID AND NOT IOS AND NOT APPLE) )
127 OCV_OPTION(WITH_OPENNI         "Include OpenNI support"                      OFF  IF (NOT ANDROID AND NOT IOS) )
128 OCV_OPTION(WITH_PNG            "Include PNG support"                         ON   IF (NOT IOS) )
129 OCV_OPTION(WITH_PVAPI          "Include Prosilica GigE support"              ON   IF (NOT ANDROID AND NOT IOS) )
130 OCV_OPTION(WITH_QT             "Build with Qt Backend support"               OFF  IF (NOT ANDROID AND NOT IOS) )
131 OCV_OPTION(WITH_QUICKTIME      "Use QuickTime for Video I/O insted of QTKit" OFF  IF APPLE )
132 OCV_OPTION(WITH_TBB            "Include Intel TBB support"                   OFF  IF (NOT IOS) )
133 OCV_OPTION(WITH_TIFF           "Include TIFF support"                        ON   IF (NOT IOS) )
134 OCV_OPTION(WITH_UNICAP         "Include Unicap support (GPL)"                OFF  IF (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS) )
135 OCV_OPTION(WITH_V4L            "Include Video 4 Linux support"               ON   IF (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS) )
136 OCV_OPTION(WITH_VIDEOINPUT     "Build HighGUI with DirectShow support"       ON   IF WIN32 )
137 OCV_OPTION(WITH_XIMEA          "Include XIMEA cameras support"               OFF  IF WIN32 )
138 OCV_OPTION(WITH_XINE           "Include Xine support (GPL)"                  OFF  IF (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS) )
139 OCV_OPTION(WITH_CLP            "Include Clp support (EPL)"                   OFF)
140
141 # OpenCV build components
142 # ===================================================
143 OCV_OPTION(BUILD_SHARED_LIBS        "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" NOT (ANDROID OR IOS) )
144 OCV_OPTION(BUILD_ANDROID_EXAMPLES   "Build examples for Android platform"         ON  IF ANDROID )
145 OCV_OPTION(BUILD_DOCS               "Create build rules for OpenCV Documentation" ON )
146 OCV_OPTION(BUILD_EXAMPLES           "Build all examples"                          OFF )
147 OCV_OPTION(BUILD_PACKAGE            "Enables 'make package_source' command"       ON )
148 OCV_OPTION(BUILD_PERF_TESTS         "Build performance tests"                     ON  IF (NOT IOS) )
149 OCV_OPTION(BUILD_TESTS              "Build accuracy & regression tests"           ON  IF (NOT IOS) )
150 OCV_OPTION(BUILD_WITH_DEBUG_INFO    "Include debug info into debug libs (not MSCV only)" ON )
151 OCV_OPTION(BUILD_WITH_STATIC_CRT    "Enables use of staticaly linked CRT for staticaly linked OpenCV" ON IF MSVC )
152 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 )
153 OCV_OPTION(BUILD_ANDROID_SERVICE    "TBD" OFF IF ANDROID )
154 OCV_OPTION(BUILD_ANDROID_PACKAGE    "TBD" OFF IF ANDROID )
155
156 # 3rd party libs
157 OCV_OPTION(BUILD_ZLIB               "Build zlib from source"         WIN32 OR IOS OR APPLE )
158 OCV_OPTION(BUILD_TIFF               "Build libtiff from source"      WIN32 OR IOS OR ANDROID OR APPLE )
159 OCV_OPTION(BUILD_JASPER             "Build libjasper from source"    WIN32 OR IOS OR ANDROID OR APPLE )
160 OCV_OPTION(BUILD_JPEG               "Build libjpeg from source"      WIN32 OR IOS OR ANDROID OR APPLE )
161 OCV_OPTION(BUILD_PNG                "Build libpng from source"       WIN32 OR IOS OR ANDROID OR APPLE )
162
163 # OpenCV installation options
164 # ===================================================
165 OCV_OPTION(INSTALL_C_EXAMPLES       "Install C examples"        OFF )
166 OCV_OPTION(INSTALL_PYTHON_EXAMPLES  "Install Python examples"   OFF )
167 OCV_OPTION(INSTALL_ANDROID_EXAMPLES "Install Android examples"  OFF  IF ANDROID )
168 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) )
169
170
171 if(MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode)
172   set(ENABLE_SOLUTION_FOLDERS0 ON)
173 else()
174   set(ENABLE_SOLUTION_FOLDERS0 OFF)
175 endif()
176
177 # OpenCV build options
178 # ===================================================
179 OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers"                                  ON   IF (NOT IOS) )
180 OCV_OPTION(ENABLE_SOLUTION_FOLDERS    "Solution folder in Visual Studio or in other IDEs"        ${ENABLE_SOLUTION_FOLDERS0} IF (CMAKE_VERSION VERSION_GREATER "2.8.0") )
181 OCV_OPTION(ENABLE_PROFILING           "Enable profiling in the GCC compiler (Add flags: -g -pg)" OFF  IF CMAKE_COMPILER_IS_GNUCXX )
182 OCV_OPTION(ENABLE_OMIT_FRAME_POINTER  "Enable -fomit-frame-pointer for GCC"                      ON   IF CMAKE_COMPILER_IS_GNUCXX )
183 OCV_OPTION(ENABLE_POWERPC             "Enable PowerPC for GCC"                                   ON   IF (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES powerpc.*) )
184 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)) )
185 OCV_OPTION(ENABLE_SSE                 "Enable SSE instructions"                                  ON   IF (MSVC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
186 OCV_OPTION(ENABLE_SSE2                "Enable SSE2 instructions"                                 ON   IF (MSVC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
187 OCV_OPTION(ENABLE_SSE3                "Enable SSE3 instructions"                                 OFF  IF (CV_ICC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
188 OCV_OPTION(ENABLE_SSSE3               "Enable SSSE3 instructions"                                OFF  IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
189 OCV_OPTION(ENABLE_SSE41               "Enable SSE4.1 instructions"                               OFF  IF (CV_ICC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
190 OCV_OPTION(ENABLE_SSE42               "Enable SSE4.2 instructions"                               OFF  IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
191 OCV_OPTION(ENABLE_NOISY_WARNINGS      "Show all warnings even if they are too noisy"             OFF )
192 OCV_OPTION(OPENCV_WARNINGS_ARE_ERRORS "Treat warnings as errors"                                 OFF )
193
194 # uncategorized options
195 # ===================================================
196 OCV_OPTION(CMAKE_VERBOSE "Verbose mode" OFF )
197
198 # backward compatibility
199 # ===================================================
200 include(cmake/OpenCVLegacyOptions.cmake OPTIONAL)
201
202
203 # ----------------------------------------------------------------------------
204 #  Get actual OpenCV version number from sources
205 # ----------------------------------------------------------------------------
206 include(cmake/OpenCVVersion.cmake REQUIRED)
207
208
209 # ----------------------------------------------------------------------------
210 #  Build & install layouts
211 # ----------------------------------------------------------------------------
212
213 # Save libs and executables in the same place
214 set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib" CACHE PATH "Output directory for libraries" )
215 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin" CACHE PATH "Output directory for applications" )
216
217 if(ANDROID OR WIN32)
218     set(OPENCV_DOC_INSTALL_PATH doc)
219 elseif(INSTALL_TO_MANGLED_PATHS)
220     set(OPENCV_DOC_INSTALL_PATH share/OpenCV-${OPENCV_VERSION}/doc)
221 else()
222     set(OPENCV_DOC_INSTALL_PATH share/OpenCV/doc)
223 endif()
224
225 if(ANDROID)
226     set(OPENCV_LIB_INSTALL_PATH libs/${ANDROID_NDK_ABI_NAME})
227 else()
228     set(OPENCV_LIB_INSTALL_PATH lib${LIB_SUFFIX})
229 endif()
230
231 set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${OPENCV_LIB_INSTALL_PATH}")
232 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
233
234 set(OPENCV_INCLUDE_PREFIX include)
235 if(INSTALL_TO_MANGLED_PATHS)
236   set(OPENCV_INCLUDE_PREFIX include/opencv-${OPENCV_VERSION})
237 endif()
238
239 if(WIN32)
240   # Postfix of DLLs:
241   set(OPENCV_DLLVERSION "${OPENCV_VERSION_MAJOR}${OPENCV_VERSION_MINOR}${OPENCV_VERSION_PATCH}")
242   set(OPENCV_DEBUG_POSTFIX d)
243 else()
244   # Postfix of so's:
245   set(OPENCV_DLLVERSION "")
246   set(OPENCV_DEBUG_POSTFIX "")
247 endif()
248
249 if(DEFINED CMAKE_DEBUG_POSTFIX)
250   set(OPENCV_DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
251 endif()
252
253 if(CMAKE_VERBOSE)
254   set(CMAKE_VERBOSE_MAKEFILE 1)
255 endif()
256
257
258 # ----------------------------------------------------------------------------
259 #  Path for build/platform -specific headers
260 # ----------------------------------------------------------------------------
261 set(OPENCV_CONFIG_FILE_INCLUDE_DIR "${CMAKE_BINARY_DIR}/" CACHE PATH "Where to create the platform-dependant cvconfig.h")
262 add_definitions(-DHAVE_CVCONFIG_H)
263 ocv_include_directories(${OPENCV_CONFIG_FILE_INCLUDE_DIR})
264
265
266 # ----------------------------------------------------------------------------
267 #  Autodetect if we are in a SVN repository
268 # ----------------------------------------------------------------------------
269 find_host_program(SVNVERSION_PATH svnversion)
270 mark_as_advanced(force SVNVERSION_PATH)
271 if(SVNVERSION_PATH)
272     message(STATUS "Extracting svn version, please wait...")
273     execute_process(COMMAND ${SVNVERSION_PATH} -n ${OpenCV_SOURCE_DIR} OUTPUT_VARIABLE SVNVERSION_RESULT)
274
275     if(SVNVERSION_RESULT MATCHES "exported")
276         # This is NOT a svn repository:
277         set(OPENCV_SVNVERSION "")
278         message(STATUS "SVNVERSION: exported")
279     else()
280         set(OPENCV_SVNVERSION " svn:${SVNVERSION_RESULT}")
281         message(STATUS "SVNVERSION: ${OPENCV_SVNVERSION}")
282     endif()
283 else()
284     # We don't have svnversion:
285     set(OPENCV_SVNVERSION "")
286 endif()
287
288
289 # ----------------------------------------------------------------------------
290 # OpenCV compiler and linker options
291 # ----------------------------------------------------------------------------
292 # In case of Makefiles if the user does not setup CMAKE_BUILD_TYPE, assume it's Release:
293 if(CMAKE_GENERATOR MATCHES "Makefiles|Ninja" AND "${CMAKE_BUILD_TYPE}" STREQUAL "")
294   set(CMAKE_BUILD_TYPE Release)
295 endif()
296
297 include(cmake/OpenCVCompilerOptions.cmake REQUIRED)
298
299
300 # ----------------------------------------------------------------------------
301 # Use statically or dynamically linked CRT?
302 # Default: dynamic
303 # ----------------------------------------------------------------------------
304 if(MSVC)
305   include(cmake/OpenCVCRTLinkage.cmake REQUIRED)
306 endif(MSVC)
307
308
309 # ----------------------------------------------------------------------------
310 #       CHECK FOR SYSTEM LIBRARIES, OPTIONS, ETC..
311 # ----------------------------------------------------------------------------
312 if(UNIX)
313   include(cmake/OpenCVFindPkgConfig.cmake OPTIONAL)
314   include(CheckFunctionExists)
315   include(CheckIncludeFile)
316
317   if(NOT APPLE)
318     CHECK_INCLUDE_FILE(alloca.h HAVE_ALLOCA_H)
319     CHECK_FUNCTION_EXISTS(alloca HAVE_ALLOCA)
320     CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
321     CHECK_INCLUDE_FILE(pthread.h HAVE_LIBPTHREAD)
322     if(ANDROID)
323       set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} dl m log)
324     elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD|NetBSD|DragonFly")
325       set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} m pthread)
326     else()
327       set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} dl m pthread rt)
328     endif()
329   else()
330     add_definitions(-DHAVE_ALLOCA -DHAVE_ALLOCA_H -DHAVE_LIBPTHREAD -DHAVE_UNISTD_H)
331   endif()
332 endif()
333
334 #
335 # Check to see if we have large file support (needed by zlib)
336 #
337 include(CheckTypeSize)
338 check_type_size(off64_t OFF64_T)
339 if(HAVE_OFF64_T)
340   add_definitions(-D_LARGEFILE64_SOURCE=1)
341 endif()
342
343 include(cmake/OpenCVPCHSupport.cmake REQUIRED)
344 include(cmake/OpenCVModule.cmake REQUIRED)
345
346 # ----------------------------------------------------------------------------
347 #  Detect 3rd-party libraries
348 # ----------------------------------------------------------------------------
349
350 include(cmake/OpenCVFindLibsGrfmt.cmake REQUIRED)
351 include(cmake/OpenCVFindLibsGUI.cmake   REQUIRED)
352 include(cmake/OpenCVFindLibsVideo.cmake REQUIRED)
353 include(cmake/OpenCVFindLibsPerf.cmake  REQUIRED)
354
355
356 # ----------------------------------------------------------------------------
357 #  Detect other 3rd-party libraries/tools
358 # ----------------------------------------------------------------------------
359
360 # --- LATEX for pdf documentation ---
361 if(BUILD_DOCS)
362   include(cmake/OpenCVFindLATEX.cmake REQUIRED)
363 endif(BUILD_DOCS)
364
365 # --- Python Support ---
366 include(cmake/OpenCVDetectPython.cmake REQUIRED)
367
368 # --- Java Support ---
369 if(ANDROID)
370   include(cmake/OpenCVDetectApacheAnt.cmake REQUIRED)
371   include(cmake/OpenCVDetectAndroidSDK.cmake REQUIRED)
372
373   if(NOT ANDROID_TOOLS_Pkg_Revision GREATER 13)
374     message(WARNING "OpenCV requires Android SDK tools revision 14 or newer. Otherwise tests and samples will no be compiled.")
375   endif()
376 endif(ANDROID)
377
378 if(ANDROID AND ANDROID_EXECUTABLE AND ANT_EXECUTABLE AND (ANT_VERSION VERSION_GREATER 1.7) AND (ANDROID_TOOLS_Pkg_Revision GREATER 13))
379   SET(CAN_BUILD_ANDROID_PROJECTS TRUE)
380 else()
381   SET(CAN_BUILD_ANDROID_PROJECTS FALSE)
382 endif()
383
384
385 # ----------------------------------------------------------------------------
386 # Solution folders:
387 # ----------------------------------------------------------------------------
388 if(ENABLE_SOLUTION_FOLDERS)
389   set_property(GLOBAL PROPERTY USE_FOLDERS ON)
390   set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
391 endif()
392
393 # Extra OpenCV targets: uninstall, package_source, perf, etc.
394 include(cmake/OpenCVExtraTargets.cmake REQUIRED)
395
396
397 # ----------------------------------------------------------------------------
398 # Process subdirectories
399 # ----------------------------------------------------------------------------
400
401 # opencv.hpp and legacy headers
402 add_subdirectory(include)
403
404 # OpenCV modules
405 add_subdirectory(modules)
406
407 # Generate targets for documentation
408 add_subdirectory(doc)
409
410 # various data that is used by cv libraries and/or demo applications.
411 add_subdirectory(data)
412
413 # extra applications
414 add_subdirectory(apps)
415
416 # examples
417 if(BUILD_EXAMPLES OR BUILD_ANDROID_EXAMPLES OR INSTALL_PYTHON_EXAMPLES)
418   add_subdirectory(samples)
419 endif()
420
421 if(BUILD_ANDROID_SERVICE)
422   add_subdirectory(android/service)
423 endif()
424
425 if(BUILD_ANDROID_PACKAGE)
426   add_subdirectory(android/package)
427 endif()
428
429 # ----------------------------------------------------------------------------
430 # Finalization: generate configuration-based files
431 # ----------------------------------------------------------------------------
432 ocv_track_build_dependencies()
433
434 # Generate platform-dependent and configuration-dependent headers
435 include(cmake/OpenCVGenHeaders.cmake REQUIRED)
436
437 # Generate opencv.pc for pkg-config command
438 include(cmake/OpenCVGenPkgconfig.cmake REQUIRED)
439
440 # Generate OpenCV.mk for ndk-build (Android build tool)
441 include(cmake/OpenCVGenAndroidMK.cmake REQUIRED)
442
443 # Generate OpenCVСonfig.cmake and OpenCVConfig-version.cmake for cmake projects
444 include(cmake/OpenCVGenConfig.cmake REQUIRED)
445
446
447 # ----------------------------------------------------------------------------
448 # Summary:
449 # ----------------------------------------------------------------------------
450 status("")
451 status("General configuration for OpenCV ${OPENCV_VERSION} =====================================")
452 if(OPENCV_SVNVERSION)
453   status("Version control:" ${OPENCV_SVNVERSION})
454 endif()
455
456 # ========================== build platform ==========================
457 status("")
458 status("  Platform:")
459 status("    Host:"             ${CMAKE_HOST_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_VERSION} ${CMAKE_HOST_SYSTEM_PROCESSOR})
460 if(CMAKE_CROSSCOMPILING)
461   status("    Target:"         ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION} ${CMAKE_SYSTEM_PROCESSOR})
462 endif()
463 status("    CMake:"            ${CMAKE_VERSION})
464 status("    CMake generator:"  ${CMAKE_GENERATOR})
465 status("    CMake build tool:" ${CMAKE_BUILD_TOOL})
466 if(MSVC)
467   status("    MSVC:"           ${MSVC_VERSION})
468 endif()
469 if(CMAKE_GENERATOR MATCHES Xcode)
470   status("    Xcode:"          ${XCODE_VERSION})
471 endif()
472 if(NOT CMAKE_GENERATOR MATCHES "Xcode|Visual Studio")
473   status("    Configuration:"  ${CMAKE_BUILD_TYPE})
474 endif()
475
476 # ========================== C/C++ options ==========================
477 status("")
478 status("  C/C++:")
479 status("    Built as dynamic libs?:" BUILD_SHARED_LIBS THEN YES ELSE NO)
480 status("    C++ Compiler:"           CMAKE_COMPILER_IS_GNUCXX THEN "${CMAKE_CXX_COMPILER} (ver ${CMAKE_GCC_REGEX_VERSION})" ELSE "${CMAKE_CXX_COMPILER}" )
481 status("    C++ flags (Release):"    ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE})
482 status("    C++ flags (Debug):"      ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG})
483 status("    C Compiler:"             ${CMAKE_C_COMPILER})
484 status("    C flags (Release):"      ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE})
485 status("    C flags (Debug):"        ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG})
486 if(WIN32)
487   status("    Linker flags (Release):" ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_RELEASE})
488   status("    Linker flags (Debug):"   ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_DEBUG})
489 else()
490   status("    Linker flags (Release):" ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_RELEASE})
491   status("    Linker flags (Debug):"   ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_DEBUG})
492 endif()
493 status("    Precompiled headers:"     PCHSupport_FOUND AND ENABLE_PRECOMPILED_HEADERS THEN YES ELSE NO)
494
495 # ========================== OpenCV modules ==========================
496 status("")
497 status("  OpenCV modules:")
498 string(REPLACE "opencv_" "" OPENCV_MODULES_BUILD_ST          "${OPENCV_MODULES_BUILD}")
499 string(REPLACE "opencv_" "" OPENCV_MODULES_DISABLED_USER_ST  "${OPENCV_MODULES_DISABLED_USER}")
500 string(REPLACE "opencv_" "" OPENCV_MODULES_DISABLED_FORCE_ST "${OPENCV_MODULES_DISABLED_FORCE}")
501 set(OPENCV_MODULES_DISABLED_AUTO_ST "")
502 foreach(m ${OPENCV_MODULES_DISABLED_AUTO})
503   set(__mdeps "")
504   foreach(d ${OPENCV_MODULE_${m}_DEPS})
505     if(d MATCHES "^opencv_" AND NOT HAVE_${d})
506       list(APPEND __mdeps ${d})
507     endif()
508   endforeach()
509   list(APPEND OPENCV_MODULES_DISABLED_AUTO_ST "${m}(deps: ${__mdeps})")
510 endforeach()
511 string(REPLACE "opencv_" "" OPENCV_MODULES_DISABLED_AUTO_ST  "${OPENCV_MODULES_DISABLED_AUTO_ST}")
512
513 status("    To be built:"            OPENCV_MODULES_BUILD          THEN ${OPENCV_MODULES_BUILD_ST}          ELSE "-")
514 status("    Disabled:"               OPENCV_MODULES_DISABLED_USER  THEN ${OPENCV_MODULES_DISABLED_USER_ST}  ELSE "-")
515 status("    Disabled by dependency:" OPENCV_MODULES_DISABLED_AUTO  THEN ${OPENCV_MODULES_DISABLED_AUTO_ST}  ELSE "-")
516 status("    Unavailable:"            OPENCV_MODULES_DISABLED_FORCE THEN ${OPENCV_MODULES_DISABLED_FORCE_ST} ELSE "-")
517
518 # ========================== Android details ==========================
519 if(ANDROID)
520   status("")
521   status("  Android: ")
522   status("    Android ABI:" ${ANDROID_ABI})
523   status("    Native API level:" android-${ANDROID_NATIVE_API_LEVEL})
524   status("    SDK target:" "${ANDROID_SDK_TARGET}")
525   if(BUILD_WITH_ANDROID_NDK)
526     status("    Android NDK:" "${ANDROID_NDK} (toolchain: ${ANDROID_TOOLCHAIN_NAME})")
527   elseif(BUILD_WITH_STANDALONE_TOOLCHAIN)
528     status("    Android toolchain:" "${ANDROID_STANDALONE_TOOLCHAIN}")
529   endif()
530   status("    android tool:"  ANDROID_EXECUTABLE  THEN "${ANDROID_EXECUTABLE} (${ANDROID_TOOLS_Pkg_Desc})" ELSE NO)
531   status("    ant:"           ANT_EXECUTABLE      THEN "${ANT_EXECUTABLE} (ver ${ANT_VERSION})"            ELSE NO)
532   status("    Build service:" BUILD_ANDROID_SERVICE THEN YES ELSE NO)
533 endif()
534
535 # ========================== GUI ==========================
536 status("")
537 status("  GUI: ")
538
539 if(HAVE_QT)
540   status("    QT 4.x:"            HAVE_QT        THEN "YES (ver ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH} ${QT_EDITION})" ELSE NO)
541   status("    QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${QT_QTOPENGL_LIBRARY})" ELSE NO)
542 else()
543   if(DEFINED WITH_QT)
544     status("    QT 4.x:" NO)
545   endif()
546   if(WIN32)
547     status("    Win32 UI:" YES)
548   else()
549     if(APPLE)
550       if(WITH_CARBON)
551         status("    Carbon:" YES)
552       else()
553         status("    Cocoa:"  YES)
554       endif()
555     else()
556       status("    GTK+ 2.x:" HAVE_GTK      THEN "YES (ver ${ALIASOF_gtk+-2.0_VERSION})"     ELSE NO)
557       status("    GThread :" HAVE_GTHREAD  THEN "YES (ver ${ALIASOF_gthread-2.0_VERSION})"  ELSE NO)
558       status("    GtkGlExt:" HAVE_GTKGLEXT THEN "YES (ver ${ALIASOF_gtkglext-1.0_VERSION})" ELSE NO)
559     endif()
560   endif()
561 endif()
562
563 status("    OpenGL support:" HAVE_OPENGL THEN "YES (${OPENGL_LIBRARIES})" ELSE NO)
564
565 # ========================== MEDIA IO ==========================
566 status("")
567 status("  Media I/O: ")
568 status("    ZLib:"         BUILD_ZLIB    THEN "build (ver ${ZLIB_VERSION_STRING})"               ELSE "${ZLIB_LIBRARY} (ver ${ZLIB_VERSION_STRING})")
569
570 if(WITH_JPEG)
571   status("    JPEG:"       JPEG_FOUND    THEN "${JPEG_LIBRARY} (ver ${JPEG_LIB_VERSION})"        ELSE "build (ver ${JPEG_LIB_VERSION})")
572 else()
573   status("    JPEG:"       "NO")
574 endif()
575 if(WITH_PNG)
576   status("    PNG:"        PNG_FOUND     THEN "${PNG_LIBRARY} (ver ${PNG_VERSION})"              ELSE "build (ver ${PNG_VERSION})")
577 else()
578   status("    PNG:"        "NO")
579 endif()
580 if(WITH_TIFF)
581   if(TIFF_VERSION_STRING AND TIFF_FOUND)
582     status("    TIFF:"     "${TIFF_LIBRARY} (ver ${TIFF_VERSION} - ${TIFF_VERSION_STRING})")
583   else()
584     status("    TIFF:"     TIFF_FOUND    THEN "${TIFF_LIBRARY} (ver ${TIFF_VERSION})"            ELSE "build (ver ${TIFF_VERSION} - ${TIFF_VERSION_STRING})")
585   endif()
586 else()
587   status("    TIFF:"       "NO")
588 endif()
589 if(WITH_JASPER)
590   status("    JPEG 2000:"  JASPER_FOUND  THEN "${JASPER_LIBRARY} (ver ${JASPER_VERSION_STRING})" ELSE "build (ver ${JASPER_VERSION_STRING})")
591 else()
592   status("    JPEG 2000:"  "NO")
593 endif()
594
595 status("    OpenEXR:"   WITH_OPENEXR AND OPENEXR_FOUND     THEN "${OPENEXR_LIBRARIES} (ver ${OPENEXR_VERSION})"                     ELSE NO)
596
597 # ========================== VIDEO IO ==========================
598 status("")
599 status("  Video I/O:")
600
601 if(DEFINED WITH_1394)
602   status("    DC1394 1.x:"     HAVE_DC1394         THEN "YES (ver ${ALIASOF_libdc1394_VERSION})"   ELSE NO)
603   status("    DC1394 2.x:"     HAVE_DC1394_2       THEN "YES (ver ${ALIASOF_libdc1394-2_VERSION})" ELSE NO)
604 endif(DEFINED WITH_1394)
605
606 if(ANDROID)
607   if(HAVE_opencv_androidcamera)
608     status("    AndroidNativeCamera:" BUILD_ANDROID_CAMERA_WRAPPER
609                                                    THEN "YES, build for Android${ANDROID_VERSION}" ELSE "YES, use prebuilt libraries")
610   else()
611     status("    AndroidNativeCamera:" "NO (native camera requires Android API level 8 or higher)")
612   endif()
613 endif()
614
615 if(DEFINED WITH_AVFOUNDATION)
616   status("    AVFoundation:"   WITH_AVFOUNDATION   THEN YES                                        ELSE NO)
617 endif(DEFINED WITH_AVFOUNDATION)
618
619 if(DEFINED WITH_FFMPEG)
620   if(WIN32)
621     status("    FFMPEG:"       WITH_FFMPEG         THEN "YES (prebuilt binaries)"                  ELSE NO)
622   else()
623     status("    FFMPEG:"       HAVE_FFMPEG         THEN YES ELSE NO)
624   endif()
625   status("      codec:"        HAVE_FFMPEG_CODEC   THEN "YES (ver ${ALIASOF_libavcodec_VERSION})"  ELSE NO)
626   status("      format:"       HAVE_FFMPEG_FORMAT  THEN "YES (ver ${ALIASOF_libavformat_VERSION})" ELSE NO)
627   status("      util:"         HAVE_FFMPEG_UTIL    THEN "YES (ver ${ALIASOF_libavutil_VERSION})"   ELSE NO)
628   status("      swscale:"      HAVE_FFMPEG_SWSCALE THEN "YES (ver ${ALIASOF_libswscale_VERSION})"  ELSE NO)
629   status("      gentoo-style:" HAVE_GENTOO_FFMPEG  THEN YES                                        ELSE NO)
630 endif(DEFINED WITH_FFMPEG)
631
632 if(DEFINED WITH_GSTREAMER)
633   status("    GStreamer:"      HAVE_GSTREAMER      THEN ""                                         ELSE NO)
634   if(HAVE_GSTREAMER)
635     status("      base:"       "YES (ver ${ALIASOF_gstreamer-base-0.10_VERSION})")
636     status("      app:"        "YES (ver ${ALIASOF_gstreamer-app-0.10_VERSION})")
637     status("      video:"      "YES (ver ${ALIASOF_gstreamer-video-0.10_VERSION})")
638   endif()
639 endif(DEFINED WITH_GSTREAMER)
640
641 if(DEFINED WITH_OPENNI)
642   status("    OpenNI:"         HAVE_OPENNI         THEN "YES (ver ${OPENNI_VERSION_STRING}, build ${OPENNI_VERSION_BUILD})"
643                                                                                                    ELSE NO)
644   status("    OpenNI PrimeSensor Modules:" HAVE_OPENNI_PRIME_SENSOR_MODULE
645                                                    THEN "YES (${OPENNI_PRIME_SENSOR_MODULE})"      ELSE NO)
646 endif(DEFINED WITH_OPENNI)
647
648 if(DEFINED WITH_PVAPI)
649   status("    PvAPI:"          HAVE_PVAPI          THEN YES                                        ELSE NO)
650 endif(DEFINED WITH_PVAPI)
651
652 if(DEFINED WITH_QUICKTIME)
653   status("    QuickTime:"      WITH_QUICKTIME      THEN YES                                        ELSE NO)
654   status("    QTKit:"          WITH_QUICKTIME      THEN NO                                         ELSE YES)
655 endif(DEFINED WITH_QUICKTIME)
656
657 if(DEFINED WITH_UNICAP)
658   status("    UniCap:"         HAVE_UNICAP         THEN "YES (ver ${ALIASOF_libunicap_VERSION})"   ELSE NO)
659   status("    UniCap ucil:"    HAVE_UNICAP_UCIL    THEN "YES (ver ${ALIASOF_libucil_VERSION})"     ELSE NO)
660 endif(DEFINED WITH_UNICAP)
661
662 if(DEFINED WITH_V4L)
663   if(HAVE_CAMV4L)
664     set(HAVE_CAMV4L_STR "YES")
665   else()
666     set(HAVE_CAMV4L_STR "NO")
667   endif()
668   if(HAVE_CAMV4L2)
669     set(HAVE_CAMV4L2_STR "YES")
670   else()
671     set(HAVE_CAMV4L2_STR "NO")
672   endif()
673   status("    V4L/V4L2:"       HAVE_LIBV4L         THEN "Using libv4l (ver ${ALIASOF_libv4l1_VERSION})"
674                                                                                                    ELSE "${HAVE_CAMV4L_STR}/${HAVE_CAMV4L2_STR}")
675 endif(DEFINED WITH_V4L)
676
677 if(DEFINED WITH_VIDEOINPUT)
678   status("    DirectShow:"     HAVE_VIDEOINPUT     THEN YES                                        ELSE NO)
679 endif(DEFINED WITH_VIDEOINPUT)
680
681 if(DEFINED WITH_XIMEA)
682   status("    XIMEA:"          HAVE_XIMEA          THEN YES                                        ELSE NO)
683 endif(DEFINED WITH_XIMEA)
684
685 if(DEFINED WITH_XINE)
686   status("    Xine:"           HAVE_XINE           THEN "YES (ver ${ALIASOF_libxine_VERSION})"     ELSE NO)
687 endif(DEFINED WITH_XINE)
688
689 # ========================== Other third-party libraries ==========================
690 status("")
691 status("  Other third-party libraries:")
692
693 if(DEFINED WITH_IPP)
694   if(WITH_IPP AND IPP_FOUND)
695     status("    Use IPP:" "${IPP_LATEST_VERSION_STR} [${IPP_LATEST_VERSION_MAJOR}.${IPP_LATEST_VERSION_MINOR}.${IPP_LATEST_VERSION_BUILD}]")
696     status("         at:" "${IPP_ROOT_DIR}")
697   else()
698     status("    Use IPP:"   WITH_IPP AND NOT IPP_FOUND THEN "IPP not found" ELSE NO)
699   endif()
700 endif(DEFINED WITH_IPP)
701
702 if(DEFINED WITH_TBB)
703   status("    Use TBB:"   HAVE_TBB   THEN "YES (ver ${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR} interface ${TBB_INTERFACE_VERSION})" ELSE NO)
704 endif(DEFINED WITH_TBB)
705
706 if(DEFINED WITH_CUDA)
707   status("    Use Cuda:"  HAVE_CUDA  THEN "YES (ver ${CUDA_VERSION_STRING})" ELSE NO)
708 endif(DEFINED WITH_CUDA)
709
710 status("    Use Eigen:" HAVE_EIGEN THEN "YES (ver ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION})" ELSE NO)
711 status("    Use Clp:"   HAVE_CLP   THEN YES ELSE NO)
712
713 if(HAVE_CUDA)
714   status("")
715   status("  NVIDIA CUDA:"            "(ver ${CUDA_VERSION_STRING})")
716
717   status("    Use CUFFT:"            HAVE_CUFFT  THEN YES ELSE NO)
718   status("    Use CUBLAS:"           HAVE_CUBLAS THEN YES ELSE NO)
719   status("    NVIDIA GPU arch:"      ${OPENCV_CUDA_ARCH_BIN})
720   status("    NVIDIA PTX archs:"     ${OPENCV_CUDA_ARCH_BIN})
721   status("    NVIDIA GPU features:"  ${OPENCV_CUDA_ARCH_FEATURES})
722 endif()
723
724 # ========================== python ==========================
725 status("")
726 status("  Python:")
727 status("    Interpreter:"   PYTHON_EXECUTABLE     THEN "${PYTHON_EXECUTABLE} (ver ${PYTHON_VERSION_FULL})"         ELSE NO)
728 if(BUILD_opencv_python)
729   if(PYTHONLIBS_VERSION_STRING)
730     status("    Libraries:"     HAVE_opencv_python  THEN  "${PYTHON_LIBRARIES} (ver ${PYTHONLIBS_VERSION_STRING})" ELSE NO)
731   else()
732     status("    Libraries:"     HAVE_opencv_python  THEN  ${PYTHON_LIBRARIES}                                      ELSE NO)
733   endif()
734   status("    numpy:"         PYTHON_USE_NUMPY    THEN "${PYTHON_NUMPY_INCLUDE_DIR} (ver ${PYTHON_NUMPY_VERSION})" ELSE "NO (Python wrappers can not be generated)")
735   status("    packages path:" PYTHON_EXECUTABLE   THEN "${PYTHON_PACKAGES_PATH}"                                   ELSE "-")
736 endif()
737
738 # ========================== documentation ==========================
739 if(BUILD_DOCS)
740   status("")
741   status("  Documentation:")
742   if(HAVE_SPHINX)
743     status("    Build Documentation:" PDFLATEX_COMPILER      THEN YES ELSE "YES (only HTML and without math expressions)")
744   else()
745     status("    Build Documentation:" NO)
746   endif()
747   status("    Sphinx:"              HAVE_SPHINX              THEN "${SPHINX_BUILD} (ver ${SPHINX_VERSION})" ELSE NO)
748   status("    PdfLaTeX compiler:"   PDFLATEX_COMPILER        THEN "${PDFLATEX_COMPILER}" ELSE NO)
749 endif()
750
751 # ========================== samples and tests ==========================
752 status("")
753 status("  Tests and samples:")
754 status("    Tests:"             BUILD_TESTS AND HAVE_opencv_ts       THEN YES ELSE NO)
755 status("    Performance tests:" BUILD_PERF_TESTS AND HAVE_opencv_ts  THEN YES ELSE NO)
756 status("    Examples:"          BUILD_EXAMPLES                       THEN YES ELSE NO)
757
758 if(ANDROID)
759   status("    Android tests:"    BUILD_TESTS AND CAN_BUILD_ANDROID_PROJECTS            THEN YES ELSE NO)
760   status("    Android examples:" BUILD_ANDROID_EXAMPLES AND CAN_BUILD_ANDROID_PROJECTS THEN YES ELSE NO)
761 endif()
762
763 # ========================== auxiliary ==========================
764 status("")
765 status("  Install path:" "${CMAKE_INSTALL_PREFIX}")
766 status("")
767 status("  cvconfig.h is in:" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}")
768 status("-----------------------------------------------------------------")
769 status("")
770
771 ocv_finalize_status()
772
773 # ----------------------------------------------------------------------------
774 # Warn in the case of in-source build
775 # ----------------------------------------------------------------------------
776 if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
777   message(WARNING "The source directory is the same as binary directory. \"make clean\" may damage the source tree")
778 endif()
779