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:
@@ -459,6 +459,19 @@ function(ocv_convert_to_lib_name var)
|
||||
set(${var} ${tmp} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# create imported targets for a list of external libraries
|
||||
function(ocv_create_imported_targets var)
|
||||
set(target_list "")
|
||||
|
||||
foreach(library ${ARGN})
|
||||
ocv_convert_to_lib_name(libname "${library}")
|
||||
add_library("opencv_dep_${libname}" UNKNOWN IMPORTED)
|
||||
set_target_properties("opencv_dep_${libname}" PROPERTIES IMPORTED_LOCATION "${library}")
|
||||
list(APPEND target_list "opencv_dep_${libname}")
|
||||
endforeach()
|
||||
|
||||
set("${var}" "${target_list}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# add install command
|
||||
function(ocv_install_target)
|
||||
|
Reference in New Issue
Block a user