2010-05-12 01:44:00 +08:00
# ----------------------------------------------------------------------------
# Root CMake file for OpenCV
#
# From the off-tree build directory, invoke:
# $ cmake <PATH_TO_OPENCV_ROOT>
#
#
# - OCT-2008: Initial version <joseluisblancoc@gmail.com>
#
# ----------------------------------------------------------------------------
set ( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true )
2011-01-01 00:45:18 +08:00
2010-05-12 01:44:00 +08:00
# Add these standard paths to the search paths for FIND_LIBRARY
# to find libraries from these locations first
if ( UNIX )
2011-01-01 00:45:18 +08:00
set ( CMAKE_LIBRARY_PATH ${ CMAKE_LIBRARY_PATH } /lib /usr/lib )
2010-05-12 01:44:00 +08:00
endif ( )
2011-01-01 00:45:18 +08:00
2010-05-12 01:44:00 +08:00
# it _must_ go before PROJECT(OpenCV) in order to work
2011-05-02 16:13:36 +08:00
if ( WIN32 )
set ( CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory" )
else ( )
set ( CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation Directory" )
2010-05-12 01:44:00 +08:00
endif ( )
2011-01-01 00:45:18 +08:00
set ( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" )
set ( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
2010-10-09 10:15:08 +08:00
2010-05-12 01:44:00 +08:00
set ( CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE )
set ( CMAKE_C_FLAGS_MINSIZEREL "" CACHE INTERNAL "" FORCE )
set ( CMAKE_C_FLAGS_RELWITHDEBINFO "" CACHE INTERNAL "" FORCE )
set ( CMAKE_CXX_FLAGS_MINSIZEREL "" CACHE INTERNAL "" FORCE )
set ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "" CACHE INTERNAL "" FORCE )
set ( CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "" CACHE INTERNAL "" FORCE )
set ( CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "" CACHE INTERNAL "" FORCE )
set ( CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL "" CACHE INTERNAL "" FORCE )
set ( CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "" CACHE INTERNAL "" FORCE )
set ( CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "" CACHE INTERNAL "" FORCE )
set ( CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "" CACHE INTERNAL "" FORCE )
2010-08-25 20:49:17 +08:00
set ( CMAKE_VERBOSE OFF CACHE BOOL "Verbose mode" )
2011-01-01 00:45:18 +08:00
if ( CMAKE_VERBOSE )
set ( CMAKE_VERBOSE_MAKEFILE 1 )
2010-08-25 20:49:17 +08:00
endif ( )
2010-05-12 01:44:00 +08:00
2011-01-01 00:45:18 +08:00
2010-05-12 01:44:00 +08:00
project ( OpenCV )
2011-01-01 00:45:18 +08:00
2010-05-12 01:44:00 +08:00
cmake_minimum_required ( VERSION 2.4 )
2011-01-01 00:45:18 +08:00
2010-05-12 01:44:00 +08:00
if ( MSVC )
set ( CMAKE_USE_RELATIVE_PATHS ON CACHE INTERNAL "" FORCE )
endif ( )
2011-01-01 00:45:18 +08:00
2010-05-12 01:44:00 +08:00
# --------------------------------------------------------------
# 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 ( )
2011-01-01 00:45:18 +08:00
2010-05-12 01:44:00 +08:00
# ----------------------------------------------------------------------------
# Current version number:
# ----------------------------------------------------------------------------
2011-05-03 06:20:22 +08:00
set ( OPENCV_VERSION "2.2.9" )
2010-05-12 01:44:00 +08:00
string ( REGEX MATCHALL "[0-9]" OPENCV_VERSION_PARTS "${OPENCV_VERSION}" )
list ( GET OPENCV_VERSION_PARTS 0 OPENCV_VERSION_MAJOR )
list ( GET OPENCV_VERSION_PARTS 1 OPENCV_VERSION_MINOR )
list ( GET OPENCV_VERSION_PARTS 2 OPENCV_VERSION_PATCH )
set ( OPENCV_SOVERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}" )
if ( WIN32 )
# Postfix of DLLs:
set ( OPENCV_DLLVERSION "${OPENCV_VERSION_MAJOR}${OPENCV_VERSION_MINOR}${OPENCV_VERSION_PATCH}" )
set ( OPENCV_DEBUG_POSTFIX d )
else ( )
# Postfix of so's:
#set(OPENCV_DLLVERSION "${OPENCV_VERSION_MAJOR}${OPENCV_VERSION_MINOR}${OPENCV_VERSION_PATCH}")
set ( OPENCV_DLLVERSION "" )
set ( OPENCV_DEBUG_POSTFIX )
endif ( )
# ----------------------------------------------------------------------------
# Build static or dynamic libs?
# Default: dynamic libraries:
2011-01-01 00:45:18 +08:00
# ----------------------------------------------------------------------------
set ( BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" )
2010-05-12 01:44:00 +08:00
# ----------------------------------------------------------------------------
# Variables for cvconfig.h.cmake
# ----------------------------------------------------------------------------
set ( PACKAGE "opencv" )
set ( PACKAGE_BUGREPORT "opencvlibrary-devel@lists.sourceforge.net" )
set ( PACKAGE_NAME "opencv" )
set ( PACKAGE_STRING "${PACKAGE} ${OPENCV_VERSION}" )
set ( PACKAGE_TARNAME "${PACKAGE}" )
set ( PACKAGE_VERSION "${OPENCV_VERSION}" )
2011-01-01 00:45:18 +08:00
2010-05-12 01:44:00 +08:00
# ----------------------------------------------------------------------------
# Autodetect if we are in a SVN repository
# ----------------------------------------------------------------------------
find_program ( SVNVERSION_PATH svnversion )
mark_as_advanced ( force SVNVERSION_PATH )
if ( SVNVERSION_PATH )
message ( STATUS "Extracting svn version, please wait..." )
execute_process ( COMMAND ${ SVNVERSION_PATH } -n ${ CMAKE_SOURCE_DIR } OUTPUT_VARIABLE SVNVERSION_RESULT )
if ( SVNVERSION_RESULT MATCHES "exported" )
# This is NOT a svn repository:
set ( OPENCV_SVNVERSION "" )
else ( )
set ( OPENCV_SVNVERSION " svn:${SVNVERSION_RESULT}" )
endif ( )
message ( STATUS "SVNVERSION: ${OPENCV_SVNVERSION}" )
else ( )
# We don't have svnversion:
set ( OPENCV_SVNVERSION "" )
endif ( )
2011-05-30 21:32:57 +08:00
# ----------------------------------------------------------------------------
# Detect Microsoft compiler:
# ----------------------------------------------------------------------------
if ( CMAKE_CL_64 )
set ( MSVC64 1 )
endif ( )
2011-01-01 00:45:18 +08:00
2010-05-12 01:44:00 +08:00
# ----------------------------------------------------------------------------
# Detect GNU version:
# ----------------------------------------------------------------------------
if ( CMAKE_COMPILER_IS_GNUCXX )
execute_process ( COMMAND ${ CMAKE_CXX_COMPILER } --version
O U T P U T _ V A R I A B L E C M A K E _ O P E N C V _ G C C _ V E R S I O N _ F U L L
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
# 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 )
2010-08-25 20:49:17 +08:00
2010-05-12 01:44:00 +08:00
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})" )
2010-08-06 01:24:41 +08:00
if ( WIN32 )
execute_process ( COMMAND ${ CMAKE_CXX_COMPILER } -dumpmachine
O U T P U T _ V A R I A B L E C M A K E _ O P E N C V _ G C C _ T A R G E T _ M A C H I N E
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
if ( CMAKE_OPENCV_GCC_TARGET_MACHINE MATCHES "64" )
set ( MINGW64 1 )
endif ( )
endif ( )
2010-05-12 01:44:00 +08:00
endif ( )
2011-01-01 00:45:18 +08:00
2010-05-12 01:44:00 +08:00
# ----------------------------------------------------------------------------
# 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 ( )
2011-01-01 00:45:18 +08:00
2010-05-12 01:44:00 +08:00
# ----------------------------------------------------------------------------
# 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" )
# Build tests:
# ===================================================
set ( BUILD_TESTS ON CACHE BOOL "Build tests" )
# Build 3rdparty libraries under unix
# ===================================================
2011-05-27 21:47:18 +08:00
if ( WIN32 )
2010-05-12 01:44:00 +08:00
set ( OPENCV_BUILD_3RDPARTY_LIBS TRUE CACHE BOOL "Build 3rd party libraries" )
else ( )
set ( OPENCV_BUILD_3RDPARTY_LIBS FALSE CACHE BOOL "Build 3rd party libraries" )
endif ( )
include ( OpenCVPCHSupport.cmake REQUIRED )
include ( OpenCVModule.cmake REQUIRED )
2011-04-30 18:42:33 +08:00
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 )
endif ( )
2010-05-12 01:44:00 +08:00
if ( UNIX )
include ( OpenCVFindPkgConfig.cmake OPTIONAL )
include ( CheckFunctionExists )
include ( CheckIncludeFile )
endif ( )
#if(MSVC)
# set(DEFAULT_ENABLE_OPENMP ON)
#else()
# set(DEFAULT_ENABLE_OPENMP OFF)
#endif()
#set(ENABLE_OPENMP ${DEFAULT_ENABLE_OPENMP} CACHE BOOL "")
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 arm* )
# We can use only -O2 because the -O3 causes gcc crash
set ( USE_O2 ON CACHE BOOL "Enable -O2 for GCC" )
set ( USE_FAST_MATH ON CACHE BOOL "Enable -ffast-math for GCC" )
endif ( )
2010-08-25 20:49:17 +08:00
2011-05-11 22:45:35 +08:00
if ( ${ CMAKE_SYSTEM_PROCESSOR } MATCHES amd64*|x86_64* )
2010-05-12 01:44:00 +08:00
set ( X86_64 1 )
endif ( )
2011-05-11 22:45:35 +08:00
if ( ${ CMAKE_SYSTEM_PROCESSOR } MATCHES i686*|i386*|x86* )
2010-05-12 01:44:00 +08:00
set ( X86 1 )
2011-05-11 22:45:35 +08:00
endif ( )
2010-08-25 20:49:17 +08:00
2010-05-12 01:44:00 +08:00
if ( ${ CMAKE_SYSTEM_PROCESSOR } MATCHES powerpc* )
set ( USE_O3 ON CACHE BOOL "Enable -O3 for GCC" )
set ( ENABLE_POWERPC ON CACHE BOOL "Enable PowerPC for GCC" )
endif ( )
2010-08-25 20:49:17 +08:00
2010-05-12 01:44:00 +08:00
if ( X86 OR X86_64 )
# enable everything, since the available set of instructions is checked at runtime
2010-11-24 17:46:46 +08:00
set ( USE_O3 ON CACHE BOOL "Enable -O3" )
set ( USE_FAST_MATH ON CACHE BOOL "Enable -ffast-math" )
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" )
2010-05-12 01:44:00 +08:00
endif ( )
endif ( )
# allow fine grained control over which libraries not to link, even if
# they are available on the system
# ====================================================================
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" )
2010-07-04 20:32:31 +08:00
set ( WITH_OPENEXR ON CACHE BOOL "Include ILM support via OpenEXR" )
2010-05-12 01:44:00 +08:00
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 ( )
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 ( )
2011-01-01 00:45:18 +08:00
set ( WITH_TBB OFF CACHE BOOL "Include Intel TBB support" )
set ( WITH_IPP OFF CACHE BOOL "Include Intel IPP support" )
2011-05-27 20:15:36 +08:00
set ( WITH_EIGEN ON CACHE BOOL "Include Eigen2/Eigen3 support" )
2010-07-15 21:36:00 +08:00
set ( WITH_CUDA OFF CACHE BOOL "Include NVidia Cuda Runtime support" )
2010-05-12 01:44:00 +08:00
2010-07-17 06:38:57 +08:00
if ( WIN32 )
2011-01-01 00:45:18 +08:00
set ( WITH_VIDEOINPUT ON CACHE BOOL "Enable VideoInput support" )
2010-07-17 06:38:57 +08:00
endif ( )
2011-01-22 01:00:08 +08:00
set ( WITH_OPENNI OFF CACHE BOOL "Include OpenNI support" )
2011-01-01 00:45:18 +08:00
2010-05-12 01:44:00 +08:00
# ===================================================
# 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 } } )
2010-08-25 20:49:17 +08:00
endif ( )
2010-05-12 01:44:00 +08:00
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 )
CHECK_MODULE ( gtk+-2.0 HAVE_GTK )
CHECK_MODULE ( gthread-2.0 HAVE_GTHREAD )
else ( )
set ( HAVE_GTK FALSE )
set ( HAVE_GTHREAD FALSE )
endif ( )
if ( WITH_GSTREAMER )
CHECK_MODULE ( gstreamer-base-0.10 HAVE_GSTREAMER )
2011-04-24 05:24:41 +08:00
CHECK_MODULE ( gstreamer-app-0.10 HAVE_GSTREAMER )
2010-05-12 01:44:00 +08:00
CHECK_MODULE ( gstreamer-video-0.10 HAVE_GSTREAMER )
else ( )
set ( HAVE_GSTREAMER FALSE )
endif ( )
endif ( )
if ( WITH_UNICAP )
CHECK_MODULE ( libunicap HAVE_UNICAP_ )
CHECK_MODULE ( libucil HAVE_UNICAP_UCIL )
if ( HAVE_UNICAP_ AND HAVE_UNICAP_UCIL )
set ( HAVE_UNICAP 1 )
endif ( )
else ( )
set ( HAVE_UNICAP FALSE )
endif ( )
2010-08-25 20:49:17 +08:00
2010-05-12 01:44:00 +08:00
if ( WITH_PVAPI )
find_path ( PVAPI_INCLUDE_PATH "PvApi.h"
2010-06-29 23:49:15 +08:00
P A T H S " / u s r / l o c a l / i n c l u d e " " / u s r / i n c l u d e "
2010-05-12 01:44:00 +08:00
D O C " T h e p a t h t o P v A P I h e a d e r " )
if ( PVAPI_INCLUDE_PATH )
set ( HAVE_PVAPI 1 )
endif ( )
endif ( )
set ( HAVE_FFMPEG 0 )
if ( WITH_FFMPEG )
CHECK_MODULE ( libavcodec HAVE_FFMPEG_CODEC )
CHECK_MODULE ( libavformat HAVE_FFMPEG_FORMAT )
CHECK_MODULE ( libavutil HAVE_FFMPEG_UTIL )
CHECK_MODULE ( libswscale HAVE_FFMPEG_SWSCALE )
CHECK_INCLUDE_FILE ( libavformat/avformat.h HAVE_GENTOO_FFMPEG )
CHECK_INCLUDE_FILE ( ffmpeg/avformat.h HAVE_FFMPEG_FFMPEG )
if ( NOT HAVE_GENTOO_FFMPEG AND NOT HAVE_FFMPEG_FFMPEG )
if ( EXISTS /usr/include/ffmpeg/libavformat/avformat.h OR HAVE_FFMPEG_SWSCALE )
set ( HAVE_GENTOO_FFMPEG 1 )
endif ( )
endif ( )
if ( HAVE_FFMPEG_CODEC AND HAVE_FFMPEG_FORMAT AND HAVE_FFMPEG_UTIL )
if ( HAVE_FFMPEG_SWSCALE OR NOT HAVE_GENTOO_FFMPEG )
set ( HAVE_FFMPEG 1 )
2010-08-25 20:49:17 +08:00
endif ( )
2010-05-12 01:44:00 +08:00
endif ( )
# Find the bzip2 library because it is required on some systems
FIND_LIBRARY ( BZIP2_LIBRARIES NAMES bz2 bzip2 )
if ( NOT BZIP2_LIBRARIES )
# Do an other trial
FIND_FILE ( BZIP2_LIBRARIES NAMES libbz2.so.1 PATHS /lib )
endif ( )
endif ( )
if ( WITH_1394 )
CHECK_MODULE ( libdc1394-2 HAVE_DC1394_2 )
if ( NOT HAVE_DC1394_2 )
CHECK_MODULE ( libdc1394 HAVE_DC1394 )
endif ( )
else ( )
set ( HAVE_DC1394_2 FALSE )
set ( HAVE_DC1394 FALSE )
endif ( )
2011-05-27 21:47:18 +08:00
if ( NOT OPENCV_BUILD_3RDPARTY_LIBS )
include ( FindZLIB )
if ( WITH_PNG )
include ( FindPNG )
if ( PNG_FOUND )
CHECK_INCLUDE_FILE ( ${ PNG_PNG_INCLUDE_DIR } /png.h HAVE_PNG_H )
CHECK_INCLUDE_FILE ( ${ PNG_PNG_INCLUDE_DIR } /libpng/png.h HAVE_LIBPNG_PNG_H )
endif ( )
else ( )
set ( PNG_FOUND FALSE )
endif ( )
if ( WITH_TIFF )
include ( FindTIFF )
else ( )
set ( TIFF_FOUND FALSE )
endif ( )
if ( WITH_JASPER )
include ( FindJasper )
else ( )
set ( JASPER_FOUND FALSE )
endif ( )
if ( WITH_JPEG )
include ( FindJPEG )
else ( )
set ( JPEG_FOUND FALSE )
endif ( )
endif ( )
2010-05-12 01:44:00 +08:00
if ( NOT APPLE )
CHECK_INCLUDE_FILE ( alloca.h HAVE_ALLOCA_H )
CHECK_FUNCTION_EXISTS ( alloca HAVE_ALLOCA )
CHECK_INCLUDE_FILE ( unistd.h HAVE_UNISTD_H )
CHECK_INCLUDE_FILE ( pthread.h HAVE_LIBPTHREAD )
if ( WITH_XINE )
CHECK_MODULE ( libxine HAVE_XINE )
else ( )
set ( HAVE_XINE FALSE )
endif ( )
if ( WITH_V4L )
CHECK_MODULE ( libv4l1 HAVE_LIBV4L )
CHECK_INCLUDE_FILE ( linux/videodev.h HAVE_CAMV4L )
CHECK_INCLUDE_FILE ( linux/videodev2.h HAVE_CAMV4L2 )
else ( )
set ( HAVE_LIBV4L FALSE )
set ( HAVE_CAMV4L FALSE )
set ( HAVE_CAMV4L2 FALSE )
endif ( )
2011-04-06 22:31:03 +08:00
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "FreeBSD" OR ${ CMAKE_SYSTEM_NAME } MATCHES "NetBSD" AND NOT ANDROID )
2010-05-12 01:44:00 +08:00
set ( OPENCV_LINKER_LIBS m pthread )
2011-04-06 22:31:03 +08:00
elseif ( ANDROID )
2011-05-14 02:32:05 +08:00
set ( OPENCV_LINKER_LIBS dl m log )
2010-05-12 01:44:00 +08:00
else ( )
set ( OPENCV_LINKER_LIBS dl m pthread rt )
endif ( )
else ( )
add_definitions ( -DHAVE_ALLOCA -DHAVE_ALLOCA_H -DHAVE_LIBPTHREAD -DHAVE_UNISTD_H )
endif ( )
endif ( )
2010-12-05 09:19:36 +08:00
if ( WITH_PNG AND NOT PNG_FOUND )
set ( PNG_LIBRARIES libpng )
endif ( )
if ( WITH_JPEG AND NOT JPEG_FOUND )
set ( JPEG_LIBRARIES libjpeg )
endif ( )
if ( WITH_TIFF AND NOT TIFF_FOUND )
set ( TIFF_LIBRARIES libtiff )
endif ( )
if ( WITH_JASPER AND NOT JASPER_FOUND )
set ( JASPER_LIBRARIES libjasper )
endif ( )
2011-04-06 22:31:03 +08:00
if ( ANDROID )
2011-04-11 22:47:06 +08:00
#android camera support
2011-04-06 22:31:03 +08:00
set ( NativeCamera_DIR "${CMAKE_SOURCE_DIR}/android/native-camera/build" )
FIND_PACKAGE ( NativeCamera QUIET )
if ( NativeCamera_FOUND )
set ( HAVE_ANDROID_NATIVE_CAMERA TRUE )
2011-05-14 02:32:05 +08:00
set ( OPENCV_LINKER_LIBS ${ OPENCV_LINKER_LIBS } ${ NativeCamera_LIBS } )
2011-04-06 22:31:03 +08:00
else ( )
set ( HAVE_ANDROID_NATIVE_CAMERA FALSE )
2011-05-14 02:32:05 +08:00
message ( STATUS "Could NOT find NativeCamera for Android" )
2011-04-06 22:31:03 +08:00
endif ( )
endif ( )
2010-12-05 10:10:59 +08:00
#message(STATUS "Graphic libraries: ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARIES} ${JASPER_LIBRARIES}")
2010-12-05 09:19:36 +08:00
2010-07-04 20:32:31 +08:00
if ( WITH_OPENEXR )
include ( OpenCVFindOpenEXR.cmake )
endif ( )
2010-05-12 01:44:00 +08:00
set ( BUILD_NEW_PYTHON_SUPPORT ON CACHE BOOL "Build with Python support" )
if ( BUILD_NEW_PYTHON_SUPPORT )
find_package ( PythonInterp )
find_package ( PythonLibs )
# cmake 2.4 (at least on Ubuntu 8.04 (hardy)) don't define PYTHONLIBS_FOUND
if ( NOT PYTHONLIBS_FOUND AND PYTHON_INCLUDE_PATH )
set ( PYTHONLIBS_FOUND ON )
endif ( NOT PYTHONLIBS_FOUND AND PYTHON_INCLUDE_PATH )
2010-08-25 20:49:17 +08:00
2010-05-12 01:44:00 +08:00
execute_process ( COMMAND ${ PYTHON_EXECUTABLE } --version
E R R O R _ V A R I A B L E P Y T H O N _ V E R S I O N _ F U L L
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
string ( REGEX MATCH "[0-9].[0-9]" PYTHON_VERSION_MAJOR_MINOR "${PYTHON_VERSION_FULL}" )
if ( UNIX )
set ( PYTHON_PLUGIN_INSTALL_PATH lib/python ${ PYTHON_VERSION_MAJOR_MINOR } /site-packages/opencv )
2011-05-24 08:30:03 +08:00
if ( APPLE )
set ( PYTHON_PACKAGES_PATH lib/python ${ PYTHON_VERSION_MAJOR_MINOR } /site-packages CACHE PATH "Where to install the python packages." )
else ( ) #debian based assumed, install to the dist-packages.
set ( PYTHON_PACKAGES_PATH lib/python ${ PYTHON_VERSION_MAJOR_MINOR } /dist-packages CACHE PATH "Where to install the python packages." )
endif ( )
2010-05-12 01:44:00 +08:00
endif ( )
if ( WIN32 )
get_filename_component ( PYTHON_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION_MAJOR_MINOR}\\InstallPath]" ABSOLUTE CACHE )
set ( PYTHON_PLUGIN_INSTALL_PATH "${PYTHON_PATH}/Lib/site-packages/opencv" )
set ( PYTHON_PACKAGES_PATH "${PYTHON_PATH}/Lib/site-packages" )
endif ( )
# Attempt to discover the NumPy include directory. If this succeeds, build with NumPy
execute_process ( COMMAND ${ PYTHON_EXECUTABLE } -c "import numpy.distutils; print numpy.distutils.misc_util.get_numpy_include_dirs()[0]"
R E S U L T _ V A R I A B L E P Y T H O N _ N U M P Y _ P R O C E S S
O U T P U T _ V A R I A B L E P Y T H O N _ N U M P Y _ I N C L U D E _ D I R S
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
if ( PYTHON_NUMPY_PROCESS EQUAL 0 )
set ( PYTHON_USE_NUMPY 1 )
add_definitions ( -D PYTHON_USE_NUMPY=1 )
include_directories ( AFTER ${ PYTHON_NUMPY_INCLUDE_DIRS } )
message ( STATUS " Use INCLUDE: ${PYTHON_NUMPY_INCLUDE_DIRS}" )
else ( )
set ( PYTHON_USE_NUMPY 0 )
endif ( )
2011-02-23 04:43:26 +08:00
execute_process ( COMMAND ${ PYTHON_EXECUTABLE } -c "import sphinx; print sphinx.__version__"
R E S U L T _ V A R I A B L E S P H I N X _ P R O C E S S
O U T P U T _ V A R I A B L E S P H I N X _ V E R S I O N
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
set ( HAVE_SPHINX 0 )
if ( SPHINX_PROCESS EQUAL 0 )
find_program ( SPHINX_BUILD sphinx-build )
if ( SPHINX_BUILD )
set ( HAVE_SPHINX 1 )
message ( STATUS " Found Sphinx ${SPHINX_VERSION}: ${SPHINX_BUILD}" )
endif ( )
endif ( )
2010-05-12 01:44:00 +08:00
endif ( )
2010-06-07 16:29:10 +08:00
#YV
############################### QT ################################
2010-07-12 23:29:31 +08:00
2010-07-27 22:17:43 +08:00
set ( WITH_QT OFF CACHE BOOL "Build with Qt Backend support" )
set ( WITH_QT_OPENGL OFF CACHE BOOL "Add OpenGL extension to Qt" )
2010-07-12 23:29:31 +08:00
2010-07-28 01:29:22 +08:00
set ( HAVE_QT 0 )
set ( HAVE_QT_OPENGL 0 )
2010-06-07 16:29:10 +08:00
2010-07-12 23:29:31 +08:00
if ( WITH_QT )
find_package ( Qt4 )
if ( QT4_FOUND )
set ( HAVE_QT 1 )
2010-08-25 20:49:17 +08:00
add_definitions ( -DHAVE_QT ) #We need to define te macro this way, using cvconfig.h.cmake does not work
2010-07-28 01:29:22 +08:00
2010-07-27 21:19:29 +08:00
find_package ( OpenGL QUIET )
2010-07-30 22:13:20 +08:00
2011-01-01 00:45:18 +08:00
#if (NOT WIN32)
if ( WITH_QT_OPENGL )
2011-05-27 21:47:18 +08:00
if ( QT_QTOPENGL_FOUND AND OPENGL_FOUND )
set ( HAVE_QT_OPENGL 1 )
add_definitions ( -DHAVE_QT_OPENGL )
#link_directories("${OPENGL_LIBRARIES}")
set ( OPENCV_LINKER_LIBS ${ OPENCV_LINKER_LIBS } ${ OPENGL_LIBRARIES } )
endif ( )
2011-05-11 22:45:35 +08:00
endif ( )
#endif()
2010-08-25 20:49:17 +08:00
2010-06-26 01:19:11 +08:00
endif ( )
2010-06-07 16:29:10 +08:00
endif ( )
2010-08-25 20:49:17 +08:00
2010-05-12 01:44:00 +08:00
############################### TBB ################################
if ( WITH_TBB )
if ( UNIX AND NOT APPLE )
PKG_CHECK_MODULES ( TBB tbb )
message ( STATUS "TBB detected: ${TBBLIB_FOUND}" )
2010-08-25 20:49:17 +08:00
if ( TBB_FOUND )
2010-05-12 01:44:00 +08:00
set ( HAVE_TBB 1 )
2010-11-20 20:05:28 +08:00
if ( NOT ${ TBB_INCLUDE_DIRS } STREQUAL "" )
include_directories ( ${ TBB_INCLUDE_DIRS } )
2010-05-12 01:44:00 +08:00
endif ( )
2010-11-20 20:05:28 +08:00
link_directories ( ${ TBB_LIBRARY_DIRS } )
2011-04-02 03:19:03 +08:00
set ( OPENCV_LINKER_LIBS ${ OPENCV_LINKER_LIBS } ${ TBB_LIBRARIES } )
2010-05-12 01:44:00 +08:00
endif ( )
2011-04-02 03:19:03 +08:00
endif ( )
2010-05-12 01:44:00 +08:00
if ( NOT HAVE_TBB )
2011-05-27 21:47:18 +08:00
set ( TBB_DEFAULT_INCLUDE_DIRS "/opt/intel/tbb" "/usr/local/include" "/usr/include" "C:/Program Files/Intel/TBB" "C:/Program Files (x86)/Intel/TBB" )
find_path ( TBB_INCLUDE_DIR "tbb/tbb.h" PATHS ${ TBB_DEFAULT_INCLUDE_DIRS } DOC "The path to TBB headers" )
2010-05-12 01:44:00 +08:00
if ( TBB_INCLUDE_DIR )
if ( UNIX )
set ( TBB_LIB_DIR "${TBB_INCLUDE_DIR}/../lib" CACHE PATH "Full path of TBB library directory" )
link_directories ( "${TBB_LIB_DIR}" )
endif ( )
if ( APPLE )
set ( OPENCV_LINKER_LIBS ${ OPENCV_LINKER_LIBS } libtbb.dylib )
elseif ( UNIX )
set ( OPENCV_LINKER_LIBS ${ OPENCV_LINKER_LIBS } tbb )
elseif ( WIN32 )
2011-05-27 21:47:18 +08:00
if ( CMAKE_COMPILER_IS_GNUCXX )
set ( TBB_LIB_DIR "${TBB_INCLUDE_DIR}/../lib" CACHE PATH "Full path of TBB library directory" )
link_directories ( "${TBB_LIB_DIR}" )
set ( OPENCV_LINKER_LIBS ${ OPENCV_LINKER_LIBS } tbb )
else ( )
get_filename_component ( _TBB_LIB_PATH "${TBB_INCLUDE_DIR}/../lib" ABSOLUTE )
if ( ${ CMAKE_SYSTEM_PROCESSOR } MATCHES amd64*|x86_64* )
set ( _TBB_LIB_PATH "${_TBB_LIB_PATH}/intel64" )
2011-04-02 03:19:03 +08:00
endif ( )
if ( ${ CMAKE_SYSTEM_PROCESSOR } MATCHES x86*|i386*|i686* )
2011-05-27 21:47:18 +08:00
set ( _TBB_LIB_PATH "${_TBB_LIB_PATH}/ia32" )
endif ( )
if ( MSVC80 )
set ( _TBB_LIB_PATH "${_TBB_LIB_PATH}/vc8" )
elseif ( MSVC90 )
set ( _TBB_LIB_PATH "${_TBB_LIB_PATH}/vc9" )
elseif ( MSVC10 )
set ( _TBB_LIB_PATH "${_TBB_LIB_PATH}/vc10" )
endif ( )
set ( TBB_LIB_DIR "${_TBB_LIB_PATH}" CACHE PATH "Full path of TBB library directory" )
link_directories ( "${TBB_LIB_DIR}" )
endif ( )
endif ( )
set ( HAVE_TBB 1 )
if ( NOT "${TBB_INCLUDE_DIR}" STREQUAL "" )
include_directories ( "${TBB_INCLUDE_DIR}" )
endif ( )
endif ( )
endif ( )
2011-04-02 03:19:03 +08:00
endif ( WITH_TBB )
2011-01-01 00:45:18 +08:00
2011-04-29 22:20:24 +08:00
#Threading Framework -- temporary decision for ARM-s instead of TBB
if ( NOT HAVE_TBB )
2011-05-27 21:47:18 +08:00
file ( GLOB THREADING_FRAMEWORK_HEADER "${CMAKE_SOURCE_DIR}/modules/core/include/opencv2/core/threading_framework.hpp" )
file ( GLOB THREADING_FRAMEWORK_SOURCE "${CMAKE_SOURCE_DIR}/modules/core/src/threading_framework.cpp" )
if ( THREADING_FRAMEWORK_HEADER AND THREADING_FRAMEWORK_SOURCE )
set ( HAVE_THREADING_FRAMEWORK 1 )
endif ( )
2011-04-29 22:20:24 +08:00
endif ( )
2011-01-01 00:45:18 +08:00
############################ Intel IPP #############################
set ( IPP_FOUND )
if ( WITH_IPP )
include ( OpenCVFindIPP.cmake )
endif ( )
if ( IPP_FOUND )
add_definitions ( -DHAVE_IPP )
include_directories ( ${ IPP_INCLUDE_DIRS } )
link_directories ( ${ IPP_LIBRARY_DIRS } )
set ( OPENCV_LINKER_LIBS ${ OPENCV_LINKER_LIBS } ${ IPP_LIBRARIES } )
2010-05-12 01:44:00 +08:00
endif ( )
2011-01-01 00:45:18 +08:00
2010-07-17 06:38:57 +08:00
############################### CUDA ################################
2010-07-15 21:36:00 +08:00
2011-01-20 17:22:05 +08:00
if ( WITH_CUDA )
2011-01-01 00:45:18 +08:00
find_package ( CUDA 3.2 )
2011-01-20 17:22:05 +08:00
if ( CUDA_FOUND )
2011-01-01 00:45:18 +08:00
set ( HAVE_CUDA 1 )
message ( STATUS "CUDA detected: " ${ CUDA_VERSION } )
2011-02-16 16:42:12 +08:00
set ( CUDA_ARCH_BIN "1.1 1.2 1.3 2.0" CACHE STRING "Specify 'real' GPU architectures to build binaries for, BIN(PTX) format is supported" )
2011-01-20 22:13:07 +08:00
set ( CUDA_ARCH_PTX "1.1 1.3" CACHE STRING "Specify 'virtual' PTX architectures to build PTX intermediate code for" )
2011-01-18 20:01:28 +08:00
2011-01-27 16:26:10 +08:00
string ( REGEX REPLACE "\\." "" ARCH_BIN_NO_POINTS "${CUDA_ARCH_BIN}" )
2011-01-20 22:13:07 +08:00
string ( REGEX REPLACE "\\." "" ARCH_PTX_NO_POINTS "${CUDA_ARCH_PTX}" )
2011-01-18 20:01:28 +08:00
2011-02-01 20:28:39 +08:00
# Ckeck if user specified 1.0 compute capability: we don't support it
2011-01-25 22:13:12 +08:00
string ( REGEX MATCH "1.0" HAS_ARCH_10 "${CUDA_ARCH_BIN} ${CUDA_ARCH_PTX}" )
2011-01-27 16:26:10 +08:00
set ( CUDA_ARCH_BIN_OR_PTX_10 0 )
2011-01-20 22:13:07 +08:00
if ( NOT ${ HAS_ARCH_10 } STREQUAL "" )
2011-01-27 16:26:10 +08:00
set ( CUDA_ARCH_BIN_OR_PTX_10 1 )
2011-01-20 22:13:07 +08:00
endif ( )
2011-01-20 17:22:05 +08:00
2011-02-01 20:28:39 +08:00
# NVCC flags to be set
2011-01-27 16:26:10 +08:00
set ( NVCC_FLAGS_EXTRA "" )
2011-02-01 20:28:39 +08:00
# These vars will be passed into the templates
2011-01-27 16:26:10 +08:00
set ( OPENCV_CUDA_ARCH_BIN "" )
set ( OPENCV_CUDA_ARCH_PTX "" )
2011-02-01 20:28:39 +08:00
set ( OPENCV_CUDA_ARCH_FEATURES "" )
2011-01-20 17:22:05 +08:00
2011-02-01 20:28:39 +08:00
# Tell NVCC to add binaries for the specified GPUs
2011-01-27 16:26:10 +08:00
string ( REGEX MATCHALL "[0-9()]+" ARCH_LIST "${ARCH_BIN_NO_POINTS}" )
2011-01-20 22:13:07 +08:00
foreach ( ARCH IN LISTS ARCH_LIST )
2011-01-25 22:13:12 +08:00
if ( ARCH MATCHES "([0-9]+)\\(([0-9]+)\\)" )
2011-02-01 20:28:39 +08:00
# User explicitly specified PTX for the concrete BIN
2011-01-25 22:13:12 +08:00
set ( NVCC_FLAGS_EXTRA ${ NVCC_FLAGS_EXTRA } -gencode arch=compute_ ${ CMAKE_MATCH_2 } ,code=sm_ ${ CMAKE_MATCH_1 } )
2011-01-27 16:26:10 +08:00
set ( OPENCV_CUDA_ARCH_BIN "${OPENCV_CUDA_ARCH_BIN} ${CMAKE_MATCH_1}" )
2011-02-01 20:28:39 +08:00
set ( OPENCV_CUDA_ARCH_FEATURES "${OPENCV_CUDA_ARCH_FEATURES} ${CMAKE_MATCH_2}" )
2011-01-25 22:13:12 +08:00
else ( )
2011-02-01 20:28:39 +08:00
# User didn't explicitly specify PTX for the concrete BIN, we assume PTX=BIN
2011-01-25 22:13:12 +08:00
set ( NVCC_FLAGS_EXTRA ${ NVCC_FLAGS_EXTRA } -gencode arch=compute_ ${ ARCH } ,code=sm_ ${ ARCH } )
2011-01-27 16:26:10 +08:00
set ( OPENCV_CUDA_ARCH_BIN "${OPENCV_CUDA_ARCH_BIN} ${ARCH}" )
2011-02-01 20:28:39 +08:00
set ( OPENCV_CUDA_ARCH_FEATURES "${OPENCV_CUDA_ARCH_FEATURES} ${ARCH}" )
2011-01-25 22:13:12 +08:00
endif ( )
2011-01-18 20:01:28 +08:00
endforeach ( )
2011-01-20 17:22:05 +08:00
2011-02-01 20:28:39 +08:00
# Tell NVCC to add PTX intermediate code for the specified architectures
2011-01-20 22:13:07 +08:00
string ( REGEX MATCHALL "[0-9]+" ARCH_LIST "${ARCH_PTX_NO_POINTS}" )
foreach ( ARCH IN LISTS ARCH_LIST )
set ( NVCC_FLAGS_EXTRA ${ NVCC_FLAGS_EXTRA } -gencode arch=compute_ ${ ARCH } ,code=compute_ ${ ARCH } )
2011-01-27 16:26:10 +08:00
set ( OPENCV_CUDA_ARCH_PTX "${OPENCV_CUDA_ARCH_PTX} ${ARCH}" )
2011-02-01 20:28:39 +08:00
set ( OPENCV_CUDA_ARCH_FEATURES "${OPENCV_CUDA_ARCH_FEATURES} ${ARCH}" )
endforeach ( )
2011-01-20 17:22:05 +08:00
2011-02-01 20:28:39 +08:00
# These vars will be processed in other scripts
2011-01-20 22:13:07 +08:00
set ( CUDA_NVCC_FLAGS ${ CUDA_NVCC_FLAGS } ${ NVCC_FLAGS_EXTRA } )
2011-01-20 17:22:05 +08:00
set ( OpenCV_CUDA_CC "${NVCC_FLAGS_EXTRA}" )
2011-01-20 22:13:07 +08:00
message ( STATUS "CUDA NVCC flags: ${CUDA_NVCC_FLAGS}" )
2011-01-18 20:01:28 +08:00
endif ( )
2010-07-15 21:36:00 +08:00
endif ( )
2010-06-29 23:49:15 +08:00
2011-01-01 00:45:18 +08:00
2010-07-17 06:38:57 +08:00
############################### VideoInput ################################
if ( WIN32 AND WITH_VIDEOINPUT )
2011-05-27 21:47:18 +08:00
if ( CMAKE_CXX_COMPILER MATCHES "dw2" )
else ( )
if ( NOT MINGW64 )
set ( HAVE_VIDEOINPUT 1 )
endif ( )
endif ( )
2010-07-17 06:38:57 +08:00
endif ( )
2011-01-22 01:00:08 +08:00
############################### OpenNI ################################
set ( HAVE_OPENNI FALSE )
2011-02-04 21:41:10 +08:00
set ( HAVE_OPENNI_PRIME_SENSOR_MODULE FALSE )
2011-01-22 01:00:08 +08:00
if ( WITH_OPENNI )
2011-02-23 04:43:26 +08:00
include ( OpenCVFindOpenNI.cmake )
2011-02-04 21:41:10 +08:00
endif ( )
2011-01-01 00:45:18 +08:00
2011-05-27 20:15:36 +08:00
############################## Eigen ##############################
2010-06-29 23:49:15 +08:00
2011-05-27 20:15:36 +08:00
if ( WITH_EIGEN )
find_path ( EIGEN_INCLUDE_PATH "Eigen/Core"
2010-06-29 23:49:15 +08:00
P A T H S " / u s r / l o c a l / i n c l u d e / e i g e n 2 " " / o p t / i n c l u d e / e i g e n 2 " " / u s r / i n c l u d e / e i g e n 2 "
2010-10-01 17:13:35 +08:00
" / u s r / l o c a l / i n c l u d e / e i g e n 3 " " / o p t / i n c l u d e / e i g e n 3 " " / u s r / i n c l u d e / e i g e n 3 "
D O C " T h e p a t h t o E i g e n 2 / E i g e n 3 h e a d e r s " )
2011-05-27 20:15:36 +08:00
if ( EIGEN_INCLUDE_PATH )
include_directories ( ${ EIGEN_INCLUDE_PATH } )
set ( HAVE_EIGEN 1 )
2010-06-29 23:49:15 +08:00
endif ( )
endif ( )
2010-05-12 01:44:00 +08:00
2010-12-05 09:19:36 +08:00
################## Extra HighGUI libs on Windows ###################
if ( WIN32 )
2011-02-23 04:43:26 +08:00
set ( HIGHGUI_LIBRARIES ${ HIGHGUI_LIBRARIES } comctl32 gdi32 ole32 )
if ( MSVC )
set ( HIGHGUI_LIBRARIES ${ HIGHGUI_LIBRARIES } vfw32 )
2011-05-30 21:32:57 +08:00
if ( NOT BUILD_SHARED_LIBS )
if ( MSVC64 )
if ( HAVE_VIDEOINPUT )
set ( HIGHGUI_LIBRARIES ${ HIGHGUI_LIBRARIES } ${ CMAKE_SOURCE_DIR } /3rdparty/lib/videoInput64.lib strmiids )
endif ( )
elseif ( MSVC )
if ( HAVE_VIDEOINPUT )
set ( HIGHGUI_LIBRARIES ${ HIGHGUI_LIBRARIES } ${ CMAKE_SOURCE_DIR } /3rdparty/lib/videoInput.lib strmiids )
endif ( )
endif ( )
endif ( )
2011-02-23 04:43:26 +08:00
endif ( )
if ( MINGW )
if ( MINGW64 )
2010-12-05 09:19:36 +08:00
set ( HIGHGUI_LIBRARIES ${ HIGHGUI_LIBRARIES } msvfw32 avifil32 avicap32 winmm )
2011-02-23 04:43:26 +08:00
if ( HAVE_VIDEOINPUT )
set ( HIGHGUI_LIBRARIES ${ HIGHGUI_LIBRARIES } videoInput64 strmiids )
endif ( )
else ( )
2010-12-05 09:19:36 +08:00
set ( HIGHGUI_LIBRARIES ${ HIGHGUI_LIBRARIES } vfw32 winmm )
2011-02-23 04:43:26 +08:00
if ( HAVE_VIDEOINPUT )
2010-12-05 09:19:36 +08:00
set ( HIGHGUI_LIBRARIES ${ HIGHGUI_LIBRARIES } videoInput strmiids )
2011-02-23 04:43:26 +08:00
endif ( )
endif ( )
2010-12-05 09:19:36 +08:00
endif ( )
endif ( )
2010-05-12 01:44:00 +08:00
2011-02-23 04:43:26 +08:00
################## Reference Manual ##################
2011-05-10 00:50:29 +08:00
set ( BUILD_DOCS ON CACHE BOOL "Build OpenCV Reference Manual" )
2010-05-12 01:44:00 +08:00
2011-01-01 00:45:18 +08:00
2010-05-18 23:41:28 +08:00
################### DOXYGEN ###############
2011-02-23 04:43:26 +08:00
#find_package(Doxygen)
#
#if(DOXYGEN_FOUND)
# set(BUILD_DOXYGEN_DOCS ON CACHE BOOL "Generate HTML docs using Doxygen")
#endif()
2010-05-18 23:41:28 +08:00
2011-01-01 00:45:18 +08:00
2010-05-12 01:44:00 +08:00
# ----------------------------------------------------------------------------
# UPDATE CONFIG FILES & SCRIPTS:
#
# CONFIGURE_FILE(InputFile OutputFile [COPYONLY] [ESCAPE_QUOTES] [@ONLY])
# If @ONLY is specified, only variables of the form @VAR@ will be
# replaces and ${VAR} will be ignored.
#
# A directory will be created for each platform so the "cvconfig.h" file is
# not overwritten if cmake generates code in the same path.
# ----------------------------------------------------------------------------
add_definitions ( -DHAVE_CONFIG_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" )
2011-01-01 00:45:18 +08:00
2010-05-12 01:44:00 +08:00
# ---------------------------------------------------------------------------
# The C+//0 include & link directories:
# ---------------------------------------------------------------------------
include_directories ( "."
" $ { O P E N C V _ C O N F I G _ F I L E _ I N C L U D E _ D I R } "
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / i n c l u d e "
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / i n c l u d e / o p e n c v "
)
2011-01-01 00:45:18 +08:00
2010-05-12 01:44:00 +08:00
# ----------------------------------------------------------------------------
# Set the maximum level of warnings:
# ----------------------------------------------------------------------------
# Should be set to true for development
set ( OPENCV_WARNINGS_ARE_ERRORS OFF CACHE BOOL "Treat warnings as errors" )
set ( EXTRA_C_FLAGS "" )
set ( EXTRA_C_FLAGS_RELEASE "" )
set ( EXTRA_C_FLAGS_DEBUG "" )
set ( EXTRA_EXE_LINKER_FLAGS "" )
set ( EXTRA_EXE_LINKER_FLAGS_RELEASE "" )
set ( EXTRA_EXE_LINKER_FLAGS_DEBUG "" )
if ( MSVC )
set ( EXTRA_C_FLAGS "${EXTRA_C_FLAGS} /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS" )
# 64-bit portability warnings, in MSVC8
if ( MSVC80 )
set ( EXTRA_C_FLAGS "${EXTRA_C_FLAGS} /Wp64" )
2011-05-06 20:24:56 +08:00
2010-05-12 01:44:00 +08:00
endif ( )
#if(MSVC90)
# set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} /D _BIND_TO_CURRENT_CRT_VERSION=1 /D _BIND_TO_CURRENT_VCLIBS_VERSION=1")
#endif()
set ( EXTRA_EXE_LINKER_FLAGS_RELEASE "${EXTRA_EXE_LINKER_FLAGS_RELEASE} /debug" )
#if(ENABLE_OPENMP)
# set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} /openmp")
#endif()
# Remove unreferenced functions: function level linking
set ( EXTRA_C_FLAGS "${EXTRA_C_FLAGS} /Gy" )
set ( EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} /Zi" )
endif ( )
if ( CMAKE_COMPILER_IS_GNUCXX )
# High level of warnings.
set ( EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wall" )
# The -Wno-long-long is required in 64bit systems when including sytem headers.
if ( ${ CMAKE_SYSTEM_PROCESSOR } MATCHES x86_64* )
set ( EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-long-long" )
endif ( )
if ( ${ CMAKE_SYSTEM_PROCESSOR } MATCHES amd64* )
set ( EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-long-long" )
endif ( )
# We need pthread's
if ( UNIX )
2011-04-06 22:31:03 +08:00
if ( NOT ANDROID )
2010-05-12 01:44:00 +08:00
set ( EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -pthread" )
2011-04-06 22:31:03 +08:00
endif ( )
2010-05-12 01:44:00 +08:00
endif ( )
if ( OPENCV_WARNINGS_ARE_ERRORS )
set ( EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Werror" )
endif ( )
if ( X86 )
if ( NOT MINGW64 )
if ( NOT X86_64 )
if ( NOT APPLE )
set ( EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -march=i686" )
endif ( )
endif ( )
endif ( )
endif ( )
# Other optimizations
if ( USE_OMIT_FRAME_POINTER )
2010-11-24 17:46:46 +08:00
set ( EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -fomit-frame-pointer" )
2010-05-12 01:44:00 +08:00
endif ( )
if ( USE_O2 )
2010-11-24 17:46:46 +08:00
set ( EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -O2" )
2010-05-12 01:44:00 +08:00
endif ( )
if ( USE_O3 )
2010-11-24 17:46:46 +08:00
set ( EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -O3" )
2010-05-12 01:44:00 +08:00
endif ( )
if ( USE_FAST_MATH )
2010-11-24 17:46:46 +08:00
set ( EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -ffast-math" )
2010-05-12 01:44:00 +08:00
endif ( )
if ( ENABLE_POWERPC )
2010-11-24 17:46:46 +08:00
set ( EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -mcpu=G3 -mtune=G5" )
2010-05-12 01:44:00 +08:00
endif ( )
if ( ENABLE_SSE )
2010-11-24 17:46:46 +08:00
set ( EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -msse" )
2010-05-12 01:44:00 +08:00
endif ( )
if ( ENABLE_SSE2 )
2010-11-24 17:46:46 +08:00
set ( EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -msse2" )
2010-05-12 01:44:00 +08:00
endif ( )
# SSE3 and further should be disabled under MingW because it generates compiler errors
if ( NOT MINGW )
2010-11-24 17:46:46 +08:00
if ( ENABLE_SSE3 )
set ( EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -msse3" )
endif ( )
if ( ${ CMAKE_OPENCV_GCC_VERSION_NUM } GREATER 402 )
set ( HAVE_GCC43_OR_NEWER 1 )
endif ( )
if ( ${ CMAKE_OPENCV_GCC_VERSION_NUM } GREATER 401 )
set ( HAVE_GCC42_OR_NEWER 1 )
endif ( )
if ( HAVE_GCC43_OR_NEWER OR APPLE )
if ( ENABLE_SSSE3 )
set ( EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -mssse3" )
endif ( )
if ( HAVE_GCC42_OR_NEWER )
if ( ENABLE_SSE41 )
set ( EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -msse4.1" )
endif ( )
if ( ENABLE_SSE42 )
set ( EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -msse4.2" )
endif ( )
endif ( )
endif ( )
2010-05-12 01:44:00 +08:00
endif ( )
2010-08-25 20:49:17 +08:00
2010-05-12 01:44:00 +08:00
if ( X86 OR X86_64 )
if ( NOT APPLE )
if ( ${ CMAKE_SIZEOF_VOID_P } EQUAL 4 )
set ( EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -mfpmath=387" )
endif ( )
endif ( )
endif ( )
# Profiling?
if ( ENABLE_PROFILING )
set ( EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -pg -g" )
else ( )
# Remove unreferenced functions: function level linking
if ( NOT APPLE )
set ( EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -ffunction-sections" )
endif ( )
endif ( )
# Parallel mode
#if(ENABLE_OPENMP)
# set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -D_GLIBCXX_PARALLEL -fopenmp")
# set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} gomp)
#endif()
set ( EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -DNDEBUG" )
2010-10-22 20:02:39 +08:00
set ( EXTRA_C_FLAGS_DEBUG "${EXTRA_C_FLAGS_DEBUG} -O0 -ggdb3 -DDEBUG -D_DEBUG" )
2011-04-20 22:48:02 +08:00
2010-05-12 01:44:00 +08:00
endif ( )
# Extra link libs if the user selects building static libs:
IF ( NOT BUILD_SHARED_LIBS )
if ( CMAKE_COMPILER_IS_GNUCXX )
set ( OPENCV_LINKER_LIBS ${ OPENCV_LINKER_LIBS } stdc++ )
endif ( )
endif ( )
# Add user supplied extra options (optimization, etc...)
# ==========================================================
set ( OPENCV_EXTRA_C_FLAGS "" CACHE STRING "Extra compiler options" )
set ( OPENCV_EXTRA_C_FLAGS_RELEASE "" CACHE STRING "Extra compiler options for Release build" )
set ( OPENCV_EXTRA_C_FLAGS_DEBUG "" CACHE STRING "Extra compiler options for Debug build" )
set ( OPENCV_EXTRA_EXE_LINKER_FLAGS "" CACHE STRING "Extra linker flags" FORCE )
set ( OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE "" CACHE STRING "Extra linker flags for Release build" FORCE )
set ( OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG "" CACHE STRING "Extra linker flags for Debug build" FORCE )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS} ${OPENCV_EXTRA_C_FLAGS}" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_C_FLAGS} ${OPENCV_EXTRA_C_FLAGS}" )
set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${EXTRA_C_FLAGS_RELEASE} ${OPENCV_EXTRA_C_FLAGS_RELEASE}" )
set ( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${EXTRA_C_FLAGS_RELEASE} ${OPENCV_EXTRA_C_FLAGS_RELEASE}" )
set ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${EXTRA_C_FLAGS_DEBUG} ${OPENCV_EXTRA_C_FLAGS_DEBUG}" )
set ( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${EXTRA_C_FLAGS_DEBUG} ${OPENCV_EXTRA_C_FLAGS_DEBUG}" )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EXTRA_EXE_LINKER_FLAGS} ${OPENCV_EXTRA_EXE_LINKER_FLAGS}" )
set ( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${EXTRA_EXE_LINKER_FLAGS_RELEASE} ${OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE}" )
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" )
if ( "${CMAKE_BUILD_TYPE}" STREQUAL "" )
set ( CMAKE_BUILD_TYPE Release )
endif ( )
endif ( )
if ( WIN32 AND MSVC )
# avoid warnings from MSVC about overriding the /W* option
# we replace /W3 with /W4 only for C++ files,
# since all the 3rd-party libraries OpenCV uses are in C,
# and we do not care about their warnings.
string ( REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
string ( REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" )
string ( REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" )
# allow extern "C" functions throw exceptions
string ( REPLACE "/EHsc" "/EHsc-" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" )
string ( REPLACE "/EHsc" "/EHsc-" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" )
string ( REPLACE "/EHsc" "/EHsc-" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" )
string ( REPLACE "/EHsc" "/EHsc-" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
string ( REPLACE "/EHsc" "/EHsc-" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" )
string ( REPLACE "/EHsc" "/EHsc-" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" )
2010-08-25 20:49:17 +08:00
2011-01-01 00:45:18 +08:00
string ( REPLACE "/Zm1000" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
string ( REPLACE "/Zm1000" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" )
2010-05-12 01:44:00 +08:00
endif ( )
if ( "${CMAKE_CONFIGURE_LDFLAGS}" )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_CONFIGURE_LDFLAGS}" )
endif ( "${CMAKE_CONFIGURE_LDFLAGS}" )
2011-01-01 00:45:18 +08:00
2010-05-12 01:44:00 +08:00
# ----------------------------------------------------------------------------
# PROCESS SUBDIRECTORIES:
# ----------------------------------------------------------------------------
# Save libs and executables in the same place
set ( LIBRARY_OUTPUT_PATH ${ CMAKE_BINARY_DIR } /lib CACHE PATH "Output directory for libraries" )
set ( EXECUTABLE_OUTPUT_PATH ${ CMAKE_BINARY_DIR } /bin CACHE PATH "Output directory for applications" )
if ( WIN32 )
set ( OPENCV_DOC_INSTALL_PATH doc )
else ( )
set ( OPENCV_DOC_INSTALL_PATH share/opencv/doc )
endif ( )
2011-01-01 00:45:18 +08:00
2010-05-12 01:44:00 +08:00
# --------------------------------------------------------------------------------------------
# Installation for CMake Module: OpenCVConfig.cmake
# Part 1/3: ${BIN_DIR}/OpenCVConfig.cmake -> For use *without* "make install"
# Part 2/3: ${BIN_DIR}/unix-install/OpenCVConfig.cmake -> For use with "make install"
# Part 3/3: ${BIN_DIR}/win-install/OpenCVConfig.cmake -> For use within binary installers/packages
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# Part 1/3: ${BIN_DIR}/OpenCVConfig.cmake -> For use *without* "make install"
# -------------------------------------------------------------------------------------------
# Name of libraries is: libcv.so.1.1.0, etc...
# OPENCV_DLLVERSION must be set to "110", etc..
# Already done above.
# Set CMAKE_INCLUDE_DIRS_CONFIGCMAKE to the list of include directories:
set ( CMAKE_INCLUDE_DIRS_CONFIGCMAKE "\" ${ OPENCV_CONFIG_FILE_INCLUDE_DIR } \" \"${CMAKE_CURRENT_SOURCE_DIR}/include\" \"${CMAKE_CURRENT_SOURCE_DIR}/include/opencv\"")
2010-05-14 17:35:39 +08:00
set ( CMAKE_BASE_INCLUDE_DIRS_CONFIGCMAKE "\" ${ CMAKE_CURRENT_SOURCE_DIR } \"")
2010-05-12 01:44:00 +08:00
2011-04-11 22:47:06 +08:00
set ( CMAKE_LIB_DIRS_CONFIGCMAKE "${LIBRARY_OUTPUT_PATH}" )
if ( ANDROID )
2011-05-27 21:47:18 +08:00
if ( NOT BUILD_SHARED_LIBS )
set ( CMAKE_LIB_DIRS_CONFIGCMAKE ${ CMAKE_LIB_DIRS_CONFIGCMAKE } "${CMAKE_BINARY_DIR}/lib" )
endif ( )
2011-04-11 22:47:06 +08:00
2011-05-27 21:47:18 +08:00
if ( HAVE_ANDROID_NATIVE_CAMERA )
set ( CMAKE_LIB_DIRS_CONFIGCMAKE ${ CMAKE_LIB_DIRS_CONFIGCMAKE } ${ NativeCamera_LIB_DIR } )
endif ( )
2011-04-06 22:31:03 +08:00
endif ( )
2010-05-12 01:44:00 +08:00
configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig.cmake" IMMEDIATE @ONLY )
# --------------------------------------------------------------------------------------------
# Part 2/3: ${BIN_DIR}/unix-install/OpenCVConfig.cmake -> For use *with* "make install"
# -------------------------------------------------------------------------------------------
# Set CMAKE_INCLUDE_DIRS_CONFIGCMAKE to the list of include directories:
2010-06-01 23:47:36 +08:00
set ( CMAKE_INCLUDE_DIRS_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}/include/opencv" "${CMAKE_INSTALL_PREFIX}/include" )
2010-05-14 17:35:39 +08:00
set ( CMAKE_BASE_INCLUDE_DIRS_CONFIGCMAKE "\" \"")
2010-05-12 01:44:00 +08:00
set ( CMAKE_LIB_DIRS_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}/lib" )
2010-11-30 06:18:28 +08:00
exec_program ( mkdir ARGS "-p \" ${ CMAKE_BINARY_DIR } /unix-install/\ "" OUTPUT_VARIABLE RET_VAL )
2010-05-12 01:44:00 +08:00
configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake" IMMEDIATE @ONLY )
if ( UNIX )
# For a command "FIND_PACKAGE(FOO)", CMake will look at the directory /usr/share|lib/FOO/FOOConfig.cmake, so:
2011-05-31 06:13:32 +08:00
install ( FILES ${ CMAKE_BINARY_DIR } /unix-install/OpenCVConfig.cmake DESTINATION share/opencv/ )
2010-05-12 01:44:00 +08:00
endif ( )
# --------------------------------------------------------------------------------------------
# Part 3/3: ${BIN_DIR}/win-install/OpenCVConfig.cmake -> For use within binary installers/packages
# -------------------------------------------------------------------------------------------
if ( WIN32 )
# Set CMAKE_INCLUDE_DIRS_CONFIGCMAKE to the list of include directories:
2010-11-30 06:18:28 +08:00
# support for 3rdparty libraries.
2010-12-05 07:02:36 +08:00
# This will expand to, for example, <program files>/OpenCV 1.1.0/include
set ( CMAKE_INCLUDE_DIRS_CONFIGCMAKE "\" \${THIS_OPENCV_CONFIG_PATH}/include\"
\ " \ $ { T H I S _ O P E N C V _ C O N F I G _ P A T H } / i n c l u d e / o p e n c v \ "
\ " \ $ { T H I S _ O P E N C V _ C O N F I G _ P A T H } / 3 r d p a r t y / i n c l u d e \ " " )
set ( CMAKE_BASE_INCLUDE_DIRS_CONFIGCMAKE "\" \${THIS_OPENCV_CONFIG_PATH}\"")
# This will expand to, for example, <program files>/OpenCV 1.1.0/lib
# support for 3rdparty libraries.
set ( CMAKE_LIB_DIRS_CONFIGCMAKE "\" \${THIS_OPENCV_CONFIG_PATH}/lib\"
\ " \ $ { T H I S _ O P E N C V _ C O N F I G _ P A T H } / 3 r d p a r t y / l i b \ " " )
2010-08-25 20:49:17 +08:00
2010-05-12 01:44:00 +08:00
#exec_program(${CMAKE_COMMAND} ARGS "-E make_directory \"${CMAKE_BINARY_DIR}/win-install/\"")
2010-11-30 06:18:28 +08:00
exec_program ( mkdir ARGS "-p \" ${ CMAKE_BINARY_DIR } /win-install/\ "" OUTPUT_VARIABLE RET_VAL )
2010-12-05 04:36:59 +08:00
configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" IMMEDIATE @ONLY )
2010-12-05 03:21:45 +08:00
# 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}/" )
2010-11-30 06:18:28 +08:00
# if videoInput support is enabled (which is by default on WIN32) copy the static library required to the installation path
# DESTINATION could also be "${CMAKE_INSTALL_PREFIX}/lib") to simplify dev environment setup of client applications
IF ( HAVE_VIDEOINPUT )
install ( FILES "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/lib/videoInput.lib" "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/lib/videoInput64.lib"
D E S T I N A T I O N " $ { C M A K E _ I N S T A L L _ P R E F I X } / 3 r d p a r t y / l i b " )
install ( FILES "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/include/videoInput.h" DESTINATION "${CMAKE_INSTALL_PREFIX}/3rdparty/include" )
ENDIF ( )
# Add the OpenCV configuration header to the install path
# Useful for instance if a client application checks against the features OpenCV has been compiled with
install ( FILES "${CMAKE_BINARY_DIR}/cvconfig.h" DESTINATION "${CMAKE_INSTALL_PREFIX}/include" )
2010-05-12 01:44:00 +08:00
endif ( )
# --------------------------------------------------------------------------------------------
# Part 2/2: ${BIN_DIR}/unix-install/opencv.pc -> For use *with* "make install"
# prefix=/usr
# exec_prefix=${prefix}
# libdir=${exec_prefix}/lib
# includedir=${prefix}/include/opencv
# -------------------------------------------------------------------------------------------
set ( prefix ${ CMAKE_INSTALL_PREFIX } )
set ( exec_prefix "\${prefix}" )
set ( libdir "\${exec_prefix}/lib" )
set ( includedir "\${prefix}/include" )
set ( VERSION ${ OPENCV_VERSION } )
configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/opencv.pc.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/opencv.pc" @ONLY IMMEDIATE )
if ( UNIX )
install ( FILES ${ CMAKE_BINARY_DIR } /unix-install/opencv.pc DESTINATION lib/pkgconfig )
endif ( )
# ----------------------------------------------------------------------------
# Uninstall target, for "make uninstall"
# ----------------------------------------------------------------------------
CONFIGURE_FILE (
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e _ u n i n s t a l l . c m a k e . i n "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c m a k e _ u n i n s t a l l . c m a k e "
I M M E D I A T E @ O N L Y )
ADD_CUSTOM_TARGET ( uninstall
" $ { C M A K E _ C O M M A N D } " - P " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c m a k e _ u n i n s t a l l . c m a k e " )
# ----------------------------------------------------------------------------
# CPack target
# ----------------------------------------------------------------------------
set ( BUILD_PACKAGE OFF CACHE BOOL "Build a installer with the SDK" )
if ( BUILD_PACKAGE )
configure_file (
P a c k a g e . c m a k e . i n
$ { C M A K E _ B I N A R Y _ D I R } / . c p a c k / P a c k a g e . c m a k e
@ O N L Y
)
2010-08-25 20:49:17 +08:00
2010-05-12 01:44:00 +08:00
include ( ${ CMAKE_BINARY_DIR } /.cpack/Package.cmake )
set ( root_files README )
file ( GLOB root_src_files *.in *.cmake CMakeLists.txt )
if ( NOT WIN32 )
install ( FILES ${ root_files }
D E S T I N A T I O N $ { O P E N C V _ D O C _ I N S T A L L _ P A T H }
C O M P O N E N T m a i n )
else ( )
install ( FILES ${ root_files }
D E S T I N A T I O N " . "
C O M P O N E N T m a i n )
install ( FILES ${ root_src_files }
D E S T I N A T I O N " . "
C O M P O N E N T s r c )
2010-08-25 20:49:17 +08:00
# Add the "win-install/OpenCVConfig.cmake" file to the "main" install component
install ( FILES
2010-05-12 01:44:00 +08:00
" $ { C M A K E _ B I N A R Y _ D I R } / w i n - i n s t a l l / O p e n C V C o n f i g . c m a k e "
D E S T I N A T I O N " . "
C O M P O N E N T m a i n
)
2010-12-09 20:23:41 +08:00
install ( FILES
" i n c l u d e / C M a k e L i s t s . t x t "
D E S T I N A T I O N " i n c l u d e / "
C O M P O N E N T s r c
)
2010-05-12 01:44:00 +08:00
if ( CMAKE_INSTALL_DEBUG_LIBRARIES )
2010-11-26 07:12:37 +08:00
foreach ( m calib3d core contrib features2d ffmpeg flann gpu highgui imgproc legacy ml objdetect video )
2011-05-31 06:13:32 +08:00
install ( FILES ${ EXECUTABLE_OUTPUT_PATH } /Debug/opencv_ ${ m } ${ OPENCV_DLLVERSION } d.dll
2010-05-12 01:44:00 +08:00
D E S T I N A T I O N b i n C O M P O N E N T m a i n )
2011-05-31 06:13:32 +08:00
install ( FILES ${ LIBRARY_OUTPUT_PATH } /Debug/opencv_ ${ m } ${ OPENCV_DLLVERSION } d.lib
2010-05-12 01:44:00 +08:00
D E S T I N A T I O N l i b C O M P O N E N T m a i n )
2010-08-25 20:49:17 +08:00
endforeach ( )
2010-05-12 01:44:00 +08:00
endif ( )
install ( DIRECTORY data samples DESTINATION "." COMPONENT main PATTERN ".svn" EXCLUDE )
2010-12-05 09:19:36 +08:00
install ( DIRECTORY 3rdparty android modules tests DESTINATION "." COMPONENT src PATTERN ".svn" EXCLUDE )
2011-02-23 04:43:26 +08:00
#install(DIRECTORY doc/ DESTINATION doc COMPONENT src FILES_MATCHING PATTERN "*.tex")
#install(DIRECTORY doc/pics DESTINATION doc COMPONENT src PATTERN ".svn" EXCLUDE)
#install(DIRECTORY doc/latex2sphinx DESTINATION doc COMPONENT src PATTERN ".svn" EXCLUDE)
2010-08-25 20:49:17 +08:00
2010-05-12 01:44:00 +08:00
endif ( )
endif ( )
2011-05-11 21:37:20 +08:00
#-----------------------------------
# Solution folders:
#-----------------------------------
if ( ${ CMAKE_VERSION } VERSION_GREATER "2.8.0" )
2011-05-27 21:47:18 +08:00
set ( ENABLE_SOLUTION_FOLDERS OFF CACHE BOOL "Solution folder in Visual Studio or in other IDEs" )
2011-05-11 21:37:20 +08:00
endif ( )
2011-05-17 22:15:23 +08:00
if ( ENABLE_SOLUTION_FOLDERS )
set_property ( GLOBAL PROPERTY USE_FOLDERS ON )
set_property ( GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets" )
endif ( )
2010-05-12 01:44:00 +08:00
#-----------------------------------
# Subdirectories:
#-----------------------------------
add_subdirectory ( include )
add_subdirectory ( modules )
2011-05-10 00:50:29 +08:00
if ( BUILD_DOCS )
2010-05-12 01:44:00 +08:00
include ( OpenCVFindLATEX.cmake REQUIRED )
2010-08-25 20:49:17 +08:00
2010-05-12 01:44:00 +08:00
if ( PDFLATEX_COMPILER )
message ( STATUS "PDF LaTeX found!" )
endif ( )
endif ( )
2011-05-10 00:50:29 +08:00
add_subdirectory ( doc )
2010-05-12 01:44:00 +08:00
add_subdirectory ( data )
if ( BUILD_EXAMPLES OR INSTALL_PYTHON_EXAMPLES )
add_subdirectory ( samples )
endif ( )
2011-02-10 04:55:11 +08:00
#if(BUILD_TESTS)
# enable_testing()
# add_subdirectory(tests)
#endif()
2010-05-12 01:44:00 +08:00
add_subdirectory ( 3rdparty )
# ----------------------------------------------------------------------------
2011-01-01 00:45:18 +08:00
# Summary:
2010-05-12 01:44:00 +08:00
# ----------------------------------------------------------------------------
message ( STATUS "" )
message ( STATUS "General configuration for opencv ${OPENCV_VERSION} =====================================" )
message ( STATUS "" )
2011-02-23 04:43:26 +08:00
message ( STATUS " Built as dynamic libs?: ${BUILD_SHARED_LIBS}" )
message ( STATUS " Compiler: ${CMAKE_COMPILER}" )
message ( STATUS " C++ flags (Release): ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}" )
message ( STATUS " C++ flags (Debug): ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}" )
2010-05-12 01:44:00 +08:00
if ( WIN32 )
2011-02-23 04:43:26 +08:00
message ( STATUS " Linker flags (Release): ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_RELEASE}" )
message ( STATUS " Linker flags (Debug): ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_DEBUG}" )
2010-05-12 01:44:00 +08:00
else ( )
2011-02-23 04:43:26 +08:00
message ( STATUS " Linker flags (Release): ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}" )
message ( STATUS " Linker flags (Debug): ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" )
2010-05-12 01:44:00 +08:00
endif ( )
2010-06-07 16:29:10 +08:00
#YV
2010-07-12 23:29:31 +08:00
message ( STATUS "" )
message ( STATUS " GUI: " )
2010-05-12 01:44:00 +08:00
2010-07-12 23:29:31 +08:00
if ( HAVE_QT )
2011-02-23 04:43:26 +08:00
message ( STATUS " QT 4.x: ${HAVE_QT}" )
message ( STATUS " QT OpenGL support: ${HAVE_QT_OPENGL}" )
2010-07-12 23:29:31 +08:00
else ( )
if ( WIN32 )
2011-02-23 04:43:26 +08:00
message ( STATUS " Win32 UI: YES" )
2010-07-12 23:29:31 +08:00
else ( )
if ( APPLE )
if ( WITH_CARBON )
2011-02-23 04:43:26 +08:00
message ( STATUS " Carbon: YES" )
2010-07-12 23:29:31 +08:00
else ( )
2011-02-23 04:43:26 +08:00
message ( STATUS " Cocoa: YES" )
2010-07-12 23:29:31 +08:00
endif ( )
else ( )
2011-02-23 04:43:26 +08:00
message ( STATUS " GTK+ 2.x: ${HAVE_GTK}" )
message ( STATUS " GThread: ${HAVE_GTHREAD}" )
2010-07-12 23:29:31 +08:00
endif ( )
endif ( )
2010-08-25 20:49:17 +08:00
endif ( )
2010-05-12 01:44:00 +08:00
2010-07-12 23:29:31 +08:00
message ( STATUS "" )
2011-04-26 23:46:15 +08:00
message ( STATUS " Media I/O: " )
if ( ZLIB_FOUND )
message ( STATUS " ZLib: ${ZLIB_FOUND}" )
else ( )
message ( STATUS " ZLib: build" )
endif ( )
2010-05-12 01:44:00 +08:00
if ( NOT WITH_JPEG OR JPEG_FOUND )
2011-02-23 04:43:26 +08:00
message ( STATUS " JPEG: ${JPEG_FOUND}" )
2010-05-12 01:44:00 +08:00
else ( )
2011-02-23 04:43:26 +08:00
message ( STATUS " JPEG: build" )
2010-05-12 01:44:00 +08:00
endif ( )
if ( NOT WITH_PNG OR PNG_FOUND )
2011-02-23 04:43:26 +08:00
message ( STATUS " PNG: ${PNG_FOUND}" )
2010-05-12 01:44:00 +08:00
else ( )
2011-02-23 04:43:26 +08:00
message ( STATUS " PNG: build" )
2010-05-12 01:44:00 +08:00
endif ( )
if ( NOT WITH_TIFF OR TIFF_FOUND )
2011-02-23 04:43:26 +08:00
message ( STATUS " TIFF: ${TIFF_FOUND}" )
2010-05-12 01:44:00 +08:00
else ( )
2011-02-23 04:43:26 +08:00
message ( STATUS " TIFF: build" )
2010-05-12 01:44:00 +08:00
endif ( )
if ( NOT WITH_JASPER OR JASPER_FOUND )
2011-02-23 04:43:26 +08:00
message ( STATUS " JPEG 2000: ${JASPER_FOUND}" )
2010-05-12 01:44:00 +08:00
else ( )
2011-02-23 04:43:26 +08:00
message ( STATUS " JPEG 2000: build" )
2010-05-12 01:44:00 +08:00
endif ( )
2010-07-04 20:32:31 +08:00
if ( WITH_OPENEXR AND OPENEXR_FOUND )
2011-02-23 04:43:26 +08:00
message ( STATUS " OpenEXR: YES" )
2010-07-04 20:32:31 +08:00
else ( )
2011-02-23 04:43:26 +08:00
message ( STATUS " OpenEXR: NO" )
2010-07-04 20:32:31 +08:00
endif ( )
2011-02-04 21:41:10 +08:00
if ( NOT HAVE_OPENNI OR HAVE_OPENNI_PRIME_SENSOR_MODULE )
2011-02-23 04:43:26 +08:00
message ( STATUS " OpenNI: ${HAVE_OPENNI}" )
2011-01-22 01:00:08 +08:00
else ( )
2011-02-23 04:43:26 +08:00
message ( STATUS " OpenNI: ${HAVE_OPENNI} (WARNING: PrimeSensor Modules for OpenNI are not installed (not found in OPENNI_PRIME_SENSOR_MODULE_BIN_DIR).)" )
2011-02-04 21:41:10 +08:00
endif ( )
2011-01-22 01:00:08 +08:00
2010-05-12 01:44:00 +08:00
if ( UNIX AND NOT APPLE )
message ( STATUS "" )
message ( STATUS " Video I/O: " )
2011-02-23 04:43:26 +08:00
message ( STATUS " DC1394 1.x: ${HAVE_DC1394}" )
message ( STATUS " DC1394 2.x: ${HAVE_DC1394_2}" )
message ( STATUS " FFMPEG: ${HAVE_FFMPEG}" )
message ( STATUS " codec: ${HAVE_FFMPEG_CODEC}" )
message ( STATUS " format: ${HAVE_FFMPEG_FORMAT}" )
message ( STATUS " util: ${HAVE_FFMPEG_UTIL}" )
message ( STATUS " swscale: ${HAVE_FFMPEG_SWSCALE}" )
message ( STATUS " gentoo-style: ${HAVE_GENTOO_FFMPEG}" )
message ( STATUS " GStreamer: ${HAVE_GSTREAMER}" )
message ( STATUS " UniCap: ${HAVE_UNICAP}" )
message ( STATUS " PvAPI: ${HAVE_PVAPI}" )
2010-05-12 01:44:00 +08:00
if ( HAVE_LIBV4L )
2011-02-23 04:43:26 +08:00
message ( STATUS " V4L/V4L2: Using libv4l" )
2010-05-12 01:44:00 +08:00
else ( )
2011-02-23 04:43:26 +08:00
message ( STATUS " V4L/V4L2: ${HAVE_CAMV4L}/${HAVE_CAMV4L2}" )
2010-05-12 01:44:00 +08:00
endif ( )
2011-02-23 04:43:26 +08:00
message ( STATUS " Xine: ${HAVE_XINE}" )
2011-04-06 22:31:03 +08:00
if ( ANDROID )
message ( STATUS " AndroidNativeCamera: ${HAVE_ANDROID_NATIVE_CAMERA}" )
endif ( )
2011-01-22 01:00:08 +08:00
endif ( ) #if(UNIX AND NOT APPLE)
2010-05-12 01:44:00 +08:00
if ( APPLE )
message ( STATUS "" )
if ( WITH_QUICKTIME )
2011-02-23 04:43:26 +08:00
message ( STATUS " Video I/O: QuickTime" )
2010-05-12 01:44:00 +08:00
else ( )
2011-02-23 04:43:26 +08:00
message ( STATUS " Video I/O: QTKit" )
2010-05-12 01:44:00 +08:00
endif ( )
endif ( )
2010-07-17 06:38:57 +08:00
if ( WIN32 )
message ( STATUS "" )
message ( STATUS " Video I/O: " )
if ( HAVE_VIDEOINPUT )
2011-02-23 04:43:26 +08:00
message ( STATUS " VideoInput: YES" )
2010-07-17 06:38:57 +08:00
else ( )
2011-02-23 04:43:26 +08:00
message ( STATUS " VideoInput: NO" )
2010-07-17 06:38:57 +08:00
endif ( )
endif ( )
2010-05-12 01:44:00 +08:00
message ( STATUS "" )
message ( STATUS " Interfaces: " )
2011-02-23 04:43:26 +08:00
message ( STATUS " Python: ${BUILD_NEW_PYTHON_SUPPORT}" )
message ( STATUS " Python interpreter: ${PYTHON_EXECUTABLE}" )
2010-11-04 01:57:51 +08:00
if ( PYTHON_USE_NUMPY )
2011-02-23 04:43:26 +08:00
message ( STATUS " Python numpy: YES" )
2010-11-04 01:57:51 +08:00
else ( )
2011-02-23 04:43:26 +08:00
message ( STATUS " Python numpy: NO (Python interface will not cover OpenCV 2.x API)" )
2010-11-04 01:57:51 +08:00
endif ( )
2010-05-12 01:44:00 +08:00
2011-01-01 00:45:18 +08:00
if ( WITH_IPP AND IPP_FOUND )
2011-02-23 04:43:26 +08:00
message ( STATUS " Use IPP: ${IPP_LATEST_VERSION_STR} [${IPP_LATEST_VERSION_MAJOR}.${IPP_LATEST_VERSION_MINOR}.${IPP_LATEST_VERSION_BUILD}]" )
message ( STATUS " at: ${IPP_ROOT_DIR}" )
2011-01-01 00:45:18 +08:00
elseif ( WITH_IPP AND NOT IPP_FOUND )
2011-02-23 04:43:26 +08:00
message ( STATUS " Use IPP: IPP not found" )
2010-05-12 01:44:00 +08:00
else ( )
2011-02-23 04:43:26 +08:00
message ( STATUS " Use IPP: NO" )
2010-05-12 01:44:00 +08:00
endif ( )
if ( HAVE_TBB )
2011-02-23 04:43:26 +08:00
message ( STATUS " Use TBB: YES" )
2010-05-12 01:44:00 +08:00
else ( )
2011-02-23 04:43:26 +08:00
message ( STATUS " Use TBB: NO" )
2011-04-29 22:20:24 +08:00
if ( HAVE_THREADING_FRAMEWORK )
message ( STATUS " Use ThreadingFramework: YES" )
else ( )
message ( STATUS " Use ThreadingFramework: NO" )
endif ( )
2010-05-12 01:44:00 +08:00
endif ( )
2010-07-15 21:36:00 +08:00
if ( HAVE_CUDA )
2011-02-23 04:43:26 +08:00
message ( STATUS " Use Cuda: YES" )
2010-07-15 21:36:00 +08:00
else ( )
2011-02-23 04:43:26 +08:00
message ( STATUS " Use Cuda: NO" )
2010-07-15 21:36:00 +08:00
endif ( )
2011-05-27 20:15:36 +08:00
if ( HAVE_EIGEN )
message ( STATUS " Use Eigen: YES" )
2010-06-29 23:49:15 +08:00
else ( )
2011-05-27 20:15:36 +08:00
message ( STATUS " Use Eigen: NO" )
2010-06-29 23:49:15 +08:00
endif ( )
2010-06-11 07:38:37 +08:00
message ( STATUS "" )
message ( STATUS " Documentation: " )
2011-05-10 00:50:29 +08:00
if ( BUILD_DOCS AND PDFLATEX_COMPILER AND HAVE_SPHINX )
message ( STATUS " Build Documentation: YES" )
2010-05-12 01:44:00 +08:00
else ( )
2011-05-10 00:50:29 +08:00
message ( STATUS " Build Documentation: NO" )
2010-05-12 01:44:00 +08:00
endif ( )
2010-05-18 23:41:28 +08:00
2011-02-23 04:43:26 +08:00
#if(BUILD_DOXYGEN_DOCS AND DOXYGEN_FOUND)
#message(STATUS " Doxygen HTMLs YES")
#else()
#message(STATUS " Doxygen HTMLs NO")
#endif()
2010-05-18 23:41:28 +08:00
2010-05-12 01:44:00 +08:00
message ( STATUS "" )
2011-02-23 04:43:26 +08:00
message ( STATUS " Install path: ${CMAKE_INSTALL_PREFIX}" )
2010-05-12 01:44:00 +08:00
message ( STATUS "" )
2011-02-23 04:43:26 +08:00
message ( STATUS " cvconfig.h is in: ${OPENCV_CONFIG_FILE_INCLUDE_DIR}" )
2010-05-12 01:44:00 +08:00
message ( STATUS "-----------------------------------------------------------------" )
message ( STATUS "" )
#----------------------------------------------------------------------------
# Generate the OpenCVConfig.cmake file for unix
# installation in CMAKE_INSTALL_PREFIX
#----------------------------------------------------------------------------