@ -6,16 +6,19 @@
# G l o b a l v a r i a b l e s :
#
# 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
# O P E N C V _ M O D U L E _ $ { t h e _ m o d u l e } _ B I N A R Y _ D I R
# O P E N C V _ M O D U L E _ $ { t h e _ m o d u l e } _ D E S C R I P T I O N
# 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 - P U B L I C | I N T E R N A L | B I N D I N G S
# O P E N C V _ M O D U L E _ $ { t h e _ m o d u l e } _ H E A D E R S
# O P E N C V _ M O D U L E _ $ { t h e _ m o d u l e } _ S O U R C E S
# O P E N C V _ M O D U L E _ $ { t h e _ m o d u l e } _ D E P S - f i n a l f l a t t e n e d s e t o f m o d u l e d e p e n d e n c i e s
# O P E N C V _ M O D U L E _ $ { t h e _ m o d u l e } _ D E P S _ T O _ L I N K - d i f f e r s f r o m a b o v e f o r w o r l d b u i l d o n l y
# O P E N C V _ M O D U L E _ $ { t h e _ m o d u l e } _ D E P S _ E X T - n o n - m o d u l e d e p e n d e n c i e s
# O P E N C V _ M O D U L E _ $ { t h e _ m o d u l e } _ R E Q _ D E P S
# O P E N C V _ M O D U L E _ $ { t h e _ m o d u l e } _ O P T _ D E P S
# O P E N C V _ M O D U L E _ $ { t h e _ m o d u l e } _ P R I V A T E _ R E Q _ D E P S
# O P E N C V _ M O D U L E _ $ { t h e _ m o d u l e } _ P R I V A T E _ O P T _ D E P S
# O P E N C V _ M O D U L E _ $ { t h e _ m o d u l e } _ I S _ P A R T _ O F _ W O R L D
# H A V E _ $ { t h e _ m o d u l e } - f o r f a s t c h e c k o f m o d u l e a v a i l a b i l i t y
# T o c o n t r o l t h e s e t u p o f t h e m o d u l e y o u c o u l d a l s o s e t :
@ -53,6 +56,7 @@ foreach(mod ${OPENCV_MODULES_BUILD} ${OPENCV_MODULES_DISABLED_USER} ${OPENCV_MOD
unset ( OPENCV_MODULE_ ${ mod } _OPT_DEPS CACHE )
unset ( OPENCV_MODULE_ ${ mod } _PRIVATE_REQ_DEPS CACHE )
unset ( OPENCV_MODULE_ ${ mod } _PRIVATE_OPT_DEPS CACHE )
unset ( OPENCV_MODULE_ ${ mod } _LINK_DEPS CACHE )
endforeach ( )
# c l e a n m o d u l e s i n f o w h i c h n e e d s t o b e r e c a l c u l a t e d
@ -61,6 +65,7 @@ set(OPENCV_MODULES_BUILD "" CACHE INTERNAL "List of OpenCV modules incl
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" )
unset ( OPENCV_WORLD_MODULES CACHE )
# a d d s d e p e n d e n c i e s t o O p e n C V m o d u l e
# U s a g e :
@ -68,6 +73,7 @@ set(OPENCV_MODULES_DISABLED_FORCE "" CACHE INTERNAL "List of OpenCV modules whic
# N o t e s :
# * < l i s t o f d e p e n d e n c i e s > - c a n i n c l u d e f u l l n a m e s o f m o d u l e s o r f u l l p a t h e s t o s h a r e d / s t a t i c l i b r a r i e s o r c m a k e t a r g e t s
macro ( ocv_add_dependencies full_modname )
ocv_debug_message ( "ocv_add_dependencies(" ${ full_modname } ${ ARGN } ")" )
# w e d o n ' t c l e a n t h e d e p e n d e n c i e s h e r e t o a l l o w t h i s m a c r o s e v e r a l t i m e s f o r e v e r y m o d u l e
foreach ( d "REQUIRED" ${ ARGN } )
if ( d STREQUAL "REQUIRED" )
@ -105,6 +111,7 @@ endmacro()
# E x a m p l e :
# ocv_add_module ( yaom INTERNAL opencv_core opencv_highgui opencv_flann OPTIONAL opencv_cuda )
macro ( ocv_add_module _name )
ocv_debug_message ( "ocv_add_module(" ${ _name } ${ ARGN } ")" )
string ( TOLOWER "${_name}" name )
string ( REGEX REPLACE "^opencv_" "" ${ name } "${name}" )
set ( the_module opencv_ ${ name } )
@ -134,6 +141,8 @@ macro(ocv_add_module _name)
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" )
set ( OPENCV_MODULE_ ${ the_module } _LINK_DEPS "" CACHE INTERNAL "" )
# p a r s e l i s t o f d e p e n d e n c i e s
if ( "${ARGV1}" STREQUAL "INTERNAL" OR "${ARGV1}" STREQUAL "BINDINGS" )
set ( OPENCV_MODULE_ ${ the_module } _CLASS "${ARGV1}" CACHE INTERNAL "The category of the module" )
@ -150,8 +159,14 @@ macro(ocv_add_module _name)
endif ( )
# a d d s e l f t o t h e w o r l d d e p e n d e n c i e s
if ( NOT DEFINED OPENCV_MODULE_IS_PART_OF_WORLD AND NOT OPENCV_MODULE_ ${ the_module } _CLASS STREQUAL "BINDINGS" OR OPENCV_MODULE_IS_PART_OF_WORLD )
if ( ( NOT DEFINED OPENCV_MODULE_IS_PART_OF_WORLD AND NOT OPENCV_MODULE_ ${ the_module } _CLASS STREQUAL "BINDINGS"
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 )
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 "" )
ocv_add_dependencies ( opencv_world OPTIONAL ${ the_module } )
else ( )
set ( OPENCV_MODULE_ ${ the_module } _IS_PART_OF_WORLD OFF CACHE INTERNAL "" )
endif ( )
if ( BUILD_ ${ the_module } )
@ -164,12 +179,15 @@ macro(ocv_add_module _name)
# s t o p p r o c e s s i n g o f c u r r e n t f i l e
return ( )
else ( OPENCV_INITIAL_PASS )
else ( )
set ( OPENCV_MODULE_ ${ the_module } _BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE INTERNAL "" )
if ( NOT BUILD_ ${ the_module } )
return ( ) # e x t r a p r o t e c t i o n f r o m r e d e f i n i t i o n
endif ( )
project ( ${ the_module } )
endif ( OPENCV_INITIAL_PASS )
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 ( )
endmacro ( )
# e x c l u d e s m o d u l e f r o m c u r r e n t c o n f i g u r a t i o n
@ -200,7 +218,11 @@ macro(ocv_glob_modules)
# c o l l e c t m o d u l e s
set ( OPENCV_INITIAL_PASS ON )
set ( OPENCV_PROCESSING_EXTRA_MODULES 0 )
foreach ( __path ${ ARGN } )
if ( "${__path}" STREQUAL "EXTRA" )
set ( OPENCV_PROCESSING_EXTRA_MODULES 1 )
endif ( )
get_filename_component ( __path "${__path}" ABSOLUTE )
list ( FIND __directories_observed "${__path}" __pathIdx )
@ -222,16 +244,7 @@ macro(ocv_glob_modules)
endif ( )
list ( APPEND __directories_observed "${__modpath}" )
if ( OCV_MODULE_RELOCATE_ON_INITIAL_PASS )
file ( MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}" )
file ( COPY "${__modpath}/CMakeLists.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}" )
add_subdirectory ( "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}" "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}" )
if ( "${OPENCV_MODULE_opencv_${mod}_LOCATION}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}" )
set ( OPENCV_MODULE_opencv_ ${ mod } _LOCATION "${__modpath}" CACHE PATH "" FORCE )
endif ( )
else ( )
add_subdirectory ( "${__modpath}" "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}" )
endif ( )
add_subdirectory ( "${__modpath}" "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}" )
endif ( )
endforeach ( )
endif ( )
@ -244,15 +257,31 @@ macro(ocv_glob_modules)
# c r e a t e m o d u l e s
set ( OPENCV_INITIAL_PASS OFF PARENT_SCOPE )
set ( OPENCV_INITIAL_PASS OFF )
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 ( )
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 ( )
unset ( __shortname )
endmacro ( )
@ -394,11 +423,36 @@ function(__ocv_resolve_dependencies)
__ocv_sort_modules_by_deps ( OPENCV_MODULE_ ${ m } _DEPS )
ocv_list_sort ( OPENCV_MODULE_ ${ m } _DEPS_EXT )
set ( LINK_DEPS ${ OPENCV_MODULE_${m } _DEPS} )
# p r o c e s s w o r l d
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 ( )
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" )
set ( OPENCV_MODULE_ ${ m } _DEPS_TO_LINK ${ LINK_DEPS } CACHE INTERNAL "Flattened dependencies of ${m} module (for linker)" )
# message ( STATUS " module deps: ${OPENCV_MODULE_${m}_DEPS}" )
# message ( STATUS " extra deps: ${OPENCV_MODULE_${m}_DEPS_EXT}" )
# 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 "" )
endforeach ( )
__ocv_sort_modules_by_deps ( OPENCV_MODULES_BUILD )
@ -406,6 +460,7 @@ function(__ocv_resolve_dependencies)
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" )
set ( OPENCV_WORLD_MODULES ${ OPENCV_WORLD_MODULES } CACHE INTERNAL "List of OpenCV modules included into the world" )
endfunction ( )
@ -422,18 +477,31 @@ macro(ocv_include_modules)
endforeach ( )
endmacro ( )
# s e t u p i n c l u d e p a t h s f o r t h e l i s t o f p a s s e d m o d u l e s
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 ( )
# s e t u p i n c l u d e p a t h s f o r t h e l i s t o f p a s s e d m o d u l e s a n d r e c u r s i v e l y a d d d e p e n d e n t m o d u l e s
macro ( ocv_include_modules_recurse )
macro ( ocv_target_ include_modules_recurse target )
foreach ( d ${ ARGN } )
if ( d MATCHES "^opencv_" AND HAVE_ ${ d } )
if ( EXISTS "${OPENCV_MODULE_${d}_LOCATION}/include" )
ocv_include_directories ( "${OPENCV_MODULE_${d}_LOCATION}/include" )
ocv_target_ include_directories ( ${ target } "${OPENCV_MODULE_${d}_LOCATION}/include" )
endif ( )
if ( OPENCV_MODULE_ ${ d } _DEPS )
ocv_include_modules ( ${ OPENCV_MODULE_${d } _DEPS} )
ocv_target_ include_modules ( ${ target } ${ OPENCV_MODULE_${d } _DEPS} )
endif ( )
elseif ( EXISTS "${d}" )
ocv_include_directories ( "${d}" )
ocv_target_ include_directories ( ${ target } "${d}" )
endif ( )
endforeach ( )
endmacro ( )
@ -441,11 +509,12 @@ endmacro()
# s e t u p i n c l u d e p a t h f o r O p e n C V h e a d e r s f o r s p e c i f i e d m o d u l e
# ocv_module_include_directories ( <extra include directories/extra include modules> )
macro ( ocv_module_include_directories )
ocv_include_directories ( "${OPENCV_MODULE_${the_module}_LOCATION}/include"
" $ { 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 } " # f o r p r e c o m p i l e d h e a d e r s
)
ocv_include_modules ( ${ OPENCV_MODULE_${the_module } _DEPS} ${ ARGN } )
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 } " # f o r p r e c o m p i l e d h e a d e r s
)
ocv_target_include_modules ( ${ the_module } ${ OPENCV_MODULE_${the_module } _DEPS} ${ ARGN } )
endmacro ( )
@ -454,6 +523,8 @@ endmacro()
# U s a g e :
# ocv_set_module_sources ( [HEADERS] <list of files> [SOURCES] <list of files> )
macro ( ocv_set_module_sources )
ocv_debug_message ( "ocv_set_module_sources(" ${ ARGN } ")" )
set ( OPENCV_MODULE_ ${ the_module } _HEADERS "" )
set ( OPENCV_MODULE_ ${ the_module } _SOURCES "" )
@ -481,31 +552,50 @@ endmacro()
# U s a g e :
# ocv_glob_module_sources ( [EXCLUDE_CUDA] <extra sources&headers in the same format as used in ocv_set_module_sources> )
macro ( ocv_glob_module_sources )
ocv_debug_message ( "ocv_glob_module_sources(" ${ ARGN } ")" )
set ( _argn ${ ARGN } )
list ( FIND _argn "EXCLUDE_CUDA" exclude_cuda )
if ( NOT exclude_cuda EQUAL -1 )
list ( REMOVE_AT _argn ${ exclude_cuda } )
endif ( )
file ( GLOB_RECURSE lib_srcs "src/*.cpp" )
file ( GLOB_RECURSE lib_int_hdrs "src/*.hpp" "src/*.h" )
file ( GLOB lib_hdrs "include/opencv2/*.hpp" "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h" )
file ( GLOB lib_hdrs_detail "include/opencv2/${name}/detail/*.hpp" "include/opencv2/${name}/detail/*.h" )
file ( GLOB_RECURSE lib_srcs_apple "src/*.mm" )
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 "
)
if ( APPLE )
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 "
)
list ( APPEND lib_srcs ${ lib_srcs_apple } )
endif ( )
ocv_source_group ( "Src" DIRBASE "${CMAKE_CURRENT_SOURCE_DIR}/src" FILES ${ lib_srcs } ${ lib_int_hdrs } )
ocv_source_group ( "Include" DIRBASE "${CMAKE_CURRENT_SOURCE_DIR}/include" FILES ${ lib_hdrs } ${ lib_hdrs_detail } )
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 } )
if ( exclude_cuda EQUAL -1 )
file ( GLOB lib_cuda_srcs "src/cuda/*.cu" )
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 "
)
set ( cuda_objs "" )
set ( lib_cuda_hdrs "" )
if ( HAVE_CUDA )
ocv_include_directories ( ${ CUDA_INCLUDE_DIRS } )
file ( GLOB lib_cuda_hdrs "src/cuda/*.hpp" )
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 "
)
ocv_cuda_compile ( cuda_objs ${ lib_cuda_srcs } ${ lib_cuda_hdrs } )
source_group ( "Src\\Cuda" FILES ${ lib_cuda_srcs } ${ lib_cuda_hdrs } )
@ -516,17 +606,19 @@ macro(ocv_glob_module_sources)
set ( lib_cuda_hdrs "" )
endif ( )
file ( GLOB cl_kernels "src/opencl/*.cl" )
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 "
)
if ( cl_kernels )
set ( OCL_NAME opencl_kernels_ ${ name } )
ocv_include_directories ( ${ OPENCL_INCLUDE_DIRS } )
string ( REGEX REPLACE "opencv_" "" the_module_barename "${the_module}" )
add_custom_command (
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 p e n c l _ k e r n e l s . 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 p e n c l _ k e r n e l s . h p p "
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 = " $ { t h e _ m o d u l e _ b a r e n a m e } " - D C L _ D I R = " $ { C M A K E _ C U R R E N T _ S O U R C E _ 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 p e n c l _ k e r n e l s . 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 "
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 "
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 "
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 " )
ocv_source_group ( "Src\\opencl\\kernels" FILES ${ cl_kernels } )
ocv_source_group ( "Src\\opencl\\kernels\\autogenerated" FILES "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels .hpp" )
list ( APPEND lib_srcs ${ cl_kernels } "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels .hpp" )
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" )
endif ( )
ocv_set_module_sources ( ${ _argn } HEADERS ${ lib_hdrs } ${ lib_hdrs_detail }
@ -537,29 +629,39 @@ endmacro()
# c r e a t e s n e w t a r g e t , c o n f i g u r e s s t a n d a r d d e p e n d e n c i e s , c o m p i l e r s f l a g s , i n s t a l l r u l e s
# U s a g e :
# ocv_create_module ( <extra link dependencies> )
# ocv_create_module ( SKIP_LINK )
# ocv_create_module ( )
macro ( ocv_create_module )
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 )
# n o t h i n g
set ( the_module_target opencv_world )
else ( )
_ocv_create_module ( ${ ARGN } )
set ( the_module_target ${ the_module } )
endif ( )
endmacro ( )
macro ( _ocv_create_module )
# T h e c o n d i t i o n w e o u g h t t o b e t e s t i n g h e r e i s w h e t h e r o c v _ a d d _ p r e c o m p i l e d _ h e a d e r s w i l l
# b e c a l l e d a t s o m e p o i n t i n t h e f u t u r e . W e c a n ' t l o o k i n t o t h e f u t u r e , t h o u g h ,
# s o t h i s w i l l h a v e t o d o .
if ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/precomp.hpp" )
if ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/precomp.hpp" AND NOT ${ the_module } STREQUAL opencv_world )
get_native_precompiled_header ( ${ the_module } precomp.hpp )
endif ( )
add_library ( ${ the_module } ${ OPENCV_MODULE_TYPE } ${ OPENCV_MODULE_${the_module } _HEADERS} ${ OPENCV_MODULE_${the_module } _SOURCES}
ocv_ add_library( ${ the_module } ${ OPENCV_MODULE_TYPE } ${ OPENCV_MODULE_${the_module } _HEADERS} ${ OPENCV_MODULE_${the_module } _SOURCES}
" $ { 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 "
$ { $ { t h e _ m o d u l e } _ p c h } )
if ( NOT the_module STREQUAL opencv_ts )
set_target_properties ( ${ the_module } PROPERTIES COMPILE_DEFINITIONS OPENCV_NOSTL )
endif ( )
if ( NOT "${ARGN}" STREQUAL "SKIP_LINK" )
target_link_libraries ( ${ the_module } ${ OPENCV_MODULE_${the_module } _DEPS} )
target_link_libraries ( ${ the_module } LINK_INTERFACE_LIBRARIES ${ OPENCV_MODULE_${the_module } _DEPS} )
target_link_libraries ( ${ the_module } ${ 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 ( )
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 } )
endif ( )
add_dependencies ( opencv_modules ${ the_module } )
@ -614,13 +716,16 @@ macro(ocv_create_module)
endif ( )
endforeach ( )
endif ( )
_ocv_add_precompiled_headers ( ${ the_module } )
endmacro ( )
# o p e n c v p r e c o m p i l e d h e a d e r s macro ( can add pch to modules and tests )
# t h i s m a c r o m u s t b e c a l l e d a f t e r a n y " a d d _ d e f i n i t i o n s " c o m m a n d s , o t h e r w i s e p r e c o m p i l e d h e a d e r s w i l l n o t w o r k
# U s a g e :
# ocv_add_precompiled_headers ( ${ the_module } )
macro ( ocv_add_precompiled_headers the_target )
macro ( _ocv_add_precompiled_headers the_target )
ocv_debug_message ( "ocv_add_precompiled_headers(" ${ the_target } ${ ARGN } ")" )
if ( "${the_target}" MATCHES "^opencv_test_.*$" )
SET ( pch_path "test/test_" )
elseif ( "${the_target}" MATCHES "^opencv_perf_.*$" )
@ -637,6 +742,7 @@ endmacro()
# U s a g e :
# ocv_define_module ( module_name [INTERNAL] [EXCLUDE_CUDA] [REQUIRED] [<list of dependencies>] [OPTIONAL <list of optional dependencies>] )
macro ( ocv_define_module module_name )
ocv_debug_message ( "ocv_define_module(" ${ module_name } ${ ARGN } ")" )
set ( _argn ${ ARGN } )
set ( exclude_cuda "" )
foreach ( arg ${ _argn } )
@ -647,10 +753,9 @@ macro(ocv_define_module module_name)
endforeach ( )
ocv_add_module ( ${ module_name } ${ _argn } )
ocv_module_include_directories ( )
ocv_glob_module_sources ( ${ exclude_cuda } )
ocv_module_include_directories ( )
ocv_create_module ( )
ocv_add_precompiled_headers ( ${ the_module } )
ocv_add_accuracy_tests ( )
ocv_add_perf_tests ( )
@ -685,7 +790,7 @@ macro(__ocv_parse_test_sources tests_type)
set ( __file_group_name "" )
set ( __file_group_sources "" )
elseif ( arg STREQUAL "DEPENDS_ON" )
set ( __currentvar "OPENCV_TEST _${the_module}_DEPS" )
set ( __currentvar "OPENCV_${tests_type} _${the_module}_DEPS" )
elseif ( "${__currentvar}" STREQUAL "__file_group_sources" AND NOT __file_group_name )
set ( __file_group_name "${arg}" )
else ( )
@ -700,20 +805,20 @@ endmacro()
# t h i s i s a c o m m a n d f o r a d d i n g O p e n C V p e r f o r m a n c e t e s t s t o t h e m o d u l e
# ocv_add_perf_tests ( <extra_dependencies> )
function ( ocv_add_perf_tests )
set ( perf_path "${CMAKE_CURRENT_SOURCE_DIR}/perf" )
ocv_debug_message ( "ocv_add_perf_tests(" ${ ARGN } ")" )
set ( perf_path "${CMAKE_CURRENT_LIST_DIR}/perf" )
if ( BUILD_PERF_TESTS AND EXISTS "${perf_path}" )
__ocv_parse_test_sources ( PERF ${ ARGN } )
# o p e n c v _ i m g c o d e c s i s r e q u i r e d f o r i m r e a d / i m w r i t e
set ( perf_deps ${ the_module } opencv_ts opencv_imgcodecs ${ OPENCV_PERF _${the_module } _DEPS} ${ OPENCV_MODULE_opencv_ts_DEPS } )
set ( perf_deps ${ the_module } opencv_ts opencv_imgcodecs ${ OPENCV_MODULE _${the_module } _DEPS} ${ OPENCV_MODULE_opencv_ts_DEPS } )
ocv_check_dependencies ( ${ perf_deps } )
if ( OCV_DEPENDENCIES_FOUND )
set ( the_target "opencv_perf_${name}" )
# project ( ${ the_target } )
ocv_module_include_directories ( ${ perf_deps } "${perf_path}" )
if ( NOT OPENCV_PERF_ ${ the_module } _SOURCES )
file ( GLOB_RECURSE perf_srcs "${perf_path}/*.cpp" )
file ( GLOB_RECURSE perf_hdrs "${perf_path}/*.hpp" "${perf_path}/*.h" )
@ -722,10 +827,13 @@ function(ocv_add_perf_tests)
set ( OPENCV_PERF_ ${ the_module } _SOURCES ${ perf_srcs } ${ perf_hdrs } )
endif ( )
get_native_precompiled_header ( ${ the_target } perf_precomp.hpp )
if ( NOT BUILD_opencv_world )
get_native_precompiled_header ( ${ the_target } perf_precomp.hpp )
endif ( )
add_executable ( ${ the_target } ${ OPENCV_PERF_${the_module } _SOURCES} ${ ${the_target } _pch} )
target_link_libraries ( ${ the_target } ${ OPENCV_MODULE_${the_module } _DEPS} ${ perf_deps } ${ OPENCV_LINKER_LIBS } )
ocv_add_executable ( ${ the_target } ${ OPENCV_PERF_${the_module } _SOURCES} ${ ${the_target } _pch} )
ocv_target_include_modules ( ${ the_target } ${ perf_deps } "${perf_path}" )
ocv_target_link_libraries ( ${ the_target } ${ OPENCV_MODULE_${the_module } _DEPS} ${ perf_deps } ${ OPENCV_LINKER_LIBS } )
add_dependencies ( opencv_perf_tests ${ the_target } )
# A d d i t i o n a l t a r g e t p r o p e r t i e s
@ -738,8 +846,9 @@ function(ocv_add_perf_tests)
set_target_properties ( ${ the_target } PROPERTIES FOLDER "tests performance" )
endif ( )
ocv_add_precompiled_headers ( ${ the_target } )
if ( NOT BUILD_opencv_world )
_ocv_add_precompiled_headers ( ${ the_target } )
endif ( )
else ( OCV_DEPENDENCIES_FOUND )
# T O D O : w a r n a b o u t u n s a t i s f i e d d e p e n d e n c i e s
endif ( OCV_DEPENDENCIES_FOUND )
@ -752,21 +861,19 @@ endfunction()
# t h i s i s a c o m m a n d f o r a d d i n g O p e n C V a c c u r a c y / r e g r e s s i o n t e s t s t o t h e m o d u l e
# ocv_add_accuracy_tests ( [FILES <source group name> <list of sources>] [DEPENDS_ON] <list of extra dependencies> )
function ( ocv_add_accuracy_tests )
set ( test_path "${CMAKE_CURRENT_SOURCE_DIR}/test" )
ocv_check_dependencies ( ${ test_deps } )
ocv_debug_message ( "ocv_add_accuracy_tests(" ${ ARGN } ")" )
set ( test_path "${CMAKE_CURRENT_LIST_DIR}/test" )
if ( BUILD_TESTS AND EXISTS "${test_path}" )
__ocv_parse_test_sources ( TEST ${ ARGN } )
# o p e n c v _ i m g c o d e c s i s r e q u i r e d f o r i m r e a d / i m w r i t e
set ( test_deps ${ the_module } opencv_ts opencv_imgcodecs opencv_videoio ${ OPENCV_TEST _${the_module } _DEPS} ${ OPENCV_MODULE_opencv_ts_DEPS } )
set ( test_deps ${ the_module } opencv_ts opencv_imgcodecs opencv_videoio ${ OPENCV_MODULE _${the_module } _DEPS} ${ OPENCV_MODULE_opencv_ts_DEPS } )
ocv_check_dependencies ( ${ test_deps } )
if ( OCV_DEPENDENCIES_FOUND )
set ( the_target "opencv_test_${name}" )
# project ( ${ the_target } )
ocv_module_include_directories ( ${ test_deps } "${test_path}" )
if ( NOT OPENCV_TEST_ ${ the_module } _SOURCES )
file ( GLOB_RECURSE test_srcs "${test_path}/*.cpp" )
file ( GLOB_RECURSE test_hdrs "${test_path}/*.hpp" "${test_path}/*.h" )
@ -775,10 +882,13 @@ function(ocv_add_accuracy_tests)
set ( OPENCV_TEST_ ${ the_module } _SOURCES ${ test_srcs } ${ test_hdrs } )
endif ( )
get_native_precompiled_header ( ${ the_target } test_precomp.hpp )
add_executable ( ${ the_target } ${ OPENCV_TEST_${the_module } _SOURCES} ${ ${the_target } _pch} )
if ( NOT BUILD_opencv_world )
get_native_precompiled_header ( ${ the_target } test_precomp.hpp )
endif ( )
target_link_libraries ( ${ the_target } ${ OPENCV_MODULE_${the_module } _DEPS} ${ test_deps } ${ OPENCV_LINKER_LIBS } )
ocv_add_executable ( ${ the_target } ${ OPENCV_TEST_${the_module } _SOURCES} ${ ${the_target } _pch} )
ocv_target_include_modules ( ${ the_target } ${ test_deps } "${test_path}" )
ocv_target_link_libraries ( ${ the_target } ${ OPENCV_MODULE_${the_module } _DEPS} ${ test_deps } ${ OPENCV_LINKER_LIBS } )
add_dependencies ( opencv_tests ${ the_target } )
# A d d i t i o n a l t a r g e t p r o p e r t i e s
@ -795,7 +905,9 @@ function(ocv_add_accuracy_tests)
get_target_property ( LOC ${ the_target } LOCATION )
add_test ( ${ the_target } "${LOC}" )
ocv_add_precompiled_headers ( ${ the_target } )
if ( NOT BUILD_opencv_world )
_ocv_add_precompiled_headers ( ${ the_target } )
endif ( )
else ( OCV_DEPENDENCIES_FOUND )
# T O D O : w a r n a b o u t u n s a t i s f i e d d e p e n d e n c i e s
endif ( OCV_DEPENDENCIES_FOUND )
@ -807,6 +919,8 @@ function(ocv_add_accuracy_tests)
endfunction ( )
function ( ocv_add_samples )
ocv_debug_message ( "ocv_add_samples(" ${ ARGN } ")" )
set ( samples_path "${CMAKE_CURRENT_SOURCE_DIR}/samples" )
string ( REGEX REPLACE "^opencv_" "" module_id ${ the_module } )
@ -816,15 +930,14 @@ function(ocv_add_samples)
if ( OCV_DEPENDENCIES_FOUND )
file ( GLOB sample_sources "${samples_path}/*.cpp" )
ocv_include_modules ( ${ OPENCV_MODULE_${the_module } _DEPS} )
foreach ( source ${ sample_sources } )
get_filename_component ( name "${source}" NAME_WE )
set ( the_target "example_${module_id}_${name}" )
add_executable ( ${ the_target } "${source}" )
target_link_librari es( ${ the_target } ${ samples_deps } )
ocv_ add_executable( ${ the_target } "${source}" )
ocv_target_include_modul es( ${ the_target } ${ samples_deps } )
ocv_target_link_libraries ( ${ the_target } ${ samples_deps } )
set_target_properties ( ${ the_target } PROPERTIES PROJECT_LABEL "(sample) ${name}" )
if ( ENABLE_SOLUTION_FOLDERS )
@ -847,82 +960,3 @@ function(ocv_add_samples)
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 )
endif ( )
endfunction ( )
# i n t e r n a l m a c r o ; f i n d s a l l l i n k d e p e n d e n c i e s o f t h e m o d u l e
# s h o u l d b e u s e d a t t h e e n d o f C M a k e p r o c e s s i n g
macro ( __ocv_track_module_link_dependencies the_module optkind )
set ( ${ the_module } _MODULE_DEPS_ ${ optkind } "" )
set ( ${ the_module } _EXTRA_DEPS_ ${ optkind } "" )
get_target_property ( __module_type ${ the_module } TYPE )
if ( __module_type STREQUAL "STATIC_LIBRARY" )
# i n c a s e o f s t a t i c l i b r a r y w e h a v e t o i n h e r i t i t s dependencies ( in right order!!! )
if ( NOT DEFINED ${ the_module } _LIB_DEPENDS_ ${ optkind } )
ocv_split_libs_list ( ${ the_module } _LIB_DEPENDS ${ the_module } _LIB_DEPENDS_DBG ${ the_module } _LIB_DEPENDS_OPT )
endif ( )
set ( __resolved_deps "" )
set ( __mod_depends ${ ${the_module } _LIB_DEPENDS_ ${ optkind } } )
set ( __has_cycle FALSE )
while ( __mod_depends )
list ( GET __mod_depends 0 __dep )
list ( REMOVE_AT __mod_depends 0 )
if ( __dep STREQUAL the_module )
set ( __has_cycle TRUE )
else ( ) # if ( "${OPENCV_MODULES_BUILD}" MATCHES "(^|;)${__dep}(;|$)" )
ocv_regex_escape ( __rdep "${__dep}" )
if ( __resolved_deps MATCHES "(^|;)${__rdep}(;|$)" )
# a l l d e p e n d e n c i e s o f t h i s m o d u l e a r e a l r e a d y r e s o l v e d
list ( APPEND ${ the_module } _MODULE_DEPS_ ${ optkind } "${__dep}" )
else ( )
get_target_property ( __module_type ${ __dep } TYPE )
if ( __module_type STREQUAL "STATIC_LIBRARY" )
if ( NOT DEFINED ${ __dep } _LIB_DEPENDS_ ${ optkind } )
ocv_split_libs_list ( ${ __dep } _LIB_DEPENDS ${ __dep } _LIB_DEPENDS_DBG ${ __dep } _LIB_DEPENDS_OPT )
endif ( )
list ( INSERT __mod_depends 0 ${ ${__dep } _LIB_DEPENDS_ ${ optkind } } ${ __dep } )
list ( APPEND __resolved_deps "${__dep}" )
elseif ( NOT __module_type )
list ( APPEND ${ the_module } _EXTRA_DEPS_ ${ optkind } "${__dep}" )
endif ( )
endif ( )
# else ( )
# get_target_property ( __dep_location "${__dep}" LOCATION )
endif ( )
endwhile ( )
ocv_list_unique ( ${ the_module } _MODULE_DEPS_ ${ optkind } )
# ocv_list_reverse ( ${ the_module } _MODULE_DEPS_ ${ optkind } )
ocv_list_unique ( ${ the_module } _EXTRA_DEPS_ ${ optkind } )
# ocv_list_reverse ( ${ the_module } _EXTRA_DEPS_ ${ optkind } )
if ( __has_cycle )
# n o t s u r e i f i t c a n w o r k
list ( APPEND ${ the_module } _MODULE_DEPS_ ${ optkind } "${the_module}" )
endif ( )
unset ( __dep_location )
unset ( __mod_depends )
unset ( __resolved_deps )
unset ( __has_cycle )
unset ( __rdep )
endif ( ) # S T A T I C _ L I B R A R Y
unset ( __module_type )
# message ( "${the_module}_MODULE_DEPS_${optkind}" )
# message ( " ${${the_module}_MODULE_DEPS_${optkind}}" )
# message ( " ${OPENCV_MODULE_${the_module}_DEPS}" )
# message ( "" )
# message ( "${the_module}_EXTRA_DEPS_${optkind}" )
# message ( " ${${the_module}_EXTRA_DEPS_${optkind}}" )
# message ( "" )
endmacro ( )
# c r e a t e s l i s t s o f b u i l d d e p e n d e n c i e s n e e d e d f o r e x t e r n a l p r o j e c t s
macro ( ocv_track_build_dependencies )
foreach ( m ${ OPENCV_MODULES_BUILD } )
__ocv_track_module_link_dependencies ( "${m}" OPT )
__ocv_track_module_link_dependencies ( "${m}" DBG )
endforeach ( )
endmacro ( )