Merge pull request #1551 from alalek:cmake_install_win

This commit is contained in:
Andrey Pavlenko 2013-10-10 18:20:34 +04:00 committed by OpenCV Buildbot
commit 3b1c53fa8d
34 changed files with 557 additions and 310 deletions

View File

@ -46,5 +46,5 @@ if(ENABLE_SOLUTION_FOLDERS)
endif()
if(NOT BUILD_SHARED_LIBS)
install(TARGETS ${JASPER_LIBRARY} ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main)
ocv_install_target(${JASPER_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main)
endif()

View File

@ -39,5 +39,5 @@ if(ENABLE_SOLUTION_FOLDERS)
endif()
if(NOT BUILD_SHARED_LIBS)
install(TARGETS ${JPEG_LIBRARY} ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main)
ocv_install_target(${JPEG_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main)
endif()

View File

@ -55,5 +55,5 @@ if(ENABLE_SOLUTION_FOLDERS)
endif()
if(NOT BUILD_SHARED_LIBS)
install(TARGETS ${PNG_LIBRARY} ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main)
ocv_install_target(${PNG_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main)
endif()

View File

@ -115,5 +115,5 @@ if(ENABLE_SOLUTION_FOLDERS)
endif()
if(NOT BUILD_SHARED_LIBS)
install(TARGETS ${TIFF_LIBRARY} ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main)
ocv_install_target(${TIFF_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main)
endif()

View File

@ -62,7 +62,7 @@ if(ENABLE_SOLUTION_FOLDERS)
endif()
if(NOT BUILD_SHARED_LIBS)
install(TARGETS IlmImf ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main)
ocv_install_target(IlmImf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main)
endif()
set(OPENEXR_INCLUDE_PATHS ${OPENEXR_INCLUDE_PATHS} PARENT_SCOPE)

View File

@ -247,8 +247,8 @@ if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(tbb PROPERTIES FOLDER "3rdparty")
endif()
install(TARGETS tbb
RUNTIME DESTINATION bin COMPONENT main
ocv_install_target(tbb EXPORT OpenCVModules
RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT main
LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main
ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main
)

View File

@ -95,5 +95,5 @@ if(ENABLE_SOLUTION_FOLDERS)
endif()
if(NOT BUILD_SHARED_LIBS)
install(TARGETS ${ZLIB_LIBRARY} ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main)
ocv_install_target(${ZLIB_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main)
endif()

View File

@ -30,10 +30,6 @@ if(NOT CMAKE_TOOLCHAIN_FILE)
else()
set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation Directory")
endif()
if(MSVC)
set(CMAKE_USE_RELATIVE_PATHS ON CACHE INTERNAL "" FORCE)
endif()
else(NOT CMAKE_TOOLCHAIN_FILE)
#Android: set output folder to ${CMAKE_BINARY_DIR}
set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_BINARY_DIR} CACHE PATH "root for library output, set this to change where android libs are compiled to" )
@ -60,6 +56,10 @@ endif()
project(OpenCV CXX C)
if(MSVC)
set(CMAKE_USE_RELATIVE_PATHS ON CACHE INTERNAL "" FORCE)
endif()
include(cmake/OpenCVUtils.cmake)
# ----------------------------------------------------------------------------
@ -190,6 +190,7 @@ OCV_OPTION(BUILD_TBB "Download and build TBB from source" ANDROID
# OpenCV installation options
# ===================================================
OCV_OPTION(INSTALL_CREATE_DISTRIB "Change install rules to build the distribution package" OFF )
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 )
@ -245,6 +246,21 @@ else()
set(OPENCV_DOC_INSTALL_PATH share/OpenCV/doc)
endif()
if(WIN32)
if(DEFINED OpenCV_RUNTIME AND DEFINED OpenCV_ARCH)
set(OpenCV_INSTALL_BINARIES_PREFIX "${OpenCV_ARCH}/${OpenCV_RUNTIME}/")
else()
message(STATUS "Can't detect runtime and/or arch")
set(OpenCV_INSTALL_BINARIES_PREFIX "")
endif()
else()
set(OpenCV_INSTALL_BINARIES_PREFIX "")
endif()
set(OPENCV_SAMPLES_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}samples")
set(OPENCV_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}bin")
if(ANDROID)
set(LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/lib/${ANDROID_NDK_ABI_NAME}")
set(3P_LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/3rdparty/lib/${ANDROID_NDK_ABI_NAME}")
@ -255,9 +271,18 @@ if(ANDROID)
else()
set(LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/lib")
set(3P_LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/3rdparty/lib${LIB_SUFFIX}")
if(WIN32)
if(OpenCV_STATIC)
set(OPENCV_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib${LIB_SUFFIX}")
else()
set(OPENCV_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}lib${LIB_SUFFIX}")
endif()
set(OPENCV_3P_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib${LIB_SUFFIX}")
else()
set(OPENCV_LIB_INSTALL_PATH lib${LIB_SUFFIX})
set(OPENCV_3P_LIB_INSTALL_PATH share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH})
set(OPENCV_INCLUDE_INSTALL_PATH include)
endif()
set(OPENCV_INCLUDE_INSTALL_PATH "include")
math(EXPR SIZEOF_VOID_P_BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
if(LIB_SUFFIX AND NOT SIZEOF_VOID_P_BITS EQUAL LIB_SUFFIX)
@ -836,7 +861,20 @@ if(HAVE_OPENCL)
status(" Include path:" ${OPENCL_INCLUDE_DIRS})
endif()
if(OPENCL_LIBRARIES)
status(" libraries:" ${OPENCL_LIBRARIES})
set(__libs "")
foreach(l ${OPENCL_LIBRARIES})
if(TARGET ${l})
get_target_property(p ${l} LOCATION)
if(p MATCHES NOTFOUND)
list(APPEND __libs "${l}")
else()
list(APPEND __libs "${p}")
endif()
else()
list(APPEND __libs "${l}")
endif()
endforeach()
status(" libraries:" ${__libs})
endif()
status(" Use AMD FFT:" HAVE_CLAMDFFT THEN YES ELSE NO)
status(" Use AMD BLAS:" HAVE_CLAMDBLAS THEN YES ELSE NO)

View File

@ -69,9 +69,17 @@ set_target_properties(opencv_performance PROPERTIES
# Install part
# -----------------------------------------------------------
install(TARGETS opencv_haartraining RUNTIME DESTINATION bin COMPONENT main)
install(TARGETS opencv_createsamples RUNTIME DESTINATION bin COMPONENT main)
install(TARGETS opencv_performance RUNTIME DESTINATION bin COMPONENT main)
if(INSTALL_CREATE_DISTRIB)
if(BUILD_SHARED_LIBS)
install(TARGETS opencv_haartraining RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT main)
install(TARGETS opencv_createsamples RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT main)
install(TARGETS opencv_performance RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT main)
endif()
else()
install(TARGETS opencv_haartraining RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT main)
install(TARGETS opencv_createsamples RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT main)
install(TARGETS opencv_performance RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT main)
endif()
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(opencv_performance PROPERTIES FOLDER "applications")

View File

@ -33,4 +33,10 @@ if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "applications")
endif()
install(TARGETS ${the_target} RUNTIME DESTINATION bin COMPONENT main)
if(INSTALL_CREATE_DISTRIB)
if(BUILD_SHARED_LIBS)
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT main)
endif()
else()
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT main)
endif()

View File

@ -96,6 +96,12 @@ if(CMAKE_VERSION VERSION_GREATER 2.6.2)
unset(OpenCV_CONFIG_PATH CACHE)
endif()
if(NOT OpenCV_FIND_QUIETLY)
message(STATUS "OpenCV ARCH: ${OpenCV_ARCH}")
message(STATUS "OpenCV RUNTIME: ${OpenCV_RUNTIME}")
message(STATUS "OpenCV STATIC: ${OpenCV_STATIC}")
endif()
get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH CACHE)
if(OpenCV_RUNTIME AND OpenCV_ARCH)
if(OpenCV_STATIC AND EXISTS "${OpenCV_CONFIG_PATH}/${OpenCV_ARCH}/${OpenCV_RUNTIME}/staticlib/OpenCVConfig.cmake")
@ -150,8 +156,10 @@ if(OpenCV_LIB_PATH AND EXISTS "${OpenCV_LIB_PATH}/OpenCVConfig.cmake")
endif()
else()
if(NOT OpenCV_FIND_QUIETLY)
message(WARNING "Found OpenCV 2.4.3 Windows Super Pack but it has not binaries compatible with your configuration.
You should manually point CMake variable OpenCV_DIR to your build of OpenCV library.")
message(WARNING
"Found OpenCV Windows Pack but it has not binaries compatible with your configuration.
You should manually point CMake variable OpenCV_DIR to your build of OpenCV library."
)
endif()
set(OpenCV_FOUND FALSE CACHE BOOL "" FORCE)
set(OPENCV_FOUND FALSE CACHE BOOL "" FORCE)

View File

@ -110,3 +110,43 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*|amd64.*|AMD64.*")
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "arm.*|ARM.*")
set(ARM 1)
endif()
# Similar code is existed in OpenCVConfig.cmake
if(NOT DEFINED OpenCV_STATIC)
# look for global setting
if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS)
set(OpenCV_STATIC OFF)
else()
set(OpenCV_STATIC ON)
endif()
endif()
if(MSVC)
if(CMAKE_CL_64)
set(OpenCV_ARCH x64)
else()
set(OpenCV_ARCH x86)
endif()
if(MSVC_VERSION EQUAL 1400)
set(OpenCV_RUNTIME vc8)
elseif(MSVC_VERSION EQUAL 1500)
set(OpenCV_RUNTIME vc9)
elseif(MSVC_VERSION EQUAL 1600)
set(OpenCV_RUNTIME vc10)
elseif(MSVC_VERSION EQUAL 1700)
set(OpenCV_RUNTIME vc11)
endif()
elseif(MINGW)
set(OpenCV_RUNTIME mingw)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
OUTPUT_VARIABLE OPENCV_GCC_TARGET_MACHINE
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(CMAKE_OPENCV_GCC_TARGET_MACHINE MATCHES "64")
set(MINGW64 1)
set(OpenCV_ARCH x64)
else()
set(OpenCV_ARCH x86)
endif()
endif()

View File

@ -37,6 +37,7 @@ if(PYTHON_EXECUTABLE)
endif()
if(NOT ANDROID AND NOT IOS)
ocv_check_environment_variables(PYTHON_LIBRARY PYTHON_INCLUDE_DIR)
if(CMAKE_VERSION VERSION_GREATER 2.8.8 AND PYTHON_VERSION_FULL)
find_host_package(PythonLibs ${PYTHON_VERSION_FULL} EXACT)
else()

View File

@ -57,55 +57,10 @@ if(BUILD_FAT_JAVA_LIB AND HAVE_opencv_java)
list(APPEND OPENCV_MODULES_CONFIGCMAKE opencv_java)
endif()
macro(ocv_generate_dependencies_map_configcmake suffix configuration)
set(OPENCV_DEPENDENCIES_MAP_${suffix} "")
set(OPENCV_PROCESSED_LIBS "")
set(OPENCV_LIBS_TO_PROCESS ${OPENCV_MODULES_CONFIGCMAKE})
while(OPENCV_LIBS_TO_PROCESS)
list(GET OPENCV_LIBS_TO_PROCESS 0 __ocv_lib)
get_target_property(__libname ${__ocv_lib} LOCATION_${configuration})
get_filename_component(__libname "${__libname}" NAME)
if(WIN32)
string(REGEX REPLACE "${CMAKE_SHARED_LIBRARY_SUFFIX}$" "${OPENCV_LINK_LIBRARY_SUFFIX}" __libname "${__libname}")
endif()
if (CUDA_FOUND AND WIN32)
if(${__ocv_lib}_EXTRA_DEPS_${suffix})
list(REMOVE_ITEM ${__ocv_lib}_EXTRA_DEPS_${suffix} ${CUDA_LIBRARIES} ${CUDA_CUFFT_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_npp_LIBRARY} ${CUDA_nvcuvid_LIBRARY} ${CUDA_nvcuvenc_LIBRARY})
endif()
endif()
string(REPLACE " " "\\ " __mod_deps "${${__ocv_lib}_MODULE_DEPS_${suffix}}")
string(REPLACE " " "\\ " __ext_deps "${${__ocv_lib}_EXTRA_DEPS_${suffix}}")
string(REPLACE "\"" "\\\"" __mod_deps "${__mod_deps}")
string(REPLACE "\"" "\\\"" __ext_deps "${__ext_deps}")
set(OPENCV_DEPENDENCIES_MAP_${suffix} "${OPENCV_DEPENDENCIES_MAP_${suffix}}set(OpenCV_${__ocv_lib}_LIBNAME_${suffix} \"${__libname}\")\n")
set(OPENCV_DEPENDENCIES_MAP_${suffix} "${OPENCV_DEPENDENCIES_MAP_${suffix}}set(OpenCV_${__ocv_lib}_DEPS_${suffix} ${__mod_deps})\n")
set(OPENCV_DEPENDENCIES_MAP_${suffix} "${OPENCV_DEPENDENCIES_MAP_${suffix}}set(OpenCV_${__ocv_lib}_EXTRA_DEPS_${suffix} ${__ext_deps})\n")
list(APPEND OPENCV_PROCESSED_LIBS ${__ocv_lib})
list(APPEND OPENCV_LIBS_TO_PROCESS ${${__ocv_lib}_MODULE_DEPS_${suffix}})
list(REMOVE_ITEM OPENCV_LIBS_TO_PROCESS ${OPENCV_PROCESSED_LIBS})
endwhile()
unset(OPENCV_PROCESSED_LIBS)
unset(OPENCV_LIBS_TO_PROCESS)
unset(__ocv_lib)
unset(__libname)
endmacro()
ocv_generate_dependencies_map_configcmake(OPT Release)
ocv_generate_dependencies_map_configcmake(DBG Debug)
# -------------------------------------------------------------------------------------------
# Part 1/3: ${BIN_DIR}/OpenCVConfig.cmake -> For use *without* "make install"
# -------------------------------------------------------------------------------------------
set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"${OPENCV_CONFIG_FILE_INCLUDE_DIR}\" \"${OpenCV_SOURCE_DIR}/include\" \"${OpenCV_SOURCE_DIR}/include/opencv\"")
set(OpenCV_LIB_DIRS_CONFIGCMAKE "\"${LIBRARY_OUTPUT_PATH}\"")
set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"${3P_LIBRARY_OUTPUT_PATH}\"")
set(OpenCV2_INCLUDE_DIRS_CONFIGCMAKE "")
foreach(m ${OPENCV_MODULES_BUILD})
@ -130,13 +85,6 @@ configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.
set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}/opencv" "\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}\"")
set(OpenCV2_INCLUDE_DIRS_CONFIGCMAKE "\"\"")
if(ANDROID)
set(OpenCV_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/sdk/native/libs/\${ANDROID_NDK_ABI_NAME}\"")
set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/sdk/native/3rdparty/libs/\${ANDROID_NDK_ABI_NAME}\"")
else()
set(OpenCV_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_LIB_INSTALL_PATH}\"")
set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_3P_LIB_INSTALL_PATH}\"")
endif()
if(INSTALL_TO_MANGLED_PATHS)
string(REPLACE "OpenCV" "OpenCV-${OPENCV_VERSION}" OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "${OPENCV_3P_LIB_INSTALL_PATH}")
set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE}\"")
@ -155,9 +103,11 @@ if(UNIX)
if(INSTALL_TO_MANGLED_PATHS)
install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake DESTINATION ${OPENCV_CONFIG_INSTALL_PATH}-${OPENCV_VERSION}/)
install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig-version.cmake DESTINATION ${OPENCV_CONFIG_INSTALL_PATH}-${OPENCV_VERSION}/)
install(EXPORT OpenCVModules DESTINATION ${OPENCV_CONFIG_INSTALL_PATH}-${OPENCV_VERSION}/)
else()
install(FILES "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake" DESTINATION ${OPENCV_CONFIG_INSTALL_PATH}/)
install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig-version.cmake DESTINATION ${OPENCV_CONFIG_INSTALL_PATH}/)
install(EXPORT OpenCVModules DESTINATION ${OPENCV_CONFIG_INSTALL_PATH}/)
endif()
endif()
@ -171,12 +121,17 @@ endif()
if(WIN32)
set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_CONFIG_PATH}/include\" \"\${OpenCV_CONFIG_PATH}/include/opencv\"")
set(OpenCV2_INCLUDE_DIRS_CONFIGCMAKE "\"\"")
set(OpenCV_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_CONFIG_PATH}/${OPENCV_LIB_INSTALL_PATH}\"")
set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_CONFIG_PATH}/${OPENCV_3P_LIB_INSTALL_PATH}\"")
exec_program(mkdir ARGS "-p \"${CMAKE_BINARY_DIR}/win-install/\"" OUTPUT_VARIABLE RET_VAL)
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" IMMEDIATE @ONLY)
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" IMMEDIATE @ONLY)
install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}/")
install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}/")
if(BUILD_SHARED_LIBS)
install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}/lib")
install(EXPORT OpenCVModules DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}/lib")
else()
install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}/staticlib")
install(EXPORT OpenCVModules DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}/staticlib")
endif()
install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}")
install(FILES "${OpenCV_SOURCE_DIR}/cmake/OpenCVConfig.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}/")
endif()

