2 function(ocv_cmake_dump_vars)
3 cmake_parse_arguments(DUMP "" "TOFILE" "" ${ARGN})
4 set(regex "${DUMP_UNPARSED_ARGUMENTS}")
5 get_cmake_property(_variableNames VARIABLES)
7 foreach(_variableName ${_variableNames})
8 if(_variableName MATCHES "${regex}")
9 set(VARS "${VARS}${_variableName}=${${_variableName}}\n")
13 file(WRITE ${CMAKE_BINARY_DIR}/${DUMP_TOFILE} "${VARS}")
15 message(AUTHOR_WARNING "${VARS}")
20 # Search packages for host system instead of packages for target system
21 # in case of cross compilation thess macro should be defined by toolchain file
22 if(NOT COMMAND find_host_package)
23 macro(find_host_package)
27 if(NOT COMMAND find_host_program)
28 macro(find_host_program)
34 # Note: it doesn't support lists in arguments
36 # ocv_assert(MyLib_FOUND)
37 # ocv_assert(DEFINED MyLib_INCLUDE_DIRS)
40 string(REPLACE ";" " " __assert_msg "${ARGN}")
41 message(AUTHOR_WARNING "Assertion failed: ${__assert_msg}")
45 macro(ocv_debug_message)
46 # string(REPLACE ";" " " __msg "${ARGN}")
47 # message(STATUS "${__msg}")
50 macro(ocv_check_environment_variables)
52 if(NOT DEFINED ${_var} AND DEFINED ENV{${_var}})
53 set(__value "$ENV{${_var}}")
54 file(TO_CMAKE_PATH "${__value}" __value) # Assume that we receive paths
55 set(${_var} "${__value}")
56 message(STATUS "Update variable ${_var} from environment: ${${_var}}")
61 # rename modules target to world if needed
62 macro(_ocv_fix_target target_var)
63 if(BUILD_opencv_world)
64 if(OPENCV_MODULE_${${target_var}}_IS_PART_OF_WORLD)
65 set(${target_var} opencv_world)
70 # adds include directories in such way that directories from the OpenCV source tree go first
71 function(ocv_include_directories)
72 ocv_debug_message("ocv_include_directories( ${ARGN} )")
75 get_filename_component(__abs_dir "${dir}" ABSOLUTE)
76 if("${__abs_dir}" MATCHES "^${OpenCV_SOURCE_DIR}" OR "${__abs_dir}" MATCHES "^${OpenCV_BINARY_DIR}")
77 list(APPEND __add_before "${dir}")
79 include_directories(AFTER SYSTEM "${dir}")
82 include_directories(BEFORE ${__add_before})
85 # adds include directories in such way that directories from the OpenCV source tree go first
86 function(ocv_target_include_directories target)
87 _ocv_fix_target(target)
90 get_filename_component(__abs_dir "${dir}" ABSOLUTE)
91 if("${__abs_dir}" MATCHES "^${OpenCV_SOURCE_DIR}" OR "${__abs_dir}" MATCHES "^${OpenCV_BINARY_DIR}")
92 list(APPEND __params "${__abs_dir}")
94 list(APPEND __params "${dir}")
97 if(HAVE_CUDA OR CMAKE_VERSION VERSION_LESS 2.8.11)
98 include_directories(${__params})
101 target_include_directories(${target} PRIVATE ${__params})
103 set(__new_inc "${OCV_TARGET_INCLUDE_DIRS_${target}};${__params}")
104 set(OCV_TARGET_INCLUDE_DIRS_${target} "${__new_inc}" CACHE INTERNAL "")
109 # clears all passed variables
110 macro(ocv_clear_vars)
111 foreach(_var ${ARGN})
116 set(OCV_COMPILER_FAIL_REGEX
117 "command line option .* is valid for .* but not for C\\+\\+" # GNU
118 "command line option .* is valid for .* but not for C" # GNU
119 "unrecognized .*option" # GNU
120 "unknown .*option" # Clang
121 "ignoring unknown option" # MSVC
122 "warning D9002" # MSVC, any lang
123 "option .*not supported" # Intel
124 "[Uu]nknown option" # HP
125 "[Ww]arning: [Oo]ption" # SunPro
126 "command option .* is not recognized" # XL
127 "not supported in this configuration; ignored" # AIX
128 "File with unknown suffix passed to linker" # PGI
129 "WARNING: unknown flag:" # Open64
132 MACRO(ocv_check_compiler_flag LANG FLAG RESULT)
133 if(NOT DEFINED ${RESULT})
134 if("_${LANG}_" MATCHES "_CXX_")
135 set(_fname "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx")
136 if("${CMAKE_CXX_FLAGS} ${FLAG} " MATCHES "-Werror " OR "${CMAKE_CXX_FLAGS} ${FLAG} " MATCHES "-Werror=unknown-pragmas ")
137 FILE(WRITE "${_fname}" "int main() { return 0; }\n")
139 FILE(WRITE "${_fname}" "#pragma\nint main() { return 0; }\n")
141 elseif("_${LANG}_" MATCHES "_C_")
142 set(_fname "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c")
143 if("${CMAKE_C_FLAGS} ${FLAG} " MATCHES "-Werror " OR "${CMAKE_C_FLAGS} ${FLAG} " MATCHES "-Werror=unknown-pragmas ")
144 FILE(WRITE "${_fname}" "int main(void) { return 0; }\n")
146 FILE(WRITE "${_fname}" "#pragma\nint main(void) { return 0; }\n")
148 elseif("_${LANG}_" MATCHES "_OBJCXX_")
149 set(_fname "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.mm")
150 if("${CMAKE_CXX_FLAGS} ${FLAG} " MATCHES "-Werror " OR "${CMAKE_CXX_FLAGS} ${FLAG} " MATCHES "-Werror=unknown-pragmas ")
151 FILE(WRITE "${_fname}" "int main() { return 0; }\n")
153 FILE(WRITE "${_fname}" "#pragma\nint main() { return 0; }\n")
159 MESSAGE(STATUS "Performing Test ${RESULT}")
160 TRY_COMPILE(${RESULT}
161 "${CMAKE_BINARY_DIR}"
163 COMPILE_DEFINITIONS "${FLAG}"
164 OUTPUT_VARIABLE OUTPUT)
166 FOREACH(_regex ${OCV_COMPILER_FAIL_REGEX})
167 IF("${OUTPUT}" MATCHES "${_regex}")
174 SET(${RESULT} 1 CACHE INTERNAL "Test ${RESULT}")
175 MESSAGE(STATUS "Performing Test ${RESULT} - Success")
177 MESSAGE(STATUS "Performing Test ${RESULT} - Failed")
178 SET(${RESULT} "" CACHE INTERNAL "Test ${RESULT}")
186 macro(ocv_check_flag_support lang flag varname)
187 if("_${lang}_" MATCHES "_CXX_")
189 elseif("_${lang}_" MATCHES "_C_")
191 elseif("_${lang}_" MATCHES "_OBJCXX_")
197 string(TOUPPER "${flag}" ${varname})
198 string(REGEX REPLACE "^(/|-)" "HAVE_${_lang}_" ${varname} "${${varname}}")
199 string(REGEX REPLACE " -|-|=| |\\." "_" ${varname} "${${varname}}")
201 ocv_check_compiler_flag("${_lang}" "${ARGN} ${flag}" ${${varname}})
205 macro(ocv_warnings_disable)
206 if(NOT ENABLE_NOISY_WARNINGS)
208 set(_msvc_warnings "")
209 set(_gxx_warnings "")
211 if(arg MATCHES "^CMAKE_")
212 list(APPEND _flag_vars ${arg})
213 elseif(arg MATCHES "^/wd")
214 list(APPEND _msvc_warnings ${arg})
215 elseif(arg MATCHES "^-W")
216 list(APPEND _gxx_warnings ${arg})
219 if(MSVC AND _msvc_warnings AND _flag_vars)
220 foreach(var ${_flag_vars})
221 foreach(warning ${_msvc_warnings})
222 set(${var} "${${var}} ${warning}")
225 elseif((CMAKE_COMPILER_IS_GNUCXX OR (UNIX AND CV_ICC)) AND _gxx_warnings AND _flag_vars)
226 foreach(var ${_flag_vars})
227 foreach(warning ${_gxx_warnings})
228 if(NOT warning MATCHES "^-Wno-")
229 string(REPLACE "${warning}" "" ${var} "${${var}}")
230 string(REPLACE "-W" "-Wno-" warning "${warning}")
232 ocv_check_flag_support(${var} "${warning}" _varname)
234 set(${var} "${${var}} ${warning}")
240 unset(_msvc_warnings)
242 endif(NOT ENABLE_NOISY_WARNINGS)
245 macro(add_apple_compiler_options the_module)
246 ocv_check_flag_support(OBJCXX "-fobjc-exceptions" HAVE_OBJC_EXCEPTIONS)
247 if(HAVE_OBJC_EXCEPTIONS)
248 foreach(source ${OPENCV_MODULE_${the_module}_SOURCES})
249 if("${source}" MATCHES "\\.mm$")
250 get_source_file_property(flags "${source}" COMPILE_FLAGS)
252 set(flags "${_flags} -fobjc-exceptions")
254 set(flags "-fobjc-exceptions")
257 set_source_files_properties("${source}" PROPERTIES COMPILE_FLAGS "${flags}")
263 # Provides an option that the user can optionally select.
264 # Can accept condition to control when option is available for user.
266 # option(<option_variable> "help string describing the option" <initial value or boolean expression> [IF <condition>])
267 macro(OCV_OPTION variable description value)
268 set(__value ${value})
270 set(__varname "__value")
272 if(arg STREQUAL "IF" OR arg STREQUAL "if")
273 set(__varname "__condition")
275 list(APPEND ${__varname} ${arg})
279 if("${__condition}" STREQUAL "")
280 set(__condition 2 GREATER 1)
284 if("${__value}" MATCHES ";")
286 option(${variable} "${description}" ON)
288 option(${variable} "${description}" OFF)
290 elseif(DEFINED ${__value})
292 option(${variable} "${description}" ON)
294 option(${variable} "${description}" OFF)
297 option(${variable} "${description}" ${__value})
300 unset(${variable} CACHE)
307 # Macros that checks if module have been installed.
308 # After it adds module to build and define
309 # constants passed as second arg
310 macro(CHECK_MODULE module_name define)
313 set(ALIAS ALIASOF_${module_name})
314 set(ALIAS_FOUND ${ALIAS}_FOUND)
315 set(ALIAS_INCLUDE_DIRS ${ALIAS}_INCLUDE_DIRS)
316 set(ALIAS_LIBRARY_DIRS ${ALIAS}_LIBRARY_DIRS)
317 set(ALIAS_LIBRARIES ${ALIAS}_LIBRARIES)
319 PKG_CHECK_MODULES(${ALIAS} ${module_name})
323 foreach(P "${ALIAS_INCLUDE_DIRS}")
325 list(APPEND VIDEOIO_INCLUDE_DIRS ${${P}})
326 list(APPEND HIGHGUI_INCLUDE_DIRS ${${P}})
330 foreach(P "${ALIAS_LIBRARY_DIRS}")
332 list(APPEND VIDEOIO_LIBRARY_DIRS ${${P}})
333 list(APPEND HIGHGUI_LIBRARY_DIRS ${${P}})
337 list(APPEND VIDEOIO_LIBRARIES ${${ALIAS_LIBRARIES}})
338 list(APPEND HIGHGUI_LIBRARIES ${${ALIAS_LIBRARIES}})
344 set(OPENCV_BUILD_INFO_FILE "${OpenCV_BINARY_DIR}/version_string.tmp")
345 file(REMOVE "${OPENCV_BUILD_INFO_FILE}")
346 function(ocv_output_status msg)
347 message(STATUS "${msg}")
348 string(REPLACE "\\" "\\\\" msg "${msg}")
349 string(REPLACE "\"" "\\\"" msg "${msg}")
350 file(APPEND "${OPENCV_BUILD_INFO_FILE}" "\"${msg}\\n\"\n")
353 macro(ocv_finalize_status)
354 if(NOT OPENCV_SKIP_STATUS_FINALIZATION)
355 if(DEFINED OPENCV_MODULE_opencv_core_BINARY_DIR)
356 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OPENCV_BUILD_INFO_FILE}" "${OPENCV_MODULE_opencv_core_BINARY_DIR}/version_string.inc" OUTPUT_QUIET)
362 # Status report function.
363 # Automatically align right column and selects text based on condition.
366 # status(<heading> <value1> [<value2> ...])
367 # status(<heading> <condition> THEN <text for TRUE> ELSE <text for FALSE> )
368 function(status text)
373 set(status_current_name "cond")
375 if(arg STREQUAL "THEN")
376 set(status_current_name "then")
377 elseif(arg STREQUAL "ELSE")
378 set(status_current_name "else")
380 list(APPEND status_${status_current_name} ${arg})
384 if(DEFINED status_cond)
385 set(status_placeholder_length 32)
386 string(RANDOM LENGTH ${status_placeholder_length} ALPHABET " " status_placeholder)
387 string(LENGTH "${text}" status_text_length)
388 if(status_text_length LESS status_placeholder_length)
389 string(SUBSTRING "${text}${status_placeholder}" 0 ${status_placeholder_length} status_text)
390 elseif(DEFINED status_then OR DEFINED status_else)
391 ocv_output_status("${text}")
392 set(status_text "${status_placeholder}")
394 set(status_text "${text}")
397 if(DEFINED status_then OR DEFINED status_else)
399 string(REPLACE ";" " " status_then "${status_then}")
400 string(REGEX REPLACE "^[ \t]+" "" status_then "${status_then}")
401 ocv_output_status("${status_text} ${status_then}")
403 string(REPLACE ";" " " status_else "${status_else}")
404 string(REGEX REPLACE "^[ \t]+" "" status_else "${status_else}")
405 ocv_output_status("${status_text} ${status_else}")
408 string(REPLACE ";" " " status_cond "${status_cond}")
409 string(REGEX REPLACE "^[ \t]+" "" status_cond "${status_cond}")
410 ocv_output_status("${status_text} ${status_cond}")
413 ocv_output_status("${text}")
418 # splits cmake libraries list of format "general;item1;debug;item2;release;item3" to two lists
419 macro(ocv_split_libs_list lst lstdbg lstopt)
423 foreach(word ${${lst}})
424 if(word STREQUAL "debug" OR word STREQUAL "optimized")
425 set(perv_keyword ${word})
426 elseif(word STREQUAL "general")
428 elseif(perv_keyword STREQUAL "debug")
429 list(APPEND ${lstdbg} "${word}")
431 elseif(perv_keyword STREQUAL "optimized")
432 list(APPEND ${lstopt} "${word}")
435 list(APPEND ${lstdbg} "${word}")
436 list(APPEND ${lstopt} "${word}")
443 # remove all matching elements from the list
444 macro(ocv_list_filterout lst regex)
445 foreach(item ${${lst}})
446 if(item MATCHES "${regex}")
447 list(REMOVE_ITEM ${lst} "${item}")
453 # stable & safe duplicates removal macro
454 macro(ocv_list_unique __lst)
456 list(REMOVE_DUPLICATES ${__lst})
461 # safe list reversal macro
462 macro(ocv_list_reverse __lst)
464 list(REVERSE ${__lst})
469 # safe list sorting macro
470 macro(ocv_list_sort __lst)
477 # add prefix to each item in the list
478 macro(ocv_list_add_prefix LST PREFIX)
480 foreach(item ${${LST}})
481 list(APPEND __tmp "${PREFIX}${item}")
488 # add suffix to each item in the list
489 macro(ocv_list_add_suffix LST SUFFIX)
491 foreach(item ${${LST}})
492 list(APPEND __tmp "${item}${SUFFIX}")
499 # gets and removes the first element from list
500 macro(ocv_list_pop_front LST VAR)
502 list(GET ${LST} 0 ${VAR})
503 list(REMOVE_AT ${LST} 0)
510 # simple regex escaping routine (does not cover all cases!!!)
511 macro(ocv_regex_escape var regex)
512 string(REGEX REPLACE "([+.*^$])" "\\\\1" ${var} "${regex}")
516 # convert list of paths to full paths
517 macro(ocv_convert_to_full_paths VAR)
520 foreach(path ${${VAR}})
521 get_filename_component(${VAR} "${path}" ABSOLUTE)
522 list(APPEND __tmp "${${VAR}}")
530 # convert list of paths to libraries names without lib prefix
531 macro(ocv_convert_to_lib_name var)
533 foreach(path ${ARGN})
534 get_filename_component(__tmp_name "${path}" NAME_WE)
535 string(REGEX REPLACE "^lib" "" __tmp_name ${__tmp_name})
536 list(APPEND __tmp "${__tmp_name}")
544 # add install command
545 function(ocv_install_target)
546 install(TARGETS ${ARGN})
552 if(NOT DEFINED __target)
555 if(isPackage EQUAL 1)
556 set(__package "${e}")
559 if(e STREQUAL "EXPORT")
564 if(DEFINED __package)
565 list(APPEND ${__package}_TARGETS ${__target})
566 set(${__package}_TARGETS "${${__package}_TARGETS}" CACHE INTERNAL "List of ${__package} targets")
569 if(INSTALL_CREATE_DISTRIB)
570 if(MSVC AND NOT BUILD_SHARED_LIBS)
571 set(__target "${ARGV0}")
581 if(isArchive EQUAL 1 AND e STREQUAL "DESTINATION")
584 if(e STREQUAL "ARCHIVE")
591 # message(STATUS "Process ${__target} dst=${__dst}...")
593 if(CMAKE_VERSION VERSION_LESS 2.8.12)
594 get_target_property(fname ${__target} LOCATION_DEBUG)
595 if(fname MATCHES "\\.lib$")
596 string(REGEX REPLACE "\\.lib$" ".pdb" fname "${fname}")
597 install(FILES ${fname} DESTINATION ${__dst} CONFIGURATIONS Debug)
600 get_target_property(fname ${__target} LOCATION_RELEASE)
601 if(fname MATCHES "\\.lib$")
602 string(REGEX REPLACE "\\.lib$" ".pdb" fname "${fname}")
603 install(FILES ${fname} DESTINATION ${__dst} CONFIGURATIONS Release)
606 # CMake 2.8.12 brokes PDB support in STATIC libraries for MSVS
614 # read set of version defines from the header file
615 macro(ocv_parse_header FILENAME FILE_VAR)
617 set(__parnet_scope OFF)
619 foreach(name ${ARGN})
620 if("${name}" STREQUAL "PARENT_SCOPE")
621 set(__parnet_scope ON)
622 elseif("${name}" STREQUAL "CACHE")
625 set(vars_regex "${vars_regex}|${name}")
627 set(vars_regex "${name}")
630 if(EXISTS "${FILENAME}")
631 file(STRINGS "${FILENAME}" ${FILE_VAR} REGEX "#define[ \t]+(${vars_regex})[ \t]+[0-9]+" )
635 foreach(name ${ARGN})
636 if(NOT "${name}" STREQUAL "PARENT_SCOPE" AND NOT "${name}" STREQUAL "CACHE")
638 if(${FILE_VAR} MATCHES ".+[ \t]${name}[ \t]+([0-9]+).*")
639 string(REGEX REPLACE ".+[ \t]${name}[ \t]+([0-9]+).*" "\\1" ${name} "${${FILE_VAR}}")
644 set(${name} ${${name}} CACHE INTERNAL "${name} parsed from ${FILENAME}" FORCE)
645 elseif(__parnet_scope)
646 set(${name} "${${name}}" PARENT_SCOPE)
655 # read single version define from the header file
656 macro(ocv_parse_header2 LIBNAME HDR_PATH VARNAME)
657 ocv_clear_vars(${LIBNAME}_VERSION_MAJOR
658 ${LIBNAME}_VERSION_MAJOR
659 ${LIBNAME}_VERSION_MINOR
660 ${LIBNAME}_VERSION_PATCH
661 ${LIBNAME}_VERSION_TWEAK
662 ${LIBNAME}_VERSION_STRING)
664 if(EXISTS "${HDR_PATH}")
665 file(STRINGS "${HDR_PATH}" ${LIBNAME}_H REGEX "^#define[ \t]+${VARNAME}[ \t]+\"[^\"]*\".*$" LIMIT_COUNT 1)
669 string(REGEX REPLACE "^.*[ \t]${VARNAME}[ \t]+\"([0-9]+).*$" "\\1" ${LIBNAME}_VERSION_MAJOR "${${LIBNAME}_H}")
670 string(REGEX REPLACE "^.*[ \t]${VARNAME}[ \t]+\"[0-9]+\\.([0-9]+).*$" "\\1" ${LIBNAME}_VERSION_MINOR "${${LIBNAME}_H}")
671 string(REGEX REPLACE "^.*[ \t]${VARNAME}[ \t]+\"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" ${LIBNAME}_VERSION_PATCH "${${LIBNAME}_H}")
672 set(${LIBNAME}_VERSION_MAJOR ${${LIBNAME}_VERSION_MAJOR} ${ARGN})
673 set(${LIBNAME}_VERSION_MINOR ${${LIBNAME}_VERSION_MINOR} ${ARGN})
674 set(${LIBNAME}_VERSION_PATCH ${${LIBNAME}_VERSION_PATCH} ${ARGN})
675 set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_MAJOR}.${${LIBNAME}_VERSION_MINOR}.${${LIBNAME}_VERSION_PATCH}")
677 # append a TWEAK version if it exists:
678 set(${LIBNAME}_VERSION_TWEAK "")
679 if("${${LIBNAME}_H}" MATCHES "^.*[ \t]${VARNAME}[ \t]+\"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$")
680 set(${LIBNAME}_VERSION_TWEAK "${CMAKE_MATCH_1}" ${ARGN})
682 if(${LIBNAME}_VERSION_TWEAK)
683 set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_STRING}.${${LIBNAME}_VERSION_TWEAK}" ${ARGN})
685 set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_STRING}" ${ARGN})
690 # read single version info from the pkg file
691 macro(ocv_parse_pkg LIBNAME PKG_PATH SCOPE)
692 if(EXISTS "${PKG_PATH}/${LIBNAME}.pc")
693 file(STRINGS "${PKG_PATH}/${LIBNAME}.pc" line_to_parse REGEX "^Version:[ \t]+[0-9.]*.*$" LIMIT_COUNT 1)
694 STRING(REGEX REPLACE ".*Version: ([^ ]+).*" "\\1" ALIASOF_${LIBNAME}_VERSION "${line_to_parse}" )
698 ################################################################################################
699 # short command to setup source group
700 function(ocv_source_group group)
701 if(BUILD_opencv_world AND OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD)
702 set(group "${the_module}\\${group}")
704 cmake_parse_arguments(SG "" "DIRBASE" "GLOB;GLOB_RECURSE;FILES" ${ARGN})
707 list(APPEND files ${SG_FILES})
710 file(GLOB srcs ${SG_GLOB})
711 list(APPEND files ${srcs})
714 file(GLOB_RECURSE srcs ${SG_GLOB_RECURSE})
715 list(APPEND files ${srcs})
719 file(RELATIVE_PATH fpart "${SG_DIRBASE}" "${f}")
720 if(fpart MATCHES "^\\.\\.")
721 message(AUTHOR_WARNING "Can't detect subpath for source_group command: Group=${group} FILE=${f} DIRBASE=${SG_DIRBASE}")
724 get_filename_component(fpart "${fpart}" PATH)
726 set(fpart "/${fpart}") # add '/'
727 string(REPLACE "/" "\\" fpart "${fpart}")
730 source_group("${group}${fpart}" FILES ${f})
733 source_group(${group} FILES ${files})
737 function(ocv_target_link_libraries target)
738 _ocv_fix_target(target)
739 set(LINK_DEPS ${ARGN})
741 if(BUILD_opencv_world)
742 foreach(m ${OPENCV_MODULES_BUILD})
743 if(OPENCV_MODULE_${m}_IS_PART_OF_WORLD)
744 if(";${LINK_DEPS};" MATCHES ";${m};")
745 list(REMOVE_ITEM LINK_DEPS ${m})
746 if(NOT (";${LINK_DEPS};" MATCHES ";opencv_world;"))
747 list(APPEND LINK_DEPS opencv_world)
753 target_link_libraries(${target} ${LINK_DEPS})
756 function(_ocv_append_target_includes target)
757 if(DEFINED OCV_TARGET_INCLUDE_DIRS_${target})
758 target_include_directories(${target} PRIVATE ${OCV_TARGET_INCLUDE_DIRS_${target}})
759 unset(OCV_TARGET_INCLUDE_DIRS_${target} CACHE)
763 function(ocv_add_executable target)
764 add_executable(${target} ${ARGN})
765 _ocv_append_target_includes(${target})
768 function(ocv_add_library target)
774 if(var MATCHES ".cu")
775 list(APPEND cuda_srcs ${var})
780 ocv_include_directories(${CUDA_INCLUDE_DIRS})
781 ocv_cuda_compile(cuda_objs ${lib_cuda_srcs} ${lib_cuda_hdrs})
785 add_library(${target} ${ARGN} ${cuda_objs})
786 _ocv_append_target_includes(${target})