Started top-level CMakeLists.txt file reorganization: cmake scripts are moved to separate folder; refactored BUILD_*, INSTALL_*, ENABLE_*, USE_*, WITH_* options.

This commit is contained in:
Andrey Kamaev 2012-01-03 13:48:12 +00:00
parent 60eecd4529
commit 8cab65c173
22 changed files with 1069 additions and 1229 deletions

View File

@ -11,6 +11,15 @@
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
# --------------------------------------------------------------
# Indicate CMake 2.7 and above that we don't want to mix relative
# and absolute paths in linker lib lists.
# Run "cmake --help-policy CMP0003" for more information.
# --------------------------------------------------------------
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif()
# Following block can broke build in case of cross-compilng
# but CMAKE_CROSSCOMPILING variable will be set only on project(OpenCV) command
# so we will try to detect crosscompiling by presense of CMAKE_TOOLCHAIN_FILE
@ -63,29 +72,162 @@ if(CMAKE_VERBOSE)
set(CMAKE_VERBOSE_MAKEFILE 1)
endif()
# --------------------------------------------------------------
# Indicate CMake 2.7 and above that we don't want to mix relative
# and absolute paths in linker lib lists.
# Run "cmake --help-policy CMP0003" for more information.
# --------------------------------------------------------------
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
include(cmake/OpenCVUtils.cmake REQUIRED)
# ----------------------------------------------------------------------------
# Detect Microsoft compiler:
# ----------------------------------------------------------------------------
if(CMAKE_CL_64)
set(MSVC64 1)
endif()
# ----------------------------------------------------------------------------
# Build static or dynamic libs?
# Default: dynamic libraries
# Detect Intel ICC compiler -- for -fPIC in 3rdparty ( UNIX ONLY ):
# see include/opencv/cxtypes.h file for related ICC & CV_ICC defines.
# NOTE: The system needs to determine if the '-fPIC' option needs to be added
# for the 3rdparty static libs being compiled. The CMakeLists.txt files
# in 3rdparty use the CV_ICC definition being set here to determine if
# the -fPIC flag should be used.
# ----------------------------------------------------------------------------
if(NOT IOS)
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)")
else()
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)")
if(UNIX)
if (__ICL)
set(CV_ICC __ICL)
elseif(__ICC)
set(CV_ICC __ICC)
elseif(__ECL)
set(CV_ICC __ECL)
elseif(__ECC)
set(CV_ICC __ECC)
elseif(__INTEL_COMPILER)
set(CV_ICC __INTEL_COMPILER)
elseif(CMAKE_C_COMPILER MATCHES "icc")
set(CV_ICC icc_matches_c_compiler)
endif()
endif()
if(MSVC AND CMAKE_C_COMPILER MATCHES "icc")
set(CV_ICC __INTEL_COMPILER_FOR_WINDOWS)
endif()
# ----------------------------------------------------------------------------
# Include debug info into debug libs?
# Default: yes
# Detect GNU version:
# ----------------------------------------------------------------------------
set(BUILD_WITH_DEBUG_INFO ON CACHE BOOL "Include debug info into debug libs")
if(CMAKE_COMPILER_IS_GNUCXX)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version
OUTPUT_VARIABLE CMAKE_OPENCV_GCC_VERSION_FULL
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -v
ERROR_VARIABLE CMAKE_OPENCV_GCC_INFO_FULL
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Typical output in CMAKE_OPENCV_GCC_VERSION_FULL: "c+//0 (whatever) 4.2.3 (...)"
# Look for the version number
string(REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" CMAKE_GCC_REGEX_VERSION "${CMAKE_OPENCV_GCC_VERSION_FULL}")
# Split the three parts:
string(REGEX MATCHALL "[0-9]+" CMAKE_OPENCV_GCC_VERSIONS "${CMAKE_GCC_REGEX_VERSION}")
list(GET CMAKE_OPENCV_GCC_VERSIONS 0 CMAKE_OPENCV_GCC_VERSION_MAJOR)
list(GET CMAKE_OPENCV_GCC_VERSIONS 1 CMAKE_OPENCV_GCC_VERSION_MINOR)
set(CMAKE_OPENCV_GCC_VERSION ${CMAKE_OPENCV_GCC_VERSION_MAJOR}${CMAKE_OPENCV_GCC_VERSION_MINOR})
math(EXPR CMAKE_OPENCV_GCC_VERSION_NUM "${CMAKE_OPENCV_GCC_VERSION_MAJOR}*100 + ${CMAKE_OPENCV_GCC_VERSION_MINOR}")
message(STATUS "Detected version of GNU GCC: ${CMAKE_OPENCV_GCC_VERSION} (${CMAKE_OPENCV_GCC_VERSION_NUM})")
if(WIN32)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
OUTPUT_VARIABLE CMAKE_OPENCV_GCC_TARGET_MACHINE
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(CMAKE_OPENCV_GCC_TARGET_MACHINE MATCHES "64")
set(MINGW64 1)
endif()
endif()
endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES amd64.*|x86_64.*)
set(X86_64 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES i686.*|i386.*|x86.*)
set(X86 1)
endif()
# Optional 3rd party components
# ===================================================
OCV_OPTION(WITH_1394 "Include IEEE1394 support" ON IF (UNIX AND NOT ANDROID AND NOT IOS) )
OCV_OPTION(WITH_ANDROID_CAMERA "Build with native Android camera support" ON IF (ANDROID AND ANDROID_NATIVE_API_LEVEL GREATER 7) )
OCV_OPTION(WITH_AVFOUNDATION "Use AVFoundation for Video I/O" ON IF IOS)
OCV_OPTION(WITH_CARBON "Use Carbon for UI instead of Cocoa" OFF IF APPLE )
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) )
OCV_OPTION(WITH_CUDA "Include NVidia Cuda Runtime support" ON IF (CMAKE_VERSION VERSION_GREATER "2.8" AND NOT ANDROID AND NOT IOS) )
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) )
OCV_OPTION(WITH_EIGEN "Include Eigen2/Eigen3 support" ON)
OCV_OPTION(WITH_FFMPEG "Include FFMPEG support" ON IF (UNIX AND NOT ANDROID AND NOT IOS) )
OCV_OPTION(WITH_GSTREAMER "Include Gstreamer support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS) )
OCV_OPTION(WITH_GTK "Include GTK support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS) )
OCV_OPTION(WITH_IPP "Include Intel IPP support" OFF IF (MSVC OR X86 OR X86_64) )
OCV_OPTION(WITH_JASPER "Include JPEG2K support" ON IF (NOT IOS) )
OCV_OPTION(WITH_JPEG "Include JPEG support" ON IF (NOT IOS) )
OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ON IF (NOT IOS) )
OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF IF (NOT ANDROID AND NOT IOS) )
OCV_OPTION(WITH_OPENNI "Include OpenNI support" OFF IF (NOT ANDROID AND NOT IOS) )
OCV_OPTION(WITH_PNG "Include PNG support" ON IF (NOT IOS) )
OCV_OPTION(WITH_PVAPI "Include Prosilica GigE support" ON IF (UNIX AND NOT ANDROID AND NOT IOS) )
OCV_OPTION(WITH_QT "Build with Qt Backend support" OFF IF (NOT ANDROID AND NOT IOS) )
OCV_OPTION(WITH_QUICKTIME "Use QuickTime for Video I/O insted of QTKit" OFF IF APPLE )
OCV_OPTION(WITH_TBB "Include Intel TBB support" OFF IF (NOT IOS) )
OCV_OPTION(WITH_TIFF "Include TIFF support" ON IF (NOT IOS) )
OCV_OPTION(WITH_UNICAP "Include Unicap support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS) )
OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS) )
OCV_OPTION(WITH_VIDEOINPUT "Build HighGUI with DirectShow support" ON IF WIN32 )
OCV_OPTION(WITH_XIMEA "Include XIMEA cameras support" OFF IF WIN32 )
OCV_OPTION(WITH_XINE "Include Xine support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS) )
# OpenCV build components
# ===================================================
if(ANDROID OR IOS)
OCV_OPTION(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" OFF )
else()
OCV_OPTION(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" ON )
endif()
OCV_OPTION(BUILD_ANDROID_EXAMPLES "Build examples for Android platform" ON IF ANDROID )
OCV_OPTION(BUILD_DOCS "Create build rules for OpenCV Documentation" ON )
OCV_OPTION(BUILD_JAVA_SUPPORT "Build with Java support" ON IF (ANDROID AND ANDROID_NATIVE_API_LEVEL GREATER 7) )
OCV_OPTION(BUILD_EXAMPLES "Build all examples" OFF )
OCV_OPTION(BUILD_NEW_PYTHON_SUPPORT "Build with Python support" ON IF (NOT ANDROID AND NOT IOS) )
OCV_OPTION(BUILD_PACKAGE "Enables 'make package_source' command" ON )
OCV_OPTION(BUILD_PERF_TESTS "Build performance tests" ON IF (NOT IOS) )
OCV_OPTION(BUILD_TESTS "Build accuracy & regression tests" ON IF (NOT IOS) )
OCV_OPTION(BUILD_WITH_DEBUG_INFO "Include debug info into debug libs" ON )
OCV_OPTION(BUILD_WITH_STATIC_CRT "Enables use of staticaly linked CRT for staticaly linked OpenCV" ON IF MSVC )
if(WIN32 OR ANDROID)
set(OPENCV_BUILD_3RDPARTY_LIBS TRUE CACHE INTERNAL "Build 3rd party libraries")
else()
# Build 3rdparty libraries under unix
set(OPENCV_BUILD_3RDPARTY_LIBS FALSE CACHE BOOL "Build 3rd party libraries")
endif()
# OpenCV installation options
# ===================================================
OCV_OPTION(INSTALL_C_EXAMPLES "Install C examples" OFF )
OCV_OPTION(INSTALL_PYTHON_EXAMPLES "Install Python examples" OFF )
OCV_OPTION(INSTALL_ANDROID_EXAMPLES "Install Android examples" OFF IF ANDROID )
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) )
# OpenCV build options
# ===================================================
OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" ON IF (NOT IOS) )
OCV_OPTION(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" OFF IF (CMAKE_VERSION VERSION_GREATER "2.8.0") )
OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add flags: -g -pg)" OFF IF CMAKE_COMPILER_IS_GNUCXX )
OCV_OPTION(ENABLE_OMIT_FRAME_POINTER "Enable -fomit-frame-pointer for GCC" ON IF CMAKE_COMPILER_IS_GNUCXX )
OCV_OPTION(ENABLE_POWERPC "Enable PowerPC for GCC" ON IF (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES powerpc.*) )
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)) )
OCV_OPTION(ENABLE_SSE "Enable SSE instructions" ON IF (MSVC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
OCV_OPTION(ENABLE_SSE2 "Enable SSE2 instructions" ON IF (MSVC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
OCV_OPTION(ENABLE_SSE3 "Enable SSE3 instructions" OFF IF (CV_ICC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
OCV_OPTION(ENABLE_SSSE3 "Enable SSSE3 instructions" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
OCV_OPTION(ENABLE_SSE41 "Enable SSE4.1 instructions" OFF IF (CV_ICC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
OCV_OPTION(ENABLE_SSE42 "Enable SSE4.2 instructions" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
# ----------------------------------------------------------------------------
# Get actual OpenCV version number from sources
@ -100,7 +242,7 @@ set(OPENCV_VERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_VER
set(OPENCV_SOVERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}")
# create a dependency on version file
# we will never use output of the following command but cmake will rerun if version file changes
# we never use output of the following command but cmake will rerun if version file changes
configure_file("${OPENCV_VERSION_FILE}" "${CMAKE_BINARY_DIR}/junk/version.junk" COPYONLY)
if(WIN32)
@ -115,8 +257,8 @@ endif()
#name mangling
set(OPENCV_INCLUDE_PREFIX include)
if(UNIX AND NOT ANDROID AND BUILD_SHARED_LIBS)
option(OPENCV_MANGLED_INSTALL_PATHS "Enables mangled install paths, that help with side by side installs." False)
if(INSTALL_TO_MANGLED_PATHS AND BUILD_SHARED_LIBS)
SET(OPENCV_MANGLED_INSTALL_PATHS ${INSTALL_TO_MANGLED_PATHS} )
if(OPENCV_MANGLED_INSTALL_PATHS)
set(OPENCV_INCLUDE_PREFIX include/opencv-${OPENCV_VERSION})
endif()
@ -144,29 +286,12 @@ endif()
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${OPENCV_LIB_INSTALL_PATH}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# search packages for host system instead of packages for target system
# in case of cross compilation thess macro should be defined by toolchain file
if(NOT COMMAND find_host_package)
macro(find_host_package)
find_package(${ARGN})
endmacro()
endif()
if(NOT COMMAND find_host_program)
macro(find_host_program)
find_program(${ARGN})
endmacro()
endif()
# ----------------------------------------------------------------------------
# Use statically or dynamically linked CRT?
# Default: dynamic
# ----------------------------------------------------------------------------
if(WIN32 AND NOT BUILD_SHARED_LIBS)
option (BUILD_WITH_STATIC_CRT "Enables use of staticaly linked CRT" ON)
endif()
if(MSVC)
if(BUILD_WITH_STATIC_CRT)
if(NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT)
foreach(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
@ -183,7 +308,7 @@ if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libcmtd.lib")
else(BUILD_WITH_STATIC_CRT)
else()
foreach(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
@ -196,7 +321,7 @@ if(MSVC)
string(REGEX REPLACE "/MTd" "/MDd" ${flag_var} "${${flag_var}}")
endif()
endforeach(flag_var)
endif(BUILD_WITH_STATIC_CRT)
endif()
if(NOT ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.8 AND NOT ${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} LESS 8.6)
include(ProcessorCount)
@ -261,256 +386,25 @@ else()
set(OPENCV_SVNVERSION "")
endif()
# ----------------------------------------------------------------------------
# Detect Microsoft compiler:
# ----------------------------------------------------------------------------
if(CMAKE_CL_64)
set(MSVC64 1)
endif()
# ----------------------------------------------------------------------------
# Detect GNU version:
# ----------------------------------------------------------------------------
if(CMAKE_COMPILER_IS_GNUCXX)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version
OUTPUT_VARIABLE CMAKE_OPENCV_GCC_VERSION_FULL
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -v
ERROR_VARIABLE CMAKE_OPENCV_GCC_INFO_FULL
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Typical output in CMAKE_OPENCV_GCC_VERSION_FULL: "c+//0 (whatever) 4.2.3 (...)"
# Look for the version number
string(REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" CMAKE_GCC_REGEX_VERSION "${CMAKE_OPENCV_GCC_VERSION_FULL}")
# Split the three parts:
string(REGEX MATCHALL "[0-9]+" CMAKE_OPENCV_GCC_VERSIONS "${CMAKE_GCC_REGEX_VERSION}")
list(GET CMAKE_OPENCV_GCC_VERSIONS 0 CMAKE_OPENCV_GCC_VERSION_MAJOR)
list(GET CMAKE_OPENCV_GCC_VERSIONS 1 CMAKE_OPENCV_GCC_VERSION_MINOR)
set(CMAKE_OPENCV_GCC_VERSION ${CMAKE_OPENCV_GCC_VERSION_MAJOR}${CMAKE_OPENCV_GCC_VERSION_MINOR})
math(EXPR CMAKE_OPENCV_GCC_VERSION_NUM "${CMAKE_OPENCV_GCC_VERSION_MAJOR}*100 + ${CMAKE_OPENCV_GCC_VERSION_MINOR}")
message(STATUS "Detected version of GNU GCC: ${CMAKE_OPENCV_GCC_VERSION} (${CMAKE_OPENCV_GCC_VERSION_NUM})")
if(WIN32)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
OUTPUT_VARIABLE CMAKE_OPENCV_GCC_TARGET_MACHINE
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(CMAKE_OPENCV_GCC_TARGET_MACHINE MATCHES "64")
set(MINGW64 1)
endif()
endif()
endif()
# ----------------------------------------------------------------------------
# Detect Intel ICC compiler -- for -fPIC in 3rdparty ( UNIX ONLY ):
# see include/opencv/cxtypes.h file for related ICC & CV_ICC defines.
# NOTE: The system needs to determine if the '-fPIC' option needs to be added
# for the 3rdparty static libs being compiled. The CMakeLists.txt files
# in 3rdparty use the CV_ICC definition being set here to determine if
# the -fPIC flag should be used.
# ----------------------------------------------------------------------------
if(UNIX)
if (__ICL)
set(CV_ICC __ICL)
elseif(__ICC)
set(CV_ICC __ICC)
elseif(__ECL)
set(CV_ICC __ECL)
elseif(__ECC)
set(CV_ICC __ECC)
elseif(__INTEL_COMPILER)
set(CV_ICC __INTEL_COMPILER)
elseif(CMAKE_C_COMPILER MATCHES "icc")
set(CV_ICC icc_matches_c_compiler)
endif()
endif()
# ----------------------------------------------------------------------------
# CHECK FOR SYSTEM LIBRARIES, OPTIONS, ETC..
# ----------------------------------------------------------------------------
# Build/install (or not) some apps:
# ===================================================
set(BUILD_EXAMPLES OFF CACHE BOOL "Build all examples")
set(INSTALL_C_EXAMPLES OFF CACHE BOOL "Install C examples")
set(INSTALL_PYTHON_EXAMPLES OFF CACHE BOOL "Install Python examples")
include(cmake/OpenCVPCHSupport.cmake REQUIRED)
include(cmake/OpenCVModule.cmake REQUIRED)
if(ANDROID)
set(INSTALL_ANDROID_EXAMPLES OFF CACHE BOOL "Install Android examples")
endif()
# Build tests:
# ===================================================
if(NOT IOS)
set(BUILD_TESTS ON CACHE BOOL "Build tests")
else()
set(BUILD_TESTS OFF CACHE BOOL "Build tests")
endif()
set(BUILD_PERF_TESTS ON CACHE BOOL "Build performance tests")
# Build 3rdparty libraries under unix
# ===================================================
if(WIN32)
set(OPENCV_BUILD_3RDPARTY_LIBS TRUE CACHE INTERNAL "Build 3rd party libraries")
else()
set(OPENCV_BUILD_3RDPARTY_LIBS FALSE CACHE BOOL "Build 3rd party libraries")
endif()
if(NOT IOS)
include(OpenCVPCHSupport.cmake REQUIRED)
endif()
include(OpenCVModule.cmake REQUIRED)
if(ANDROID)
include(OpenCVAndroidProject.cmake REQUIRED)
endif()
if(PCHSupport_FOUND)
SET(USE_PRECOMPILED_HEADERS ON CACHE BOOL "Use precompiled headers")
else()
SET(USE_PRECOMPILED_HEADERS OFF CACHE BOOL "Use precompiled headers" FORCE)
include(cmake/OpenCVAndroidProject.cmake REQUIRED)
endif()
if(UNIX)
include(OpenCVFindPkgConfig.cmake OPTIONAL)
include(cmake/OpenCVFindPkgConfig.cmake OPTIONAL)
include(CheckFunctionExists)
include(CheckIncludeFile)
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
set(ENABLE_PROFILING OFF CACHE BOOL "Enable profiling in the GCC compiler (Add flags: -g -pg)")
set(USE_OMIT_FRAME_POINTER ON CACHE BOOL "Enable -fomit-frame-pointer for GCC")
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES amd64.*|x86_64.*)
set(X86_64 1)
endif()
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES i686.*|i386.*|x86.*)
set(X86 1)
endif()
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES powerpc.*)
set(ENABLE_POWERPC ON CACHE BOOL "Enable PowerPC for GCC")
endif ()
if(X86 OR X86_64)
# enable everything, since the available set of instructions is checked at runtime
#IF ("${CMAKE_GCC_REGEX_VERSION}" VERSION_GREATER 4.5)
SET(_USE_FAST_MATH OFF)
#ELSE()
# SET(_USE_FAST_MATH ON)
#ENDIF()
set(USE_FAST_MATH ${_USE_FAST_MATH} CACHE BOOL "Enable -ffast-math (not recommended for GCC 4.6.x)")
set(ENABLE_SSE ON CACHE BOOL "Enable SSE instructions")
set(ENABLE_SSE2 ON CACHE BOOL "Enable SSE2 instructions")
set(ENABLE_SSE3 OFF CACHE BOOL "Enable SSE3 instructions")
set(ENABLE_SSSE3 OFF CACHE BOOL "Enable SSSE3 instructions")
set(ENABLE_SSE41 OFF CACHE BOOL "Enable SSE4.1 instructions")
set(ENABLE_SSE42 OFF CACHE BOOL "Enable SSE4.2 instructions")
endif()
endif()
if(MSVC)
set(ENABLE_SSE ON CACHE BOOL "Enable SSE instructions for MSVC")
set(ENABLE_SSE2 ON CACHE BOOL "Enable SSE2 instructions for MSVC")
if(CMAKE_C_COMPILER MATCHES "icc")
set(ENABLE_SSE3 OFF CACHE BOOL "Enable SSE3 instructions for ICC")
set(ENABLE_SSE4_1 OFF CACHE BOOL "Enable SSE4.1 instructions for ICC")
endif()
endif()
# allow fine grained control over which libraries not to link, even if
# they are available on the system
# ====================================================================
if(NOT IOS)
set(WITH_PNG ON CACHE BOOL "Include PNG support")
set(WITH_JPEG ON CACHE BOOL "Include JPEG support")
set(WITH_JASPER ON CACHE BOOL "Include JPEG2K support")
set(WITH_TIFF ON CACHE BOOL "Include TIFF support")
set(WITH_OPENEXR ON CACHE BOOL "Include ILM support via OpenEXR")
if(UNIX)
set(WITH_FFMPEG ON CACHE BOOL "Include FFMPEG support")
if(NOT APPLE)
set(WITH_UNICAP OFF CACHE BOOL "Include Unicap support (GPL)")
set(WITH_GTK ON CACHE BOOL "Include GTK support")
set(WITH_GSTREAMER ON CACHE BOOL "Include Gstreamer support")
set(WITH_V4L ON CACHE BOOL "Include Video 4 Linux support")
set(WITH_XINE OFF CACHE BOOL "Include Xine support (GPL)")
endif()
set(WITH_PVAPI ON CACHE BOOL "Include Prosilica GigE support")
set(WITH_1394 ON CACHE BOOL "Include IEEE1394 support")
endif()
endif()
if(APPLE)
set(WITH_CARBON OFF CACHE BOOL "Use Carbon for UI instead of Cocoa")
set(WITH_QUICKTIME OFF CACHE BOOL "Use QuickTime for Video I/O insted of QTKit")
endif()
if(IOS)
set(WITH_AVFOUNDATION ON CACHE BOOL "Use AVFoundation for Video I/O")
endif()
set(WITH_TBB OFF CACHE BOOL "Include Intel TBB support")
set(WITH_THREADING_FRAMEWORK OFF CACHE BOOL "Include Threading Framework support (lightweight analogue of TBB for ARM-s)")
set(WITH_IPP OFF CACHE BOOL "Include Intel IPP support")
set(WITH_EIGEN ON CACHE BOOL "Include Eigen2/Eigen3 support")
if( CMAKE_VERSION VERSION_GREATER "2.8")
set(WITH_CUDA ON CACHE BOOL "Include NVidia Cuda Runtime support")
set(WITH_CUFFT ON CACHE BOOL "Include NVidia Cuda Fast Fourier Transform (FFT) library support")
set(WITH_CUBLAS OFF CACHE BOOL "Include NVidia Cuda Basic Linear Algebra Subprograms (BLAS) library support")
else()
set(WITH_CUDA OFF CACHE BOOL "Include NVidia Cuda Runtime support")
set(WITH_CUFFT OFF CACHE BOOL "Include NVidia Cuda Fast Fourier Transform (FFT) library support")
set(WITH_CUBLAS OFF CACHE BOOL "Include NVidia Cuda Basic Linear Algebra Subprograms (BLAS) library support")
endif()
set(WITH_OPENNI OFF CACHE BOOL "Include OpenNI support")
set(WITH_XIMEA OFF CACHE BOOL "Include XIMEA cameras support")
set(WITH_OPENGL OFF CACHE BOOL "Include OpenGL support")
set(HAVE_OPENGL 0)
# ===================================================
# Macros that checks if module have been installed.
# After it adds module to build and define
# constants passed as second arg
# ===================================================
macro(CHECK_MODULE module_name define)
set(${define} 0)
if(PKG_CONFIG_FOUND)
set(ALIAS ALIASOF_${module_name})
set(ALIAS_FOUND ${ALIAS}_FOUND)
set(ALIAS_INCLUDE_DIRS ${ALIAS}_INCLUDE_DIRS)
set(ALIAS_LIBRARY_DIRS ${ALIAS}_LIBRARY_DIRS)
set(ALIAS_LIBRARIES ${ALIAS}_LIBRARIES)
PKG_CHECK_MODULES(${ALIAS} ${module_name})
if (${ALIAS_FOUND})
set(${define} 1)
foreach(P "${ALIAS_INCLUDE_DIRS}")
if (${P})
list(APPEND HIGHGUI_INCLUDE_DIRS ${${P}})
endif()
endforeach()
foreach(P "${ALIAS_LIBRARY_DIRS}")
if (${P})
list(APPEND HIGHGUI_LIBRARY_DIRS ${${P}})
endif()
endforeach()
list(APPEND HIGHGUI_LIBRARIES ${${ALIAS_LIBRARIES}})
endif()
endif()
endmacro()
if(UNIX)
if(NOT APPLE)
if(WITH_GTK)
@ -681,25 +575,11 @@ endif()
#message(STATUS "Graphic libraries: ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARIES} ${JASPER_LIBRARIES}")
if(WITH_OPENEXR)
include(OpenCVFindOpenEXR.cmake)
include(cmake/OpenCVFindOpenEXR.cmake)
endif()
set(BUILD_DOCS ON CACHE BOOL "Build OpenCV Documentation")
if(BUILD_DOCS)
include(OpenCVFindLATEX.cmake REQUIRED)
endif()
set(BUILD_NEW_PYTHON_SUPPORT ON CACHE BOOL "Build with Python support")
if (WIN32)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(BUILD_NEW_PYTHON_SUPPORT OFF)
endif()
endif()
if(ANDROID)
set(BUILD_NEW_PYTHON_SUPPORT OFF)
include(cmake/OpenCVFindLATEX.cmake REQUIRED)
endif()
# Always try to find python
@ -768,11 +648,7 @@ endif()
# Java support
# ===================================================
if (PYTHON_EXECUTABLE AND ANDROID AND ANDROID_NATIVE_API_LEVEL GREATER 7)
option(BUILD_JAVA_SUPPORT "Build with Java support" TRUE)
endif()
if (BUILD_JAVA_SUPPORT)
if (BUILD_JAVA_SUPPORT AND PYTHON_EXECUTABLE)
file(TO_CMAKE_PATH "$ENV{ANT_DIR}" ANT_DIR_ENV_PATH)
file(TO_CMAKE_PATH "$ENV{ProgramFiles}" ProgramFiles_ENV_PATH)
@ -792,9 +668,7 @@ if (BUILD_JAVA_SUPPORT)
)
if(ANDROID_EXECUTABLE)
message(STATUS " Found android tool: ${ANDROID_EXECUTABLE}")
get_filename_component(ANDROID_SDK_TOOLS_PATH "${ANDROID_EXECUTABLE}" PATH)
#read source.properties
if (EXISTS "${ANDROID_SDK_TOOLS_PATH}/source.properties")
file(STRINGS "${ANDROID_SDK_TOOLS_PATH}/source.properties" ANDROID_SDK_TOOLS_SOURCE_PROPERTIES_LINES REGEX "^[ ]*[^#].*$")
@ -887,15 +761,13 @@ if (BUILD_JAVA_SUPPORT)
endif()
endif()
if(CAN_BUILD_ANDROID_PROJECTS)
SET(BUILD_ANDROID_EXAMPLES TRUE CACHE BOOL "Build examples for Android platform")
if(NOT CAN_BUILD_ANDROID_PROJECTS)
UNSET(BUILD_ANDROID_EXAMPLES CACHE)
endif()
#YV
############################### QT ################################
set(WITH_QT OFF CACHE BOOL "Build with Qt Backend support")
set(HAVE_QT 0)
set(HAVE_QT_OPENGL 0)
@ -983,25 +855,11 @@ if (WITH_TBB)
endif()
endif(WITH_TBB)
#Threading Framework -- temporary decision for ARM-s instead of TBB
set(HAVE_THREADING_FRAMEWORK)
if (NOT HAVE_TBB AND WITH_THREADING_FRAMEWORK)
file(GLOB THREADING_FRAMEWORK_HEADER "${OpenCV_SOURCE_DIR}/modules/core/include/opencv2/core/threading_framework.hpp")
file(GLOB THREADING_FRAMEWORK_SOURCE "${OpenCV_SOURCE_DIR}/modules/core/src/threading_framework.cpp")
if(THREADING_FRAMEWORK_HEADER AND THREADING_FRAMEWORK_SOURCE)
set(HAVE_THREADING_FRAMEWORK 1)
endif()
if (TEGRA_DIR)
set(HAVE_THREADING_FRAMEWORK 1)
endif()
endif()
############################ Intel IPP #############################
set(IPP_FOUND)
if(WITH_IPP)
include(OpenCVFindIPP.cmake)
include(cmake/OpenCVFindIPP.cmake)
endif()
if(IPP_FOUND)
@ -1092,14 +950,14 @@ set(HAVE_OPENNI FALSE)
set(HAVE_OPENNI_PRIME_SENSOR_MODULE FALSE)
if(WITH_OPENNI)
include(OpenCVFindOpenNI.cmake)
include(cmake/OpenCVFindOpenNI.cmake)
endif()
############################### XIMEA ################################
set(HAVE_XIMEA FALSE)
if(WITH_XIMEA)
include(OpenCVFindXimea.cmake)
include(cmake/OpenCVFindXimea.cmake)
endif()
if(XIMEA_FOUND)
@ -1123,7 +981,6 @@ endif()
################## Extra HighGUI libs on Windows ###################
if(WIN32)
set(WITH_VIDEOINPUT ON CACHE BOOL "Build HighGUI with DirectShow support")
set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} comctl32 gdi32 ole32)
if(WITH_VIDEOINPUT)
@ -1155,8 +1012,6 @@ endif()
############## Android source tree for native camera ###############
if(ANDROID AND ANDROID_NATIVE_API_LEVEL GREATER 7)
option(WITH_ANDROID_CAMERA "Build with native Android camera support" TRUE)
SET (ANDROID_SOURCE_TREE "ANDROID_SOURCE_TREE-NOTFOUND" CACHE PATH
"Path to Android source tree.
Set this variable to path to your Android sources to compile
@ -1190,7 +1045,7 @@ add_definitions(-DHAVE_CVCONFIG_H)
set(OPENCV_CONFIG_FILE_INCLUDE_DIR "${CMAKE_BINARY_DIR}/" CACHE PATH "Where to create the platform-dependant cvconfig.h")
message(STATUS "Parsing 'cvconfig.h.cmake'")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cvconfig.h.cmake" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/cvconfig.h.cmake" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h")
# ---------------------------------------------------------------------------
# The C+//0 include & link directories:
@ -1261,10 +1116,12 @@ if(CMAKE_COMPILER_IS_GNUCXX)
endif()
# Other optimizations
if(USE_OMIT_FRAME_POINTER)
if(ENABLE_OMIT_FRAME_POINTER)
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -fomit-frame-pointer")
else()
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -fno-omit-frame-pointer")
endif()
if(USE_FAST_MATH)
if(ENABLE_FAST_MATH)
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -ffast-math")
endif()
if(ENABLE_POWERPC)
@ -1374,7 +1231,7 @@ set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${EXTRA_EX
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${EXTRA_EXE_LINKER_FLAGS_DEBUG} ${OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG}")
# In case of Makefiles if the user does not setup CMAKE_BUILD_TYPE, assume it's Release:
if (${CMAKE_GENERATOR} MATCHES ".*Makefiles" AND "${CMAKE_BUILD_TYPE}" STREQUAL "")
if (CMAKE_GENERATOR MATCHES ".*Makefiles" AND "${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE Release)
endif()
@ -1418,9 +1275,9 @@ set(CMAKE_OPENCV2_INCLUDE_DIRS_CONFIGCMAKE "${CMAKE_CURRENT_SOURCE_DIR}")
set(CMAKE_LIB_DIRS_CONFIGCMAKE "${LIBRARY_OUTPUT_PATH}")
set(CMAKE_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"${CMAKE_BINARY_DIR}/3rdparty/${OPENCV_LIB_INSTALL_PATH}\"")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig.cmake" IMMEDIATE @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig.cmake" IMMEDIATE @ONLY)
#support for version checking when finding opencv. find_package(OpenCV 2.3.1 EXACT) should now work.
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig-version.cmake" IMMEDIATE @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig-version.cmake" IMMEDIATE @ONLY)
# --------------------------------------------------------------------------------------------
# Part 2/3: ${BIN_DIR}/unix-install/OpenCVConfig.cmake -> For use *with* "make install"
# -------------------------------------------------------------------------------------------
@ -1438,8 +1295,8 @@ else()
endif()
endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake" IMMEDIATE @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig-version.cmake" IMMEDIATE @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake" IMMEDIATE @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig-version.cmake" IMMEDIATE @ONLY)
if(UNIX)
#http://www.vtk.org/Wiki/CMake/Tutorials/Packaging reference
@ -1471,7 +1328,7 @@ if(WIN32)
set(CMAKE_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_CONFIG_PATH}/share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH}\"")
exec_program(mkdir ARGS "-p \"${CMAKE_BINARY_DIR}/win-install/\"" OUTPUT_VARIABLE RET_VAL)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" IMMEDIATE @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" IMMEDIATE @ONLY)
# Install the OpenCVConfig.cmake file which has the right paths pointing to the install directory
install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}/")
@ -1509,7 +1366,7 @@ if(ANDROID)
set(CMAKE_BASE_INCLUDE_DIR_CONFIGCMAKE "\"${CMAKE_CURRENT_SOURCE_DIR}\"")
set(CMAKE_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/OpenCV.mk.in" "${CMAKE_BINARY_DIR}/OpenCV.mk" IMMEDIATE @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/OpenCV.mk.in" "${CMAKE_BINARY_DIR}/OpenCV.mk" IMMEDIATE @ONLY)
endif(ANDROID)
# -------------------------------------------------------------------------------------------
@ -1520,7 +1377,7 @@ if(ANDROID)
set(CMAKE_BASE_INCLUDE_DIR_CONFIGCMAKE "")
set(CMAKE_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/../..")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/OpenCV.mk.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCV.mk" IMMEDIATE @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/OpenCV.mk.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCV.mk" IMMEDIATE @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCV.mk DESTINATION share/OpenCV/)
endif(ANDROID)
@ -1554,9 +1411,9 @@ if(OPENCV_MANGLED_INSTALL_PATHS)
endforeach()
set(OpenCV_LIB_COMPONENTS ${OpenCV_LIB_COMPONENTS_})
set(OPENCV_PC_FILE_NAME "opencv-${OPENCV_VERSION}.pc")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/opencv-XXX.pc.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/${OPENCV_PC_FILE_NAME}" @ONLY IMMEDIATE)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/opencv-XXX.pc.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/${OPENCV_PC_FILE_NAME}" @ONLY IMMEDIATE)
else()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/opencv.pc.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/${OPENCV_PC_FILE_NAME}" @ONLY IMMEDIATE)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/opencv.pc.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/${OPENCV_PC_FILE_NAME}" @ONLY IMMEDIATE)
endif()
if(UNIX AND NOT ANDROID)
@ -1567,7 +1424,7 @@ endif()
# Uninstall target, for "make uninstall"
# ----------------------------------------------------------------------------
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
@ -1576,8 +1433,6 @@ ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/c
#-----------------------------------
# Source package:
#-----------------------------------
set(BUILD_PACKAGE ON CACHE BOOL "Enables 'make package_source' command")
if(BUILD_PACKAGE)
set(TARBALL_NAME "${CMAKE_PROJECT_NAME}-${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_VERSION_PATCH}")
if (NOT WIN32)
@ -1602,11 +1457,6 @@ endif()
#-----------------------------------
# Solution folders:
#-----------------------------------
if(${CMAKE_VERSION} VERSION_GREATER "2.8.0")
set(ENABLE_SOLUTION_FOLDERS OFF CACHE BOOL "Solution folder in Visual Studio or in other IDEs")
endif()
if(ENABLE_SOLUTION_FOLDERS)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
@ -1647,57 +1497,11 @@ endif()
# ----------------------------------------------------------------------------
# Summary:
# ----------------------------------------------------------------------------
macro(status text)
SET(status_cond)
SET(status_then)
SET(status_else)
SET(status_current_name "cond")
foreach(arg ${ARGN})
if(arg STREQUAL "THEN")
SET(status_current_name "then")
elseif(arg STREQUAL "ELSE")
SET(status_current_name "else")
else()
LIST(APPEND status_${status_current_name} ${arg})
endif()
endforeach()
if(DEFINED status_cond)
SET(status_placeholder_length 32)
string(RANDOM LENGTH ${status_placeholder_length} ALPHABET " " status_placeholder)
string(LENGTH "${text}" status_text_length)
if (status_text_length LESS status_placeholder_length)
string(SUBSTRING "${text}${status_placeholder}" 0 ${status_placeholder_length} status_text)
elseif (DEFINED status_then OR DEFINED status_else)
message(STATUS "${text}")
SET(status_text "${status_placeholder}")
else()
SET(status_text "${text}")
endif()
if (DEFINED status_then OR DEFINED status_else)
if(${status_cond})
string(REPLACE ";" " " status_then "${status_then}")
message(STATUS "${status_text}" "${status_then}")
else()
string(REPLACE ";" " " status_else "${status_else}")
message(STATUS "${status_text}" "${status_else}")
endif()
else()
string(REPLACE ";" " " status_cond "${status_cond}")
message(STATUS "${status_text}" "${status_cond}")
endif()
else()
message(STATUS "${text}")
endif()
endmacro()
status("")
status("General configuration for opencv ${OPENCV_VERSION} =====================================")
status("")
status(" Built as dynamic libs?:" BUILD_SHARED_LIBS THEN YES ELSE NO)
status(" Compiler:" CMAKE_COMPILER THEN "${CMAKE_COMPILER}" ELSE "${CMAKE_CXX_COMPILER}")
status(" C++ Compiler:" CMAKE_COMPILER THEN "${CMAKE_COMPILER}" ELSE "${CMAKE_CXX_COMPILER}")
status(" C++ flags (Release):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE})
status(" C++ flags (Debug):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG})
if(WIN32)
@ -1719,8 +1523,8 @@ if(ANDROID)
elseif(BUILD_WITH_STANDALONE_TOOLCHAIN)
status(" Android toolchain:" "${ANDROID_STANDALONE_TOOLCHAIN}")
endif()
status(" android tool:" ANDROID_EXECUTABLE THEN "${ANDROID_EXECUTABLE} (${ANDROID_TOOLS_Pkg_Desc})" ELSE NO)
status(" ant:" ANT_EXECUTABLE THEN "${ANT_EXECUTABLE} (ver ${ANT_VERSION})" ELSE NO)
status(" android tool:" ANDROID_EXECUTABLE THEN "${ANDROID_EXECUTABLE} (${ANDROID_TOOLS_Pkg_Desc})" ELSE NO)
status(" ant:" ANT_EXECUTABLE THEN "${ANT_EXECUTABLE} (ver ${ANT_VERSION})" ELSE NO)
endif()
#YV
@ -1741,8 +1545,8 @@ else()
status(" Cocoa:" YES)
endif()
else()
status(" GTK+ 2.x:" HAVE_GTK THEN YES ELSE NO)
status(" GThread :" HAVE_GTHREAD THEN YES ELSE NO)
status(" GTK+ 2.x:" HAVE_GTK THEN YES ELSE NO)
status(" GThread :" HAVE_GTHREAD THEN YES ELSE NO)
status(" GtkGlExt:" HAVE_GTKGLEXT THEN YES ELSE NO)
endif()
endif()
@ -1753,7 +1557,7 @@ status(" OpenGL support:" HAVE_OPENGL THEN YES ELSE NO)
# media
status("")
status(" Media I/O: ")
status(" ZLib:" ZLIB_FOUND THEN ${ZLIB_FOUND} ELSE build)
status(" ZLib:" ZLIB_FOUND THEN ${ZLIB_FOUND} ELSE build)
status(" JPEG:" NOT WITH_JPEG OR JPEG_FOUND THEN ${JPEG_FOUND} ELSE build)
status(" PNG:" NOT WITH_PNG OR PNG_FOUND THEN ${PNG_FOUND} ELSE build)
status(" TIFF:" NOT WITH_TIFF OR TIFF_FOUND THEN ${TIFF_FOUND} ELSE build)
@ -1763,7 +1567,9 @@ status(" OpenEXR:" WITH_OPENEXR AND OPENEXR_FOUND THEN YES
status(" OpenNI:" HAVE_OPENNI THEN YES ELSE NO)
status(" OpenNI PrimeSensor Modules:"
HAVE_OPENNI_PRIME_SENSOR_MODULE THEN YES ELSE NO)
status(" XIMEA:" HAVE_XIMEA THEN YES ELSE NO)
if(WIN32)
status(" XIMEA:" HAVE_XIMEA THEN YES ELSE NO)
endif()
# video
status("")
@ -1780,7 +1586,7 @@ if(UNIX AND NOT APPLE)
status(" GStreamer:" HAVE_GSTREAMER THEN YES ELSE NO)
status(" UniCap:" HAVE_UNICAP THEN YES ELSE NO)
status(" PvAPI:" HAVE_PVAPI THEN YES ELSE NO)
status(" V4L/V4L2:" HAVE_LIBV4L THEN Using libv4l ELSE ${HAVE_CAMV4L}/${HAVE_CAMV4L2})
status(" V4L/V4L2:" HAVE_LIBV4L THEN "Using libv4l" ELSE ${HAVE_CAMV4L}/${HAVE_CAMV4L2})
status(" Xine:" HAVE_XINE THEN YES ELSE NO)
if(ANDROID)
@ -1792,7 +1598,7 @@ if(UNIX AND NOT APPLE)
endif()
elseif(APPLE)
if(NOT IOS)
status(" Video I/O:" WITH_QUICKTIME THEN QuickTime ELSE QTKit)
status(" Video I/O:" WITH_QUICKTIME THEN QuickTime ELSE QTKit)
else()
status(" Video I/O: AVFoundation")
endif()
@ -1808,15 +1614,10 @@ if(WITH_IPP AND IPP_FOUND)
status(" Use IPP:" "${IPP_LATEST_VERSION_STR} [${IPP_LATEST_VERSION_MAJOR}.${IPP_LATEST_VERSION_MINOR}.${IPP_LATEST_VERSION_BUILD}]")
status(" at:" "${IPP_ROOT_DIR}")
else()
status(" Use IPP:" WITH_IPP AND NOT IPP_FOUND THEN IPP not found ELSE NO)
endif()
status(" Use TBB:" HAVE_TBB THEN YES ELSE NO)
if(UNIX)
status(" Use ThreadingFramework:" HAVE_THREADING_FRAMEWORK THEN YES ELSE NO)
status(" Use IPP:" WITH_IPP AND NOT IPP_FOUND THEN "IPP not found" ELSE NO)
endif()
status(" Use TBB:" HAVE_TBB THEN YES ELSE NO)
status(" Use Cuda:" HAVE_CUDA THEN YES ELSE NO)
status(" Use Eigen:" HAVE_EIGEN THEN YES ELSE NO)
@ -1825,12 +1626,10 @@ status(" Python interpreter:" PYTHON_EXECUTABLE THEN "${PYTHON_EXECUTAB
# interfaces to other languages
status("")
status(" Interfaces:")
status(" Python:" BUILD_NEW_PYTHON_SUPPORT THEN YES ELSE NO)
status(" Python numpy:" PYTHON_USE_NUMPY AND BUILD_NEW_PYTHON_SUPPORT THEN YES ELSE "NO (Python wrappers will not be generated)")
if(ANDROID AND ANDROID_NATIVE_API_LEVEL LESS 8)
status(" Java:" "NO (Java API requires Android API level 8 or higher)")
else()
status(" Java:" BUILD_JAVA_SUPPORT THEN YES ELSE NO)
status(" Python:" BUILD_NEW_PYTHON_SUPPORT AND PYTHON_EXECUTABLE THEN YES ELSE NO)
status(" Python numpy:" PYTHON_USE_NUMPY AND BUILD_NEW_PYTHON_SUPPORT THEN YES ELSE "NO (Python wrappers will not be generated)")
if(ANDROID)
status(" Java:" BUILD_JAVA_SUPPORT AND PYTHON_EXECUTABLE THEN YES ELSE NO)
endif()
# documentation
@ -1838,8 +1637,8 @@ status("")
status(" Documentation:")
status(" Sphinx:" HAVE_SPHINX THEN "${SPHINX_BUILD} (ver ${SPHINX_VERSION})" ELSE NO)
status(" PdfLaTeX compiler:" PDFLATEX_COMPILER THEN "${PDFLATEX_COMPILER}" ELSE NO)
if (BUILD_DOCS AND HAVE_SPHINX)
status(" Build Documentation:" PDFLATEX_COMPILER THEN YES ELSE "YES (only HTML without math formulas)")
if(BUILD_DOCS AND HAVE_SPHINX)
status(" Build Documentation:" PDFLATEX_COMPILER THEN YES ELSE "YES (only HTML without math expressions)")
else()
status(" Build Documentation:" NO)
endif()
@ -1852,11 +1651,11 @@ status(" Performance tests:" BUILD_PERF_TESTS THEN YES ELSE NO)
status(" Examples:" BUILD_EXAMPLES THEN YES ELSE NO)
if(ANDROID)
status(" Android tests:" BUILD_TESTS AND CAN_BUILD_ANDROID_PROJECTS THEN YES ELSE NO)
status(" Android examples:" BUILD_ANDROID_EXAMPLES THEN YES ELSE NO)
status(" Android tests:" BUILD_TESTS AND CAN_BUILD_ANDROID_PROJECTS THEN YES ELSE NO)
status(" Android examples:" BUILD_ANDROID_EXAMPLES THEN YES ELSE NO)
endif()
# auxiliary
#auxiliary
status("")
status(" Install path:" "${CMAKE_INSTALL_PREFIX}")
status("")

View File

@ -4,75 +4,9 @@
# cmake -C
########################
#Build shared libraries (.dll/.so CACHE BOOL "" ) instead of static ones (.lib/.a CACHE BOOL "" )
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" )
#Build 3rd party libraries
set(OPENCV_BUILD_3RDPARTY_LIBS ON CACHE BOOL "" )
#Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel.
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" )
#Include IEEE1394 support
set(WITH_1394 OFF CACHE BOOL "" )
#Include NVidia Cuda Runtime support
set(WITH_CUDA OFF CACHE BOOL "" )
#Include Eigen2/Eigen3 support
set(WITH_EIGEN2 OFF CACHE BOOL "" )
#Include FFMPEG support
set(WITH_FFMPEG OFF CACHE BOOL "" )
#Include Gstreamer support
set(WITH_GSTREAMER OFF CACHE BOOL "" )
#Include GTK support
set(WITH_GTK OFF CACHE BOOL "" )
#Include Intel IPP support
set(WITH_IPP OFF CACHE BOOL "" )
#Include JPEG2K support
set(WITH_JASPER ON CACHE BOOL "" )
#Include JPEG support
set(WITH_JPEG ON CACHE BOOL "" )
#Include ILM support via OpenEXR
set(WITH_OPENEXR OFF CACHE BOOL "" )
#Include OpenNI support
set(WITH_OPENNI OFF CACHE BOOL "" )
#Include PNG support
set(WITH_PNG ON CACHE BOOL "" )
#Include Prosilica GigE support
set(WITH_PVAPI OFF CACHE BOOL "" )
#Build with Qt Backend support
set(WITH_QT OFF CACHE BOOL "" )
#Add OpenGL support
set(WITH_OPENGL OFF CACHE BOOL "" )
#Include Intel TBB support
set(WITH_TBB OFF CACHE BOOL "" )
#Include TIFF support
set(WITH_TIFF ON CACHE BOOL "" )
#Include Unicap support (GPL CACHE BOOL "" )
set(WITH_UNICAP OFF CACHE BOOL "" )
#Include Video 4 Linux support
set(WITH_V4L OFF CACHE BOOL "" )
#Include Xine support (GPL CACHE BOOL "" )
set(WITH_XINE OFF CACHE BOOL "" )
#no python available on Android
set(BUILD_NEW_PYTHON_SUPPORT OFF CACHE INTERNAL "" FORCE)

View File

@ -305,16 +305,18 @@ endfunction()
endif()
endforeach()
# set IPP INCLUDE, LIB dirs and library names
set_ipp_variables(${IPP_LATEST_VERSION_STR})
if(IPP_FOUND)
# set IPP INCLUDE, LIB dirs and library names
set_ipp_variables(${IPP_LATEST_VERSION_STR})
# set CACHE variable IPP_H_PATH,
# path to IPP header files for the latest version
find_path(
IPP_H_PATH
NAMES ippversion.h
PATHS ${IPP_ROOT_DIR}
PATH_SUFFIXES include
DOC "The path to Intel(R) IPP header files"
NO_DEFAULT_PATH
NO_CMAKE_PATH)
# set CACHE variable IPP_H_PATH,
# path to IPP header files for the latest version
find_path(
IPP_H_PATH
NAMES ippversion.h
PATHS ${IPP_ROOT_DIR}
PATH_SUFFIXES include
DOC "The path to Intel(R) IPP header files"
NO_DEFAULT_PATH
NO_CMAKE_PATH)
endif()

View File

@ -5,7 +5,7 @@
#
# XIMEA_FOUND - True if XIMEA API found
# XIMEA_PATH: - Path to the XIMEA API folder
# XIMEA_LIBRARY_DIRS - XIMEA libraries folder
# XIMEA_LIBRARY_DIR - XIMEA libraries folder
#
# Created: 5 Aug 2011 by Marian Zajko (marian.zajko@ximea.com)
#
@ -14,22 +14,22 @@ set(XIMEA_FOUND)
set(XIMEA_PATH)
set(XIMEA_LIBRARY_DIR)
# Try to find the XIMEA API path in registry.
GET_FILENAME_COMPONENT(XIMEA_PATH "[HKEY_CURRENT_USER\\Software\\XIMEA\\CamSupport\\API;Path]" ABSOLUTE)
if(WIN32)
# Try to find the XIMEA API path in registry.
GET_FILENAME_COMPONENT(XIMEA_PATH "[HKEY_CURRENT_USER\\Software\\XIMEA\\CamSupport\\API;Path]" ABSOLUTE)
if(XIMEA_PATH)
set(XIMEA_FOUND 1)
if(XIMEA_PATH)
set(XIMEA_FOUND 1)
# set LIB folders
set(XIMEA_LIBRARY_DIR "${XIMEA_PATH}\\x86")
# set LIB folders
set(XIMEA_LIBRARY_DIR "${XIMEA_PATH}\\x86")
else()
set(XIMEA_FOUND 0)
else()
set(XIMEA_FOUND 0)
endif()
endif()
mark_as_advanced(FORCE XIMEA_FOUND)
mark_as_advanced(FORCE XIMEA_PATH)
mark_as_advanced(FORCE XIMEA_LIBRARY_DIR)

View File

@ -9,7 +9,7 @@ macro(add_opencv_precompiled_headers the_target)
SET(pch_name "src/precomp")
endif()
set(pch_header "${CMAKE_CURRENT_SOURCE_DIR}/${pch_name}.hpp")
if(PCHSupport_FOUND AND USE_PRECOMPILED_HEADERS AND EXISTS "${pch_header}")
if(PCHSupport_FOUND AND ENABLE_PRECOMPILED_HEADERS AND EXISTS "${pch_header}")
if(CMAKE_GENERATOR MATCHES Visual)
set(${the_target}_pch "${CMAKE_CURRENT_SOURCE_DIR}/${pch_name}.cpp")
add_native_precompiled_header(${the_target} ${pch_header})

118
cmake/OpenCVUtils.cmake Normal file
View File

@ -0,0 +1,118 @@
# Search packages for host system instead of packages for target system
# in case of cross compilation thess macro should be defined by toolchain file
if(NOT COMMAND find_host_package)
macro(find_host_package)
find_package(${ARGN})
endmacro()
endif()
if(NOT COMMAND find_host_program)
macro(find_host_program)
find_program(${ARGN})
endmacro()
endif()
# Provides an option that the user can optionally select.
# Can accept condition to control when option is available for user.
# Usage:
# option(<option_variable> "help string describing option" <initial value> [IF <condition>])
macro(OCV_OPTION variable description value)
SET(__condition ${ARGN})
if("${__condition}" STREQUAL "")
SET(__condition 1)
endif()
list(REMOVE_ITEM __condition "IF" "if")
if(${__condition})
OPTION(${variable} "${description}" ${value})
else()
UNSET(${variable} CACHE)
endif()
UNSET(__condition)
endmacro()
# Macros that checks if module have been installed.
# After it adds module to build and define
# constants passed as second arg
macro(CHECK_MODULE module_name define)
set(${define} 0)
if(PKG_CONFIG_FOUND)
set(ALIAS ALIASOF_${module_name})
set(ALIAS_FOUND ${ALIAS}_FOUND)
set(ALIAS_INCLUDE_DIRS ${ALIAS}_INCLUDE_DIRS)
set(ALIAS_LIBRARY_DIRS ${ALIAS}_LIBRARY_DIRS)
set(ALIAS_LIBRARIES ${ALIAS}_LIBRARIES)
PKG_CHECK_MODULES(${ALIAS} ${module_name})
if (${ALIAS_FOUND})
set(${define} 1)
foreach(P "${ALIAS_INCLUDE_DIRS}")
if (${P})
list(APPEND HIGHGUI_INCLUDE_DIRS ${${P}})
endif()
endforeach()
foreach(P "${ALIAS_LIBRARY_DIRS}")
if (${P})
list(APPEND HIGHGUI_LIBRARY_DIRS ${${P}})
endif()
endforeach()
list(APPEND HIGHGUI_LIBRARIES ${${ALIAS_LIBRARIES}})
endif()
endif()
endmacro()
# Status report macro.
# Automatically align right column and selects text based on condition.
# Usage:
# status(<text>)
# status(<heading> <value1> [<value2> ...])
# status(<heading> <condition> THEN <text for TRUE> ELSE <text for FALSE> )
macro(status text)
SET(status_cond)
SET(status_then)
SET(status_else)
SET(status_current_name "cond")
foreach(arg ${ARGN})
if(arg STREQUAL "THEN")
SET(status_current_name "then")
elseif(arg STREQUAL "ELSE")
SET(status_current_name "else")
else()
LIST(APPEND status_${status_current_name} ${arg})
endif()
endforeach()
if(DEFINED status_cond)
SET(status_placeholder_length 32)
string(RANDOM LENGTH ${status_placeholder_length} ALPHABET " " status_placeholder)
string(LENGTH "${text}" status_text_length)
if (status_text_length LESS status_placeholder_length)
string(SUBSTRING "${text}${status_placeholder}" 0 ${status_placeholder_length} status_text)
elseif (DEFINED status_then OR DEFINED status_else)
message(STATUS "${text}")
SET(status_text "${status_placeholder}")
else()
SET(status_text "${text}")
endif()
if (DEFINED status_then OR DEFINED status_else)
if(${status_cond})
string(REPLACE ";" " " status_then "${status_then}")
message(STATUS "${status_text}" "${status_then}")
else()
string(REPLACE ";" " " status_else "${status_else}")
message(STATUS "${status_text}" "${status_else}")
endif()
else()
string(REPLACE ";" " " status_cond "${status_cond}")
message(STATUS "${status_text}" "${status_cond}")
endif()
else()
message(STATUS "${text}")
endif()
endmacro()

View File

@ -163,9 +163,6 @@
/* Intel Threading Building Blocks */
#cmakedefine HAVE_TBB
/* Threading Framework --- temporary decision for ARM instead of Intel TBB */
#cmakedefine HAVE_THREADING_FRAMEWORK
/* Eigen Matrix & Linear Algebra Library */
#cmakedefine HAVE_EIGEN

View File

@ -198,19 +198,6 @@ CV_INLINE IppiSize ippiSize(int width, int height)
int _begin, _end, _grainsize;
};
#ifdef HAVE_THREADING_FRAMEWORK
#include "opencv2/core/threading_framework.hpp"
template<typename Body>
static void parallel_for( const BlockedRange& range, const Body& body )
{
tf::parallel_for<Body>(range, body);
}
typedef tf::ConcurrentVector<Rect> ConcurrentRectVector;
typedef tf::ConcurrentVector<double> ConcurrentDoubleVector;
#else
template<typename Body> static inline
void parallel_for( const BlockedRange& range, const Body& body )
{
@ -218,7 +205,6 @@ CV_INLINE IppiSize ippiSize(int width, int height)
}
typedef std::vector<Rect> ConcurrentRectVector;
typedef std::vector<double> ConcurrentDoubleVector;
#endif
template<typename Iterator, typename Body> static inline
void parallel_do( Iterator first, Iterator last, const Body& body )

View File

@ -1076,7 +1076,7 @@ void CascadeClassifier::detectMultiScale( const Mat& image, vector<Rect>& object
int stripCount, stripSize;
#if defined(HAVE_TBB) || defined(HAVE_THREADING_FRAMEWORK)
#ifdef HAVE_TBB
const int PTS_PER_THREAD = 1000;
stripCount = ((processingRectSize.width/yStep)*(processingRectSize.height + yStep-1)/yStep + PTS_PER_THREAD/2)/PTS_PER_THREAD;
stripCount = std::min(std::max(stripCount, 1), 100);

View File

@ -1,3 +1,7 @@
if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
return()
endif()
# ----------------------------------------------------------------------------
# CMake file for python support
# ----------------------------------------------------------------------------