View File

@ -11,9 +11,11 @@
# OPENCV_MODULE_${the_module}_HEADERS
# OPENCV_MODULE_${the_module}_SOURCES
# OPENCV_MODULE_${the_module}_DEPS - final flattened set of module dependencies
# OPENCV_MODULE_${the_module}_DEPS_EXT
# OPENCV_MODULE_${the_module}_DEPS_EXT - non-module dependencies
# OPENCV_MODULE_${the_module}_REQ_DEPS
# OPENCV_MODULE_${the_module}_OPT_DEPS
# OPENCV_MODULE_${the_module}_PRIVATE_REQ_DEPS
# OPENCV_MODULE_${the_module}_PRIVATE_OPT_DEPS
# HAVE_${the_module} - for fast check of module availability
# To control the setup of the module you could also set:
@ -48,6 +50,8 @@ foreach(mod ${OPENCV_MODULES_BUILD} ${OPENCV_MODULES_DISABLED_USER} ${OPENCV_MOD
endif()
unset(OPENCV_MODULE_${mod}_REQ_DEPS CACHE)
unset(OPENCV_MODULE_${mod}_OPT_DEPS CACHE)
unset(OPENCV_MODULE_${mod}_PRIVATE_REQ_DEPS CACHE)
unset(OPENCV_MODULE_${mod}_PRIVATE_OPT_DEPS CACHE)
endforeach()
# clean modules info which needs to be recalculated
@ -69,6 +73,10 @@ macro(ocv_add_dependencies full_modname)
set(__depsvar OPENCV_MODULE_${full_modname}_REQ_DEPS)
elseif(d STREQUAL "OPTIONAL")
set(__depsvar OPENCV_MODULE_${full_modname}_OPT_DEPS)
elseif(d STREQUAL "PRIVATE_REQUIRED")
set(__depsvar OPENCV_MODULE_${full_modname}_PRIVATE_REQ_DEPS)
elseif(d STREQUAL "PRIVATE_OPTIONAL")
set(__depsvar OPENCV_MODULE_${full_modname}_PRIVATE_OPT_DEPS)
else()
list(APPEND ${__depsvar} "${d}")
endif()
@ -77,9 +85,17 @@ macro(ocv_add_dependencies full_modname)
ocv_list_unique(OPENCV_MODULE_${full_modname}_REQ_DEPS)
ocv_list_unique(OPENCV_MODULE_${full_modname}_OPT_DEPS)
ocv_list_unique(OPENCV_MODULE_${full_modname}_PRIVATE_REQ_DEPS)
ocv_list_unique(OPENCV_MODULE_${full_modname}_PRIVATE_OPT_DEPS)
set(OPENCV_MODULE_${full_modname}_REQ_DEPS ${OPENCV_MODULE_${full_modname}_REQ_DEPS} CACHE INTERNAL "Required dependencies of ${full_modname} module")
set(OPENCV_MODULE_${full_modname}_OPT_DEPS ${OPENCV_MODULE_${full_modname}_OPT_DEPS} CACHE INTERNAL "Optional dependencies of ${full_modname} module")
set(OPENCV_MODULE_${full_modname}_REQ_DEPS ${OPENCV_MODULE_${full_modname}_REQ_DEPS}
CACHE INTERNAL "Required dependencies of ${full_modname} module")
set(OPENCV_MODULE_${full_modname}_OPT_DEPS ${OPENCV_MODULE_${full_modname}_OPT_DEPS}
CACHE INTERNAL "Optional dependencies of ${full_modname} module")
set(OPENCV_MODULE_${full_modname}_PRIVATE_REQ_DEPS ${OPENCV_MODULE_${full_modname}_PRIVATE_REQ_DEPS}
CACHE INTERNAL "Required private dependencies of ${full_modname} module")
set(OPENCV_MODULE_${full_modname}_PRIVATE_OPT_DEPS ${OPENCV_MODULE_${full_modname}_PRIVATE_OPT_DEPS}
CACHE INTERNAL "Optional private dependencies of ${full_modname} module")
endmacro()
# declare new OpenCV module in current folder
@ -173,126 +189,6 @@ macro(ocv_module_disable module)
endmacro()
# Internal macro; partly disables OpenCV module
macro(__ocv_module_turn_off the_module)
list(REMOVE_ITEM OPENCV_MODULES_DISABLED_AUTO "${the_module}")
list(APPEND OPENCV_MODULES_DISABLED_AUTO "${the_module}")
list(REMOVE_ITEM OPENCV_MODULES_BUILD "${the_module}")
list(REMOVE_ITEM OPENCV_MODULES_PUBLIC "${the_module}")
set(HAVE_${the_module} OFF CACHE INTERNAL "Module ${the_module} can not be built in current configuration")
endmacro()
# Internal macro for dependencies tracking
macro(__ocv_flatten_module_required_dependencies the_module)
set(__flattened_deps "")
set(__resolved_deps "")
set(__req_depends ${OPENCV_MODULE_${the_module}_REQ_DEPS})
while(__req_depends)
ocv_list_pop_front(__req_depends __dep)
if(__dep STREQUAL the_module)
__ocv_module_turn_off(${the_module}) # TODO: think how to deal with cyclic dependency
break()
elseif(";${OPENCV_MODULES_DISABLED_USER};${OPENCV_MODULES_DISABLED_AUTO};" MATCHES ";${__dep};")
__ocv_module_turn_off(${the_module}) # depends on disabled module
list(APPEND __flattened_deps "${__dep}")
elseif(";${OPENCV_MODULES_BUILD};" MATCHES ";${__dep};")
if(";${__resolved_deps};" MATCHES ";${__dep};")
list(APPEND __flattened_deps "${__dep}") # all dependencies of this module are already resolved
else()
# put all required subdependencies before this dependency and mark it as resolved
list(APPEND __resolved_deps "${__dep}")
list(INSERT __req_depends 0 ${OPENCV_MODULE_${__dep}_REQ_DEPS} ${__dep})
endif()
elseif(__dep MATCHES "^opencv_")
__ocv_module_turn_off(${the_module}) # depends on missing module
message(WARNING "Unknown \"${__dep}\" module is listened in the dependencies of \"${the_module}\" module")
break()
else()
# skip non-modules
endif()
endwhile()
if(__flattened_deps)
list(REMOVE_DUPLICATES __flattened_deps)
set(OPENCV_MODULE_${the_module}_DEPS ${__flattened_deps})
else()
set(OPENCV_MODULE_${the_module}_DEPS "")
endif()
ocv_clear_vars(__resolved_deps __flattened_deps __req_depends __dep)
endmacro()
# Internal macro for dependencies tracking
macro(__ocv_flatten_module_optional_dependencies the_module)
set(__flattened_deps "")
set(__resolved_deps "")
set(__opt_depends ${OPENCV_MODULE_${the_module}_REQ_DEPS} ${OPENCV_MODULE_${the_module}_OPT_DEPS})
while(__opt_depends)
ocv_list_pop_front(__opt_depends __dep)
if(__dep STREQUAL the_module)
__ocv_module_turn_off(${the_module}) # TODO: think how to deal with cyclic dependency
break()
elseif(";${OPENCV_MODULES_BUILD};" MATCHES ";${__dep};")
if(";${__resolved_deps};" MATCHES ";${__dep};")
list(APPEND __flattened_deps "${__dep}") # all dependencies of this module are already resolved
else()
# put all subdependencies before this dependency and mark it as resolved
list(APPEND __resolved_deps "${__dep}")
list(INSERT __opt_depends 0 ${OPENCV_MODULE_${__dep}_REQ_DEPS} ${OPENCV_MODULE_${__dep}_OPT_DEPS} ${__dep})
endif()
else()
# skip non-modules or missing modules
endif()
endwhile()
if(__flattened_deps)
list(REMOVE_DUPLICATES __flattened_deps)
set(OPENCV_MODULE_${the_module}_DEPS ${__flattened_deps})
else()
set(OPENCV_MODULE_${the_module}_DEPS "")
endif()
ocv_clear_vars(__resolved_deps __flattened_deps __opt_depends __dep)
endmacro()
macro(__ocv_flatten_module_dependencies)
foreach(m ${OPENCV_MODULES_DISABLED_USER})
set(HAVE_${m} OFF CACHE INTERNAL "Module ${m} will not be built in current configuration")
endforeach()
foreach(m ${OPENCV_MODULES_BUILD})
set(HAVE_${m} ON CACHE INTERNAL "Module ${m} will be built in current configuration")
__ocv_flatten_module_required_dependencies(${m})
set(OPENCV_MODULE_${m}_DEPS ${OPENCV_MODULE_${m}_DEPS} CACHE INTERNAL "Flattened required dependencies of ${m} module")
endforeach()
foreach(m ${OPENCV_MODULES_BUILD})
__ocv_flatten_module_optional_dependencies(${m})
# save dependencies from other modules
set(OPENCV_MODULE_${m}_DEPS ${OPENCV_MODULE_${m}_DEPS} CACHE INTERNAL "Flattened dependencies of ${m} module")
# save extra dependencies
set(OPENCV_MODULE_${m}_DEPS_EXT ${OPENCV_MODULE_${m}_REQ_DEPS} ${OPENCV_MODULE_${m}_OPT_DEPS})
if(OPENCV_MODULE_${m}_DEPS_EXT AND OPENCV_MODULE_${m}_DEPS)
list(REMOVE_ITEM OPENCV_MODULE_${m}_DEPS_EXT ${OPENCV_MODULE_${m}_DEPS})
endif()
ocv_list_filterout(OPENCV_MODULE_${m}_DEPS_EXT "^opencv_[^ ]+$")
set(OPENCV_MODULE_${m}_DEPS_EXT ${OPENCV_MODULE_${m}_DEPS_EXT} CACHE INTERNAL "Extra dependencies of ${m} module")
endforeach()
# order modules by dependencies
set(OPENCV_MODULES_BUILD_ "")
foreach(m ${OPENCV_MODULES_BUILD})
list(APPEND OPENCV_MODULES_BUILD_ ${OPENCV_MODULE_${m}_DEPS} ${m})
endforeach()
ocv_list_unique(OPENCV_MODULES_BUILD_)
set(OPENCV_MODULES_PUBLIC ${OPENCV_MODULES_PUBLIC} CACHE INTERNAL "List of OpenCV modules marked for export")
set(OPENCV_MODULES_BUILD ${OPENCV_MODULES_BUILD_} CACHE INTERNAL "List of OpenCV modules included into the build")
set(OPENCV_MODULES_DISABLED_AUTO ${OPENCV_MODULES_DISABLED_AUTO} CACHE INTERNAL "List of OpenCV modules implicitly disabled due to dependencies")
endmacro()
# collect modules from specified directories
# NB: must be called only once!
macro(ocv_glob_modules)
@ -342,7 +238,7 @@ macro(ocv_glob_modules)
ocv_clear_vars(__ocvmodules __directories_observed __path __modpath __pathIdx)
# resolve dependencies
__ocv_flatten_module_dependencies()
__ocv_resolve_dependencies()
# create modules
set(OPENCV_INITIAL_PASS OFF PARENT_SCOPE)
@ -351,11 +247,167 @@ macro(ocv_glob_modules)
if(m MATCHES "^opencv_")
string(REGEX REPLACE "^opencv_" "" __shortname "${m}")
add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/${__shortname}")
else()
message(WARNING "Check module name: ${m}")
add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/${m}")
endif()
endforeach()
unset(__shortname)
endmacro()
# disables OpenCV module with missing dependencies
function(__ocv_module_turn_off the_module)
list(REMOVE_ITEM OPENCV_MODULES_DISABLED_AUTO "${the_module}")
list(APPEND OPENCV_MODULES_DISABLED_AUTO "${the_module}")
list(REMOVE_ITEM OPENCV_MODULES_BUILD "${the_module}")
list(REMOVE_ITEM OPENCV_MODULES_PUBLIC "${the_module}")
set(HAVE_${the_module} OFF CACHE INTERNAL "Module ${the_module} can not be built in current configuration")
set(OPENCV_MODULES_DISABLED_AUTO "${OPENCV_MODULES_DISABLED_AUTO}" CACHE INTERNAL "")
set(OPENCV_MODULES_BUILD "${OPENCV_MODULES_BUILD}" CACHE INTERNAL "")
set(OPENCV_MODULES_PUBLIC "${OPENCV_MODULES_PUBLIC}" CACHE INTERNAL "")
endfunction()
# sort modules by dependencies
function(__ocv_sort_modules_by_deps __lst)
ocv_list_sort(${__lst})
set(${__lst}_ORDERED ${${__lst}} CACHE INTERNAL "")
set(__result "")
foreach (m ${${__lst}})
list(LENGTH __result __lastindex)
set(__index ${__lastindex})
foreach (__d ${__result})
set(__deps "${OPENCV_MODULE_${__d}_DEPS}")
if(";${__deps};" MATCHES ";${m};")
list(FIND __result "${__d}" __i)
if(__i LESS "${__index}")
set(__index "${__i}")
endif()
endif()
endforeach()
if(__index STREQUAL __lastindex)
list(APPEND __result "${m}")
else()
list(INSERT __result ${__index} "${m}")
endif()
endforeach()
set(${__lst} "${__result}" PARENT_SCOPE)
endfunction()
# resolve dependensies
function(__ocv_resolve_dependencies)
foreach(m ${OPENCV_MODULES_DISABLED_USER})
set(HAVE_${m} OFF CACHE INTERNAL "Module ${m} will not be built in current configuration")
endforeach()
foreach(m ${OPENCV_MODULES_BUILD})
set(HAVE_${m} ON CACHE INTERNAL "Module ${m} will be built in current configuration")
endforeach()
# disable MODULES with unresolved dependencies
set(has_changes ON)
while(has_changes)
set(has_changes OFF)
foreach(m ${OPENCV_MODULES_BUILD})
set(__deps ${OPENCV_MODULE_${m}_REQ_DEPS} ${OPENCV_MODULE_${m}_PRIVATE_REQ_DEPS})
while(__deps)
ocv_list_pop_front(__deps d)
string(TOLOWER "${d}" upper_d)
if(NOT (HAVE_${d} OR HAVE_${upper_d} OR TARGET ${d} OR EXISTS ${d}))
if(d MATCHES "^opencv_") # TODO Remove this condition in the future and use HAVE_ variables only
message(STATUS "Module ${m} disabled because ${d} dependency can't be resolved!")
__ocv_module_turn_off(${m})
set(has_changes ON)
break()
else()
message(STATUS "Assume that non-module dependency is available: ${d} (for module ${m})")
endif()
endif()
endwhile()
endforeach()
endwhile()
# message(STATUS "List of active modules: ${OPENCV_MODULES_BUILD}")
foreach(m ${OPENCV_MODULES_BUILD})
set(deps_${m} ${OPENCV_MODULE_${m}_REQ_DEPS})
foreach(d ${OPENCV_MODULE_${m}_OPT_DEPS})
if(NOT (";${deps_${m}};" MATCHES ";${d};"))
if(HAVE_${d} OR TARGET ${d})
list(APPEND deps_${m} ${d})
endif()
endif()
endforeach()
# message(STATUS "Initial deps of ${m} (w/o private deps): ${deps_${m}}")
endforeach()
# propagate dependencies
set(has_changes ON)
while(has_changes)
set(has_changes OFF)
foreach(m2 ${OPENCV_MODULES_BUILD}) # transfer deps of m2 to m
foreach(m ${OPENCV_MODULES_BUILD})
if((NOT m STREQUAL m2) AND ";${deps_${m}};" MATCHES ";${m2};")
foreach(d ${deps_${m2}})
if(NOT (";${deps_${m}};" MATCHES ";${d};"))
# message(STATUS " Transfer dependency ${d} from ${m2} to ${m}")
list(APPEND deps_${m} ${d})
set(has_changes ON)
endif()
endforeach()
endif()
endforeach()
endforeach()
endwhile()
# process private deps
foreach(m ${OPENCV_MODULES_BUILD})
foreach(d ${OPENCV_MODULE_${m}_PRIVATE_REQ_DEPS})
if(NOT (";${deps_${m}};" MATCHES ";${d};"))
list(APPEND deps_${m} ${d})
endif()
endforeach()
foreach(d ${OPENCV_MODULE_${m}_PRIVATE_OPT_DEPS})
if(NOT (";${deps_${m}};" MATCHES ";${d};"))
if(HAVE_${d} OR TARGET ${d})
list(APPEND deps_${m} ${d})
endif()
endif()
endforeach()
endforeach()
ocv_list_sort(OPENCV_MODULES_BUILD)
foreach(m ${OPENCV_MODULES_BUILD})
# message(STATUS "FULL deps of ${m}: ${deps_${m}}")
set(OPENCV_MODULE_${m}_DEPS ${deps_${m}})
set(OPENCV_MODULE_${m}_DEPS_EXT ${deps_${m}})
ocv_list_filterout(OPENCV_MODULE_${m}_DEPS_EXT "^opencv_[^ ]+$")
if(OPENCV_MODULE_${m}_DEPS_EXT AND OPENCV_MODULE_${m}_DEPS)
list(REMOVE_ITEM OPENCV_MODULE_${m}_DEPS ${OPENCV_MODULE_${m}_DEPS_EXT})
endif()
endforeach()
# reorder dependencies
foreach(m ${OPENCV_MODULES_BUILD})
__ocv_sort_modules_by_deps(OPENCV_MODULE_${m}_DEPS)
ocv_list_sort(OPENCV_MODULE_${m}_DEPS_EXT)
set(OPENCV_MODULE_${m}_DEPS ${OPENCV_MODULE_${m}_DEPS} CACHE INTERNAL "Flattened dependencies of ${m} module")
set(OPENCV_MODULE_${m}_DEPS_EXT ${OPENCV_MODULE_${m}_DEPS_EXT} CACHE INTERNAL "Extra dependencies of ${m} module")
# message(STATUS " module deps: ${OPENCV_MODULE_${m}_DEPS}")
# message(STATUS " extra deps: ${OPENCV_MODULE_${m}_DEPS_EXT}")
endforeach()
__ocv_sort_modules_by_deps(OPENCV_MODULES_BUILD)
set(OPENCV_MODULES_PUBLIC ${OPENCV_MODULES_PUBLIC} CACHE INTERNAL "List of OpenCV modules marked for export")
set(OPENCV_MODULES_BUILD ${OPENCV_MODULES_BUILD} CACHE INTERNAL "List of OpenCV modules included into the build")
set(OPENCV_MODULES_DISABLED_AUTO ${OPENCV_MODULES_DISABLED_AUTO} CACHE INTERNAL "List of OpenCV modules implicitly disabled due to dependencies")
endfunction()
# setup include paths for the list of passed modules
macro(ocv_include_modules)
foreach(d ${ARGN})
@ -377,7 +429,7 @@ macro(ocv_include_modules_recurse)
ocv_include_directories("${OPENCV_MODULE_${d}_LOCATION}/include")
endif()
if(OPENCV_MODULE_${d}_DEPS)
ocv_include_modules_recurse(${OPENCV_MODULE_${d}_DEPS})
ocv_include_modules(${OPENCV_MODULE_${d}_DEPS})
endif()
elseif(EXISTS "${d}")
ocv_include_directories("${d}")
@ -436,7 +488,6 @@ macro(ocv_glob_module_sources)
file(GLOB lib_cuda_srcs "src/cuda/*.cu")
set(cuda_objs "")
set(lib_cuda_hdrs "")
if(HAVE_CUDA AND lib_cuda_srcs)
ocv_include_directories(${CUDA_INCLUDE_DIRS})
file(GLOB lib_cuda_hdrs "src/cuda/*.hpp")
@ -448,7 +499,6 @@ macro(ocv_glob_module_sources)
source_group("Src" FILES ${lib_srcs} ${lib_int_hdrs})
file(GLOB cl_kernels "src/opencl/*.cl")
if(HAVE_OPENCL AND cl_kernels)
ocv_include_directories(${OPENCL_INCLUDE_DIRS})
add_custom_command(
@ -484,12 +534,10 @@ macro(ocv_create_module)
${${the_module}_pch})
if(NOT "${ARGN}" STREQUAL "SKIP_LINK")
target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS})
target_link_libraries(${the_module} LINK_PRIVATE ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
if (HAVE_CUDA)
target_link_libraries(${the_module} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
endif()
if(HAVE_OPENCL AND OPENCL_LIBRARIES)
target_link_libraries(${the_module} ${OPENCL_LIBRARIES})
target_link_libraries(${the_module} LINK_PRIVATE ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
endif()
endif()
@ -530,8 +578,8 @@ macro(ocv_create_module)
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc /DEBUG")
endif()
install(TARGETS ${the_module}
RUNTIME DESTINATION bin COMPONENT main
ocv_install_target(${the_module} EXPORT OpenCVModules
RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT main
LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main
ARCHIVE DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main
)

View File

@ -11,6 +11,17 @@ if(NOT COMMAND find_host_program)
endmacro()
endif()
macro(ocv_check_environment_variables)
foreach(_var ${ARGN})
if(NOT DEFINED ${_var} AND DEFINED ENV{${_var}})
set(__value "$ENV{${_var}}")
file(TO_CMAKE_PATH "${__value}" __value) # Assume that we receive paths
set(${_var} "${__value}")
message(STATUS "Update variable ${_var} from environment: ${${_var}}")
endif()
endforeach()
endmacro()
# adds include directories in such way that directories from the OpenCV source tree go first
function(ocv_include_directories)
set(__add_before "")
@ -425,6 +436,48 @@ macro(ocv_convert_to_full_paths VAR)
endmacro()
# add install command
function(ocv_install_target)
install(TARGETS ${ARGN})
if(INSTALL_CREATE_DISTRIB)
if(MSVC AND NOT BUILD_SHARED_LIBS)
set(__target "${ARGV0}")
set(isArchive 0)
set(isDst 0)
foreach(e ${ARGN})
if(isDst EQUAL 1)
set(DST "${e}")
break()
endif()
if(isArchive EQUAL 1 AND e STREQUAL "DESTINATION")
set(isDst 1)
endif()
if(e STREQUAL "ARCHIVE")
set(isArchive 1)
else()
set(isArchive 0)
endif()
endforeach()
# message(STATUS "Process ${__target} dst=${DST}...")
if(NOT DEFINED DST)
set(DST "OPENCV_LIB_INSTALL_PATH")
endif()
get_target_property(fname ${__target} LOCATION_DEBUG)
string(REPLACE ".lib" ".pdb" fname "${fname}")
install(FILES ${fname} DESTINATION ${DST} CONFIGURATIONS Debug)
get_target_property(fname ${__target} LOCATION_RELEASE)
string(REPLACE ".lib" ".pdb" fname "${fname}")
install(FILES ${fname} DESTINATION ${DST} CONFIGURATIONS Release)
endif()
endif()
endfunction()
# read set of version defines from the header file
macro(ocv_parse_header FILENAME FILE_VAR)
set(vars_regex "")

View File

@ -16,9 +16,7 @@
# If the module is found then OPENCV_<MODULE>_FOUND is set to TRUE.
#
# This file will define the following variables:
# - OpenCV_LIBS : The list of libraries to links against.
# - OpenCV_LIB_DIR : The directory(es) where lib files are. Calling LINK_DIRECTORIES
# with this path is NOT needed.
# - OpenCV_LIBS : The list of all imported targets for OpenCV modules.
# - OpenCV_INCLUDE_DIRS : The OpenCV include directories.
# - OpenCV_COMPUTE_CAPABILITIES : The version of compute capability
# - OpenCV_ANDROID_NATIVE_API_LEVEL : Minimum required level of Android API
@ -38,6 +36,10 @@
#
# ===================================================================================
include(${CMAKE_CURRENT_LIST_DIR}/OpenCVModules.cmake)
# TODO All things below should be reviewed. What is about of moving this code into related modules (special vars/hooks/files)
# Version Compute Capability from which OpenCV has been compiled is remembered
set(OpenCV_COMPUTE_CAPABILITIES @OpenCV_CUDA_CC_CONFIGCMAKE@)
@ -104,15 +106,11 @@ SET(OpenCV_VERSION_PATCH @OPENCV_VERSION_PATCH@)
SET(OpenCV_VERSION_TWEAK @OPENCV_VERSION_TWEAK@)
# ====================================================================
# Link libraries: e.g. libopencv_core.so, opencv_imgproc220d.lib, etc...
# Link libraries: e.g. opencv_core;opencv_imgproc; etc...
# ====================================================================
SET(OpenCV_LIB_COMPONENTS @OPENCV_MODULES_CONFIGCMAKE@)
@OPENCV_DEPENDENCIES_MAP_OPT@
@OPENCV_DEPENDENCIES_MAP_DBG@
# ==============================================================
# Extra include directories, needed by OpenCV 2 new structure
# ==============================================================
@ -192,34 +190,11 @@ else()
set(OpenCV_LIB_SUFFIX "")
endif()
foreach(__opttype OPT DBG)
SET(OpenCV_LIBS_${__opttype} "")
SET(OpenCV_EXTRA_LIBS_${__opttype} "")
foreach(__cvlib ${OpenCV_FIND_COMPONENTS})
foreach(__cvdep ${OpenCV_${__cvlib}_DEPS_${__opttype}})
if(__cvdep MATCHES "^opencv_")
list(APPEND OpenCV_LIBS_${__opttype} "${OpenCV_LIB_DIR_${__opttype}}/${OpenCV_${__cvdep}_LIBNAME_${__opttype}}${OpenCV_LIB_SUFFIX}")
#indicate that this module is also found
string(TOUPPER "${__cvdep}" __cvdep)
set(${__cvdep}_FOUND 1)
elseif(EXISTS "${OpenCV_3RDPARTY_LIB_DIR_${__opttype}}/${OpenCV_${__cvdep}_LIBNAME_${__opttype}}")
list(APPEND OpenCV_LIBS_${__opttype} "${OpenCV_3RDPARTY_LIB_DIR_${__opttype}}/${OpenCV_${__cvdep}_LIBNAME_${__opttype}}")
endif()
endforeach()
list(APPEND OpenCV_LIBS_${__opttype} "${OpenCV_LIB_DIR_${__opttype}}/${OpenCV_${__cvlib}_LIBNAME_${__opttype}}${OpenCV_LIB_SUFFIX}")
list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${OpenCV_${__cvlib}_EXTRA_DEPS_${__opttype}})
endforeach()
SET(OpenCV_LIBS "${OpenCV_LIB_COMPONENTS}")
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_GREATER 2.4)
if(OpenCV_LIBS_${__opttype})
list(REMOVE_DUPLICATES OpenCV_LIBS_${__opttype})
endif()
if(OpenCV_EXTRA_LIBS_${__opttype})
list(REMOVE_DUPLICATES OpenCV_EXTRA_LIBS_${__opttype})
endif()
else()
#TODO: duplicates are annoying but they should not be the problem
endif()
foreach(__opttype OPT DBG)
SET(OpenCV_LIBS_${__opttype} "${OpenCV_LIBS}")
SET(OpenCV_EXTRA_LIBS_${__opttype} "")
# CUDA
if(OpenCV_CUDA_VERSION AND (CMAKE_CROSSCOMPILING OR (WIN32 AND NOT OpenCV_SHARED)))
@ -260,33 +235,6 @@ foreach(__opttype OPT DBG)
endif()
endforeach()
if(OpenCV_LIBS_DBG)
list(REVERSE OpenCV_LIBS_DBG)
endif()
if(OpenCV_LIBS_OPT)
list(REVERSE OpenCV_LIBS_OPT)
endif()
# CMake>=2.6 supports the notation "debug XXd optimized XX"
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_GREATER 2.4)
# Modern CMake:
SET(OpenCV_LIBS "")
foreach(__cvlib ${OpenCV_LIBS_DBG} ${OpenCV_EXTRA_LIBS_DBG})
list(APPEND OpenCV_LIBS debug "${__cvlib}")
endforeach()
foreach(__cvlib ${OpenCV_LIBS_OPT} ${OpenCV_EXTRA_LIBS_OPT})
list(APPEND OpenCV_LIBS optimized "${__cvlib}")
endforeach()
else()
# Old CMake:
if(CMAKE_BUILD_TYPE MATCHES "Debug")
SET(OpenCV_LIBS ${OpenCV_LIBS_DBG} ${OpenCV_EXTRA_LIBS_DBG})
else()
SET(OpenCV_LIBS ${OpenCV_LIBS_OPT} ${OpenCV_EXTRA_LIBS_OPT})
endif()
endif()
# ==============================================================
# Android camera helper macro
# ==============================================================
@ -322,3 +270,45 @@ if(CMAKE_CROSSCOMPILING AND OpenCV_SHARED AND (CMAKE_SYSTEM_NAME MATCHES "Linux"
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-rpath-link,${dir}")
endforeach()
endif()
#
# Some macroses for samples
#
macro(ocv_check_dependencies)
set(OCV_DEPENDENCIES_FOUND TRUE)
foreach(d ${ARGN})
if(NOT TARGET ${d})
set(OCV_DEPENDENCIES_FOUND FALSE)
break()
endif()
endforeach()
endmacro()
# adds include directories in such way that directories from the OpenCV source tree go first
function(ocv_include_directories)
set(__add_before "")
foreach(dir ${ARGN})
get_filename_component(__abs_dir "${dir}" ABSOLUTE)
if("${__abs_dir}" MATCHES "^${OpenCV_DIR}")
list(APPEND __add_before "${dir}")
else()
include_directories(AFTER SYSTEM "${dir}")
endif()
endforeach()
include_directories(BEFORE ${__add_before})
endfunction()
macro(ocv_include_modules)
include_directories(BEFORE "${OpenCV_INCLUDE_DIRS}")
endmacro()
# remove all matching elements from the list
macro(ocv_list_filterout lst regex)
foreach(item ${${lst}})
if(item MATCHES "${regex}")
list(REMOVE_ITEM ${lst} "${item}")
endif()
endforeach()
endmacro()

View File

@ -9,10 +9,16 @@ if(BUILD_DOCS AND HAVE_SPHINX)
project(opencv_docs)
set(DOC_LIST "${OpenCV_SOURCE_DIR}/doc/opencv-logo.png" "${OpenCV_SOURCE_DIR}/doc/opencv-logo2.png"
"${OpenCV_SOURCE_DIR}/doc/opencv-logo-white.png" "${OpenCV_SOURCE_DIR}/doc/opencv.ico"
"${OpenCV_SOURCE_DIR}/doc/haartraining.htm" "${OpenCV_SOURCE_DIR}/doc/license.txt"
"${OpenCV_SOURCE_DIR}/doc/pattern.png" "${OpenCV_SOURCE_DIR}/doc/acircles_pattern.png")
set(DOC_LIST
"${OpenCV_SOURCE_DIR}/doc/opencv-logo.png"
"${OpenCV_SOURCE_DIR}/doc/opencv-logo2.png"
"${OpenCV_SOURCE_DIR}/doc/opencv-logo-white.png"
"${OpenCV_SOURCE_DIR}/doc/opencv.ico"
"${OpenCV_SOURCE_DIR}/doc/pattern.png"
"${OpenCV_SOURCE_DIR}/doc/acircles_pattern.png")
if(NOT INSTALL_CREATE_DISTRIB)
list(APPEND DOC_LIST "${OpenCV_SOURCE_DIR}/doc/haartraining.htm")
endif()
set(OPTIONAL_DOC_LIST "")

View File

@ -1,8 +1,8 @@
set(the_description "The Core Functionality")
ocv_add_module(core ${ZLIB_LIBRARIES})
ocv_add_module(core PRIVATE_REQUIRED ${ZLIB_LIBRARIES})
ocv_module_include_directories(${ZLIB_INCLUDE_DIR})
if (HAVE_WINRT)
if(HAVE_WINRT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW /GS /Gm- /AI\"${WINDOWS_SDK_PATH}/References/CommonConfiguration/Neutral\" /AI\"${VISUAL_STUDIO_PATH}/vcpackages\"")
endif()

View File

@ -309,7 +309,7 @@ if(WIN32 AND WITH_FFMPEG)
COMMENT "Copying ${ffmpeg_path} to the output directory")
endif()
install(FILES "${ffmpeg_path}" DESTINATION bin COMPONENT main RENAME "${ffmpeg_bare_name_ver}")
install(FILES "${ffmpeg_path}" DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT main RENAME "${ffmpeg_bare_name_ver}")
endif()
ocv_add_accuracy_tests()

View File

@ -328,9 +328,15 @@ if(ANDROID)
LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main
ARCHIVE DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main)
else()
if(NOT INSTALL_CREATE_DISTRIB)
install(TARGETS ${the_module}
RUNTIME DESTINATION ${JAR_INSTALL_DIR} COMPONENT main
LIBRARY DESTINATION ${JAR_INSTALL_DIR} COMPONENT main)
else()
install(TARGETS ${the_module}
RUNTIME DESTINATION ${JAR_INSTALL_DIR}/${OpenCV_ARCH} COMPONENT main
LIBRARY DESTINATION ${JAR_INSTALL_DIR}/${OpenCV_ARCH} COMPONENT main)
endif()
endif()
######################################################################################################################################

View File

@ -1,5 +1,6 @@
if(NOT HAVE_OPENCL)
ocv_module_disable(ocl)
return()
endif()
set(the_description "OpenCL-accelerated Computer Vision")

View File

@ -105,10 +105,29 @@ else()
set(PYTHON_INSTALL_CONFIGURATIONS "")
endif()
install(TARGETS ${the_module}
if(WIN32)
set(PYTHON_INSTALL_ARCHIVE "")
else()
set(PYTHON_INSTALL_ARCHIVE ARCHIVE DESTINATION ${PYTHON_PACKAGES_PATH} COMPONENT main)
endif()
if(NOT INSTALL_CREATE_DISTRIB)
install(TARGETS ${the_module}
${PYTHON_INSTALL_CONFIGURATIONS}
RUNTIME DESTINATION ${PYTHON_PACKAGES_PATH} COMPONENT main
LIBRARY DESTINATION ${PYTHON_PACKAGES_PATH} COMPONENT main
ARCHIVE DESTINATION ${PYTHON_PACKAGES_PATH} COMPONENT main
${PYTHON_INSTALL_ARCHIVE}
)
install(FILES src2/cv.py ${PYTHON_INSTALL_CONFIGURATIONS} DESTINATION ${PYTHON_PACKAGES_PATH} COMPONENT main)
install(FILES src2/cv.py ${PYTHON_INSTALL_CONFIGURATIONS} DESTINATION ${PYTHON_PACKAGES_PATH} COMPONENT main)
else()
if(DEFINED PYTHON_VERSION_MAJOR)
set(__ver "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
else()
set(__ver "unknown")
endif()
install(TARGETS ${the_module}
CONFIGURATIONS Release
RUNTIME DESTINATION python/${__ver}/${OpenCV_ARCH} COMPONENT main
LIBRARY DESTINATION python/${__ver}/${OpenCV_ARCH} COMPONENT main
)
endif()

View File

@ -1,3 +1,10 @@
# Detect if we want to build samples with library binaries or not
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_LIST_DIR)
#
# BUILD CASE 1: Build samples with library sources
#
# ----------------------------------------------------------------------------
# CMake file for samples. See root CMakeLists.txt
#
@ -11,3 +18,51 @@ add_subdirectory(ocl)
if(ANDROID AND BUILD_ANDROID_EXAMPLES)
add_subdirectory(android)
endif()
#
# END OF BUILD CASE 1: Build samples with library sources
#
else()
#
# BUILD CASE 2: Build samples with library binaries
#
cmake_minimum_required(VERSION 2.8)
project(samples C CXX)
option(BUILD_EXAMPLES "Build samples" ON)
find_package(OpenCV REQUIRED)
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
if(NOT OpenCV_SHARED)
foreach(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif()
if(${flag_var} MATCHES "/MDd")
string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}")
endif()
endforeach(flag_var)
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")
endif()
endif()
add_subdirectory(c)
add_subdirectory(cpp)
add_subdirectory(ocl)
# FIXIT: can't use cvconfig.h in samples: add_subdirectory(gpu)
#
# END OF BUILD CASE 2: Build samples with library binaries
#
endif()

View File

@ -39,7 +39,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
endif()
install(TARGETS ${the_target}
RUNTIME DESTINATION "samples/c" COMPONENT main)
RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/c" COMPONENT main)
endif()
ENDMACRO()

View File

@ -34,7 +34,6 @@
//
//M*/
#include <iostream>
#include <cstdio>
#include <cstring>
@ -42,6 +41,10 @@
#include "opencv2/contrib/contrib.hpp"
#include "opencv2/highgui/highgui.hpp"
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
static void help(char **argv)
{
std::cout << "\nThis program demonstrates the contributed flesh detector CvAdaptiveSkinDetector which can be found in contrib.cpp\n"

View File

@ -8,11 +8,13 @@
/* Select appropriate case insensitive string comparison function: */
#if defined WIN32 || defined _MSC_VER
#define MY_STRNICMP strnicmp
#define MY_STRICMP stricmp
# define MY_STRNICMP _strnicmp
# define MY_STRICMP _stricmp
# define MY_STRDUP _strdup
#else
#define MY_STRNICMP strncasecmp
#define MY_STRICMP strcasecmp
# define MY_STRNICMP strncasecmp
# define MY_STRICMP strcasecmp
# define MY_STRDUP strdup
#endif
/* List of foreground (FG) DETECTION modules: */
@ -239,7 +241,7 @@ static int RunBlobTrackingAuto( CvCapture* pCap, CvBlobTrackerAuto* pTracker,cha
if(pS)
{
char* pStr = strdup(pS);
char* pStr = MY_STRDUP(pS);
char* pStrFree = pStr;
while (pStr && strlen(pStr) > 0)

View File

@ -32,11 +32,11 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
if("${srcs}" MATCHES "tutorial_code")
set(sample_kind tutorial)
set(sample_KIND TUTORIAL)
set(sample_folder "samples//tutorials")
set(sample_subfolder "tutorials")
else()
set(sample_kind example)
set(sample_KIND EXAMPLE)
set(sample_folder "samples//cpp")
set(sample_subfolder "cpp")
endif()
set(the_target "${sample_kind}_${name}")
@ -52,7 +52,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
PROJECT_LABEL "(${sample_KIND}) ${name}")
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "${sample_folder}")
set_target_properties(${the_target} PROPERTIES FOLDER "samples/${sample_subfolder}")
endif()
if(WIN32)
@ -60,7 +60,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
endif()
install(TARGETS ${the_target}
RUNTIME DESTINATION "${sample_folder}" COMPONENT main)
RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${sample_subfolder}" COMPONENT main)
endif()
ENDMACRO()

View File

@ -16,6 +16,10 @@
#include "opencv2/opencv.hpp"
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
static void help(std::string errorMessage)
{
std::cout<<"Program init error : "<<errorMessage<<std::endl;

View File

@ -11,10 +11,6 @@
*
*/
//#include <cv.h>
//#include <ml.h>
//#include <cvaux.h>
//#include <highgui.h>
#include <stdio.h>
#include <time.h>
#include <iostream>
@ -22,6 +18,10 @@
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/contrib/hybridtracker.hpp"
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
using namespace cv;
using namespace std;

View File

@ -8,6 +8,10 @@
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/highgui/highgui.hpp>
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
using namespace cv;
using namespace std;

View File

@ -60,7 +60,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
if(MSVC AND NOT BUILD_SHARED_LIBS)
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
endif()
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/${project}" COMPONENT main)
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${project}" COMPONENT main)
endif()
ENDMACRO()

View File

@ -23,7 +23,7 @@ if(ENABLE_SOLUTION_FOLDERS)
endif()
if(WIN32)
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/gpu" COMPONENT main)
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/gpu" COMPONENT main)
endif()
if(INSTALL_C_EXAMPLES AND NOT WIN32)

View File

@ -38,7 +38,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
if(MSVC AND NOT BUILD_SHARED_LIBS)
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
endif()
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/${project}" COMPONENT main)
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${project}" COMPONENT main)
endif()
ENDMACRO()