1
# Local variables (set for each module):
3
# name - short name in lower case i.e. core
4
# the_module - full name in lower case i.e. opencv_core
8
# OPENCV_MODULE_${the_module}_LOCATION
9
# OPENCV_MODULE_${the_module}_BINARY_DIR
10
# OPENCV_MODULE_${the_module}_DESCRIPTION
11
# OPENCV_MODULE_${the_module}_CLASS - PUBLIC|INTERNAL|BINDINGS
12
# OPENCV_MODULE_${the_module}_HEADERS
13
# OPENCV_MODULE_${the_module}_SOURCES
14
# OPENCV_MODULE_${the_module}_DEPS - final flattened set of module dependencies
15
# OPENCV_MODULE_${the_module}_DEPS_TO_LINK - differs from above for world build only
16
# OPENCV_MODULE_${the_module}_DEPS_EXT - non-module dependencies
17
# OPENCV_MODULE_${the_module}_REQ_DEPS
18
# OPENCV_MODULE_${the_module}_OPT_DEPS
19
# OPENCV_MODULE_${the_module}_PRIVATE_REQ_DEPS
20
# OPENCV_MODULE_${the_module}_PRIVATE_OPT_DEPS
21
# OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD
22
# OPENCV_MODULE_${the_module}_CUDA_OBJECTS - compiled CUDA objects list
23
# OPENCV_MODULE_${the_module}_WRAPPERS - list of wrappers supporting this module
24
# HAVE_${the_module} - for fast check of module availability
26
# To control the setup of the module you could also set:
27
# the_description - text to be used as current module description
28
# the_label - label for current module
29
# OPENCV_MODULE_TYPE - STATIC|SHARED - set to force override global settings for current module
30
# OPENCV_MODULE_IS_PART_OF_WORLD - ON|OFF (default ON) - should the module be added to the opencv_world?
31
# BUILD_${the_module}_INIT - ON|OFF (default ON) - initial value for BUILD_${the_module}
33
# The verbose template for OpenCV module:
35
# ocv_add_module(modname <dependencies>)
36
# ocv_glob_module_sources(([EXCLUDE_OPENCL] [EXCLUDE_CUDA] <extra sources&headers>)
37
# or glob them manually and ocv_set_module_sources(...)
38
# ocv_module_include_directories(<extra include directories>)
40
# <add extra link dependencies, compiler options, etc>
41
# ocv_add_precompiled_headers(${the_module})
42
# <add extra installation rules>
43
# ocv_add_accuracy_tests(<extra dependencies>)
44
# ocv_add_perf_tests(<extra dependencies>)
45
# ocv_add_samples(<extra dependencies>)
48
# If module have no "extra" then you can define it in one line:
50
# ocv_define_module(modname <dependencies>)
52
# clean flags for modules enabled on previous cmake run
53
# this is necessary to correctly handle modules removal
54
foreach(mod ${OPENCV_MODULES_BUILD} ${OPENCV_MODULES_DISABLED_USER} ${OPENCV_MODULES_DISABLED_AUTO} ${OPENCV_MODULES_DISABLED_FORCE})
56
unset(HAVE_${mod} CACHE)
58
unset(OPENCV_MODULE_${mod}_DEPS CACHE)
59
unset(OPENCV_MODULE_${mod}_DEPS_EXT CACHE)
60
unset(OPENCV_MODULE_${mod}_REQ_DEPS CACHE)
61
unset(OPENCV_MODULE_${mod}_OPT_DEPS CACHE)
62
unset(OPENCV_MODULE_${mod}_PRIVATE_REQ_DEPS CACHE)
63
unset(OPENCV_MODULE_${mod}_PRIVATE_OPT_DEPS CACHE)
64
unset(OPENCV_MODULE_${mod}_LINK_DEPS CACHE)
65
unset(OPENCV_MODULE_${mod}_WRAPPERS CACHE)
68
# clean modules info which needs to be recalculated
69
set(OPENCV_MODULES_PUBLIC "" CACHE INTERNAL "List of OpenCV modules marked for export")
70
set(OPENCV_MODULES_BUILD "" CACHE INTERNAL "List of OpenCV modules included into the build")
71
set(OPENCV_MODULES_DISABLED_USER "" CACHE INTERNAL "List of OpenCV modules explicitly disabled by user")
72
set(OPENCV_MODULES_DISABLED_AUTO "" CACHE INTERNAL "List of OpenCV modules implicitly disabled due to dependencies")
73
set(OPENCV_MODULES_DISABLED_FORCE "" CACHE INTERNAL "List of OpenCV modules which can not be build in current configuration")
74
unset(OPENCV_WORLD_MODULES CACHE)
76
# adds dependencies to OpenCV module
78
# add_dependencies(opencv_<name> [REQUIRED] [<list of dependencies>] [OPTIONAL <list of modules>] [WRAP <list of wrappers>])
80
# * <list of dependencies> - can include full names of modules or full paths to shared/static libraries or cmake targets
81
macro(ocv_add_dependencies full_modname)
82
ocv_debug_message("ocv_add_dependencies(" ${full_modname} ${ARGN} ")")
83
#we don't clean the dependencies here to allow this macro several times for every module
84
foreach(d "REQUIRED" ${ARGN})
85
if(d STREQUAL "REQUIRED")
86
set(__depsvar OPENCV_MODULE_${full_modname}_REQ_DEPS)
87
elseif(d STREQUAL "OPTIONAL")
88
set(__depsvar OPENCV_MODULE_${full_modname}_OPT_DEPS)
89
elseif(d STREQUAL "PRIVATE_REQUIRED")
90
set(__depsvar OPENCV_MODULE_${full_modname}_PRIVATE_REQ_DEPS)
91
elseif(d STREQUAL "PRIVATE_OPTIONAL")
92
set(__depsvar OPENCV_MODULE_${full_modname}_PRIVATE_OPT_DEPS)
93
elseif(d STREQUAL "WRAP")
94
set(__depsvar OPENCV_MODULE_${full_modname}_WRAPPERS)
96
list(APPEND ${__depsvar} "${d}")
101
ocv_list_unique(OPENCV_MODULE_${full_modname}_REQ_DEPS)
102
ocv_list_unique(OPENCV_MODULE_${full_modname}_OPT_DEPS)
103
ocv_list_unique(OPENCV_MODULE_${full_modname}_PRIVATE_REQ_DEPS)
104
ocv_list_unique(OPENCV_MODULE_${full_modname}_PRIVATE_OPT_DEPS)
105
ocv_list_unique(OPENCV_MODULE_${full_modname}_WRAPPERS)
107
set(OPENCV_MODULE_${full_modname}_REQ_DEPS ${OPENCV_MODULE_${full_modname}_REQ_DEPS}
108
CACHE INTERNAL "Required dependencies of ${full_modname} module")
109
set(OPENCV_MODULE_${full_modname}_OPT_DEPS ${OPENCV_MODULE_${full_modname}_OPT_DEPS}
110
CACHE INTERNAL "Optional dependencies of ${full_modname} module")
111
set(OPENCV_MODULE_${full_modname}_PRIVATE_REQ_DEPS ${OPENCV_MODULE_${full_modname}_PRIVATE_REQ_DEPS}
112
CACHE INTERNAL "Required private dependencies of ${full_modname} module")
113
set(OPENCV_MODULE_${full_modname}_PRIVATE_OPT_DEPS ${OPENCV_MODULE_${full_modname}_PRIVATE_OPT_DEPS}
114
CACHE INTERNAL "Optional private dependencies of ${full_modname} module")
115
set(OPENCV_MODULE_${full_modname}_WRAPPERS ${OPENCV_MODULE_${full_modname}_WRAPPERS}
116
CACHE INTERNAL "List of wrappers supporting module ${full_modname}")
119
# declare new OpenCV module in current folder
121
# ocv_add_module(<name> [INTERNAL|BINDINGS] [REQUIRED] [<list of dependencies>] [OPTIONAL <list of optional dependencies>] [WRAP <list of wrappers>])
123
# ocv_add_module(yaom INTERNAL opencv_core opencv_highgui opencv_flann OPTIONAL opencv_cudev)
124
macro(ocv_add_module _name)
125
ocv_debug_message("ocv_add_module(" ${_name} ${ARGN} ")")
126
string(TOLOWER "${_name}" name)
127
set(the_module opencv_${name})
129
# the first pass - collect modules info, the second pass - create targets
130
if(OPENCV_INITIAL_PASS)
131
#guard against redefinition
132
if(";${OPENCV_MODULES_BUILD};${OPENCV_MODULES_DISABLED_USER};" MATCHES ";${the_module};")
133
message(FATAL_ERROR "Redefinition of the ${the_module} module.
134
at: ${CMAKE_CURRENT_SOURCE_DIR}
135
previously defined at: ${OPENCV_MODULE_${the_module}_LOCATION}
139
if(NOT DEFINED the_description)
140
set(the_description "The ${name} OpenCV module")
143
if(NOT DEFINED BUILD_${the_module}_INIT)
144
set(BUILD_${the_module}_INIT ON)
147
# create option to enable/disable this module
148
option(BUILD_${the_module} "Include ${the_module} module into the OpenCV build" ${BUILD_${the_module}_INIT})
150
# remember the module details
151
set(OPENCV_MODULE_${the_module}_DESCRIPTION "${the_description}" CACHE INTERNAL "Brief description of ${the_module} module")
152
set(OPENCV_MODULE_${the_module}_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "Location of ${the_module} module sources")
154
set(OPENCV_MODULE_${the_module}_LINK_DEPS "" CACHE INTERNAL "")
156
set(ADD_MODULE_ARGN ${ARGN})
157
ocv_cmake_hook(PRE_ADD_MODULE)
158
ocv_cmake_hook(PRE_ADD_MODULE_${the_module})
160
# parse list of dependencies
161
if(" ${ARGV1}" STREQUAL " INTERNAL" OR " ${ARGV1}" STREQUAL " BINDINGS")
162
set(OPENCV_MODULE_${the_module}_CLASS "${ARGV1}" CACHE INTERNAL "The category of the module")
163
set(__ocv_argn__ ${ADD_MODULE_ARGN})
164
list(REMOVE_AT __ocv_argn__ 0)
165
ocv_add_dependencies(${the_module} ${__ocv_argn__})
168
set(OPENCV_MODULE_${the_module}_CLASS "PUBLIC" CACHE INTERNAL "The category of the module")
169
ocv_add_dependencies(${the_module} ${ADD_MODULE_ARGN})
170
if(BUILD_${the_module})
171
set(OPENCV_MODULES_PUBLIC ${OPENCV_MODULES_PUBLIC} "${the_module}" CACHE INTERNAL "List of OpenCV modules marked for export")
175
# add self to the world dependencies
176
if((NOT DEFINED OPENCV_MODULE_IS_PART_OF_WORLD
177
AND NOT OPENCV_MODULE_${the_module}_CLASS STREQUAL "BINDINGS"
178
AND (NOT DEFINED OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD OR OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD)
179
AND (NOT OPENCV_PROCESSING_EXTRA_MODULES OR NOT OPENCV_WORLD_EXCLUDE_EXTRA_MODULES)
180
AND (NOT BUILD_SHARED_LIBS OR NOT "x${OPENCV_MODULE_TYPE}" STREQUAL "xSTATIC"))
181
OR OPENCV_MODULE_IS_PART_OF_WORLD
183
set(OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD ON CACHE INTERNAL "")
184
ocv_add_dependencies(opencv_world OPTIONAL ${the_module})
186
set(OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD OFF CACHE INTERNAL "")
189
if(NOT DEFINED the_label)
190
if(OPENCV_PROCESSING_EXTRA_MODULES)
191
set(the_label "Extra")
193
set(the_label "Main")
196
set(OPENCV_MODULE_${the_module}_LABEL "${the_label};${the_module}" CACHE INTERNAL "")
198
if(BUILD_${the_module})
199
set(OPENCV_MODULES_BUILD ${OPENCV_MODULES_BUILD} "${the_module}" CACHE INTERNAL "List of OpenCV modules included into the build")
201
set(OPENCV_MODULES_DISABLED_USER ${OPENCV_MODULES_DISABLED_USER} "${the_module}" CACHE INTERNAL "List of OpenCV modules explicitly disabled by user")
204
# stop processing of current file
205
ocv_cmake_hook(POST_ADD_MODULE)
206
ocv_cmake_hook(POST_ADD_MODULE_${the_module})
209
set(OPENCV_MODULE_${the_module}_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE INTERNAL "")
210
if(NOT BUILD_${the_module})
211
return() # extra protection from redefinition
213
if(NOT OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD OR NOT ${BUILD_opencv_world})
214
if (NOT ${the_module} STREQUAL opencv_world)
215
project(${the_module})
218
-D_USE_MATH_DEFINES # M_PI constant in MSVS
219
-D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS # to use C libraries from C++ code (ffmpeg)
225
# excludes module from current configuration
226
macro(ocv_module_disable_ module)
227
set(__modname ${module})
228
if(NOT __modname MATCHES "^opencv_")
229
set(__modname opencv_${module})
231
list(APPEND OPENCV_MODULES_DISABLED_FORCE "${__modname}")
232
set(HAVE_${__modname} OFF CACHE INTERNAL "Module ${__modname} can not be built in current configuration")
233
set(OPENCV_MODULE_${__modname}_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "Location of ${__modname} module sources")
234
set(OPENCV_MODULES_DISABLED_FORCE "${OPENCV_MODULES_DISABLED_FORCE}" CACHE INTERNAL "List of OpenCV modules which can not be build in current configuration")
235
if(BUILD_${__modname})
236
# touch variable controlling build of the module to suppress "unused variable" CMake warning
241
macro(ocv_module_disable module)
242
ocv_module_disable_(${module})
243
return() # leave the current folder
246
# gather acceptable locations and generate names for them
247
# if folder contains CMakeLists.txt - it is accepted,
248
# otherwise all first-level subfolders containing CMakeLists.txt are accepted.
249
# Usage: _glob_locations(<output paths list> <output names list> <folder> [<folder> ...])
250
function(_glob_locations out_paths out_names)
252
foreach(path ${PATHS})
253
#message(STATUS "Inspect: ${path}")
254
list(LENGTH paths before)
255
get_filename_component(path "${path}" ABSOLUTE)
256
# Either module itself
257
if(NOT path STREQUAL "${OpenCV_SOURCE_DIR}/modules" AND EXISTS "${path}/CMakeLists.txt")
258
get_filename_component(name "${path}" NAME)
259
list(APPEND paths "${path}")
260
list(APPEND names "${name}")
262
# Either flat collection of modules
263
file(GLOB subdirs RELATIVE "${path}" "${path}/*")
264
foreach(subdir ${subdirs})
265
#message(STATUS "Inspect: ${path}/${subdir}")
266
if(EXISTS "${path}/${subdir}/CMakeLists.txt")
267
list(APPEND paths "${path}/${subdir}")
268
list(APPEND names "${subdir}")
272
list(LENGTH paths after)
273
if(before EQUAL after)
274
message(SEND_ERROR "No modules has been found: ${path}")
278
set(${out_paths} ${paths} PARENT_SCOPE)
279
set(${out_names} ${names} PARENT_SCOPE)
282
# Calls 'add_subdirectory' for each location.
283
# Note: both input lists should have same length.
284
# Usage: _add_modules_1(<list with paths> <list with names>)
285
macro(_add_modules_1 paths names)
286
ocv_debug_message("_add_modules_1(paths=${paths}, names=${names}, ... " ${ARGN} ")")
287
list(LENGTH ${paths} __len)
288
if(NOT __len EQUAL 0)
289
list(LENGTH ${names} __len_verify)
290
if(NOT __len EQUAL __len_verify)
291
message(FATAL_ERROR "Bad configuration! ${__len} != ${__len_verify}")
293
math(EXPR __len "${__len} - 1")
294
foreach(i RANGE ${__len})
295
list(GET ${paths} ${i} __path)
296
list(GET ${names} ${i} __name)
297
#message(STATUS "First pass: ${__name} => ${__path}")
298
include("${__path}/cmake/init.cmake" OPTIONAL)
299
add_subdirectory("${__path}" "${OpenCV_BINARY_DIR}/modules/.firstpass/${__name}")
304
# Calls 'add_subdirectory' for each module name.
305
# Usage: _add_modules_2([<module> ...])
307
ocv_debug_message("_add_modules_2(" ${ARGN} ")")
309
set(the_module "${m}")
310
ocv_cmake_hook(PRE_MODULES_CREATE_${the_module})
311
if(BUILD_opencv_world AND m STREQUAL "opencv_world"
312
OR NOT BUILD_opencv_world
313
OR NOT OPENCV_MODULE_${m}_IS_PART_OF_WORLD)
314
if(NOT m MATCHES "^opencv_")
315
message(WARNING "Incorrect module name: ${m}")
317
string(REGEX REPLACE "^opencv_" "" name "${m}")
318
#message(STATUS "Second pass: ${name} => ${OPENCV_MODULE_${m}_LOCATION}")
319
add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${OpenCV_BINARY_DIR}/modules/${name}")
321
ocv_cmake_hook(POST_MODULES_CREATE_${the_module})
326
# Check if list of input items is unique.
327
# Usage: _assert_uniqueness(<failure message> <element> [<element> ...])
328
function(_assert_uniqueness msg)
329
ocv_get_duplicates(dups ${ARGN})
332
list(FIND dups "${e}" idx)
338
message("${prefix}${e}")
340
message(FATAL_ERROR "${msg}")
344
# collect modules from specified directories
345
# NB: must be called only once!
346
# Usage: ocv_glob_modules(<main location> [<extra location> ...])
347
macro(ocv_glob_modules main_root)
348
ocv_cmake_hook(INIT_MODULES_GLOB)
349
if(DEFINED OPENCV_INITIAL_PASS)
350
message(FATAL_ERROR "OpenCV has already loaded its modules. Calling ocv_glob_modules second time is not allowed.")
354
set(OPENCV_INITIAL_PASS ON)
355
_glob_locations(__main_paths __main_names ${main_root})
356
_glob_locations(__extra_paths __extra_names ${ARGN})
357
_assert_uniqueness("Duplicated modules LOCATIONS has been found" ${__main_paths} ${__extra_paths})
358
_assert_uniqueness("Duplicated modules NAMES has been found" ${__main_names} ${__extra_names})
359
set(OPENCV_PROCESSING_EXTRA_MODULES 0)
360
ocv_cmake_hook(PRE_MODULES_SCAN)
361
_add_modules_1(__main_paths __main_names)
362
set(OPENCV_PROCESSING_EXTRA_MODULES 1)
363
ocv_cmake_hook(PRE_MODULES_SCAN_EXTRA)
364
_add_modules_1(__extra_paths __extra_names)
365
ocv_clear_vars(__main_names __extra_names __main_paths __extra_paths)
366
ocv_cmake_hook(POST_MODULES_SCAN)
368
# resolve dependencies
369
__ocv_resolve_dependencies()
371
# optionally configure delay load
372
if(MSVC AND BUILD_SHARED_LIBS AND ENABLE_DELAYLOAD AND NOT BUILD_opencv_world)
373
if(${CMAKE_SHARED_LINKER_FLAGS} MATCHES "delayimp.lib")
376
set(DELAYFLAGS "delayimp.lib")
379
foreach(mod ${OPENCV_MODULES_BUILD})
380
if(NOT ${mod} STREQUAL "opencv_core" AND NOT ${mod} MATCHES "bindings_generator|python")
381
set(DELAYFLAGS "${DELAYFLAGS} /DELAYLOAD:${mod}${OPENCV_VERSION_MAJOR}${OPENCV_VERSION_MINOR}${OPENCV_VERSION_PATCH}.dll")
385
if(NOT ${CMAKE_SHARED_LINKER_FLAGS} MATCHES "/IGNORE:4199")
386
set(DELAYFLAGS "${DELAYFLAGS} /IGNORE:4199")
389
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${DELAYFLAGS}")
390
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${DELAYFLAGS}")
391
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${DELAYFLAGS}")
395
set(OPENCV_INITIAL_PASS OFF)
396
ocv_cmake_hook(PRE_MODULES_CREATE)
397
_add_modules_2(${OPENCV_MODULES_BUILD})
398
ocv_cmake_hook(POST_MODULES_CREATE)
402
# called by root CMakeLists.txt
403
macro(ocv_register_modules)
404
if(NOT OPENCV_MODULES_PATH)
405
set(OPENCV_MODULES_PATH "${OpenCV_SOURCE_DIR}/modules")
408
ocv_glob_modules(${OPENCV_MODULES_PATH} ${OPENCV_EXTRA_MODULES_PATH})
410
# build lists of modules to be documented
411
set(OPENCV_MODULES_MAIN "")
412
set(OPENCV_MODULES_EXTRA "")
414
foreach(mod ${OPENCV_MODULES_BUILD} ${OPENCV_MODULES_DISABLED_USER} ${OPENCV_MODULES_DISABLED_AUTO} ${OPENCV_MODULES_DISABLED_FORCE})
415
string(REGEX REPLACE "^opencv_" "" mod "${mod}")
416
if("${OPENCV_MODULE_opencv_${mod}_LOCATION}" STREQUAL "${OpenCV_SOURCE_DIR}/modules/${mod}")
417
list(APPEND OPENCV_MODULES_MAIN ${mod})
419
list(APPEND OPENCV_MODULES_EXTRA ${mod})
422
ocv_list_sort(OPENCV_MODULES_MAIN)
423
ocv_list_sort(OPENCV_MODULES_EXTRA)
424
set(FIXED_ORDER_MODULES core imgproc imgcodecs videoio highgui video calib3d features2d objdetect dnn ml flann photo stitching)
425
list(REMOVE_ITEM OPENCV_MODULES_MAIN ${FIXED_ORDER_MODULES})
426
set(OPENCV_MODULES_MAIN ${FIXED_ORDER_MODULES} ${OPENCV_MODULES_MAIN})
428
set(OPENCV_MODULES_MAIN ${OPENCV_MODULES_MAIN} CACHE INTERNAL "List of main modules" FORCE)
429
set(OPENCV_MODULES_EXTRA ${OPENCV_MODULES_EXTRA} CACHE INTERNAL "List of extra modules" FORCE)
433
# disables OpenCV module with missing dependencies
434
function(__ocv_module_turn_off the_module)
435
list(REMOVE_ITEM OPENCV_MODULES_DISABLED_AUTO "${the_module}")
436
list(APPEND OPENCV_MODULES_DISABLED_AUTO "${the_module}")
437
list(REMOVE_ITEM OPENCV_MODULES_BUILD "${the_module}")
438
list(REMOVE_ITEM OPENCV_MODULES_PUBLIC "${the_module}")
439
set(HAVE_${the_module} OFF CACHE INTERNAL "Module ${the_module} can not be built in current configuration")
441
set(OPENCV_MODULES_DISABLED_AUTO "${OPENCV_MODULES_DISABLED_AUTO}" CACHE INTERNAL "")
442
set(OPENCV_MODULES_BUILD "${OPENCV_MODULES_BUILD}" CACHE INTERNAL "")
443
set(OPENCV_MODULES_PUBLIC "${OPENCV_MODULES_PUBLIC}" CACHE INTERNAL "")
446
# sort modules by dependencies
447
function(__ocv_sort_modules_by_deps __lst)
448
ocv_list_sort(${__lst})
449
set(input ${${__lst}})
453
list(LENGTH input length_before)
455
# check if module is in the result already
456
if (NOT ";${result};" MATCHES ";${m};")
457
# scan through module dependencies...
458
set(unresolved_deps_found FALSE)
459
foreach (d ${OPENCV_MODULE_${m}_DEPS})
460
# ... which are not already in the result and are enabled
461
if ((NOT ";${result};" MATCHES ";${d};") AND HAVE_${d})
462
set(unresolved_deps_found TRUE)
466
# check if all dependencies for this module has been resolved
467
if (NOT unresolved_deps_found)
468
list(APPEND result ${m})
469
list(REMOVE_ITEM input ${m})
473
list(LENGTH input length_after)
474
# check for infinite loop or unresolved dependencies
475
if (NOT length_after LESS length_before)
476
if(NOT BUILD_SHARED_LIBS)
477
if (";${input};" MATCHES ";opencv_world;")
478
list(REMOVE_ITEM input "opencv_world")
479
list(APPEND result_extra "opencv_world")
481
# We can't do here something
482
list(APPEND result ${input})
486
message(FATAL_ERROR "FATAL: Unresolved dependencies or loop in dependency graph (${length_after})\n"
487
"Processed ${__lst}: ${${__lst}}\n"
488
"Good modules: ${result}\n"
489
"Bad modules: ${input}"
491
list(APPEND result ${input})
496
set(${__lst} "${result};${result_extra}" PARENT_SCOPE)
499
# resolve dependencies
500
function(__ocv_resolve_dependencies)
501
foreach(m ${OPENCV_MODULES_DISABLED_USER})
502
set(HAVE_${m} OFF CACHE INTERNAL "Module ${m} will not be built in current configuration")
504
foreach(m ${OPENCV_MODULES_BUILD})
505
set(HAVE_${m} ON CACHE INTERNAL "Module ${m} will be built in current configuration")
511
string(REGEX REPLACE "[ ,:]+" ";" whitelist "${BUILD_LIST}" )
512
if(BUILD_opencv_world)
513
list(APPEND whitelist world)
515
ocv_list_add_prefix(whitelist "opencv_")
516
ocv_list_sort(whitelist)
517
ocv_list_unique(whitelist)
518
message(STATUS "Using whitelist: ${whitelist}")
520
foreach(depth RANGE 10)
521
set(new_whitelist ${whitelist})
522
foreach(m ${whitelist})
523
list(APPEND new_whitelist ${OPENCV_MODULE_${m}_REQ_DEPS})
524
list(APPEND new_whitelist ${OPENCV_MODULE_${m}_PRIVATE_REQ_DEPS})
526
ocv_list_sort(new_whitelist)
527
ocv_list_unique(new_whitelist)
528
if("${whitelist}" STREQUAL "${new_whitelist}")
531
set(whitelist "${new_whitelist}")
533
# Disable modules not in whitelist
534
foreach(m ${OPENCV_MODULES_BUILD})
535
list(FIND whitelist ${m} idx)
537
message(STATUS "Module ${m} disabled by whitelist")
538
__ocv_module_turn_off(${m})
543
# add reverse wrapper dependencies (BINDINDS)
544
foreach(the_module ${OPENCV_MODULES_BUILD})
545
foreach (wrapper ${OPENCV_MODULE_${the_module}_WRAPPERS})
546
if(wrapper STREQUAL "python") # hack for python (BINDINDS)
547
ocv_add_dependencies(opencv_python2 OPTIONAL ${the_module})
548
ocv_add_dependencies(opencv_python3 OPTIONAL ${the_module})
550
ocv_add_dependencies(opencv_${wrapper} OPTIONAL ${the_module})
552
if(DEFINED OPENCV_MODULE_opencv_${wrapper}_bindings_generator_CLASS)
553
ocv_add_dependencies(opencv_${wrapper}_bindings_generator OPTIONAL ${the_module})
558
# disable MODULES with unresolved dependencies
562
foreach(m ${OPENCV_MODULES_BUILD})
563
set(__deps ${OPENCV_MODULE_${m}_REQ_DEPS} ${OPENCV_MODULE_${m}_PRIVATE_REQ_DEPS})
565
ocv_list_pop_front(__deps d)
566
string(TOLOWER "${d}" upper_d)
567
if(NOT (HAVE_${d} OR HAVE_${upper_d} OR TARGET ${d} OR EXISTS ${d}))
568
if(d MATCHES "^opencv_") # TODO Remove this condition in the future and use HAVE_ variables only
569
message(STATUS "Module ${m} disabled because ${d} dependency can't be resolved!")
570
__ocv_module_turn_off(${m})
574
message(STATUS "Assume that non-module dependency is available: ${d} (for module ${m})")
581
# message(STATUS "List of active modules: ${OPENCV_MODULES_BUILD}")
583
foreach(m ${OPENCV_MODULES_BUILD})
584
set(deps_${m} ${OPENCV_MODULE_${m}_REQ_DEPS})
585
foreach(d ${OPENCV_MODULE_${m}_OPT_DEPS})
586
if(NOT (";${deps_${m}};" MATCHES ";${d};"))
587
if(HAVE_${d} OR TARGET ${d})
588
list(APPEND deps_${m} ${d})
592
# message(STATUS "Initial deps of ${m} (w/o private deps): ${deps_${m}}")
595
# propagate dependencies
599
foreach(m2 ${OPENCV_MODULES_BUILD}) # transfer deps of m2 to m
600
foreach(m ${OPENCV_MODULES_BUILD})
601
if((NOT m STREQUAL m2) AND ";${deps_${m}};" MATCHES ";${m2};")
602
foreach(d ${deps_${m2}})
603
if(NOT (";${deps_${m}};" MATCHES ";${d};"))
604
# message(STATUS " Transfer dependency ${d} from ${m2} to ${m}")
605
list(APPEND deps_${m} ${d})
608
if(BUILD_opencv_world
609
AND NOT "${m}" STREQUAL "opencv_world"
610
AND NOT "${m2}" STREQUAL "opencv_world"
611
AND OPENCV_MODULE_${m2}_IS_PART_OF_WORLD
612
AND NOT OPENCV_MODULE_${m}_IS_PART_OF_WORLD)
613
if(NOT (";${deps_${m}};" MATCHES ";opencv_world;"))
614
# message(STATUS " Transfer dependency opencv_world alias ${m2} to ${m}")
615
list(APPEND deps_${m} opencv_world)
625
# process private deps
626
foreach(m ${OPENCV_MODULES_BUILD})
627
foreach(d ${OPENCV_MODULE_${m}_PRIVATE_REQ_DEPS})
628
if(NOT (";${deps_${m}};" MATCHES ";${d};"))
629
list(APPEND deps_${m} ${d})
632
foreach(d ${OPENCV_MODULE_${m}_PRIVATE_OPT_DEPS})
633
if(NOT (";${deps_${m}};" MATCHES ";${d};"))
634
if(HAVE_${d} OR TARGET ${d})
635
list(APPEND deps_${m} ${d})
641
ocv_list_sort(OPENCV_MODULES_BUILD)
643
foreach(m ${OPENCV_MODULES_BUILD})
644
# message(STATUS "FULL deps of ${m}: ${deps_${m}}")
645
set(OPENCV_MODULE_${m}_DEPS ${deps_${m}})
646
set(OPENCV_MODULE_${m}_DEPS_EXT ${deps_${m}})
647
ocv_list_filterout(OPENCV_MODULE_${m}_DEPS_EXT "^opencv_[^ ]+$")
648
if(OPENCV_MODULE_${m}_DEPS_EXT AND OPENCV_MODULE_${m}_DEPS)
649
list(REMOVE_ITEM OPENCV_MODULE_${m}_DEPS ${OPENCV_MODULE_${m}_DEPS_EXT})
653
# reorder dependencies
654
foreach(m ${OPENCV_MODULES_BUILD})
655
__ocv_sort_modules_by_deps(OPENCV_MODULE_${m}_DEPS)
657
set(LINK_DEPS ${OPENCV_MODULE_${m}_DEPS})
660
if(BUILD_opencv_world)
661
if(OPENCV_MODULE_${m}_IS_PART_OF_WORLD)
662
list(APPEND OPENCV_WORLD_MODULES ${m})
664
foreach(m2 ${OPENCV_MODULES_BUILD})
665
if(OPENCV_MODULE_${m2}_IS_PART_OF_WORLD)
666
if(";${LINK_DEPS};" MATCHES ";${m2};")
667
list(REMOVE_ITEM LINK_DEPS ${m2})
668
if(NOT (";${LINK_DEPS};" MATCHES ";opencv_world;") AND NOT (${m} STREQUAL opencv_world))
669
list(APPEND LINK_DEPS opencv_world)
672
if("${m}" STREQUAL opencv_world)
673
list(APPEND OPENCV_MODULE_opencv_world_DEPS_EXT ${OPENCV_MODULE_${m2}_DEPS_EXT})
679
set(OPENCV_MODULE_${m}_DEPS ${OPENCV_MODULE_${m}_DEPS} CACHE INTERNAL "Flattened dependencies of ${m} module")
680
set(OPENCV_MODULE_${m}_DEPS_EXT ${OPENCV_MODULE_${m}_DEPS_EXT} CACHE INTERNAL "Extra dependencies of ${m} module")
681
set(OPENCV_MODULE_${m}_DEPS_TO_LINK ${LINK_DEPS} CACHE INTERNAL "Flattened dependencies of ${m} module (for linker)")
683
# message(STATUS " module deps of ${m}: ${OPENCV_MODULE_${m}_DEPS}")
684
# message(STATUS " module link deps of ${m}: ${OPENCV_MODULE_${m}_DEPS_TO_LINK}")
685
# message(STATUS " extra deps of ${m}: ${OPENCV_MODULE_${m}_DEPS_EXT}")
689
__ocv_sort_modules_by_deps(OPENCV_MODULES_BUILD)
691
set(OPENCV_MODULES_PUBLIC ${OPENCV_MODULES_PUBLIC} CACHE INTERNAL "List of OpenCV modules marked for export")
692
set(OPENCV_MODULES_BUILD ${OPENCV_MODULES_BUILD} CACHE INTERNAL "List of OpenCV modules included into the build")
693
set(OPENCV_MODULES_DISABLED_AUTO ${OPENCV_MODULES_DISABLED_AUTO} CACHE INTERNAL "List of OpenCV modules implicitly disabled due to dependencies")
694
set(OPENCV_WORLD_MODULES ${OPENCV_WORLD_MODULES} CACHE INTERNAL "List of OpenCV modules included into the world")
698
# setup include paths for the list of passed modules
699
macro(ocv_include_modules)
701
if(d MATCHES "^opencv_" AND HAVE_${d})
702
if (EXISTS "${OPENCV_MODULE_${d}_LOCATION}/include")
703
ocv_include_directories("${OPENCV_MODULE_${d}_LOCATION}/include")
705
elseif(EXISTS "${d}")
706
ocv_include_directories("${d}")
711
# same as previous but with dependencies
712
macro(ocv_include_modules_recurse)
713
ocv_include_modules(${ARGN})
715
if(d MATCHES "^opencv_" AND HAVE_${d} AND DEFINED OPENCV_MODULE_${d}_DEPS)
716
foreach (sub ${OPENCV_MODULE_${d}_DEPS})
717
ocv_include_modules(${sub})
723
# setup include paths for the list of passed modules
724
macro(ocv_target_include_modules target)
726
if(d MATCHES "^opencv_")
727
if(HAVE_${d} AND EXISTS "${OPENCV_MODULE_${d}_LOCATION}/include")
728
ocv_target_include_directories(${target} "${OPENCV_MODULE_${d}_LOCATION}/include")
730
elseif(EXISTS "${d}")
731
ocv_target_include_directories(${target} "${d}")
733
message(WARNING "Unexpected include: ${d} (module=${the_module})")
738
# setup include paths for the list of passed modules and recursively add dependent modules
739
macro(ocv_target_include_modules_recurse target)
741
if(d MATCHES "^opencv_" AND HAVE_${d})
742
if (EXISTS "${OPENCV_MODULE_${d}_LOCATION}/include")
743
ocv_target_include_directories(${target} "${OPENCV_MODULE_${d}_LOCATION}/include")
745
if(OPENCV_MODULE_${d}_DEPS)
746
ocv_target_include_modules(${target} ${OPENCV_MODULE_${d}_DEPS})
748
elseif(EXISTS "${d}")
749
ocv_target_include_directories(${target} "${d}")
754
# setup include path for OpenCV headers for specified module
755
# ocv_module_include_directories(<extra include directories/extra include modules>)
756
macro(ocv_module_include_directories)
757
if(ENABLE_PRECOMPILED_HEADERS OR OPENCV_INCLUDE_DIR_APPEND_MODULE_SRC)
758
ocv_target_include_directories(${the_module} "${OPENCV_MODULE_${the_module}_LOCATION}/src")
760
ocv_target_include_directories(${the_module}
761
"${OPENCV_MODULE_${the_module}_LOCATION}/include"
762
"${CMAKE_CURRENT_BINARY_DIR}" # for precompiled headers
764
ocv_target_include_modules(${the_module} ${OPENCV_MODULE_${the_module}_DEPS} ${ARGN})
768
# sets header and source files for the current module
769
# NB: all files specified as headers will be installed
771
# ocv_set_module_sources([HEADERS] <list of files> [SOURCES] <list of files>)
772
macro(ocv_set_module_sources)
773
ocv_debug_message("ocv_set_module_sources(" ${ARGN} ")")
775
set(OPENCV_MODULE_${the_module}_HEADERS "")
776
set(OPENCV_MODULE_${the_module}_SOURCES "")
778
foreach(f "HEADERS" ${ARGN})
779
if(f STREQUAL "HEADERS" OR f STREQUAL "SOURCES")
780
set(__filesvar "OPENCV_MODULE_${the_module}_${f}")
782
list(APPEND ${__filesvar} "${f}")
786
# the hacky way to embed any files into the OpenCV without modification of its build system
787
if(COMMAND ocv_get_module_external_sources)
788
ocv_get_module_external_sources()
791
if(OPENCV_MODULE_${the_module}_SOURCES_DISPATCHED)
792
list(APPEND OPENCV_MODULE_${the_module}_SOURCES ${OPENCV_MODULE_${the_module}_SOURCES_DISPATCHED})
795
# TODO Update hooks above
796
ocv_cmake_hook(INIT_MODULE_SOURCES)
797
ocv_cmake_hook(INIT_MODULE_SOURCES_${the_module})
799
# use full paths for module to be independent from the module location
800
ocv_convert_to_full_paths(OPENCV_MODULE_${the_module}_HEADERS)
802
set(OPENCV_MODULE_${the_module}_HEADERS ${OPENCV_MODULE_${the_module}_HEADERS} CACHE INTERNAL "List of header files for ${the_module}")
803
set(OPENCV_MODULE_${the_module}_SOURCES ${OPENCV_MODULE_${the_module}_SOURCES} CACHE INTERNAL "List of source files for ${the_module}")
806
# finds and sets headers and sources for the standard OpenCV module
808
# ocv_glob_module_sources([EXCLUDE_CUDA] [EXCLUDE_OPENCL] <extra sources&headers in the same format as used in ocv_set_module_sources>)
809
macro(ocv_glob_module_sources)
810
ocv_debug_message("ocv_glob_module_sources(" ${ARGN} ")")
812
list(FIND _argn "EXCLUDE_CUDA" exclude_cuda)
813
if(NOT exclude_cuda EQUAL -1)
814
list(REMOVE_AT _argn ${exclude_cuda})
816
list(FIND _argn "EXCLUDE_OPENCL" exclude_opencl)
817
if(NOT exclude_opencl EQUAL -1)
818
list(REMOVE_AT _argn ${exclude_opencl})
821
file(GLOB_RECURSE lib_srcs
822
"${CMAKE_CURRENT_LIST_DIR}/src/*.cpp"
824
file(GLOB_RECURSE lib_int_hdrs
825
"${CMAKE_CURRENT_LIST_DIR}/src/*.hpp"
826
"${CMAKE_CURRENT_LIST_DIR}/src/*.h"
829
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/*.hpp"
830
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.hpp"
831
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.h"
832
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/hal/*.hpp"
833
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/hal/*.h"
834
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/utils/*.hpp"
835
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/utils/*.h"
836
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/legacy/*.h"
838
file(GLOB lib_hdrs_detail
839
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/detail/*.hpp"
840
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/detail/*.h"
843
file(GLOB_RECURSE lib_srcs_apple
844
"${CMAKE_CURRENT_LIST_DIR}/src/*.mm"
845
"${CMAKE_CURRENT_LIST_DIR}/src/*.swift"
847
list(APPEND lib_srcs ${lib_srcs_apple})
850
ocv_source_group("Src" DIRBASE "${CMAKE_CURRENT_LIST_DIR}/src" FILES ${lib_srcs} ${lib_int_hdrs})
851
ocv_source_group("Include" DIRBASE "${CMAKE_CURRENT_LIST_DIR}/include" FILES ${lib_hdrs} ${lib_hdrs_detail})
853
set(lib_cuda_srcs "")
854
set(lib_cuda_hdrs "")
855
if(HAVE_CUDA AND exclude_cuda EQUAL -1)
856
file(GLOB lib_cuda_srcs
857
"${CMAKE_CURRENT_LIST_DIR}/src/cuda/*.cu"
859
file(GLOB lib_cuda_hdrs
860
"${CMAKE_CURRENT_LIST_DIR}/src/cuda/*.hpp"
862
source_group("Src\\Cuda" FILES ${lib_cuda_srcs} ${lib_cuda_hdrs})
866
"${CMAKE_CURRENT_LIST_DIR}/src/opencl/*.cl"
868
if(cl_kernels AND exclude_opencl EQUAL -1)
869
set(OCL_NAME opencl_kernels_${name})
871
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.cpp" # don't add .hpp file here to optimize build process
872
COMMAND ${CMAKE_COMMAND} "-DMODULE_NAME=${name}" "-DCL_DIR=${CMAKE_CURRENT_LIST_DIR}/src/opencl" "-DOUTPUT=${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.cpp" -P "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake"
873
DEPENDS ${cl_kernels} "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake"
874
COMMENT "Processing OpenCL kernels (${name})"
876
ocv_source_group("Src\\opencl\\kernels" FILES ${cl_kernels})
877
ocv_source_group("Src\\opencl\\kernels\\autogenerated" FILES "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.cpp" "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.hpp")
878
set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.cpp" "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.hpp"
879
PROPERTIES GENERATED TRUE
881
list(APPEND lib_srcs ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.cpp" "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.hpp")
884
ocv_set_module_sources(${_argn} HEADERS ${lib_hdrs} ${lib_hdrs_detail}
885
SOURCES ${lib_srcs} ${lib_int_hdrs} ${lib_cuda_srcs} ${lib_cuda_hdrs})
888
# creates OpenCV module in current folder
889
# creates new target, configures standard dependencies, compilers flags, install rules
891
# ocv_create_module(<extra link dependencies>)
893
macro(ocv_create_module)
894
ocv_debug_message("${the_module}: ocv_create_module(" ${ARGN} ")")
895
if(OPENCV_MODULE_${the_module}_CLASS STREQUAL "BINDINGS")
896
message(FATAL_ERROR "Bindings module can't call ocv_create_module()")
898
if(NOT " ${ARGN}" STREQUAL " ")
899
set(OPENCV_MODULE_${the_module}_LINK_DEPS "${OPENCV_MODULE_${the_module}_LINK_DEPS};${ARGN}" CACHE INTERNAL "")
901
if(BUILD_opencv_world AND OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD)
903
set(the_module_target opencv_world)
905
_ocv_create_module(${ARGN})
906
set(the_module_target ${the_module})
909
if(WINRT AND BUILD_TESTS)
910
# removing APPCONTAINER from modules to run from console
911
# in case of usual starting of WinRT test apps output is missing
912
# so starting of console version w/o APPCONTAINER is required to get test results
913
# also this allows to use opencv_extra test data for these tests
914
if(NOT "${the_module}" STREQUAL "opencv_ts" AND NOT "${the_module}" STREQUAL "opencv_hal")
915
add_custom_command(TARGET ${the_module}
917
COMMAND link.exe /edit /APPCONTAINER:NO $(TargetPath))
920
if("${the_module}" STREQUAL "opencv_ts")
921
# copy required dll files; WinRT apps need these dlls that are usually substituted by Visual Studio
922
# however they are not on path and need to be placed with executables to run from console w/o APPCONTAINER
923
add_custom_command(TARGET ${the_module}
925
COMMAND copy /y "\"$(VCInstallDir)redist\\$(PlatformTarget)\\Microsoft.VC$(PlatformToolsetVersion).CRT\\msvcp$(PlatformToolsetVersion).dll\"" "\"${CMAKE_BINARY_DIR}\\bin\\$(Configuration)\\msvcp$(PlatformToolsetVersion)_app.dll\""
926
COMMAND copy /y "\"$(VCInstallDir)redist\\$(PlatformTarget)\\Microsoft.VC$(PlatformToolsetVersion).CRT\\msvcr$(PlatformToolsetVersion).dll\"" "\"${CMAKE_BINARY_DIR}\\bin\\$(Configuration)\\msvcr$(PlatformToolsetVersion)_app.dll\""
927
COMMAND copy /y "\"$(VCInstallDir)redist\\$(PlatformTarget)\\Microsoft.VC$(PlatformToolsetVersion).CRT\\vccorlib$(PlatformToolsetVersion).dll\"" "\"${CMAKE_BINARY_DIR}\\bin\\$(Configuration)\\vccorlib$(PlatformToolsetVersion)_app.dll\"")
932
macro(_ocv_create_module)
933
add_definitions(-D__OPENCV_BUILD=1)
935
ocv_compiler_optimization_process_sources(OPENCV_MODULE_${the_module}_SOURCES OPENCV_MODULE_${the_module}_DEPS_EXT ${the_module})
936
set(__module_headers ${OPENCV_MODULE_${the_module}_HEADERS})
938
list(SORT __module_headers) # fix headers order, useful for bindings
940
set(OPENCV_MODULE_${the_module}_HEADERS ${__module_headers} CACHE INTERNAL "List of header files for ${the_module}")
941
set(OPENCV_MODULE_${the_module}_SOURCES ${OPENCV_MODULE_${the_module}_SOURCES} CACHE INTERNAL "List of source files for ${the_module}")
943
# The condition we ought to be testing here is whether ocv_add_precompiled_headers will
944
# be called at some point in the future. We can't look into the future, though,
945
# so this will have to do.
946
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/precomp.hpp" AND NOT ${the_module} STREQUAL opencv_world)
947
get_native_precompiled_header(${the_module} precomp.hpp)
951
AND (BUILD_SHARED_LIBS AND NOT "x${OPENCV_MODULE_TYPE}" STREQUAL "xSTATIC")
952
AND NOT OPENCV_VS_VERSIONINFO_SKIP)
953
if(DEFINED OPENCV_VS_VERSIONINFO_FILE)
954
set(_VS_VERSION_FILE "${OPENCV_VS_VERSIONINFO_FILE}")
955
elseif(DEFINED OPENCV_VS_VERSIONINFO_${the_module}_FILE)
956
set(_VS_VERSION_FILE "${OPENCV_VS_VERSIONINFO_${the_module}_FILE}")
957
elseif(NOT OPENCV_VS_VERSIONINFO_SKIP_GENERATION)
958
set(_VS_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/vs_version.rc")
959
ocv_generate_vs_version_file("${_VS_VERSION_FILE}"
961
FILEDESCRIPTION "OpenCV module: ${OPENCV_MODULE_${the_module}_DESCRIPTION}"
962
INTERNALNAME "${the_module}${OPENCV_DLLVERSION}"
963
ORIGINALFILENAME "${the_module}${OPENCV_DLLVERSION}.dll"
967
if(NOT EXISTS "${_VS_VERSION_FILE}")
968
message(STATUS "${the_module}: Required .rc file is missing: ${_VS_VERSION_FILE}")
970
source_group("Src" FILES "${_VS_VERSION_FILE}")
974
"${the_module}" STREQUAL "opencv_core" OR
975
"${the_module}" STREQUAL "opencv_world" OR
976
"${the_module}" STREQUAL "opencv_cudev"
978
AND (BUILD_SHARED_LIBS AND NOT "x${OPENCV_MODULE_TYPE}" STREQUAL "xSTATIC")
979
AND NOT OPENCV_SKIP_DLLMAIN_GENERATION
981
set(_DLLMAIN_FILE "${CMAKE_CURRENT_BINARY_DIR}/${the_module}_main.cpp")
982
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/dllmain.cpp.in" "${_DLLMAIN_FILE}" @ONLY)
985
source_group("Include" FILES "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp")
986
source_group("Src" FILES "${${the_module}_pch}")
987
ocv_cmake_hook(PRE_CREATE_MODULE_LIBRARY)
988
ocv_cmake_hook(PRE_CREATE_MODULE_LIBRARY_${the_module})
989
ocv_add_library(${the_module} ${OPENCV_MODULE_TYPE} ${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES}
990
"${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp"
995
set_target_properties(${the_module} PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};Module")
996
set_source_files_properties(${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES} ${${the_module}_pch}
997
PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};Module")
999
ocv_target_link_libraries(${the_module} PUBLIC ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK}
1000
INTERFACE ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK}
1002
ocv_target_link_libraries(${the_module} PUBLIC ${OPENCV_MODULE_${the_module}_DEPS_EXT}
1003
INTERFACE ${OPENCV_MODULE_${the_module}_DEPS_EXT}
1005
ocv_target_link_libraries(${the_module} PRIVATE ${OPENCV_LINKER_LIBS} ${OPENCV_HAL_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
1006
if (NOT ENABLE_CUDA_FIRST_CLASS_LANGUAGE AND HAVE_CUDA)
1007
ocv_target_link_libraries(${the_module} PRIVATE ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
1010
if(OPENCV_MODULE_${the_module}_COMPILE_DEFINITIONS)
1011
target_compile_definitions(${the_module} ${OPENCV_MODULE_${the_module}_COMPILE_DEFINITIONS})
1012
unset(OPENCV_MODULE_${the_module}_COMPILE_DEFINITIONS CACHE)
1015
add_dependencies(opencv_modules ${the_module})
1017
if(ENABLE_SOLUTION_FOLDERS)
1018
set_target_properties(${the_module} PROPERTIES FOLDER "modules")
1021
set_target_properties(${the_module} PROPERTIES
1022
OUTPUT_NAME "${the_module}${OPENCV_DLLVERSION}"
1023
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
1024
COMPILE_PDB_NAME "${the_module}${OPENCV_DLLVERSION}"
1025
COMPILE_PDB_NAME_DEBUG "${the_module}${OPENCV_DLLVERSION}${OPENCV_DEBUG_POSTFIX}"
1026
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
1027
COMPILE_PDB_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
1028
LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
1029
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
1030
DEFINE_SYMBOL CVAPI_EXPORTS
1033
if(BUILD_FAT_JAVA_LIB) # force exports from static modules too
1034
if(BUILD_SHARED_LIBS)
1035
message(FATAL_ERROR "Assertion failed: BUILD_SHARED_LIBS=OFF must be off if BUILD_FAT_JAVA_LIB=ON")
1037
target_compile_definitions(${the_module} PRIVATE CVAPI_EXPORTS)
1040
# For dynamic link numbering conventions
1042
# Android SDK build scripts can include only .so files into final .apk
1043
# As result we should not set version properties for Android
1044
set_target_properties(${the_module} PROPERTIES
1045
VERSION ${OPENCV_LIBVERSION}
1046
SOVERSION ${OPENCV_SOVERSION}
1050
if (ENABLE_GNU_STL_DEBUG)
1051
target_compile_definitions(${the_module} PUBLIC _GLIBCXX_DEBUG)
1055
if(CMAKE_CROSSCOMPILING)
1056
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:secchk")
1058
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc /DEBUG")
1061
get_target_property(_target_type ${the_module} TYPE)
1062
if(OPENCV_MODULE_${the_module}_CLASS STREQUAL "PUBLIC" AND
1063
("${_target_type}" STREQUAL "SHARED_LIBRARY" OR (NOT BUILD_SHARED_LIBS OR NOT INSTALL_CREATE_DISTRIB)))
1064
ocv_install_target(${the_module} EXPORT OpenCVModules OPTIONAL
1065
RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT libs
1066
LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT libs NAMELINK_SKIP
1067
ARCHIVE DESTINATION ${OPENCV_LIB_ARCHIVE_INSTALL_PATH} COMPONENT dev
1070
if("${_target_type}" STREQUAL "SHARED_LIBRARY")
1071
install(TARGETS ${the_module}
1072
LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT dev NAMELINK_ONLY)
1075
# only "public" headers need to be installed
1076
ocv_cmake_hook(PRE_INSTALL_MODULE_HEADERS)
1077
ocv_cmake_hook(PRE_INSTALL_MODULE_HEADERS_${the_module})
1078
if(OPENCV_MODULE_${the_module}_HEADERS AND ";${OPENCV_MODULES_PUBLIC};" MATCHES ";${the_module};")
1079
foreach(hdr ${OPENCV_MODULE_${the_module}_HEADERS})
1080
string(REGEX REPLACE "^.*opencv2/" "opencv2/" hdr2 "${hdr}")
1081
if(NOT hdr2 MATCHES "private" AND hdr2 MATCHES "^(opencv2/?.*)/[^/]+.h(..)?$" )
1082
install(FILES ${hdr} OPTIONAL DESTINATION "${OPENCV_INCLUDE_INSTALL_PATH}/${CMAKE_MATCH_1}" COMPONENT dev)
1084
#message("Header file will be NOT installed: ${hdr}")
1089
_ocv_add_precompiled_headers(${the_module})
1091
ocv_cmake_hook(POST_CREATE_MODULE_LIBRARY)
1092
ocv_cmake_hook(POST_CREATE_MODULE_LIBRARY_${the_module})
1095
# opencv precompiled headers macro (can add pch to modules and tests)
1096
# this macro must be called after any "add_definitions" commands, otherwise precompiled headers will not work
1098
# ocv_add_precompiled_headers(${the_module})
1099
macro(_ocv_add_precompiled_headers the_target)
1100
ocv_debug_message("ocv_add_precompiled_headers(" ${the_target} ${ARGN} ")")
1102
if("${the_target}" MATCHES "^opencv_test_.*$")
1103
SET(pch_path "test/test_")
1104
elseif("${the_target}" MATCHES "^opencv_perf_.*$")
1105
SET(pch_path "perf/perf_")
1107
SET(pch_path "src/")
1109
ocv_add_precompiled_header_to_target(${the_target} "${CMAKE_CURRENT_SOURCE_DIR}/${pch_path}precomp.hpp")
1113
# short command for adding simple OpenCV module
1114
# see ocv_add_module for argument details
1116
# ocv_define_module(module_name [INTERNAL] [EXCLUDE_CUDA] [REQUIRED] [<list of dependencies>] [OPTIONAL <list of optional dependencies>] [WRAP <list of wrappers>])
1117
macro(ocv_define_module module_name)
1118
ocv_debug_message("ocv_define_module(" ${module_name} ${ARGN} ")")
1120
set(exclude_cuda "")
1121
foreach(arg ${_argn})
1122
if("${arg}" STREQUAL "EXCLUDE_CUDA")
1123
set(exclude_cuda "${arg}")
1124
list(REMOVE_ITEM _argn ${arg})
1128
ocv_add_module(${module_name} ${_argn})
1129
ocv_glob_module_sources(${exclude_cuda})
1130
ocv_module_include_directories()
1133
ocv_add_accuracy_tests()
1134
ocv_add_perf_tests()
1138
# ensures that all passed modules are available
1139
# sets OCV_DEPENDENCIES_FOUND variable to TRUE/FALSE
1140
macro(ocv_check_dependencies)
1141
set(OCV_DEPENDENCIES_FOUND TRUE)
1143
if(d MATCHES "^opencv_[^ ]+$" AND NOT HAVE_${d})
1144
set(OCV_DEPENDENCIES_FOUND FALSE)
1150
################################################################################
1152
################################################################################
1154
if(DEFINED OPENCV_BUILD_TEST_MODULES_LIST)
1155
string(REPLACE "," ";" OPENCV_BUILD_TEST_MODULES_LIST "${OPENCV_BUILD_TEST_MODULES_LIST}") # support comma-separated list (,) too
1157
if(DEFINED OPENCV_BUILD_PERF_TEST_MODULES_LIST)
1158
string(REPLACE "," ";" OPENCV_BUILD_PERF_TEST_MODULES_LIST "${OPENCV_BUILD_PERF_TEST_MODULES_LIST}") # support comma-separated list (,) too
1161
# auxiliary macro to parse arguments of ocv_add_accuracy_tests and ocv_add_perf_tests commands
1162
macro(__ocv_parse_test_sources tests_type)
1163
set(OPENCV_${tests_type}_${the_module}_SOURCES "")
1164
set(OPENCV_${tests_type}_${the_module}_DEPS "")
1165
set(__file_group_name "")
1166
set(__file_group_sources "")
1167
foreach(arg "DEPENDS_ON" ${ARGN} "FILES")
1168
if(arg STREQUAL "FILES")
1169
set(__currentvar "__file_group_sources")
1170
if(__file_group_name AND __file_group_sources)
1171
source_group("${__file_group_name}" FILES ${__file_group_sources})
1172
list(APPEND OPENCV_${tests_type}_${the_module}_SOURCES ${__file_group_sources})
1174
set(__file_group_name "")
1175
set(__file_group_sources "")
1176
elseif(arg STREQUAL "DEPENDS_ON")
1177
set(__currentvar "OPENCV_${tests_type}_${the_module}_DEPS")
1178
elseif(" ${__currentvar}" STREQUAL " __file_group_sources" AND NOT __file_group_name) # spaces to avoid CMP0054
1179
set(__file_group_name "${arg}")
1181
list(APPEND ${__currentvar} "${arg}")
1184
unset(__file_group_name)
1185
unset(__file_group_sources)
1189
ocv_check_environment_variables(OPENCV_TEST_EXTRA_CXX_FLAGS_Release)
1191
# this is a command for adding OpenCV performance tests to the module
1192
# ocv_add_perf_tests(<extra_dependencies>)
1193
function(ocv_add_perf_tests)
1194
ocv_debug_message("ocv_add_perf_tests(" ${ARGN} ")")
1197
set(OPENCV_DEBUG_POSTFIX "")
1200
set(perf_path "${CMAKE_CURRENT_LIST_DIR}/perf")
1201
if(BUILD_PERF_TESTS AND EXISTS "${perf_path}"
1202
AND (NOT DEFINED OPENCV_BUILD_PERF_TEST_MODULES_LIST
1203
OR OPENCV_BUILD_PERF_TEST_MODULES_LIST STREQUAL "all"
1204
OR ";${OPENCV_BUILD_PERF_TEST_MODULES_LIST};" MATCHES ";${name};"
1207
__ocv_parse_test_sources(PERF ${ARGN})
1209
# opencv_imgcodecs is required for imread/imwrite
1210
set(perf_deps opencv_ts ${the_module} opencv_imgcodecs ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_MODULE_opencv_ts_DEPS})
1211
ocv_check_dependencies(${perf_deps})
1213
if(OCV_DEPENDENCIES_FOUND)
1214
set(the_target "opencv_perf_${name}")
1215
# project(${the_target})
1217
if(NOT OPENCV_PERF_${the_module}_SOURCES)
1218
file(GLOB_RECURSE perf_srcs "${perf_path}/*.cpp")
1219
file(GLOB_RECURSE perf_hdrs "${perf_path}/*.hpp" "${perf_path}/*.h")
1220
ocv_source_group("Src" DIRBASE "${perf_path}" FILES ${perf_srcs})
1221
ocv_source_group("Include" DIRBASE "${perf_path}" FILES ${perf_hdrs})
1222
set(OPENCV_PERF_${the_module}_SOURCES ${perf_srcs} ${perf_hdrs})
1225
ocv_compiler_optimization_process_sources(OPENCV_PERF_${the_module}_SOURCES OPENCV_PERF_${the_module}_DEPS ${the_target})
1227
if(NOT BUILD_opencv_world)
1228
get_native_precompiled_header(${the_target} perf_precomp.hpp)
1231
source_group("Src" FILES "${${the_target}_pch}")
1232
ocv_add_executable(${the_target} ${OPENCV_PERF_${the_module}_SOURCES} ${${the_target}_pch})
1233
ocv_target_include_modules(${the_target} ${perf_deps})
1234
ocv_target_link_libraries(${the_target} PRIVATE ${perf_deps} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS} ${OPENCV_PERF_${the_module}_DEPS})
1235
add_dependencies(opencv_perf_tests ${the_target})
1237
if(TARGET opencv_videoio_plugins)
1238
add_dependencies(${the_target} opencv_videoio_plugins)
1240
if(TARGET opencv_highgui_plugins)
1241
add_dependencies(${the_target} opencv_highgui_plugins)
1245
message("Linking HPX to Perf test of module ${name}")
1246
ocv_target_link_libraries(${the_target} LINK_PRIVATE "${HPX_LIBRARIES}")
1249
set_target_properties(${the_target} PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};PerfTest")
1250
set_source_files_properties(${OPENCV_PERF_${the_module}_SOURCES} ${${the_target}_pch}
1251
PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};PerfTest")
1253
# Additional target properties
1254
set_target_properties(${the_target} PROPERTIES
1255
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
1256
RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}"
1258
if(ENABLE_SOLUTION_FOLDERS)
1259
set_target_properties(${the_target} PROPERTIES FOLDER "tests performance")
1263
# removing APPCONTAINER from tests to run from console
1264
# look for detailed description inside of ocv_create_module macro above
1265
add_custom_command(TARGET "opencv_perf_${name}"
1267
COMMAND link.exe /edit /APPCONTAINER:NO $(TargetPath))
1270
if(NOT BUILD_opencv_world)
1271
_ocv_add_precompiled_headers(${the_target})
1274
ocv_add_test_from_target("${the_target}" "Performance" "${the_target}")
1275
ocv_add_test_from_target("opencv_sanity_${name}" "Sanity" "${the_target}"
1276
"--perf_min_samples=1"
1277
"--perf_force_samples=1"
1278
"--perf_verify_sanity")
1279
else(OCV_DEPENDENCIES_FOUND)
1280
# TODO: warn about unsatisfied dependencies
1281
endif(OCV_DEPENDENCIES_FOUND)
1283
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_TEST_INSTALL_PATH} COMPONENT tests)
1288
# this is a command for adding OpenCV accuracy/regression tests to the module
1289
# ocv_add_accuracy_tests(<list of extra dependencies>)
1290
function(ocv_add_accuracy_tests)
1291
ocv_debug_message("ocv_add_accuracy_tests(" ${ARGN} ")")
1293
set(test_path "${CMAKE_CURRENT_LIST_DIR}/test")
1294
if(BUILD_TESTS AND EXISTS "${test_path}"
1295
AND (NOT DEFINED OPENCV_BUILD_TEST_MODULES_LIST
1296
OR OPENCV_BUILD_TEST_MODULES_LIST STREQUAL "all"
1297
OR ";${OPENCV_BUILD_TEST_MODULES_LIST};" MATCHES ";${name};"
1300
__ocv_parse_test_sources(TEST ${ARGN})
1302
# opencv_imgcodecs is required for imread/imwrite
1303
set(test_deps opencv_ts ${the_module} opencv_imgcodecs opencv_videoio ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_MODULE_opencv_ts_DEPS})
1304
ocv_check_dependencies(${test_deps})
1305
if(OCV_DEPENDENCIES_FOUND)
1306
set(the_target "opencv_test_${name}")
1307
# project(${the_target})
1309
if(NOT OPENCV_TEST_${the_module}_SOURCES)
1310
file(GLOB_RECURSE test_srcs "${test_path}/*.cpp")
1311
file(GLOB_RECURSE test_hdrs "${test_path}/*.hpp" "${test_path}/*.h")
1312
ocv_source_group("Src" DIRBASE "${test_path}" FILES ${test_srcs})
1313
ocv_source_group("Include" DIRBASE "${test_path}" FILES ${test_hdrs})
1314
set(OPENCV_TEST_${the_module}_SOURCES ${test_srcs} ${test_hdrs})
1317
if(OPENCV_MODULE_${the_module}_TEST_SOURCES_DISPATCHED)
1318
list(APPEND OPENCV_TEST_${the_module}_SOURCES ${OPENCV_MODULE_${the_module}_TEST_SOURCES_DISPATCHED})
1320
ocv_compiler_optimization_process_sources(OPENCV_TEST_${the_module}_SOURCES OPENCV_TEST_${the_module}_DEPS ${the_target})
1322
if(NOT BUILD_opencv_world)
1323
get_native_precompiled_header(${the_target} test_precomp.hpp)
1326
source_group("Src" FILES "${${the_target}_pch}")
1327
ocv_add_executable(${the_target} ${OPENCV_TEST_${the_module}_SOURCES} ${${the_target}_pch})
1328
ocv_target_include_modules(${the_target} ${test_deps})
1329
if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/test")
1330
ocv_target_include_directories(${the_target} "${CMAKE_CURRENT_BINARY_DIR}/test")
1332
ocv_target_link_libraries(${the_target} PRIVATE ${test_deps} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS} ${OPENCV_TEST_${the_module}_DEPS})
1333
add_dependencies(opencv_tests ${the_target})
1335
if(TARGET opencv_videoio_plugins)
1336
add_dependencies(${the_target} opencv_videoio_plugins)
1338
if(TARGET opencv_highgui_plugins)
1339
add_dependencies(${the_target} opencv_highgui_plugins)
1343
message("Linking HPX to Perf test of module ${name}")
1344
ocv_target_link_libraries(${the_target} LINK_PRIVATE "${HPX_LIBRARIES}")
1347
set_target_properties(${the_target} PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};AccuracyTest")
1348
set_source_files_properties(${OPENCV_TEST_${the_module}_SOURCES} ${${the_target}_pch}
1349
PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};AccuracyTest")
1351
# Additional target properties
1352
set_target_properties(${the_target} PROPERTIES
1353
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
1354
RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}"
1357
ocv_append_target_property(${the_target} COMPILE_DEFINITIONS "__OPENCV_TESTS=1")
1359
if(ENABLE_SOLUTION_FOLDERS)
1360
set_target_properties(${the_target} PROPERTIES FOLDER "tests accuracy")
1363
if(OPENCV_TEST_BIGDATA)
1364
ocv_append_target_property(${the_target} COMPILE_DEFINITIONS "OPENCV_TEST_BIGDATA=1")
1367
if(NOT BUILD_opencv_world)
1368
_ocv_add_precompiled_headers(${the_target})
1371
if(OPENCV_TEST_EXTRA_CXX_FLAGS_Release)
1372
target_compile_options(${the_target} PRIVATE "$<$<CONFIG:Release>:${OPENCV_TEST_EXTRA_CXX_FLAGS_Release}>")
1375
ocv_add_test_from_target("${the_target}" "Accuracy" "${the_target}")
1376
else(OCV_DEPENDENCIES_FOUND)
1377
# TODO: warn about unsatisfied dependencies
1378
endif(OCV_DEPENDENCIES_FOUND)
1381
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_TEST_INSTALL_PATH} COMPONENT tests)
1386
function(ocv_add_samples)
1387
ocv_debug_message("ocv_add_samples(" ${ARGN} ")")
1389
set(samples_path "${CMAKE_CURRENT_SOURCE_DIR}/samples")
1390
if(NOT EXISTS "${samples_path}")
1394
string(REGEX REPLACE "^opencv_" "" module_id ${the_module})
1397
set(samples_deps ${the_module} ${OPENCV_MODULE_${the_module}_DEPS} opencv_imgcodecs opencv_videoio opencv_highgui ${ARGN})
1398
ocv_check_dependencies(${samples_deps})
1400
if(OCV_DEPENDENCIES_FOUND)
1401
file(GLOB sample_sources "${samples_path}/*.cpp")
1403
foreach(source ${sample_sources})
1404
get_filename_component(name "${source}" NAME_WE)
1405
set(the_target "example_${module_id}_${name}")
1407
ocv_add_executable(${the_target} "${source}")
1408
ocv_target_include_modules(${the_target} ${samples_deps})
1409
ocv_target_link_libraries(${the_target} PRIVATE ${samples_deps})
1411
set_target_properties(${the_target} PROPERTIES
1412
PROJECT_LABEL "(sample) ${name}"
1413
LABELS "${OPENCV_MODULE_${the_module}_LABEL};Sample")
1414
set_source_files_properties("${source}" PROPERTIES
1415
LABELS "${OPENCV_MODULE_${the_module}_LABEL};Sample")
1416
if(ENABLE_SOLUTION_FOLDERS)
1417
set_target_properties(${the_target} PROPERTIES
1418
FOLDER "samples/${module_id}")
1420
# Add single target to build all samples for the module: 'make opencv_samples_bioinspired'
1421
set(parent_target opencv_samples_${module_id})
1422
if(NOT TARGET ${parent_target})
1423
add_custom_target(${parent_target})
1424
add_dependencies(opencv_samples ${parent_target})
1426
add_dependencies(${parent_target} ${the_target})
1428
if(TARGET opencv_videoio_plugins)
1429
add_dependencies(${the_target} opencv_videoio_plugins)
1431
if(TARGET opencv_highgui_plugins)
1432
add_dependencies(${the_target} opencv_highgui_plugins)
1435
if(INSTALL_BIN_EXAMPLES)
1436
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${module_id}" COMPONENT samples)
1442
if(INSTALL_C_EXAMPLES)
1443
file(GLOB DEPLOY_FILES_AND_DIRS "${samples_path}/*")
1444
foreach(ITEM ${DEPLOY_FILES_AND_DIRS})
1445
IF( IS_DIRECTORY "${ITEM}" )
1446
LIST( APPEND sample_dirs "${ITEM}" )
1448
LIST( APPEND sample_files "${ITEM}" )
1451
install(FILES ${sample_files}
1452
DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/${module_id}"
1454
install(DIRECTORY ${sample_dirs}
1455
DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/${module_id}"