2012-02-03 19:26:49 +08:00
# Local variables (set for each module):
#
# name - short name in lower case i.e. core
# the_module - full name in lower case i.e. opencv_core
# Global variables:
#
# OPENCV_MODULE_${the_module}_LOCATION
2014-08-01 22:11:20 +08:00
# OPENCV_MODULE_${the_module}_BINARY_DIR
2012-02-03 19:26:49 +08:00
# OPENCV_MODULE_${the_module}_DESCRIPTION
2012-05-13 17:34:33 +08:00
# OPENCV_MODULE_${the_module}_CLASS - PUBLIC|INTERNAL|BINDINGS
2012-02-03 19:26:49 +08:00
# OPENCV_MODULE_${the_module}_HEADERS
# OPENCV_MODULE_${the_module}_SOURCES
# OPENCV_MODULE_${the_module}_DEPS - final flattened set of module dependencies
2014-08-01 22:11:20 +08:00
# OPENCV_MODULE_${the_module}_DEPS_TO_LINK - differs from above for world build only
2013-08-07 16:53:48 +08:00
# OPENCV_MODULE_${the_module}_DEPS_EXT - non-module dependencies
2012-02-03 19:26:49 +08:00
# OPENCV_MODULE_${the_module}_REQ_DEPS
# OPENCV_MODULE_${the_module}_OPT_DEPS
2013-08-07 16:53:48 +08:00
# OPENCV_MODULE_${the_module}_PRIVATE_REQ_DEPS
# OPENCV_MODULE_${the_module}_PRIVATE_OPT_DEPS
2014-08-01 22:11:20 +08:00
# OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD
2015-01-19 23:03:29 +08:00
# OPENCV_MODULE_${the_module}_CUDA_OBJECTS - compiled CUDA objects list
2015-02-25 20:00:44 +08:00
# OPENCV_MODULE_${the_module}_CHILDREN - list of submodules for compound modules (cmake >= 2.8.8)
2015-02-19 21:17:19 +08:00
# OPENCV_MODULE_${the_module}_WRAPPERS - list of wrappers supporting this module
2012-02-03 19:26:49 +08:00
# HAVE_${the_module} - for fast check of module availability
# To control the setup of the module you could also set:
# the_description - text to be used as current module description
# OPENCV_MODULE_TYPE - STATIC|SHARED - set to force override global settings for current module
2012-05-13 17:34:33 +08:00
# OPENCV_MODULE_IS_PART_OF_WORLD - ON|OFF (default ON) - should the module be added to the opencv_world?
# BUILD_${the_module}_INIT - ON|OFF (default ON) - initial value for BUILD_${the_module}
2015-01-19 23:03:29 +08:00
# OPENCV_MODULE_CHILDREN - list of submodules
2012-02-03 19:26:49 +08:00
# The verbose template for OpenCV module:
#
# ocv_add_module(modname <dependencies>)
2014-03-05 16:31:04 +08:00
# ocv_glob_module_sources(([EXCLUDE_CUDA] <extra sources&headers>)
# or glob them manually and ocv_set_module_sources(...)
2012-02-03 19:26:49 +08:00
# ocv_module_include_directories(<extra include directories>)
# ocv_create_module()
# <add extra link dependencies, compiler options, etc>
# ocv_add_precompiled_headers(${the_module})
# <add extra installation rules>
# ocv_add_accuracy_tests(<extra dependencies>)
# ocv_add_perf_tests(<extra dependencies>)
2013-09-04 22:41:19 +08:00
# ocv_add_samples(<extra dependencies>)
2012-02-03 19:26:49 +08:00
#
#
# If module have no "extra" then you can define it in one line:
#
# ocv_define_module(modname <dependencies>)
# clean flags for modules enabled on previous cmake run
# this is necessary to correctly handle modules removal
2012-05-13 17:34:33 +08:00
foreach ( mod ${ OPENCV_MODULES_BUILD } ${ OPENCV_MODULES_DISABLED_USER } ${ OPENCV_MODULES_DISABLED_AUTO } ${ OPENCV_MODULES_DISABLED_FORCE } )
2012-02-03 19:26:49 +08:00
if ( HAVE_ ${ mod } )
unset ( HAVE_ ${ mod } CACHE )
endif ( )
2012-05-13 17:34:33 +08:00
unset ( OPENCV_MODULE_ ${ mod } _REQ_DEPS CACHE )
unset ( OPENCV_MODULE_ ${ mod } _OPT_DEPS CACHE )
2013-08-07 16:53:48 +08:00
unset ( OPENCV_MODULE_ ${ mod } _PRIVATE_REQ_DEPS CACHE )
unset ( OPENCV_MODULE_ ${ mod } _PRIVATE_OPT_DEPS CACHE )
2014-08-01 22:11:20 +08:00
unset ( OPENCV_MODULE_ ${ mod } _LINK_DEPS CACHE )
2015-02-24 23:38:12 +08:00
unset ( OPENCV_MODULE_ ${ mod } _WRAPPERS CACHE )
2012-02-03 19:26:49 +08:00
endforeach ( )
# clean modules info which needs to be recalculated
set ( OPENCV_MODULES_PUBLIC "" CACHE INTERNAL "List of OpenCV modules marked for export" )
set ( OPENCV_MODULES_BUILD "" CACHE INTERNAL "List of OpenCV modules included into the build" )
set ( OPENCV_MODULES_DISABLED_USER "" CACHE INTERNAL "List of OpenCV modules explicitly disabled by user" )
set ( OPENCV_MODULES_DISABLED_AUTO "" CACHE INTERNAL "List of OpenCV modules implicitly disabled due to dependencies" )
set ( OPENCV_MODULES_DISABLED_FORCE "" CACHE INTERNAL "List of OpenCV modules which can not be build in current configuration" )
2014-08-01 22:11:20 +08:00
unset ( OPENCV_WORLD_MODULES CACHE )
2012-02-03 19:26:49 +08:00
# adds dependencies to OpenCV module
# Usage:
2015-02-19 21:17:19 +08:00
# add_dependencies(opencv_<name> [REQUIRED] [<list of dependencies>] [OPTIONAL <list of modules>] [WRAP <list of wrappers>])
2012-02-03 19:26:49 +08:00
# Notes:
# * <list of dependencies> - can include full names of modules or full pathes to shared/static libraries or cmake targets
macro ( ocv_add_dependencies full_modname )
2014-08-01 22:11:20 +08:00
ocv_debug_message ( "ocv_add_dependencies(" ${ full_modname } ${ ARGN } ")" )
2012-02-03 19:26:49 +08:00
#we don't clean the dependencies here to allow this macro several times for every module
2012-05-12 21:54:26 +08:00
foreach ( d "REQUIRED" ${ ARGN } )
if ( d STREQUAL "REQUIRED" )
2012-02-03 19:26:49 +08:00
set ( __depsvar OPENCV_MODULE_ ${ full_modname } _REQ_DEPS )
elseif ( d STREQUAL "OPTIONAL" )
set ( __depsvar OPENCV_MODULE_ ${ full_modname } _OPT_DEPS )
2013-08-07 16:53:48 +08:00
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 )
2015-02-19 21:17:19 +08:00
elseif ( d STREQUAL "WRAP" )
set ( __depsvar OPENCV_MODULE_ ${ full_modname } _WRAPPERS )
2012-02-03 19:26:49 +08:00
else ( )
list ( APPEND ${ __depsvar } "${d}" )
endif ( )
endforeach ( )
2012-06-18 14:53:13 +08:00
unset ( __depsvar )
2015-02-24 23:38:12 +08:00
# hack for python
set ( __python_idx )
list ( FIND OPENCV_MODULE_ ${ full_modname } _WRAPPERS "python" __python_idx )
if ( NOT __python_idx EQUAL -1 )
list ( REMOVE_ITEM OPENCV_MODULE_ ${ full_modname } _WRAPPERS "python" )
list ( APPEND OPENCV_MODULE_ ${ full_modname } _WRAPPERS "python2" "python3" )
endif ( )
unset ( __python_idx )
2012-06-18 14:53:13 +08:00
ocv_list_unique ( OPENCV_MODULE_ ${ full_modname } _REQ_DEPS )
ocv_list_unique ( OPENCV_MODULE_ ${ full_modname } _OPT_DEPS )
2013-08-07 16:53:48 +08:00
ocv_list_unique ( OPENCV_MODULE_ ${ full_modname } _PRIVATE_REQ_DEPS )
ocv_list_unique ( OPENCV_MODULE_ ${ full_modname } _PRIVATE_OPT_DEPS )
2015-02-19 21:17:19 +08:00
ocv_list_unique ( OPENCV_MODULE_ ${ full_modname } _WRAPPERS )
2013-08-07 16:53:48 +08:00
set ( OPENCV_MODULE_ ${ full_modname } _REQ_DEPS ${ OPENCV_MODULE_${full_modname } _REQ_DEPS}
C A C H E I N T E R N A L " R e q u i r e d d e p e n d e n c i e s o f $ { f u l l _ m o d n a m e } m o d u l e " )
set ( OPENCV_MODULE_ ${ full_modname } _OPT_DEPS ${ OPENCV_MODULE_${full_modname } _OPT_DEPS}
C A C H E I N T E R N A L " O p t i o n a l d e p e n d e n c i e s o f $ { f u l l _ m o d n a m e } m o d u l e " )
set ( OPENCV_MODULE_ ${ full_modname } _PRIVATE_REQ_DEPS ${ OPENCV_MODULE_${full_modname } _PRIVATE_REQ_DEPS}
C A C H E I N T E R N A L " R e q u i r e d p r i v a t e d e p e n d e n c i e s o f $ { f u l l _ m o d n a m e } m o d u l e " )
set ( OPENCV_MODULE_ ${ full_modname } _PRIVATE_OPT_DEPS ${ OPENCV_MODULE_${full_modname } _PRIVATE_OPT_DEPS}
C A C H E I N T E R N A L " O p t i o n a l p r i v a t e d e p e n d e n c i e s o f $ { f u l l _ m o d n a m e } m o d u l e " )
2015-02-19 21:17:19 +08:00
set ( OPENCV_MODULE_ ${ full_modname } _WRAPPERS ${ OPENCV_MODULE_${full_modname } _WRAPPERS}
C A C H E I N T E R N A L " L i s t o f w r a p p e r s s u p p o r t i n g m o d u l e $ { f u l l _ m o d n a m e } " )
2012-01-25 17:04:49 +08:00
endmacro ( )
2012-02-03 19:26:49 +08:00
# declare new OpenCV module in current folder
# Usage:
2015-02-19 21:17:19 +08:00
# ocv_add_module(<name> [INTERNAL|BINDINGS] [REQUIRED] [<list of dependencies>] [OPTIONAL <list of optional dependencies>] [WRAP <list of wrappers>])
2012-02-03 19:26:49 +08:00
# Example:
2015-01-15 21:14:13 +08:00
# ocv_add_module(yaom INTERNAL opencv_core opencv_highgui opencv_flann OPTIONAL opencv_cudev)
2012-02-03 19:26:49 +08:00
macro ( ocv_add_module _name )
2014-08-01 22:11:20 +08:00
ocv_debug_message ( "ocv_add_module(" ${ _name } ${ ARGN } ")" )
2012-02-03 19:26:49 +08:00
string ( TOLOWER "${_name}" name )
set ( the_module opencv_ ${ name } )
2012-03-26 03:57:58 +08:00
2012-02-03 19:26:49 +08:00
# the first pass - collect modules info, the second pass - create targets
if ( OPENCV_INITIAL_PASS )
2012-03-15 17:20:16 +08:00
#guard agains redefinition
if ( ";${OPENCV_MODULES_BUILD};${OPENCV_MODULES_DISABLED_USER};" MATCHES ";${the_module};" )
message ( FATAL_ERROR " Redefinition of the ${ the_module } module.
a t : $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
p r e v i o u s l y d e f i n e d a t : $ { O P E N C V _ M O D U L E _ $ { t h e _ m o d u l e } _ L O C A T I O N }
" )
endif ( )
2012-02-03 19:26:49 +08:00
if ( NOT DEFINED the_description )
set ( the_description "The ${name} OpenCV module" )
endif ( )
2012-03-26 03:57:58 +08:00
2012-05-13 17:34:33 +08:00
if ( NOT DEFINED BUILD_ ${ the_module } _INIT )
set ( BUILD_ ${ the_module } _INIT ON )
2012-05-12 21:54:26 +08:00
endif ( )
2012-06-18 14:53:13 +08:00
# create option to enable/disable this module
2012-05-13 17:34:33 +08:00
option ( BUILD_ ${ the_module } "Include ${the_module} module into the OpenCV build" ${ BUILD_${the_module } _INIT} )
2012-03-15 17:20:16 +08:00
2012-06-18 14:53:13 +08:00
# 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" )
2014-08-01 22:11:20 +08:00
set ( OPENCV_MODULE_ ${ the_module } _LINK_DEPS "" CACHE INTERNAL "" )
2012-06-18 14:53:13 +08:00
# parse list of dependencies
2012-03-15 17:20:16 +08:00
if ( "${ARGV1}" STREQUAL "INTERNAL" OR "${ARGV1}" STREQUAL "BINDINGS" )
2014-02-11 18:25:37 +08:00
set ( OPENCV_MODULE_ ${ the_module } _CLASS "${ARGV1}" CACHE INTERNAL "The category of the module" )
2012-03-15 17:20:16 +08:00
set ( __ocv_argn__ ${ ARGN } )
list ( REMOVE_AT __ocv_argn__ 0 )
ocv_add_dependencies ( ${ the_module } ${ __ocv_argn__ } )
unset ( __ocv_argn__ )
2011-07-25 03:22:58 +08:00
else ( )
2014-02-11 18:25:37 +08:00
set ( OPENCV_MODULE_ ${ the_module } _CLASS "PUBLIC" CACHE INTERNAL "The category of the module" )
2012-03-15 17:20:16 +08:00
ocv_add_dependencies ( ${ the_module } ${ ARGN } )
if ( BUILD_ ${ the_module } )
2012-02-03 19:26:49 +08:00
set ( OPENCV_MODULES_PUBLIC ${ OPENCV_MODULES_PUBLIC } "${the_module}" CACHE INTERNAL "List of OpenCV modules marked for export" )
endif ( )
2012-03-15 17:20:16 +08:00
endif ( )
2012-06-08 14:19:17 +08:00
2012-05-13 17:34:33 +08:00
# add self to the world dependencies
2015-01-19 23:03:29 +08:00
if ( ( NOT DEFINED OPENCV_MODULE_IS_PART_OF_WORLD
A N D N O T O P E N C V _ M O D U L E _ $ { t h e _ m o d u l e } _ C L A S S S T R E Q U A L " B I N D I N G S "
2015-06-05 21:24:38 +08:00
A N D N O T O P E N C V _ P R O C E S S I N G _ E X T R A _ M O D U L E S
AND ( NOT BUILD_SHARED_LIBS OR NOT "x${OPENCV_MODULE_TYPE}" STREQUAL "xSTATIC" ) )
2014-08-01 22:11:20 +08:00
O R O P E N C V _ M O D U L E _ I S _ P A R T _ O F _ W O R L D
)
set ( OPENCV_MODULE_ ${ the_module } _IS_PART_OF_WORLD ON CACHE INTERNAL "" )
2012-05-13 17:34:33 +08:00
ocv_add_dependencies ( opencv_world OPTIONAL ${ the_module } )
2014-08-01 22:11:20 +08:00
else ( )
set ( OPENCV_MODULE_ ${ the_module } _IS_PART_OF_WORLD OFF CACHE INTERNAL "" )
2012-05-13 17:34:33 +08:00
endif ( )
2012-03-15 17:20:16 +08:00
if ( BUILD_ ${ the_module } )
2012-02-03 19:26:49 +08:00
set ( OPENCV_MODULES_BUILD ${ OPENCV_MODULES_BUILD } "${the_module}" CACHE INTERNAL "List of OpenCV modules included into the build" )
2012-03-15 17:20:16 +08:00
else ( )
set ( OPENCV_MODULES_DISABLED_USER ${ OPENCV_MODULES_DISABLED_USER } "${the_module}" CACHE INTERNAL "List of OpenCV modules explicitly disabled by user" )
2011-07-25 03:22:58 +08:00
endif ( )
2012-03-26 03:57:58 +08:00
2015-01-19 23:03:29 +08:00
# add submodules if any
set ( OPENCV_MODULE_ ${ the_module } _CHILDREN "${OPENCV_MODULE_CHILDREN}" CACHE INTERNAL "List of ${the_module} submodules" )
2012-02-03 19:26:49 +08:00
2015-02-19 21:17:19 +08:00
# add reverse wrapper dependencies
foreach ( wrapper ${ OPENCV_MODULE_${the_module } _WRAPPERS} )
ocv_add_dependencies ( opencv_ ${ wrapper } OPTIONAL ${ the_module } )
endforeach ( )
2012-06-18 14:53:13 +08:00
# stop processing of current file
2012-02-03 19:26:49 +08:00
return ( )
2014-08-01 22:11:20 +08:00
else ( )
set ( OPENCV_MODULE_ ${ the_module } _BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE INTERNAL "" )
2012-02-03 19:26:49 +08:00
if ( NOT BUILD_ ${ the_module } )
2012-06-18 14:53:13 +08:00
return ( ) # extra protection from redefinition
2011-07-25 03:22:58 +08:00
endif ( )
2014-08-01 22:11:20 +08:00
if ( ( NOT OPENCV_MODULE_ ${ the_module } _IS_PART_OF_WORLD AND NOT ${ the_module } STREQUAL opencv_world ) OR NOT ${ BUILD_opencv_world } )
project ( ${ the_module } )
endif ( )
endif ( )
2011-07-25 03:22:58 +08:00
endmacro ( )
2012-06-18 14:53:13 +08:00
# excludes module from current configuration
2012-02-03 19:26:49 +08:00
macro ( ocv_module_disable module )
set ( __modname ${ module } )
if ( NOT __modname MATCHES "^opencv_" )
set ( __modname opencv_ ${ module } )
endif ( )
list ( APPEND OPENCV_MODULES_DISABLED_FORCE "${__modname}" )
set ( HAVE_ ${ __modname } OFF CACHE INTERNAL "Module ${__modname} can not be built in current configuration" )
2012-03-15 17:20:16 +08:00
set ( OPENCV_MODULE_ ${ __modname } _LOCATION "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "Location of ${__modname} module sources" )
2012-02-03 19:26:49 +08:00
set ( OPENCV_MODULES_DISABLED_FORCE "${OPENCV_MODULES_DISABLED_FORCE}" CACHE INTERNAL "List of OpenCV modules which can not be build in current configuration" )
2013-01-10 23:05:39 +08:00
if ( BUILD_ ${ __modname } )
# touch variable controlling build of the module to suppress "unused variable" CMake warning
endif ( )
2012-02-03 19:26:49 +08:00
unset ( __modname )
2012-06-18 14:53:13 +08:00
return ( ) # leave the current folder
2012-02-03 19:26:49 +08:00
endmacro ( )
2011-09-06 23:30:28 +08:00
2012-02-03 19:26:49 +08:00
# collect modules from specified directories
# NB: must be called only once!
macro ( ocv_glob_modules )
2012-03-15 17:20:16 +08:00
if ( DEFINED OPENCV_INITIAL_PASS )
message ( FATAL_ERROR "OpenCV has already loaded its modules. Calling ocv_glob_modules second time is not allowed." )
endif ( )
set ( __directories_observed "" )
2012-06-18 14:53:13 +08:00
# collect modules
2012-02-03 19:26:49 +08:00
set ( OPENCV_INITIAL_PASS ON )
2014-08-01 22:11:20 +08:00
set ( OPENCV_PROCESSING_EXTRA_MODULES 0 )
2012-02-03 19:26:49 +08:00
foreach ( __path ${ ARGN } )
2014-08-01 22:11:20 +08:00
if ( "${__path}" STREQUAL "EXTRA" )
set ( OPENCV_PROCESSING_EXTRA_MODULES 1 )
2015-08-14 23:08:25 +08:00
else ( )
get_filename_component ( __path "${__path}" ABSOLUTE )
2012-06-18 14:53:13 +08:00
2015-08-14 23:08:25 +08:00
list ( FIND __directories_observed "${__path}" __pathIdx )
if ( __pathIdx GREATER -1 )
message ( FATAL_ERROR "The directory ${__path} is observed for OpenCV modules second time." )
endif ( )
list ( APPEND __directories_observed "${__path}" )
set ( __count 0 )
file ( GLOB __ocvmodules RELATIVE "${__path}" "${__path}/*" )
if ( __ocvmodules )
list ( SORT __ocvmodules )
foreach ( mod ${ __ocvmodules } )
get_filename_component ( __modpath "${__path}/${mod}" ABSOLUTE )
if ( EXISTS "${__modpath}/CMakeLists.txt" )
list ( FIND __directories_observed "${__modpath}" __pathIdx )
if ( __pathIdx GREATER -1 )
message ( FATAL_ERROR "The module from ${__modpath} is already loaded." )
endif ( )
list ( APPEND __directories_observed "${__modpath}" )
add_subdirectory ( "${__modpath}" "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}" )
if ( DEFINED OPENCV_MODULE_opencv_ ${ mod } _LOCATION )
math ( EXPR __count "${__count} + 1" )
endif ( )
2012-03-15 17:20:16 +08:00
endif ( )
2015-08-14 23:08:25 +08:00
endforeach ( )
endif ( )
if ( OPENCV_PROCESSING_EXTRA_MODULES AND ${ __count } LESS 1 )
message ( SEND_ERROR "No extra modules found in folder: ${__path}\nPlease provide path to 'opencv_contrib/modules' folder." )
endif ( )
2012-01-03 21:48:12 +08:00
endif ( )
2012-02-03 19:26:49 +08:00
endforeach ( )
2012-06-18 14:53:13 +08:00
ocv_clear_vars ( __ocvmodules __directories_observed __path __modpath __pathIdx )
2012-02-03 19:26:49 +08:00
2012-06-18 14:53:13 +08:00
# resolve dependencies
2013-08-07 16:53:48 +08:00
__ocv_resolve_dependencies ( )
2012-03-26 03:57:58 +08:00
2012-06-18 14:53:13 +08:00
# create modules
2012-03-15 17:20:16 +08:00
set ( OPENCV_INITIAL_PASS OFF PARENT_SCOPE )
2012-02-03 19:26:49 +08:00
set ( OPENCV_INITIAL_PASS OFF )
2014-08-01 22:11:20 +08:00
if ( ${ BUILD_opencv_world } )
add_subdirectory ( "${OPENCV_MODULE_opencv_world_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/world" )
foreach ( m ${ OPENCV_MODULES_BUILD } )
if ( NOT OPENCV_MODULE_ ${ m } _IS_PART_OF_WORLD AND NOT ${ m } STREQUAL opencv_world )
message ( STATUS "Processing module ${m}..." )
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 ( )
endif ( )
endforeach ( )
else ( )
foreach ( m ${ OPENCV_MODULES_BUILD } )
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 ( )
endif ( )
2012-02-03 19:26:49 +08:00
unset ( __shortname )
2011-09-06 23:30:28 +08:00
endmacro ( )
2013-08-07 16:53:48 +08:00
# 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 } )
2015-01-19 23:03:29 +08:00
set ( input ${ ${__lst } } )
set ( result "" )
while ( input )
list ( LENGTH input length_before )
foreach ( m ${ input } )
# check if module is in the result already
if ( NOT ";${result};" MATCHES ";${m};" )
# scan through module dependencies...
set ( unresolved_deps_found FALSE )
foreach ( d ${ OPENCV_MODULE_${m } _CHILDREN} ${ OPENCV_MODULE_${m } _DEPS} )
# ... which are not already in the result and are enabled
if ( ( NOT ";${result};" MATCHES ";${d};" ) AND HAVE_ ${ d } )
set ( unresolved_deps_found TRUE )
break ( )
endif ( )
endforeach ( )
# chek if all dependencies for this module has been resolved
if ( NOT unresolved_deps_found )
list ( APPEND result ${ m } )
list ( REMOVE_ITEM input ${ m } )
2013-08-07 16:53:48 +08:00
endif ( )
endif ( )
endforeach ( )
2015-01-19 23:03:29 +08:00
list ( LENGTH input length_after )
# check for infinite loop or unresolved dependencies
if ( NOT length_after LESS length_before )
message ( WARNING "Unresolved dependencies or loop in dependency graph (${length_after})\n"
" P r o c e s s e d $ { _ _ l s t } : $ { $ { _ _ l s t } } \ n "
" G o o d m o d u l e s : $ { r e s u l t } \ n "
" B a d m o d u l e s : $ { i n p u t } "
)
list ( APPEND result ${ input } )
break ( )
2013-08-07 16:53:48 +08:00
endif ( )
2015-01-19 23:03:29 +08:00
endwhile ( )
set ( ${ __lst } "${result}" PARENT_SCOPE )
2013-08-07 16:53:48 +08:00
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 )
2013-10-03 06:20:54 +08:00
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 ( )
2013-08-07 16:53:48 +08:00
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 )
2014-08-01 22:11:20 +08:00
set ( LINK_DEPS ${ OPENCV_MODULE_${m } _DEPS} )
# process world
if ( BUILD_opencv_world )
if ( OPENCV_MODULE_ ${ m } _IS_PART_OF_WORLD )
list ( APPEND OPENCV_WORLD_MODULES ${ m } )
endif ( )
foreach ( m2 ${ OPENCV_MODULES_BUILD } )
if ( OPENCV_MODULE_ ${ m2 } _IS_PART_OF_WORLD )
if ( ";${LINK_DEPS};" MATCHES ";${m2};" )
list ( REMOVE_ITEM LINK_DEPS ${ m2 } )
if ( NOT ( ";${LINK_DEPS};" MATCHES ";opencv_world;" ) AND NOT ( ${ m } STREQUAL opencv_world ) )
list ( APPEND LINK_DEPS opencv_world )
endif ( )
endif ( )
if ( ${ m } STREQUAL opencv_world )
list ( APPEND OPENCV_MODULE_opencv_world_DEPS_EXT ${ OPENCV_MODULE_${m2 } _DEPS_EXT} )
endif ( )
endif ( )
endforeach ( )
endif ( )
2013-08-07 16:53:48 +08:00
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" )
2014-08-01 22:11:20 +08:00
set ( OPENCV_MODULE_ ${ m } _DEPS_TO_LINK ${ LINK_DEPS } CACHE INTERNAL "Flattened dependencies of ${m} module (for linker)" )
2013-08-07 16:53:48 +08:00
2014-08-01 22:11:20 +08:00
# message(STATUS " module deps of ${m}: ${OPENCV_MODULE_${m}_DEPS}")
# message(STATUS " module link deps of ${m}: ${OPENCV_MODULE_${m}_DEPS_TO_LINK}")
# message(STATUS " extra deps of ${m}: ${OPENCV_MODULE_${m}_DEPS_EXT}")
# message(STATUS "")
2013-08-07 16:53:48 +08:00
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" )
2014-08-01 22:11:20 +08:00
set ( OPENCV_WORLD_MODULES ${ OPENCV_WORLD_MODULES } CACHE INTERNAL "List of OpenCV modules included into the world" )
2013-08-07 16:53:48 +08:00
endfunction ( )
2012-02-03 19:26:49 +08:00
# setup include paths for the list of passed modules
macro ( ocv_include_modules )
foreach ( d ${ ARGN } )
if ( d MATCHES "^opencv_" AND HAVE_ ${ d } )
if ( EXISTS "${OPENCV_MODULE_${d}_LOCATION}/include" )
2012-03-03 23:49:23 +08:00
ocv_include_directories ( "${OPENCV_MODULE_${d}_LOCATION}/include" )
2012-02-03 19:26:49 +08:00
endif ( )
elseif ( EXISTS "${d}" )
2012-03-03 23:49:23 +08:00
ocv_include_directories ( "${d}" )
2012-02-03 19:26:49 +08:00
endif ( )
endforeach ( )
endmacro ( )
2012-01-03 21:48:12 +08:00
2015-03-26 20:25:42 +08:00
# same as previous but with dependencies
macro ( ocv_include_modules_recurse )
ocv_include_modules ( ${ ARGN } )
foreach ( d ${ ARGN } )
if ( d MATCHES "^opencv_" AND HAVE_ ${ d } AND DEFINED OPENCV_MODULE_ ${ d } _DEPS )
foreach ( sub ${ OPENCV_MODULE_${d } _DEPS} )
ocv_include_modules ( ${ sub } )
endforeach ( )
endif ( )
endforeach ( )
endmacro ( )
2014-08-01 22:11:20 +08:00
# setup include paths for the list of passed modules
macro ( ocv_target_include_modules target )
foreach ( d ${ ARGN } )
if ( d MATCHES "^opencv_" AND HAVE_ ${ d } )
if ( EXISTS "${OPENCV_MODULE_${d}_LOCATION}/include" )
ocv_target_include_directories ( ${ target } "${OPENCV_MODULE_${d}_LOCATION}/include" )
endif ( )
elseif ( EXISTS "${d}" )
ocv_target_include_directories ( ${ target } "${d}" )
endif ( )
endforeach ( )
endmacro ( )
2012-03-28 00:05:52 +08:00
# setup include paths for the list of passed modules and recursively add dependent modules
2014-08-01 22:11:20 +08:00
macro ( ocv_target_include_modules_recurse target )
2012-03-28 00:05:52 +08:00
foreach ( d ${ ARGN } )
if ( d MATCHES "^opencv_" AND HAVE_ ${ d } )
if ( EXISTS "${OPENCV_MODULE_${d}_LOCATION}/include" )
2014-08-01 22:11:20 +08:00
ocv_target_include_directories ( ${ target } "${OPENCV_MODULE_${d}_LOCATION}/include" )
2012-03-28 00:05:52 +08:00
endif ( )
if ( OPENCV_MODULE_ ${ d } _DEPS )
2014-08-01 22:11:20 +08:00
ocv_target_include_modules ( ${ target } ${ OPENCV_MODULE_${d } _DEPS} )
2012-03-28 00:05:52 +08:00
endif ( )
elseif ( EXISTS "${d}" )
2014-08-01 22:11:20 +08:00
ocv_target_include_directories ( ${ target } "${d}" )
2012-03-28 00:05:52 +08:00
endif ( )
endforeach ( )
endmacro ( )
2012-02-03 19:26:49 +08:00
# setup include path for OpenCV headers for specified module
# ocv_module_include_directories(<extra include directories/extra include modules>)
macro ( ocv_module_include_directories )
2014-08-01 22:11:20 +08:00
ocv_target_include_directories ( ${ the_module }
" $ { O P E N C V _ M O D U L E _ $ { t h e _ m o d u l e } _ L O C A T I O N } / i n c l u d e "
" $ { O P E N C V _ M O D U L E _ $ { t h e _ m o d u l e } _ L O C A T I O N } / s r c "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } " # for precompiled headers
)
ocv_target_include_modules ( ${ the_module } ${ OPENCV_MODULE_${the_module } _DEPS} ${ ARGN } )
2012-02-03 19:26:49 +08:00
endmacro ( )
2011-09-06 23:30:28 +08:00
2012-02-03 19:26:49 +08:00
# sets header and source files for the current module
# NB: all files specified as headers will be installed
# Usage:
# ocv_set_module_sources([HEADERS] <list of files> [SOURCES] <list of files>)
macro ( ocv_set_module_sources )
2014-08-01 22:11:20 +08:00
ocv_debug_message ( "ocv_set_module_sources(" ${ ARGN } ")" )
2012-02-03 19:26:49 +08:00
set ( OPENCV_MODULE_ ${ the_module } _HEADERS "" )
set ( OPENCV_MODULE_ ${ the_module } _SOURCES "" )
2012-03-26 03:57:58 +08:00
2012-02-03 19:26:49 +08:00
foreach ( f "HEADERS" ${ ARGN } )
if ( f STREQUAL "HEADERS" OR f STREQUAL "SOURCES" )
set ( __filesvar "OPENCV_MODULE_${the_module}_${f}" )
else ( )
list ( APPEND ${ __filesvar } "${f}" )
endif ( )
endforeach ( )
2012-03-26 03:57:58 +08:00
2012-02-03 19:26:49 +08:00
# the hacky way to embeed any files into the OpenCV without modification of its build system
if ( COMMAND ocv_get_module_external_sources )
ocv_get_module_external_sources ( )
endif ( )
2011-09-06 23:30:28 +08:00
2012-03-26 03:57:58 +08:00
# use full paths for module to be independent from the module location
2012-06-18 14:53:13 +08:00
ocv_convert_to_full_paths ( OPENCV_MODULE_ ${ the_module } _HEADERS )
2012-03-26 03:57:58 +08:00
2012-02-03 19:26:49 +08:00
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}" )
endmacro ( )
2011-09-06 23:30:28 +08:00
2012-02-03 19:26:49 +08:00
# finds and sets headers and sources for the standard OpenCV module
# Usage:
2014-03-05 16:31:04 +08:00
# ocv_glob_module_sources([EXCLUDE_CUDA] <extra sources&headers in the same format as used in ocv_set_module_sources>)
2012-02-03 19:26:49 +08:00
macro ( ocv_glob_module_sources )
2014-08-01 22:11:20 +08:00
ocv_debug_message ( "ocv_glob_module_sources(" ${ ARGN } ")" )
2014-03-05 16:31:04 +08:00
set ( _argn ${ ARGN } )
list ( FIND _argn "EXCLUDE_CUDA" exclude_cuda )
if ( NOT exclude_cuda EQUAL -1 )
list ( REMOVE_AT _argn ${ exclude_cuda } )
endif ( )
2014-08-01 22:11:20 +08:00
file ( GLOB_RECURSE lib_srcs
" $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / s r c / * . c p p "
)
file ( GLOB_RECURSE lib_int_hdrs
" $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / s r c / * . h p p "
" $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / s r c / * . h "
)
file ( GLOB lib_hdrs
" $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / i n c l u d e / o p e n c v 2 / * . h p p "
" $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / i n c l u d e / o p e n c v 2 / $ { n a m e } / * . h p p "
" $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / i n c l u d e / o p e n c v 2 / $ { n a m e } / * . h "
)
file ( GLOB lib_hdrs_detail
" $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / i n c l u d e / o p e n c v 2 / $ { n a m e } / d e t a i l / * . h p p "
" $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / i n c l u d e / o p e n c v 2 / $ { n a m e } / d e t a i l / * . h "
)
2014-02-08 23:31:24 +08:00
if ( APPLE )
2014-08-01 22:11:20 +08:00
file ( GLOB_RECURSE lib_srcs_apple
" $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / s r c / * . m m "
)
2014-02-08 23:31:24 +08:00
list ( APPEND lib_srcs ${ lib_srcs_apple } )
endif ( )
2011-09-06 23:30:28 +08:00
2014-08-01 22:11:20 +08:00
ocv_source_group ( "Src" DIRBASE "${CMAKE_CURRENT_LIST_DIR}/src" FILES ${ lib_srcs } ${ lib_int_hdrs } )
ocv_source_group ( "Include" DIRBASE "${CMAKE_CURRENT_LIST_DIR}/include" FILES ${ lib_hdrs } ${ lib_hdrs_detail } )
2013-12-05 07:23:52 +08:00
2014-08-13 22:07:31 +08:00
set ( lib_cuda_srcs "" )
set ( lib_cuda_hdrs "" )
if ( HAVE_CUDA AND exclude_cuda EQUAL -1 )
2014-08-01 22:11:20 +08:00
file ( GLOB lib_cuda_srcs
" $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / s r c / c u d a / * . c u "
)
2014-08-13 22:07:31 +08:00
file ( GLOB lib_cuda_hdrs
" $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / s r c / c u d a / * . h p p "
)
source_group ( "Src\\Cuda" FILES ${ lib_cuda_srcs } ${ lib_cuda_hdrs } )
2013-03-02 04:17:46 +08:00
endif ( )
2014-08-01 22:11:20 +08:00
file ( GLOB cl_kernels
" $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / s r c / o p e n c l / * . c l "
)
2013-11-19 02:48:04 +08:00
if ( cl_kernels )
2014-08-01 22:11:20 +08:00
set ( OCL_NAME opencl_kernels_ ${ name } )
2013-03-16 03:56:31 +08:00
ocv_include_directories ( ${ OPENCL_INCLUDE_DIRS } )
add_custom_command (
2014-08-01 22:11:20 +08:00
O U T P U T " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { O C L _ N A M E } . c p p " " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { O C L _ N A M E } . h p p "
2015-06-11 20:36:29 +08:00
C O M M A N D $ { C M A K E _ C O M M A N D } " - D M O D U L E _ N A M E = $ { n a m e } " " - D C L _ D I R = $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / s r c / o p e n c l " " - D O U T P U T = $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { O C L _ N A M E } . c p p " - P " $ { O p e n C V _ S O U R C E _ D I R } / c m a k e / c l 2 c p p . c m a k e "
2013-03-16 03:56:31 +08:00
D E P E N D S $ { c l _ k e r n e l s } " $ { O p e n C V _ S O U R C E _ D I R } / c m a k e / c l 2 c p p . c m a k e " )
2013-12-05 07:23:52 +08:00
ocv_source_group ( "Src\\opencl\\kernels" FILES ${ cl_kernels } )
2014-08-01 22:11:20 +08:00
ocv_source_group ( "Src\\opencl\\kernels\\autogenerated" FILES "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.cpp" "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.hpp" )
list ( APPEND lib_srcs ${ cl_kernels } "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.cpp" "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.hpp" )
2013-03-16 03:56:31 +08:00
endif ( )
2014-03-05 16:31:04 +08:00
ocv_set_module_sources ( ${ _argn } HEADERS ${ lib_hdrs } ${ lib_hdrs_detail }
2014-08-13 22:07:31 +08:00
S O U R C E S $ { l i b _ s r c s } $ { l i b _ i n t _ h d r s } $ { l i b _ c u d a _ s r c s } $ { l i b _ c u d a _ h d r s } )
2011-09-06 23:30:28 +08:00
endmacro ( )
2012-02-03 19:26:49 +08:00
# creates OpenCV module in current folder
# creates new target, configures standard dependencies, compilers flags, install rules
# Usage:
2012-05-13 17:34:33 +08:00
# ocv_create_module(<extra link dependencies>)
2014-08-01 22:11:20 +08:00
# ocv_create_module()
2012-02-03 19:26:49 +08:00
macro ( ocv_create_module )
2014-08-01 22:11:20 +08:00
ocv_debug_message ( "ocv_create_module(" ${ ARGN } ")" )
set ( OPENCV_MODULE_ ${ the_module } _LINK_DEPS "${OPENCV_MODULE_${the_module}_LINK_DEPS};${ARGN}" CACHE INTERNAL "" )
if ( ${ BUILD_opencv_world } AND OPENCV_MODULE_ ${ the_module } _IS_PART_OF_WORLD )
# nothing
set ( the_module_target opencv_world )
else ( )
_ocv_create_module ( ${ ARGN } )
set ( the_module_target ${ the_module } )
endif ( )
2015-05-18 16:57:18 +08:00
if ( WINRT )
# removing APPCONTAINER from modules to run from console
# in case of usual starting of WinRT test apps output is missing
# so starting of console version w/o APPCONTAINER is required to get test results
# also this allows to use opencv_extra test data for these tests
if ( NOT "${the_module}" STREQUAL "opencv_ts" AND NOT "${the_module}" STREQUAL "opencv_hal" )
add_custom_command ( TARGET ${ the_module }
P O S T _ B U I L D
C O M M A N D l i n k . e x e / e d i t / A P P C O N T A I N E R : N O $ ( T a r g e t P a t h ) )
endif ( )
if ( "${the_module}" STREQUAL "opencv_ts" )
# copy required dll files; WinRT apps need these dlls that are usually substituted by Visual Studio
# however they are not on path and need to be placed with executables to run from console w/o APPCONTAINER
add_custom_command ( TARGET ${ the_module }
P O S T _ B U I L D
C O M M A N D c o p y / y " \ " $ ( V C I n s t a l l D i r ) r e d i s t \ \ $ ( P l a t f o r m T a r g e t ) \ \ M i c r o s o f t . V C $ ( P l a t f o r m T o o l s e t V e r s i o n ) . C R T \ \ m s v c p $ ( P l a t f o r m T o o l s e t V e r s i o n ) . d l l \ " " " \ " $ { C M A K E _ B I N A R Y _ D I R } \ \ b i n \ \ $ ( C o n f i g u r a t i o n ) \ \ m s v c p $ ( P l a t f o r m T o o l s e t V e r s i o n ) _ a p p . d l l \ " "
C O M M A N D c o p y / y " \ " $ ( V C I n s t a l l D i r ) r e d i s t \ \ $ ( P l a t f o r m T a r g e t ) \ \ M i c r o s o f t . V C $ ( P l a t f o r m T o o l s e t V e r s i o n ) . C R T \ \ m s v c r $ ( P l a t f o r m T o o l s e t V e r s i o n ) . d l l \ " " " \ " $ { C M A K E _ B I N A R Y _ D I R } \ \ b i n \ \ $ ( C o n f i g u r a t i o n ) \ \ m s v c r $ ( P l a t f o r m T o o l s e t V e r s i o n ) _ a p p . d l l \ " "
C O M M A N D c o p y / y " \ " $ ( V C I n s t a l l D i r ) r e d i s t \ \ $ ( P l a t f o r m T a r g e t ) \ \ M i c r o s o f t . V C $ ( P l a t f o r m T o o l s e t V e r s i o n ) . C R T \ \ v c c o r l i b $ ( P l a t f o r m T o o l s e t V e r s i o n ) . d l l \ " " " \ " $ { C M A K E _ B I N A R Y _ D I R } \ \ b i n \ \ $ ( C o n f i g u r a t i o n ) \ \ v c c o r l i b $ ( P l a t f o r m T o o l s e t V e r s i o n ) _ a p p . d l l \ " " )
endif ( )
endif ( )
2014-08-01 22:11:20 +08:00
endmacro ( )
macro ( _ocv_create_module )
2013-08-08 20:23:20 +08:00
# The condition we ought to be testing here is whether ocv_add_precompiled_headers will
# be called at some point in the future. We can't look into the future, though,
# so this will have to do.
2014-08-01 22:11:20 +08:00
if ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/precomp.hpp" AND NOT ${ the_module } STREQUAL opencv_world )
2013-08-08 20:23:20 +08:00
get_native_precompiled_header ( ${ the_module } precomp.hpp )
endif ( )
2015-01-19 23:03:29 +08:00
set ( sub_objs "" )
set ( sub_links "" )
set ( cuda_objs "" )
2015-02-18 17:44:48 +08:00
if ( OPENCV_MODULE_ ${ the_module } _CHILDREN )
2015-07-11 00:18:07 +08:00
message ( STATUS "Complex module ${the_module}" )
2015-01-19 23:03:29 +08:00
foreach ( m ${ OPENCV_MODULE_${the_module } _CHILDREN} )
2015-02-25 20:00:44 +08:00
if ( BUILD_ ${ m } AND TARGET ${ m } _object )
2015-01-19 23:03:29 +08:00
get_target_property ( _sub_links ${ m } LINK_LIBRARIES )
list ( APPEND sub_objs $< TARGET_OBJECTS:${m}_object > )
list ( APPEND sub_links ${ _sub_links } )
2015-07-11 00:18:07 +08:00
message ( STATUS " + ${m}" )
2015-01-19 23:03:29 +08:00
else ( )
2015-07-11 00:18:07 +08:00
message ( STATUS " - ${m}" )
2015-01-19 23:03:29 +08:00
endif ( )
list ( APPEND cuda_objs ${ OPENCV_MODULE_${m } _CUDA_OBJECTS} )
endforeach ( )
endif ( )
2014-08-01 22:11:20 +08:00
ocv_add_library ( ${ the_module } ${ OPENCV_MODULE_TYPE } ${ OPENCV_MODULE_${the_module } _HEADERS} ${ OPENCV_MODULE_${the_module } _SOURCES}
2013-08-08 20:23:20 +08:00
" $ { 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 v c o n f i g . h " " $ { 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 } / o p e n c v 2 / o p e n c v _ m o d u l e s . h p p "
2015-01-19 23:03:29 +08:00
$ { $ { t h e _ m o d u l e } _ p c h } $ { s u b _ o b j s } )
if ( cuda_objs )
target_link_libraries ( ${ the_module } ${ cuda_objs } )
endif ( )
# TODO: is it needed?
if ( sub_links )
ocv_list_filterout ( sub_links "^opencv_" )
ocv_list_unique ( sub_links )
target_link_libraries ( ${ the_module } ${ sub_links } )
endif ( )
unset ( sub_objs )
unset ( sub_links )
unset ( cuda_objs )
2014-08-01 22:11:20 +08:00
ocv_target_link_libraries ( ${ the_module } ${ OPENCV_MODULE_${the_module } _DEPS_TO_LINK} )
ocv_target_link_libraries ( ${ the_module } LINK_INTERFACE_LIBRARIES ${ OPENCV_MODULE_${the_module } _DEPS_TO_LINK} )
ocv_target_link_libraries ( ${ the_module } ${ OPENCV_MODULE_${the_module } _DEPS_EXT} ${ OPENCV_LINKER_LIBS } ${ IPP_LIBS } ${ ARGN } )
if ( HAVE_CUDA )
ocv_target_link_libraries ( ${ the_module } ${ CUDA_LIBRARIES } ${ CUDA_npp_LIBRARY } )
2012-05-13 17:34:33 +08:00
endif ( )
2012-06-18 14:53:13 +08:00
2012-03-03 23:49:23 +08:00
add_dependencies ( opencv_modules ${ the_module } )
2012-03-26 03:57:58 +08:00
2012-02-03 19:26:49 +08:00
if ( ENABLE_SOLUTION_FOLDERS )
set_target_properties ( ${ the_module } PROPERTIES FOLDER "modules" )
endif ( )
2012-03-26 03:57:58 +08:00
2012-02-03 19:26:49 +08:00
set_target_properties ( ${ the_module } PROPERTIES
O U T P U T _ N A M E " $ { t h e _ m o d u l e } $ { O P E N C V _ D L L V E R S I O N } "
D E B U G _ P O S T F I X " $ { O P E N C V _ D E B U G _ P O S T F I X } "
2015-08-17 08:28:22 +08:00
C O M P I L E _ P D B _ N A M E " $ { t h e _ m o d u l e } $ { O P E N C V _ D L L V E R S I O N } "
C O M P I L E _ P D B _ N A M E _ D E B U G " $ { t h e _ m o d u l e } $ { O P E N C V _ D L L V E R S I O N } $ { O P E N C V _ D E B U G _ P O S T F I X } "
2012-02-03 19:26:49 +08:00
A R C H I V E _ O U T P U T _ D I R E C T O R Y $ { L I B R A R Y _ O U T P U T _ P A T H }
2015-08-17 08:28:22 +08:00
C O M P I L E _ P D B _ O U T P U T _ D I R E C T O R Y $ { L I B R A R Y _ O U T P U T _ P A T H }
2013-01-22 23:43:54 +08:00
L I B R A R Y _ O U T P U T _ D I R E C T O R Y $ { L I B R A R Y _ O U T P U T _ P A T H }
2012-02-03 19:26:49 +08:00
R U N T I M E _ O U T P U T _ D I R E C T O R Y $ { E X E C U T A B L E _ O U T P U T _ P A T H }
I N S T A L L _ N A M E _ D I R l i b
)
2012-03-26 03:57:58 +08:00
2012-02-03 19:26:49 +08:00
# For dynamic link numbering convenions
if ( NOT ANDROID )
# Android SDK build scripts can include only .so files into final .apk
# As result we should not set version properties for Android
set_target_properties ( ${ the_module } PROPERTIES
2013-01-18 18:57:55 +08:00
V E R S I O N $ { O P E N C V _ L I B V E R S I O N }
2012-02-03 19:26:49 +08:00
S O V E R S I O N $ { O P E N C V _ S O V E R S I O N }
)
endif ( )
2013-07-26 18:35:40 +08:00
if ( ( NOT DEFINED OPENCV_MODULE_TYPE AND BUILD_SHARED_LIBS )
OR ( DEFINED OPENCV_MODULE_TYPE AND OPENCV_MODULE_TYPE STREQUAL SHARED ) )
2015-01-19 23:03:29 +08:00
set_target_properties ( ${ the_module } PROPERTIES COMPILE_DEFINITIONS CVAPI_EXPORTS )
2013-09-22 01:12:39 +08:00
set_target_properties ( ${ the_module } PROPERTIES DEFINE_SYMBOL CVAPI_EXPORTS )
2012-02-03 19:26:49 +08:00
endif ( )
2011-06-03 20:01:55 +08:00
2012-02-03 19:26:49 +08:00
if ( MSVC )
if ( CMAKE_CROSSCOMPILING )
set_target_properties ( ${ the_module } PROPERTIES LINK_FLAGS "/NODEFAULTLIB:secchk" )
2012-01-03 21:48:12 +08:00
endif ( )
2012-06-18 14:53:13 +08:00
set_target_properties ( ${ the_module } PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc /DEBUG" )
2012-02-03 19:26:49 +08:00
endif ( )
2012-01-03 21:48:12 +08:00
2015-01-19 23:03:29 +08:00
ocv_install_target ( ${ the_module } EXPORT OpenCVModules OPTIONAL
2014-01-19 03:50:07 +08:00
R U N T I M E D E S T I N A T I O N $ { O P E N C V _ B I N _ I N S T A L L _ P A T H } C O M P O N E N T l i b s
2014-10-17 17:23:23 +08:00
L I B R A R Y D E S T I N A T I O N $ { O P E N C V _ L I B _ I N S T A L L _ P A T H } C O M P O N E N T l i b s N A M E L I N K _ S K I P
2014-01-17 20:30:31 +08:00
A R C H I V E D E S T I N A T I O N $ { O P E N C V _ L I B _ I N S T A L L _ P A T H } C O M P O N E N T d e v
2012-02-03 19:26:49 +08:00
)
2014-10-17 17:23:23 +08:00
get_target_property ( _target_type ${ the_module } TYPE )
if ( "${_target_type}" STREQUAL "SHARED_LIBRARY" )
install ( TARGETS ${ the_module }
L I B R A R Y D E S T I N A T I O N $ { O P E N C V _ L I B _ I N S T A L L _ P A T H } C O M P O N E N T d e v N A M E L I N K _ O N L Y )
endif ( )
2010-12-29 00:24:23 +08:00
2015-01-19 23:03:29 +08:00
foreach ( m ${ OPENCV_MODULE_${the_module } _CHILDREN} ${ the_module } )
# only "public" headers need to be installed
if ( OPENCV_MODULE_ ${ m } _HEADERS AND ";${OPENCV_MODULES_PUBLIC};" MATCHES ";${m};" )
foreach ( hdr ${ OPENCV_MODULE_${m } _HEADERS} )
string ( REGEX REPLACE "^.*opencv2/" "opencv2/" hdr2 "${hdr}" )
if ( NOT hdr2 MATCHES "opencv2/${m}/private.*" AND hdr2 MATCHES "^(opencv2/?.*)/[^/]+.h(..)?$" )
install ( FILES ${ hdr } OPTIONAL DESTINATION "${OPENCV_INCLUDE_INSTALL_PATH}/${CMAKE_MATCH_1}" COMPONENT dev )
endif ( )
endforeach ( )
endif ( )
endforeach ( )
2014-08-01 22:11:20 +08:00
_ocv_add_precompiled_headers ( ${ the_module } )
2015-01-19 23:03:29 +08:00
if ( TARGET ${ the_module } _object )
# copy COMPILE_DEFINITIONS
get_target_property ( main_defs ${ the_module } COMPILE_DEFINITIONS )
2015-02-18 17:44:48 +08:00
if ( main_defs )
set_target_properties ( ${ the_module } _object PROPERTIES COMPILE_DEFINITIONS ${ main_defs } )
endif ( )
2015-01-19 23:03:29 +08:00
# use same PCH
if ( TARGET pch_Generate_ ${ the_module } )
add_dependencies ( ${ the_module } _object pch_Generate_ ${ the_module } )
endif ( )
endif ( )
2012-02-03 19:26:49 +08:00
endmacro ( )
# opencv precompiled headers macro (can add pch to modules and tests)
# this macro must be called after any "add_definitions" commands, otherwise precompiled headers will not work
# Usage:
# ocv_add_precompiled_headers(${the_module})
2014-08-01 22:11:20 +08:00
macro ( _ocv_add_precompiled_headers the_target )
ocv_debug_message ( "ocv_add_precompiled_headers(" ${ the_target } ${ ARGN } ")" )
2012-06-18 14:53:13 +08:00
if ( "${the_target}" MATCHES "^opencv_test_.*$" )
SET ( pch_path "test/test_" )
elseif ( "${the_target}" MATCHES "^opencv_perf_.*$" )
SET ( pch_path "perf/perf_" )
else ( )
SET ( pch_path "src/" )
endif ( )
ocv_add_precompiled_header_to_target ( ${ the_target } "${CMAKE_CURRENT_SOURCE_DIR}/${pch_path}precomp.hpp" )
unset ( pch_path )
2012-02-03 19:26:49 +08:00
endmacro ( )
2010-12-29 00:24:23 +08:00
2012-02-03 19:26:49 +08:00
# short command for adding simple OpenCV module
# see ocv_add_module for argument details
# Usage:
2015-02-19 21:17:19 +08:00
# ocv_define_module(module_name [INTERNAL] [EXCLUDE_CUDA] [REQUIRED] [<list of dependencies>] [OPTIONAL <list of optional dependencies>] [WRAP <list of wrappers>])
2012-02-03 19:26:49 +08:00
macro ( ocv_define_module module_name )
2014-08-01 22:11:20 +08:00
ocv_debug_message ( "ocv_define_module(" ${ module_name } ${ ARGN } ")" )
2014-03-05 16:31:04 +08:00
set ( _argn ${ ARGN } )
set ( exclude_cuda "" )
foreach ( arg ${ _argn } )
if ( "${arg}" STREQUAL "EXCLUDE_CUDA" )
set ( exclude_cuda "${arg}" )
list ( REMOVE_ITEM _argn ${ arg } )
2014-03-05 15:25:27 +08:00
endif ( )
endforeach ( )
2014-03-05 16:31:04 +08:00
ocv_add_module ( ${ module_name } ${ _argn } )
ocv_glob_module_sources ( ${ exclude_cuda } )
2014-08-01 22:11:20 +08:00
ocv_module_include_directories ( )
2012-02-03 19:26:49 +08:00
ocv_create_module ( )
ocv_add_accuracy_tests ( )
ocv_add_perf_tests ( )
2013-09-04 22:41:19 +08:00
ocv_add_samples ( )
2012-02-03 19:26:49 +08:00
endmacro ( )
2010-12-29 00:24:23 +08:00
2012-02-03 19:26:49 +08:00
# ensures that all passed modules are available
# sets OCV_DEPENDENCIES_FOUND variable to TRUE/FALSE
macro ( ocv_check_dependencies )
set ( OCV_DEPENDENCIES_FOUND TRUE )
foreach ( d ${ ARGN } )
if ( d MATCHES "^opencv_[^ ]+$" AND NOT HAVE_ ${ d } )
set ( OCV_DEPENDENCIES_FOUND FALSE )
break ( )
2012-01-25 00:55:47 +08:00
endif ( )
2012-02-03 19:26:49 +08:00
endforeach ( )
2012-01-25 00:55:47 +08:00
endmacro ( )
2012-06-18 14:53:13 +08:00
# auxiliary macro to parse arguments of ocv_add_accuracy_tests and ocv_add_perf_tests commands
2012-02-03 19:26:49 +08:00
macro ( __ocv_parse_test_sources tests_type )
set ( OPENCV_ ${ tests_type } _ ${ the_module } _SOURCES "" )
set ( OPENCV_ ${ tests_type } _ ${ the_module } _DEPS "" )
set ( __file_group_name "" )
set ( __file_group_sources "" )
foreach ( arg "DEPENDS_ON" ${ ARGN } "FILES" )
if ( arg STREQUAL "FILES" )
set ( __currentvar "__file_group_sources" )
if ( __file_group_name AND __file_group_sources )
source_group ( "${__file_group_name}" FILES ${ __file_group_sources } )
list ( APPEND OPENCV_ ${ tests_type } _ ${ the_module } _SOURCES ${ __file_group_sources } )
endif ( )
set ( __file_group_name "" )
set ( __file_group_sources "" )
elseif ( arg STREQUAL "DEPENDS_ON" )
2014-08-01 22:11:20 +08:00
set ( __currentvar "OPENCV_${tests_type}_${the_module}_DEPS" )
2015-01-15 23:40:33 +08:00
elseif ( " ${__currentvar}" STREQUAL " __file_group_sources" AND NOT __file_group_name ) # spaces to avoid CMP0054
2012-02-03 19:26:49 +08:00
set ( __file_group_name "${arg}" )
else ( )
list ( APPEND ${ __currentvar } "${arg}" )
endif ( )
endforeach ( )
unset ( __file_group_name )
unset ( __file_group_sources )
unset ( __currentvar )
endmacro ( )
2012-01-25 00:55:47 +08:00
2012-02-03 19:26:49 +08:00
# this is a command for adding OpenCV performance tests to the module
# ocv_add_perf_tests(<extra_dependencies>)
2012-06-18 14:53:13 +08:00
function ( ocv_add_perf_tests )
2014-08-01 22:11:20 +08:00
ocv_debug_message ( "ocv_add_perf_tests(" ${ ARGN } ")" )
2015-05-18 16:57:18 +08:00
if ( WINRT )
set ( OPENCV_DEBUG_POSTFIX "" )
endif ( )
2014-08-01 22:11:20 +08:00
set ( perf_path "${CMAKE_CURRENT_LIST_DIR}/perf" )
2012-02-03 19:26:49 +08:00
if ( BUILD_PERF_TESTS AND EXISTS "${perf_path}" )
__ocv_parse_test_sources ( PERF ${ ARGN } )
2012-01-25 00:55:47 +08:00
2014-07-04 22:48:15 +08:00
# opencv_imgcodecs is required for imread/imwrite
2015-01-14 18:55:41 +08:00
set ( perf_deps opencv_ts ${ the_module } opencv_imgcodecs ${ OPENCV_MODULE_${the_module } _DEPS} ${ OPENCV_MODULE_opencv_ts_DEPS } )
2012-02-03 19:26:49 +08:00
ocv_check_dependencies ( ${ perf_deps } )
2012-01-25 00:55:47 +08:00
2012-02-03 19:26:49 +08:00
if ( OCV_DEPENDENCIES_FOUND )
set ( the_target "opencv_perf_${name}" )
2012-06-18 14:53:13 +08:00
# project(${the_target})
2012-03-26 03:57:58 +08:00
2012-02-03 19:26:49 +08:00
if ( NOT OPENCV_PERF_ ${ the_module } _SOURCES )
2013-11-22 20:51:01 +08:00
file ( GLOB_RECURSE perf_srcs "${perf_path}/*.cpp" )
file ( GLOB_RECURSE perf_hdrs "${perf_path}/*.hpp" "${perf_path}/*.h" )
2013-12-05 07:23:52 +08:00
ocv_source_group ( "Src" DIRBASE "${perf_path}" FILES ${ perf_srcs } )
ocv_source_group ( "Include" DIRBASE "${perf_path}" FILES ${ perf_hdrs } )
2012-02-03 19:26:49 +08:00
set ( OPENCV_PERF_ ${ the_module } _SOURCES ${ perf_srcs } ${ perf_hdrs } )
endif ( )
2011-07-25 03:22:58 +08:00
2014-08-01 22:11:20 +08:00
if ( NOT BUILD_opencv_world )
get_native_precompiled_header ( ${ the_target } perf_precomp.hpp )
endif ( )
2013-08-08 20:23:20 +08:00
2014-08-01 22:11:20 +08:00
ocv_add_executable ( ${ the_target } ${ OPENCV_PERF_${the_module } _SOURCES} ${ ${the_target } _pch} )
ocv_target_include_modules ( ${ the_target } ${ perf_deps } "${perf_path}" )
2015-01-14 18:55:41 +08:00
ocv_target_link_libraries ( ${ the_target } ${ perf_deps } ${ OPENCV_MODULE_${the_module } _DEPS} ${ OPENCV_LINKER_LIBS } )
2012-03-02 16:48:33 +08:00
add_dependencies ( opencv_perf_tests ${ the_target } )
2012-01-25 21:12:11 +08:00
2012-02-03 19:26:49 +08:00
# Additional target properties
set_target_properties ( ${ the_target } PROPERTIES
D E B U G _ P O S T F I X " $ { O P E N C V _ D E B U G _ P O S T F I X } "
R U N T I M E _ O U T P U T _ D I R E C T O R Y " $ { E X E C U T A B L E _ O U T P U T _ P A T H } "
)
if ( ENABLE_SOLUTION_FOLDERS )
set_target_properties ( ${ the_target } PROPERTIES FOLDER "tests performance" )
endif ( )
2015-05-18 16:57:18 +08:00
if ( WINRT )
# removing APPCONTAINER from tests to run from console
# look for detailed description inside of ocv_create_module macro above
add_custom_command ( TARGET "opencv_perf_${name}"
P O S T _ B U I L D
C O M M A N D l i n k . e x e / e d i t / A P P C O N T A I N E R : N O $ ( T a r g e t P a t h ) )
endif ( )
2014-08-01 22:11:20 +08:00
if ( NOT BUILD_opencv_world )
_ocv_add_precompiled_headers ( ${ the_target } )
endif ( )
2012-02-03 19:26:49 +08:00
else ( OCV_DEPENDENCIES_FOUND )
2012-06-18 14:53:13 +08:00
# TODO: warn about unsatisfied dependencies
2012-02-03 19:26:49 +08:00
endif ( OCV_DEPENDENCIES_FOUND )
2014-01-27 18:20:30 +08:00
if ( INSTALL_TESTS )
2014-01-29 16:01:06 +08:00
install ( TARGETS ${ the_target } RUNTIME DESTINATION ${ OPENCV_TEST_INSTALL_PATH } COMPONENT tests )
2014-01-27 18:20:30 +08:00
endif ( )
2012-02-03 19:26:49 +08:00
endif ( )
2012-06-18 14:53:13 +08:00
endfunction ( )
2012-02-02 22:06:13 +08:00
2012-02-03 19:26:49 +08:00
# 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>)
2012-06-18 14:53:13 +08:00
function ( ocv_add_accuracy_tests )
2014-08-01 22:11:20 +08:00
ocv_debug_message ( "ocv_add_accuracy_tests(" ${ ARGN } ")" )
2015-05-18 16:57:18 +08:00
if ( WINRT )
set ( OPENCV_DEBUG_POSTFIX "" )
endif ( )
2014-08-01 22:11:20 +08:00
set ( test_path "${CMAKE_CURRENT_LIST_DIR}/test" )
2012-02-03 19:26:49 +08:00
if ( BUILD_TESTS AND EXISTS "${test_path}" )
__ocv_parse_test_sources ( TEST ${ ARGN } )
2014-07-04 22:48:15 +08:00
# opencv_imgcodecs is required for imread/imwrite
2015-01-14 18:55:41 +08:00
set ( test_deps opencv_ts ${ the_module } opencv_imgcodecs opencv_videoio ${ OPENCV_MODULE_${the_module } _DEPS} ${ OPENCV_MODULE_opencv_ts_DEPS } )
2012-02-03 19:26:49 +08:00
ocv_check_dependencies ( ${ test_deps } )
if ( OCV_DEPENDENCIES_FOUND )
set ( the_target "opencv_test_${name}" )
2012-06-18 14:53:13 +08:00
# project(${the_target})
2012-03-26 03:57:58 +08:00
2012-02-03 19:26:49 +08:00
if ( NOT OPENCV_TEST_ ${ the_module } _SOURCES )
2013-11-22 20:51:01 +08:00
file ( GLOB_RECURSE test_srcs "${test_path}/*.cpp" )
file ( GLOB_RECURSE test_hdrs "${test_path}/*.hpp" "${test_path}/*.h" )
2013-12-05 07:23:52 +08:00
ocv_source_group ( "Src" DIRBASE "${test_path}" FILES ${ test_srcs } )
ocv_source_group ( "Include" DIRBASE "${test_path}" FILES ${ test_hdrs } )
2012-02-03 19:26:49 +08:00
set ( OPENCV_TEST_ ${ the_module } _SOURCES ${ test_srcs } ${ test_hdrs } )
endif ( )
2012-03-26 03:57:58 +08:00
2014-08-01 22:11:20 +08:00
if ( NOT BUILD_opencv_world )
get_native_precompiled_header ( ${ the_target } test_precomp.hpp )
endif ( )
2013-08-08 20:23:20 +08:00
2014-08-01 22:11:20 +08:00
ocv_add_executable ( ${ the_target } ${ OPENCV_TEST_${the_module } _SOURCES} ${ ${the_target } _pch} )
ocv_target_include_modules ( ${ the_target } ${ test_deps } "${test_path}" )
2015-01-14 18:55:41 +08:00
ocv_target_link_libraries ( ${ the_target } ${ test_deps } ${ OPENCV_MODULE_${the_module } _DEPS} ${ OPENCV_LINKER_LIBS } )
2012-03-02 16:48:33 +08:00
add_dependencies ( opencv_tests ${ the_target } )
2012-01-25 00:55:47 +08:00
2012-02-03 19:26:49 +08:00
# Additional target properties
set_target_properties ( ${ the_target } PROPERTIES
D E B U G _ P O S T F I X " $ { O P E N C V _ D E B U G _ P O S T F I X } "
R U N T I M E _ O U T P U T _ D I R E C T O R Y " $ { E X E C U T A B L E _ O U T P U T _ P A T H } "
)
if ( ENABLE_SOLUTION_FOLDERS )
set_target_properties ( ${ the_target } PROPERTIES FOLDER "tests accuracy" )
endif ( )
2012-03-26 03:57:58 +08:00
2012-02-03 19:26:49 +08:00
enable_testing ( )
get_target_property ( LOC ${ the_target } LOCATION )
add_test ( ${ the_target } "${LOC}" )
2015-05-18 16:57:18 +08:00
if ( WINRT )
# removing APPCONTAINER from tests to run from console
# look for detailed description inside of ocv_create_module macro above
add_custom_command ( TARGET "opencv_test_${name}"
P O S T _ B U I L D
C O M M A N D l i n k . e x e / e d i t / A P P C O N T A I N E R : N O $ ( T a r g e t P a t h ) )
endif ( )
2014-08-01 22:11:20 +08:00
if ( NOT BUILD_opencv_world )
_ocv_add_precompiled_headers ( ${ the_target } )
endif ( )
2012-02-03 19:26:49 +08:00
else ( OCV_DEPENDENCIES_FOUND )
2012-06-18 14:53:13 +08:00
# TODO: warn about unsatisfied dependencies
2012-02-03 19:26:49 +08:00
endif ( OCV_DEPENDENCIES_FOUND )
2014-01-27 18:20:30 +08:00
if ( INSTALL_TESTS )
2014-01-29 16:01:06 +08:00
install ( TARGETS ${ the_target } RUNTIME DESTINATION ${ OPENCV_TEST_INSTALL_PATH } COMPONENT tests )
2014-01-27 18:20:30 +08:00
endif ( )
2012-02-03 19:26:49 +08:00
endif ( )
2012-06-18 14:53:13 +08:00
endfunction ( )
2012-01-25 21:12:11 +08:00
2013-09-04 22:41:19 +08:00
function ( ocv_add_samples )
2014-08-01 22:11:20 +08:00
ocv_debug_message ( "ocv_add_samples(" ${ ARGN } ")" )
2013-09-04 22:41:19 +08:00
set ( samples_path "${CMAKE_CURRENT_SOURCE_DIR}/samples" )
string ( REGEX REPLACE "^opencv_" "" module_id ${ the_module } )
if ( BUILD_EXAMPLES AND EXISTS "${samples_path}" )
2014-07-10 22:27:32 +08:00
set ( samples_deps ${ the_module } ${ OPENCV_MODULE_${the_module } _DEPS} opencv_imgcodecs opencv_videoio opencv_highgui ${ ARGN } )
2013-09-04 22:41:19 +08:00
ocv_check_dependencies ( ${ samples_deps } )
if ( OCV_DEPENDENCIES_FOUND )
file ( GLOB sample_sources "${samples_path}/*.cpp" )
foreach ( source ${ sample_sources } )
get_filename_component ( name "${source}" NAME_WE )
set ( the_target "example_${module_id}_${name}" )
2014-08-01 22:11:20 +08:00
ocv_add_executable ( ${ the_target } "${source}" )
ocv_target_include_modules ( ${ the_target } ${ samples_deps } )
ocv_target_link_libraries ( ${ the_target } ${ samples_deps } )
2013-09-04 22:41:19 +08:00
set_target_properties ( ${ the_target } PROPERTIES PROJECT_LABEL "(sample) ${name}" )
if ( ENABLE_SOLUTION_FOLDERS )
set_target_properties ( ${ the_target } PROPERTIES
O U T P U T _ N A M E " $ { m o d u l e _ i d } - e x a m p l e - $ { n a m e } "
F O L D E R " s a m p l e s / $ { m o d u l e _ i d } " )
endif ( )
if ( WIN32 )
2014-01-17 20:30:31 +08:00
install ( TARGETS ${ the_target } RUNTIME DESTINATION "samples/${module_id}" COMPONENT samples )
2013-09-04 22:41:19 +08:00
endif ( )
endforeach ( )
endif ( )
endif ( )
if ( INSTALL_C_EXAMPLES AND NOT WIN32 AND EXISTS "${samples_path}" )
2014-08-20 22:13:13 +08:00
file ( GLOB DEPLOY_FILES_AND_DIRS "${samples_path}/*" )
foreach ( ITEM ${ DEPLOY_FILES_AND_DIRS } )
IF ( IS_DIRECTORY "${ITEM}" )
LIST ( APPEND sample_dirs "${ITEM}" )
ELSE ( )
LIST ( APPEND sample_files "${ITEM}" )
ENDIF ( )
endforeach ( )
2013-09-04 22:41:19 +08:00
install ( FILES ${ sample_files }
2014-01-27 21:57:11 +08:00
D E S T I N A T I O N $ { O P E N C V _ S A M P L E S _ S R C _ I N S T A L L _ P A T H } / $ { m o d u l e _ i d }
2014-01-17 20:30:31 +08:00
P E R M I S S I O N S O W N E R _ R E A D G R O U P _ R E A D W O R L D _ R E A D C O M P O N E N T s a m p l e s )
2014-08-20 22:13:13 +08:00
install ( DIRECTORY ${ sample_dirs }
D E S T I N A T I O N $ { O P E N C V _ S A M P L E S _ S R C _ I N S T A L L _ P A T H } / $ { m o d u l e _ i d }
U S E _ S O U R C E _ P E R M I S S I O N S C O M P O N E N T s a m p l e s )
2013-09-04 22:41:19 +08:00
endif ( )
endfunction ( )