Fixed precompiled headers support detection

pull/2/head
Andrey Kamaev 13 years ago
parent f392ab0e08
commit a20837fb7c
  1. 187
      cmake/OpenCVModule.cmake
  2. 20
      cmake/OpenCVPCHSupport.cmake
  3. 13
      cmake/OpenCVUtils.cmake

@ -72,17 +72,13 @@ macro(ocv_add_dependencies full_modname)
list(APPEND ${__depsvar} "${d}") list(APPEND ${__depsvar} "${d}")
endif() endif()
endforeach() endforeach()
unset(__depsvar)
ocv_list_unique(OPENCV_MODULE_${full_modname}_REQ_DEPS)
ocv_list_unique(OPENCV_MODULE_${full_modname}_OPT_DEPS)
if(OPENCV_MODULE_${full_modname}_REQ_DEPS)
list(REMOVE_DUPLICATES OPENCV_MODULE_${full_modname}_REQ_DEPS)
endif()
if(OPENCV_MODULE_${full_modname}_OPT_DEPS)
list(REMOVE_DUPLICATES OPENCV_MODULE_${full_modname}_OPT_DEPS)
endif()
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}_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}_OPT_DEPS ${OPENCV_MODULE_${full_modname}_OPT_DEPS} CACHE INTERNAL "Optional dependencies of ${full_modname} module")
unset(__depsvar)
endmacro() endmacro()
# declare new OpenCV module in current folder # declare new OpenCV module in current folder
@ -105,19 +101,22 @@ macro(ocv_add_module _name)
") ")
endif() endif()
#remember module details
if(NOT DEFINED the_description) if(NOT DEFINED the_description)
set(the_description "The ${name} OpenCV module") set(the_description "The ${name} OpenCV module")
endif() endif()
set(OPENCV_MODULE_${the_module}_DESCRIPTION "${the_description}" CACHE INTERNAL "Brief description of ${the_module} module")
set(OPENCV_MODULE_${the_module}_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "Location of ${the_module} module sources")
#create option to enable/disable this module
if(NOT DEFINED BUILD_${the_module}_INIT) if(NOT DEFINED BUILD_${the_module}_INIT)
set(BUILD_${the_module}_INIT ON) set(BUILD_${the_module}_INIT ON)
endif() endif()
# create option to enable/disable this module
option(BUILD_${the_module} "Include ${the_module} module into the OpenCV build" ${BUILD_${the_module}_INIT}) option(BUILD_${the_module} "Include ${the_module} module into the OpenCV build" ${BUILD_${the_module}_INIT})
# remember the module details
set(OPENCV_MODULE_${the_module}_DESCRIPTION "${the_description}" CACHE INTERNAL "Brief description of ${the_module} module")
set(OPENCV_MODULE_${the_module}_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "Location of ${the_module} module sources")
# parse list of dependencies
if("${ARGV1}" STREQUAL "INTERNAL" OR "${ARGV1}" STREQUAL "BINDINGS") if("${ARGV1}" STREQUAL "INTERNAL" OR "${ARGV1}" STREQUAL "BINDINGS")
set(OPENCV_MODULE_${the_module}_CLASS "${ARGV1}" CACHE INTERNAL "The cathegory of the module") set(OPENCV_MODULE_${the_module}_CLASS "${ARGV1}" CACHE INTERNAL "The cathegory of the module")
set(__ocv_argn__ ${ARGN}) set(__ocv_argn__ ${ARGN})
@ -143,28 +142,19 @@ macro(ocv_add_module _name)
set(OPENCV_MODULES_DISABLED_USER ${OPENCV_MODULES_DISABLED_USER} "${the_module}" CACHE INTERNAL "List of OpenCV modules explicitly disabled by user") set(OPENCV_MODULES_DISABLED_USER ${OPENCV_MODULES_DISABLED_USER} "${the_module}" CACHE INTERNAL "List of OpenCV modules explicitly disabled by user")
endif() endif()
#TODO: add submodules if any # TODO: add submodules if any
#stop processing of current file # stop processing of current file
return() return()
else(OPENCV_INITIAL_PASS) else(OPENCV_INITIAL_PASS)
if(NOT BUILD_${the_module}) if(NOT BUILD_${the_module})
#extra protection from redefinition return() # extra protection from redefinition
return()
endif() endif()
project(${the_module}) project(${the_module})
endif(OPENCV_INITIAL_PASS) endif(OPENCV_INITIAL_PASS)
endmacro() endmacro()
# Internal macro; disables OpenCV module # excludes module from current configuration
# ocv_module_turn_off(<module name>)
macro(__ocv_module_turn_off 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()
macro(ocv_module_disable module) macro(ocv_module_disable module)
set(__modname ${module}) set(__modname ${module})
if(NOT __modname MATCHES "^opencv_") if(NOT __modname MATCHES "^opencv_")
@ -175,41 +165,46 @@ macro(ocv_module_disable module)
set(OPENCV_MODULE_${__modname}_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "Location of ${__modname} module sources") set(OPENCV_MODULE_${__modname}_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "Location of ${__modname} module sources")
set(OPENCV_MODULES_DISABLED_FORCE "${OPENCV_MODULES_DISABLED_FORCE}" CACHE INTERNAL "List of OpenCV modules which can not be build in current configuration") set(OPENCV_MODULES_DISABLED_FORCE "${OPENCV_MODULES_DISABLED_FORCE}" CACHE INTERNAL "List of OpenCV modules which can not be build in current configuration")
unset(__modname) unset(__modname)
return()#leave the current folder return() # leave the current folder
endmacro() endmacro()
# Internal macro; partly disables OpenCV module
macro(__ocv_module_turn_off 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) macro(__ocv_flatten_module_required_dependencies the_module)
set(__flattened_deps "") set(__flattened_deps "")
set(__resolved_deps "") set(__resolved_deps "")
set(__req_depends ${OPENCV_MODULE_${the_module}_REQ_DEPS}) set(__req_depends ${OPENCV_MODULE_${the_module}_REQ_DEPS})
while(__req_depends) while(__req_depends)
list(GET __req_depends 0 __dep) ocv_list_pop_front(__req_depends __dep)
list(REMOVE_AT __req_depends 0)
if(__dep STREQUAL the_module) if(__dep STREQUAL the_module)
#TODO: think how to deal with cyclic dependency __ocv_module_turn_off(${the_module}) # TODO: think how to deal with cyclic dependency
__ocv_module_turn_off(${the_module})
break() break()
elseif("${OPENCV_MODULES_DISABLED_USER};${OPENCV_MODULES_DISABLED_AUTO}" MATCHES "(^|;)${__dep}(;|$)") elseif(";${OPENCV_MODULES_DISABLED_USER};${OPENCV_MODULES_DISABLED_AUTO};" MATCHES ";${__dep};")
#depends on disabled module __ocv_module_turn_off(${the_module}) # depends on disabled module
__ocv_module_turn_off(${the_module})
break() break()
elseif("${OPENCV_MODULES_BUILD}" MATCHES "(^|;)${__dep}(;|$)") elseif(";${OPENCV_MODULES_BUILD};" MATCHES ";${__dep};")
if(__resolved_deps MATCHES "(^|;)${__dep}(;|$)") if(";${__resolved_deps};" MATCHES ";${__dep};")
#all dependencies of this module are already resolved list(APPEND __flattened_deps "${__dep}") # all dependencies of this module are already resolved
list(APPEND __flattened_deps "${__dep}")
else() else()
#put all required subdependencies before this dependency and mark it as resolved # put all required subdependencies before this dependency and mark it as resolved
list(APPEND __resolved_deps "${__dep}") list(APPEND __resolved_deps "${__dep}")
list(INSERT __req_depends 0 ${OPENCV_MODULE_${__dep}_REQ_DEPS} ${__dep}) list(INSERT __req_depends 0 ${OPENCV_MODULE_${__dep}_REQ_DEPS} ${__dep})
endif() endif()
elseif(__dep MATCHES "^opencv_") elseif(__dep MATCHES "^opencv_")
#depends on missing module __ocv_module_turn_off(${the_module}) # depends on missing module
__ocv_module_turn_off(${the_module}) message(WARNING "Unknown \"${__dep}\" module is listened in the dependencies of \"${the_module}\" module")
break() break()
else() else()
#skip non-modules # skip non-modules
endif() endif()
endwhile() endwhile()
@ -220,37 +215,33 @@ macro(__ocv_flatten_module_required_dependencies the_module)
set(OPENCV_MODULE_${the_module}_DEPS "") set(OPENCV_MODULE_${the_module}_DEPS "")
endif() endif()
unset(__resolved_deps) ocv_clear_vars(__resolved_deps __flattened_deps __req_depends __dep)
unset(__flattened_deps)
unset(__req_depends)
unset(__dep)
endmacro() endmacro()
# Internal macro for dependencies tracking
macro(__ocv_flatten_module_optional_dependencies the_module) macro(__ocv_flatten_module_optional_dependencies the_module)
set(__flattened_deps ${OPENCV_MODULE_${the_module}_DEPS}) set(__flattened_deps ${OPENCV_MODULE_${the_module}_DEPS})
set(__resolved_deps ${OPENCV_MODULE_${the_module}_DEPS}) set(__resolved_deps ${OPENCV_MODULE_${the_module}_DEPS})
set(__opt_depends ${OPENCV_MODULE_${the_module}_OPT_DEPS}) set(__opt_depends ${OPENCV_MODULE_${the_module}_OPT_DEPS})
while(__opt_depends) while(__opt_depends)
list(GET __opt_depends 0 __dep) ocv_list_pop_front(__opt_depends __dep)
list(REMOVE_AT __opt_depends 0)
if(__dep STREQUAL the_module) if(__dep STREQUAL the_module)
#TODO: think how to deal with cyclic dependency __ocv_module_turn_off(${the_module}) # TODO: think how to deal with cyclic dependency
__ocv_module_turn_off(${the_module})
break() break()
elseif("${OPENCV_MODULES_BUILD}" MATCHES "(^|;)${__dep}(;|$)") elseif(";${OPENCV_MODULES_BUILD};" MATCHES ";${__dep};")
if(__resolved_deps MATCHES "(^|;)${__dep}(;|$)") if(";${__resolved_deps};" MATCHES ";${__dep};")
#all dependencies of this module are already resolved list(APPEND __flattened_deps "${__dep}") # all dependencies of this module are already resolved
list(APPEND __flattened_deps "${__dep}")
else() else()
#put all subdependencies before this dependency and mark it as resolved # put all subdependencies before this dependency and mark it as resolved
list(APPEND __resolved_deps "${__dep}") list(APPEND __resolved_deps "${__dep}")
list(INSERT __opt_depends 0 ${OPENCV_MODULE_${__dep}_REQ_DEPS} ${OPENCV_MODULE_${__dep}_OPT_DEPS} ${__dep}) list(INSERT __opt_depends 0 ${OPENCV_MODULE_${__dep}_REQ_DEPS} ${OPENCV_MODULE_${__dep}_OPT_DEPS} ${__dep})
endif() endif()
else() else()
#skip non-modules or missing modules # skip non-modules or missing modules
endif() endif()
endwhile() endwhile()
if(__flattened_deps) if(__flattened_deps)
list(REMOVE_DUPLICATES __flattened_deps) list(REMOVE_DUPLICATES __flattened_deps)
set(OPENCV_MODULE_${the_module}_DEPS ${__flattened_deps}) set(OPENCV_MODULE_${the_module}_DEPS ${__flattened_deps})
@ -258,10 +249,7 @@ macro(__ocv_flatten_module_optional_dependencies the_module)
set(OPENCV_MODULE_${the_module}_DEPS "") set(OPENCV_MODULE_${the_module}_DEPS "")
endif() endif()
unset(__resolved_deps) ocv_clear_vars(__resolved_deps __flattened_deps __opt_depends __dep)
unset(__flattened_deps)
unset(__opt_depends)
unset(__dep)
endmacro() endmacro()
macro(__ocv_flatten_module_dependencies) macro(__ocv_flatten_module_dependencies)
@ -269,16 +257,16 @@ macro(__ocv_flatten_module_dependencies)
set(HAVE_${m} OFF CACHE INTERNAL "Module ${m} will not be built in current configuration") set(HAVE_${m} OFF CACHE INTERNAL "Module ${m} will not be built in current configuration")
endforeach() endforeach()
foreach(m ${OPENCV_MODULES_BUILD}) foreach(m ${OPENCV_MODULES_BUILD})
set(HAVE_${m} ON CACHE INTERNAL "Module ${m} will not be built in current configuration") set(HAVE_${m} ON CACHE INTERNAL "Module ${m} will be built in current configuration")
__ocv_flatten_module_required_dependencies(${m}) __ocv_flatten_module_required_dependencies(${m})
endforeach() endforeach()
foreach(m ${OPENCV_MODULES_BUILD}) foreach(m ${OPENCV_MODULES_BUILD})
__ocv_flatten_module_optional_dependencies(${m}) __ocv_flatten_module_optional_dependencies(${m})
#dependencies from other modules # save dependencies from other modules
set(OPENCV_MODULE_${m}_DEPS ${OPENCV_MODULE_${m}_DEPS} CACHE INTERNAL "Flattened dependencies of ${m} module") set(OPENCV_MODULE_${m}_DEPS ${OPENCV_MODULE_${m}_DEPS} CACHE INTERNAL "Flattened dependencies of ${m} module")
#extra dependencies # save extra dependencies
set(OPENCV_MODULE_${m}_DEPS_EXT ${OPENCV_MODULE_${m}_REQ_DEPS} ${OPENCV_MODULE_${m}_OPT_DEPS}) 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) if(OPENCV_MODULE_${m}_DEPS_EXT AND OPENCV_MODULE_${m}_DEPS)
list(REMOVE_ITEM OPENCV_MODULE_${m}_DEPS_EXT ${OPENCV_MODULE_${m}_DEPS}) list(REMOVE_ITEM OPENCV_MODULE_${m}_DEPS_EXT ${OPENCV_MODULE_${m}_DEPS})
@ -300,10 +288,11 @@ macro(ocv_glob_modules)
endif() endif()
set(__directories_observed "") set(__directories_observed "")
#collect modules # collect modules
set(OPENCV_INITIAL_PASS ON) set(OPENCV_INITIAL_PASS ON)
foreach(__path ${ARGN}) foreach(__path ${ARGN})
ocv_get_real_path(__path "${__path}") ocv_get_real_path(__path "${__path}")
list(FIND __directories_observed "${__path}" __pathIdx) list(FIND __directories_observed "${__path}" __pathIdx)
if(__pathIdx GREATER -1) if(__pathIdx GREATER -1)
message(FATAL_ERROR "The directory ${__path} is observed for OpenCV modules second time.") message(FATAL_ERROR "The directory ${__path} is observed for OpenCV modules second time.")
@ -316,6 +305,7 @@ macro(ocv_glob_modules)
foreach(mod ${__ocvmodules}) foreach(mod ${__ocvmodules})
ocv_get_real_path(__modpath "${__path}/${mod}") ocv_get_real_path(__modpath "${__path}/${mod}")
if(EXISTS "${__modpath}/CMakeLists.txt") if(EXISTS "${__modpath}/CMakeLists.txt")
list(FIND __directories_observed "${__modpath}" __pathIdx) list(FIND __directories_observed "${__modpath}" __pathIdx)
if(__pathIdx GREATER -1) if(__pathIdx GREATER -1)
message(FATAL_ERROR "The module from ${__modpath} is already loaded.") message(FATAL_ERROR "The module from ${__modpath} is already loaded.")
@ -327,23 +317,19 @@ macro(ocv_glob_modules)
endforeach() endforeach()
endif() endif()
endforeach() endforeach()
unset(__ocvmodules) ocv_clear_vars(__ocvmodules __directories_observed __path __modpath __pathIdx)
unset(__directories_observed)
unset(__path)
unset(__modpath)
unset(__pathIdx)
#resolve dependencies # resolve dependencies
__ocv_flatten_module_dependencies() __ocv_flatten_module_dependencies()
#order modules by dependencies # order modules by dependencies
set(OPENCV_MODULES_BUILD_ "") set(OPENCV_MODULES_BUILD_ "")
foreach(m ${OPENCV_MODULES_BUILD}) foreach(m ${OPENCV_MODULES_BUILD})
list(APPEND OPENCV_MODULES_BUILD_ ${OPENCV_MODULE_${m}_DEPS} ${m}) list(APPEND OPENCV_MODULES_BUILD_ ${OPENCV_MODULE_${m}_DEPS} ${m})
endforeach() endforeach()
ocv_list_unique(OPENCV_MODULES_BUILD_) ocv_list_unique(OPENCV_MODULES_BUILD_)
#create modules # create modules
set(OPENCV_INITIAL_PASS OFF PARENT_SCOPE) set(OPENCV_INITIAL_PASS OFF PARENT_SCOPE)
set(OPENCV_INITIAL_PASS OFF) set(OPENCV_INITIAL_PASS OFF)
foreach(m ${OPENCV_MODULES_BUILD_}) foreach(m ${OPENCV_MODULES_BUILD_})
@ -389,7 +375,7 @@ endmacro()
macro(ocv_module_include_directories) macro(ocv_module_include_directories)
ocv_include_directories("${OPENCV_MODULE_${the_module}_LOCATION}/include" ocv_include_directories("${OPENCV_MODULE_${the_module}_LOCATION}/include"
"${OPENCV_MODULE_${the_module}_LOCATION}/src" "${OPENCV_MODULE_${the_module}_LOCATION}/src"
"${CMAKE_CURRENT_BINARY_DIR}"#for precompiled headers "${CMAKE_CURRENT_BINARY_DIR}" # for precompiled headers
) )
ocv_include_modules(${OPENCV_MODULE_${the_module}_DEPS} ${ARGN}) ocv_include_modules(${OPENCV_MODULE_${the_module}_DEPS} ${ARGN})
endmacro() endmacro()
@ -417,7 +403,7 @@ macro(ocv_set_module_sources)
endif() endif()
# use full paths for module to be independent from the module location # use full paths for module to be independent from the module location
ocv_to_full_paths(OPENCV_MODULE_${the_module}_HEADERS) ocv_convert_to_full_paths(OPENCV_MODULE_${the_module}_HEADERS)
set(OPENCV_MODULE_${the_module}_HEADERS ${OPENCV_MODULE_${the_module}_HEADERS} CACHE INTERNAL "List of header files for ${the_module}") set(OPENCV_MODULE_${the_module}_HEADERS ${OPENCV_MODULE_${the_module}_HEADERS} CACHE INTERNAL "List of header files for ${the_module}")
set(OPENCV_MODULE_${the_module}_SOURCES ${OPENCV_MODULE_${the_module}_SOURCES} CACHE INTERNAL "List of source files for ${the_module}") set(OPENCV_MODULE_${the_module}_SOURCES ${OPENCV_MODULE_${the_module}_SOURCES} CACHE INTERNAL "List of source files for ${the_module}")
@ -446,9 +432,11 @@ endmacro()
# ocv_create_module(SKIP_LINK) # ocv_create_module(SKIP_LINK)
macro(ocv_create_module) macro(ocv_create_module)
add_library(${the_module} ${OPENCV_MODULE_TYPE} ${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES}) add_library(${the_module} ${OPENCV_MODULE_TYPE} ${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES})
if(NOT "${ARGN}" STREQUAL "SKIP_LINK") 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} ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
endif() endif()
add_dependencies(opencv_modules ${the_module}) add_dependencies(opencv_modules ${the_module})
if(ENABLE_SOLUTION_FOLDERS) if(ENABLE_SOLUTION_FOLDERS)
@ -495,7 +483,7 @@ macro(ocv_create_module)
) )
# only "public" headers need to be installed # only "public" headers need to be installed
if(OPENCV_MODULE_${the_module}_HEADERS AND OPENCV_MODULES_PUBLIC MATCHES "(^|;)${the_module}(;|$)") if(OPENCV_MODULE_${the_module}_HEADERS AND ";${OPENCV_MODULES_PUBLIC};" MATCHES ";${the_module};")
foreach(hdr ${OPENCV_MODULE_${the_module}_HEADERS}) foreach(hdr ${OPENCV_MODULE_${the_module}_HEADERS})
string(REGEX REPLACE "^.*opencv2/" "opencv2/" hdr2 "${hdr}") string(REGEX REPLACE "^.*opencv2/" "opencv2/" hdr2 "${hdr}")
if(hdr2 MATCHES "^(opencv2/.*)/[^/]+.h(..)?$") if(hdr2 MATCHES "^(opencv2/.*)/[^/]+.h(..)?$")
@ -519,21 +507,8 @@ macro(ocv_add_precompiled_headers the_target)
else() else()
SET(pch_path "src/") SET(pch_path "src/")
endif() endif()
set(pch_header "${CMAKE_CURRENT_SOURCE_DIR}/${pch_path}precomp.hpp") ocv_add_precompiled_header_to_target(${the_target} "${CMAKE_CURRENT_SOURCE_DIR}/${pch_path}precomp.hpp")
if(PCHSupport_FOUND AND ENABLE_PRECOMPILED_HEADERS AND EXISTS "${pch_header}")
if(CMAKE_GENERATOR MATCHES Visual)
set(${the_target}_pch "${CMAKE_CURRENT_SOURCE_DIR}/${pch_path}precomp.cpp")
add_native_precompiled_header(${the_target} ${pch_header})
elseif(CMAKE_GENERATOR MATCHES Xcode)
add_native_precompiled_header(${the_target} ${pch_header})
elseif(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_GENERATOR MATCHES "Makefiles|Ninja")
add_precompiled_header(${the_target} ${pch_header})
endif()
endif()
unset(pch_header)
unset(pch_path) unset(pch_path)
unset(${the_target}_pch)
endmacro() endmacro()
# short command for adding simple OpenCV module # short command for adding simple OpenCV module
@ -563,7 +538,7 @@ macro(ocv_check_dependencies)
endforeach() endforeach()
endmacro() endmacro()
#auxiliary macro to parse arguments of ocv_add_accuracy_tests and ocv_add_perf_tests commands # auxiliary macro to parse arguments of ocv_add_accuracy_tests and ocv_add_perf_tests commands
macro(__ocv_parse_test_sources tests_type) macro(__ocv_parse_test_sources tests_type)
set(OPENCV_${tests_type}_${the_module}_SOURCES "") set(OPENCV_${tests_type}_${the_module}_SOURCES "")
set(OPENCV_${tests_type}_${the_module}_DEPS "") set(OPENCV_${tests_type}_${the_module}_DEPS "")
@ -593,7 +568,7 @@ endmacro()
# this is a command for adding OpenCV performance tests to the module # this is a command for adding OpenCV performance tests to the module
# ocv_add_perf_tests(<extra_dependencies>) # ocv_add_perf_tests(<extra_dependencies>)
macro(ocv_add_perf_tests) function(ocv_add_perf_tests)
set(perf_path "${CMAKE_CURRENT_SOURCE_DIR}/perf") set(perf_path "${CMAKE_CURRENT_SOURCE_DIR}/perf")
if(BUILD_PERF_TESTS AND EXISTS "${perf_path}") if(BUILD_PERF_TESTS AND EXISTS "${perf_path}")
__ocv_parse_test_sources(PERF ${ARGN}) __ocv_parse_test_sources(PERF ${ARGN})
@ -604,7 +579,7 @@ macro(ocv_add_perf_tests)
if(OCV_DEPENDENCIES_FOUND) if(OCV_DEPENDENCIES_FOUND)
set(the_target "opencv_perf_${name}") set(the_target "opencv_perf_${name}")
#project(${the_target}) # project(${the_target})
ocv_module_include_directories(${perf_deps} "${perf_path}") ocv_module_include_directories(${perf_deps} "${perf_path}")
@ -636,14 +611,14 @@ macro(ocv_add_perf_tests)
add_dependencies(perf ${the_target}) add_dependencies(perf ${the_target})
endif() endif()
else(OCV_DEPENDENCIES_FOUND) else(OCV_DEPENDENCIES_FOUND)
#TODO: warn about unsatisfied dependencies # TODO: warn about unsatisfied dependencies
endif(OCV_DEPENDENCIES_FOUND) endif(OCV_DEPENDENCIES_FOUND)
endif() endif()
endmacro() endfunction()
# this is a command for adding OpenCV accuracy/regression tests to the module # this is a command for adding OpenCV accuracy/regression tests to the module
# ocv_add_accuracy_tests([FILES <source group name> <list of sources>] [DEPENDS_ON] <list of extra dependencies>) # ocv_add_accuracy_tests([FILES <source group name> <list of sources>] [DEPENDS_ON] <list of extra dependencies>)
macro(ocv_add_accuracy_tests) function(ocv_add_accuracy_tests)
set(test_path "${CMAKE_CURRENT_SOURCE_DIR}/test") set(test_path "${CMAKE_CURRENT_SOURCE_DIR}/test")
ocv_check_dependencies(${test_deps}) ocv_check_dependencies(${test_deps})
if(BUILD_TESTS AND EXISTS "${test_path}") if(BUILD_TESTS AND EXISTS "${test_path}")
@ -655,7 +630,7 @@ macro(ocv_add_accuracy_tests)
if(OCV_DEPENDENCIES_FOUND) if(OCV_DEPENDENCIES_FOUND)
set(the_target "opencv_test_${name}") set(the_target "opencv_test_${name}")
#project(${the_target}) # project(${the_target})
ocv_module_include_directories(${test_deps} "${test_path}") ocv_module_include_directories(${test_deps} "${test_path}")
@ -687,12 +662,12 @@ macro(ocv_add_accuracy_tests)
ocv_add_precompiled_headers(${the_target}) ocv_add_precompiled_headers(${the_target})
else(OCV_DEPENDENCIES_FOUND) else(OCV_DEPENDENCIES_FOUND)
#TODO: warn about unsatisfied dependencies # TODO: warn about unsatisfied dependencies
endif(OCV_DEPENDENCIES_FOUND) endif(OCV_DEPENDENCIES_FOUND)
endif() endif()
endmacro() endfunction()
# internal macro; finds all link dependencies of module # internal macro; finds all link dependencies of the module
# should be used at the end of CMake processing # should be used at the end of CMake processing
macro(__ocv_track_module_link_dependencies the_module optkind) macro(__ocv_track_module_link_dependencies the_module optkind)
set(${the_module}_MODULE_DEPS_${optkind} "") set(${the_module}_MODULE_DEPS_${optkind} "")
@ -742,7 +717,7 @@ macro(__ocv_track_module_link_dependencies the_module optkind)
#ocv_list_reverse(${the_module}_EXTRA_DEPS_${optkind}) #ocv_list_reverse(${the_module}_EXTRA_DEPS_${optkind})
if(__has_cycle) if(__has_cycle)
#not sure if it can work # not sure if it can work
list(APPEND ${the_module}_MODULE_DEPS_${optkind} "${the_module}") list(APPEND ${the_module}_MODULE_DEPS_${optkind} "${the_module}")
endif() endif()
@ -754,13 +729,13 @@ macro(__ocv_track_module_link_dependencies the_module optkind)
endif()#STATIC_LIBRARY endif()#STATIC_LIBRARY
unset(__module_type) unset(__module_type)
#message("${the_module}_MODULE_DEPS_${optkind}") #message("${the_module}_MODULE_DEPS_${optkind}")
#message(" ${${the_module}_MODULE_DEPS_${optkind}}") #message(" ${${the_module}_MODULE_DEPS_${optkind}}")
#message(" ${OPENCV_MODULE_${the_module}_DEPS}") #message(" ${OPENCV_MODULE_${the_module}_DEPS}")
#message("") #message("")
#message("${the_module}_EXTRA_DEPS_${optkind}") #message("${the_module}_EXTRA_DEPS_${optkind}")
#message(" ${${the_module}_EXTRA_DEPS_${optkind}}") #message(" ${${the_module}_EXTRA_DEPS_${optkind}}")
#message("") #message("")
endmacro() endmacro()
# creates lists of build dependencies needed for external projects # creates lists of build dependencies needed for external projects

