Use imported targets for linking to CUDA
This retains the desirable quality of not including paths to CUDA libraries from the build system into the config files, and has two major advantages: * It removes the need to use link_directories, which doesn't guarantee that the libraries from the supplied directory will be used (there may be libraries with the same names earlier in the search path). * It removes the need to put -L entries into OPENCV_LINKER_LIBS. This variable is used with target_link_libraries, where such entries are treated as linker flags, so doing this is unportable. I remove the support for -L entries from OpenCVGenPkgconfig.cmake, as well, to discourage adding them in the future.
This commit is contained in:
@@ -919,25 +919,28 @@ macro(__ocv_track_module_link_dependencies the_module optkind)
|
||||
list(REMOVE_AT __mod_depends 0)
|
||||
if(__dep STREQUAL the_module)
|
||||
set(__has_cycle TRUE)
|
||||
else()#if("${OPENCV_MODULES_BUILD}" MATCHES "(^|;)${__dep}(;|$)")
|
||||
else()
|
||||
ocv_regex_escape(__rdep "${__dep}")
|
||||
if(__resolved_deps MATCHES "(^|;)${__rdep}(;|$)")
|
||||
#all dependencies of this module are already resolved
|
||||
list(APPEND ${the_module}_MODULE_DEPS_${optkind} "${__dep}")
|
||||
elseif(TARGET ${__dep})
|
||||
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)
|
||||
get_target_property(__dep_imported ${__dep} IMPORTED)
|
||||
if(__dep_imported)
|
||||
list(APPEND ${the_module}_EXTRA_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}")
|
||||
endif()
|
||||
list(INSERT __mod_depends 0 ${${__dep}_LIB_DEPENDS_${optkind}} ${__dep})
|
||||
list(APPEND __resolved_deps "${__dep}")
|
||||
endif()
|
||||
else()
|
||||
list(APPEND ${the_module}_EXTRA_DEPS_${optkind} "${__dep}")
|
||||
endif()
|
||||
#else()
|
||||
# get_target_property(__dep_location "${__dep}" LOCATION)
|
||||
endif()
|
||||
endwhile()
|
||||
|
||||
@@ -951,7 +954,7 @@ macro(__ocv_track_module_link_dependencies the_module optkind)
|
||||
list(APPEND ${the_module}_MODULE_DEPS_${optkind} "${the_module}")
|
||||
endif()
|
||||
|
||||
unset(__dep_location)
|
||||
unset(__dep_imported)
|
||||
unset(__mod_depends)
|
||||
unset(__resolved_deps)
|
||||
unset(__has_cycle)
|
||||
|
Reference in New Issue
Block a user