endif()
endmacro()
+macro(ocv_debug_message)
+# string(REPLACE ";" " " __msg "${ARGN}")
+# message(STATUS "${__msg}")
+endmacro()
+
macro(ocv_check_environment_variables)
foreach(_var ${ARGN})
if(NOT DEFINED ${_var} AND DEFINED ENV{${_var}})
endforeach()
endmacro()
+# rename modules target to world if needed
+macro(_ocv_fix_target target_var)
+ if(BUILD_opencv_world)
+ if(OPENCV_MODULE_${${target_var}}_IS_PART_OF_WORLD)
+ set(${target_var} opencv_world)
+ endif()
+ endif()
+endmacro()
+
# adds include directories in such way that directories from the OpenCV source tree go first
function(ocv_include_directories)
+ ocv_debug_message("ocv_include_directories( ${ARGN} )")
set(__add_before "")
foreach(dir ${ARGN})
get_filename_component(__abs_dir "${dir}" ABSOLUTE)
include_directories(BEFORE ${__add_before})
endfunction()
+# adds include directories in such way that directories from the OpenCV source tree go first
+function(ocv_target_include_directories target)
+ _ocv_fix_target(target)
+ set(__params "")
+ foreach(dir ${ARGN})
+ get_filename_component(__abs_dir "${dir}" ABSOLUTE)
+ if("${__abs_dir}" MATCHES "^${OpenCV_SOURCE_DIR}" OR "${__abs_dir}" MATCHES "^${OpenCV_BINARY_DIR}")
+ list(APPEND __params "${__abs_dir}")
+ else()
+ list(APPEND __params "${dir}")
+ endif()
+ endforeach()
+ if(HAVE_CUDA OR CMAKE_VERSION VERSION_LESS 2.8.11)
+ include_directories(${__params})
+ else()
+ if(TARGET ${target})
+ target_include_directories(${target} PRIVATE ${__params})
+ else()
+ set(__new_inc "${OCV_TARGET_INCLUDE_DIRS_${target}};${__params}")
+ set(OCV_TARGET_INCLUDE_DIRS_${target} "${__new_inc}" CACHE INTERNAL "")
+ endif()
+ endif()
+endfunction()
+
# clears all passed variables
macro(ocv_clear_vars)
foreach(_var ${ARGN})
set(${define} 1)
foreach(P "${ALIAS_INCLUDE_DIRS}")
if(${P})
+ list(APPEND VIDEOIO_INCLUDE_DIRS ${${P}})
list(APPEND HIGHGUI_INCLUDE_DIRS ${${P}})
endif()
endforeach()
foreach(P "${ALIAS_LIBRARY_DIRS}")
if(${P})
+ list(APPEND VIDEOIO_LIBRARY_DIRS ${${P}})
list(APPEND HIGHGUI_LIBRARY_DIRS ${${P}})
endif()
endforeach()
+ list(APPEND VIDEOIO_LIBRARIES ${${ALIAS_LIBRARIES}})
list(APPEND HIGHGUI_LIBRARIES ${${ALIAS_LIBRARIES}})
endif()
endif()
macro(ocv_finalize_status)
if(NOT OPENCV_SKIP_STATUS_FINALIZATION)
- if(TARGET opencv_core)
- execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OPENCV_BUILD_INFO_FILE}" "${opencv_core_BINARY_DIR}/version_string.inc" OUTPUT_QUIET)
+ if(DEFINED OPENCV_MODULE_opencv_core_BINARY_DIR)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OPENCV_BUILD_INFO_FILE}" "${OPENCV_MODULE_opencv_core_BINARY_DIR}/version_string.inc" OUTPUT_QUIET)
endif()
endif()
endmacro()
# message(STATUS "Process ${__target} dst=${__dst}...")
if(DEFINED __dst)
- get_target_property(fname ${__target} LOCATION_DEBUG)
- if(fname MATCHES "\\.lib$")
- string(REGEX REPLACE "\\.lib$" ".pdb" fname "${fname}")
- install(FILES ${fname} DESTINATION ${__dst} CONFIGURATIONS Debug)
- endif()
+ if(CMAKE_VERSION VERSION_LESS 2.8.12)
+ get_target_property(fname ${__target} LOCATION_DEBUG)
+ if(fname MATCHES "\\.lib$")
+ string(REGEX REPLACE "\\.lib$" ".pdb" fname "${fname}")
+ install(FILES ${fname} DESTINATION ${__dst} CONFIGURATIONS Debug)
+ endif()
- get_target_property(fname ${__target} LOCATION_RELEASE)
- if(fname MATCHES "\\.lib$")
- string(REGEX REPLACE "\\.lib$" ".pdb" fname "${fname}")
- install(FILES ${fname} DESTINATION ${__dst} CONFIGURATIONS Release)
+ get_target_property(fname ${__target} LOCATION_RELEASE)
+ if(fname MATCHES "\\.lib$")
+ string(REGEX REPLACE "\\.lib$" ".pdb" fname "${fname}")
+ install(FILES ${fname} DESTINATION ${__dst} CONFIGURATIONS Release)
+ endif()
+ else()
+ # CMake 2.8.12 brokes PDB support in STATIC libraries for MSVS
endif()
endif()
endif()
################################################################################################
# short command to setup source group
function(ocv_source_group group)
+ if(BUILD_opencv_world AND OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD)
+ set(group "${the_module}\\${group}")
+ endif()
cmake_parse_arguments(SG "" "DIRBASE" "GLOB;GLOB_RECURSE;FILES" ${ARGN})
set(files "")
if(SG_FILES)
source_group(${group} FILES ${files})
endif()
endfunction()
+
+function(ocv_target_link_libraries target)
+ _ocv_fix_target(target)
+ set(LINK_DEPS ${ARGN})
+ # process world
+ if(BUILD_opencv_world)
+ foreach(m ${OPENCV_MODULES_BUILD})
+ if(OPENCV_MODULE_${m}_IS_PART_OF_WORLD)
+ if(";${LINK_DEPS};" MATCHES ";${m};")
+ list(REMOVE_ITEM LINK_DEPS ${m})
+ if(NOT (";${LINK_DEPS};" MATCHES ";opencv_world;"))
+ list(APPEND LINK_DEPS opencv_world)
+ endif()
+ endif()
+ endif()
+ endforeach()
+ endif()
+ target_link_libraries(${target} ${LINK_DEPS})
+endfunction()
+
+function(_ocv_append_target_includes target)
+ if(DEFINED OCV_TARGET_INCLUDE_DIRS_${target})
+ target_include_directories(${target} PRIVATE ${OCV_TARGET_INCLUDE_DIRS_${target}})
+ unset(OCV_TARGET_INCLUDE_DIRS_${target} CACHE)
+ endif()
+endfunction()
+
+function(ocv_add_executable target)
+ add_executable(${target} ${ARGN})
+ _ocv_append_target_includes(${target})
+endfunction()
+
+function(ocv_add_library target)
+ set(cuda_objs "")
+ if(HAVE_CUDA)
+ set(cuda_srcs "")
+
+ foreach(var ${ARGN})
+ if(var MATCHES ".cu")
+ list(APPEND cuda_srcs ${var})
+ endif()
+ endforeach()
+
+ if(cuda_srcs)
+ ocv_include_directories(${CUDA_INCLUDE_DIRS})
+ ocv_cuda_compile(cuda_objs ${lib_cuda_srcs} ${lib_cuda_hdrs})
+ endif()
+ endif()
+
+ add_library(${target} ${ARGN} ${cuda_objs})
+ _ocv_append_target_includes(${target})
+endfunction()