@ -1,4 +1,4 @@
# taken from http://www.vtk.org/Bug/view.php?id=1260 and slightly adjusted # taken from http://public.kitware.com/Bug/view.php?id=1260 and slightly adjusted
# - Try to find precompiled headers support for GCC 3.4 and 4.x # - Try to find precompiled headers support for GCC 3.4 and 4.x
# Once done this will define: # Once done this will define:
@ -26,8 +26,8 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
SET(_PCH_include_prefix "-I") SET(_PCH_include_prefix "-I")
SET(_PCH_isystem_prefix "-isystem") SET(_PCH_isystem_prefix "-isystem")
ELSEIF(WIN32) ELSEIF(CMAKE_GENERATOR MATCHES "^Visual.*$")
SET(PCHSupport_FOUND TRUE) # for experimental msvc support SET(PCHSupport_FOUND TRUE)
SET(_PCH_include_prefix "/I") SET(_PCH_include_prefix "/I")
SET(_PCH_isystem_prefix "/I") SET(_PCH_isystem_prefix "/I")
ELSE() ELSE()
@ -324,3 +324,17 @@ MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _input)
endif() endif()
ENDMACRO(ADD_NATIVE_PRECOMPILED_HEADER) ENDMACRO(ADD_NATIVE_PRECOMPILED_HEADER)
macro(ocv_add_precompiled_header_to_target the_target pch_header)
if(PCHSupport_FOUND AND ENABLE_PRECOMPILED_HEADERS AND EXISTS "${pch_header}")
if(CMAKE_GENERATOR MATCHES Visual)
set(${the_target}_pch "${pch_header}")
add_native_precompiled_header(${the_target} ${pch_header})
unset(${the_target}_pch)
elseif(CMAKE_GENERATOR MATCHES Xcode)
add_native_precompiled_header(${the_target} ${pch_header})
elseif(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_GENERATOR MATCHES "Makefiles|Ninja")
add_precompiled_header(${the_target} ${pch_header})
endif()
endif()
endmacro()

@ -384,6 +384,17 @@ macro(ocv_list_add_suffix LST SUFFIX)
endmacro() endmacro()
# gets and removes the first element from list
macro(ocv_list_pop_front LST VAR)
if(${LST})
list(GET ${LST} 0 ${VAR})
list(REMOVE_AT ${LST} 0)
else()
set(${VAR} "")
endif()
endmacro()
# simple regex escaping routine (does not cover all cases!!!) # simple regex escaping routine (does not cover all cases!!!)
macro(ocv_regex_escape var regex) macro(ocv_regex_escape var regex)
string(REGEX REPLACE "([+.*^$])" "\\\\1" ${var} "${regex}") string(REGEX REPLACE "([+.*^$])" "\\\\1" ${var} "${regex}")
@ -401,7 +412,7 @@ endmacro()
# convert list of paths to full paths # convert list of paths to full paths
macro(ocv_to_full_paths VAR) macro(ocv_convert_to_full_paths VAR)
if(${VAR}) if(${VAR})
set(__tmp "") set(__tmp "")
foreach(path ${${VAR}}) foreach(path ${${VAR}})

Loading…
Cancel
Save