mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-09 23:30:35 -06:00
FindCUDATookit: Fix ordering of libraries in imported targets
Before this a downstream code linking to `CUDA::cusparse_static` and `CUDA::curand_static` would get a link line with `libcusparse_static.a`, then `libculibos.a`, then `libcurand_static.a`. Use `IMPORTED_LOCATION` to tell CMake about the proper dependency ordering where `libculibos.a` comes last, because the other two libraries depend on `libculibos.a`. Fixes: #22365
This commit is contained in:
@@ -844,9 +844,9 @@ if(CUDAToolkit_FOUND)
|
||||
mark_as_advanced(CUDA_${lib_name}_LIBRARY)
|
||||
|
||||
if (NOT TARGET CUDA::${lib_name} AND CUDA_${lib_name}_LIBRARY)
|
||||
add_library(CUDA::${lib_name} IMPORTED INTERFACE)
|
||||
add_library(CUDA::${lib_name} UNKNOWN IMPORTED)
|
||||
target_include_directories(CUDA::${lib_name} SYSTEM INTERFACE "${CUDAToolkit_INCLUDE_DIRS}")
|
||||
target_link_libraries(CUDA::${lib_name} INTERFACE "${CUDA_${lib_name}_LIBRARY}")
|
||||
set_property(TARGET CUDA::${lib_name} PROPERTY IMPORTED_LOCATION "${CUDA_${lib_name}_LIBRARY}")
|
||||
foreach(dep ${arg_DEPS})
|
||||
if(TARGET CUDA::${dep})
|
||||
target_link_libraries(CUDA::${lib_name} INTERFACE CUDA::${dep})
|
||||
|
||||
Reference in New Issue
Block a user