diff options
author | Robert Maynard <rmaynard@nvidia.com> | 2023-07-24 18:56:28 (GMT) |
---|---|---|
committer | Robert Maynard <rmaynard@nvidia.com> | 2023-07-24 18:56:28 (GMT) |
commit | 0744c02e24c04e4a9ec559816a2cc90c453203a0 (patch) | |
tree | 231bf21a96fe8c400e3be52a5a38cb94252a56bd /Modules/FindCUDAToolkit.cmake | |
parent | 6194193a8a0a476539590aabbb27094d1aff136a (diff) | |
download | CMake-0744c02e24c04e4a9ec559816a2cc90c453203a0.zip CMake-0744c02e24c04e4a9ec559816a2cc90c453203a0.tar.gz CMake-0744c02e24c04e4a9ec559816a2cc90c453203a0.tar.bz2 |
FindCUDAToolkit: targets pointing to stubs now use IMPORTED_IMPLIB
This ensures that we don't add rpath entries to the stubs directory
which would cause runtime loading of the wrong libraries.
Diffstat (limited to 'Modules/FindCUDAToolkit.cmake')
-rw-r--r-- | Modules/FindCUDAToolkit.cmake | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake index e9b7ae4..12aca8d 100644 --- a/Modules/FindCUDAToolkit.cmake +++ b/Modules/FindCUDAToolkit.cmake @@ -1012,17 +1012,26 @@ if(CUDAToolkit_FOUND) ) # Don't try any stub directories until we have exhausted all other # search locations. - find_library(CUDA_${lib_name}_LIBRARY - NAMES ${search_names} - HINTS ${CUDAToolkit_LIBRARY_SEARCH_DIRS} - ENV CUDA_PATH - PATH_SUFFIXES lib64/stubs lib/x64/stubs lib/stubs stubs - ) + set(CUDA_IMPORT_PROPERTY IMPORTED_LOCATION) + set(CUDA_IMPORT_TYPE UNKNOWN) + if(NOT CUDA_${lib_name}_LIBRARY) + find_library(CUDA_${lib_name}_LIBRARY + NAMES ${search_names} + HINTS ${CUDAToolkit_LIBRARY_SEARCH_DIRS} + ENV CUDA_PATH + PATH_SUFFIXES lib64/stubs lib/x64/stubs lib/stubs stubs + ) + if(CUDA_${lib_name}_LIBRARY AND NOT WIN32) + # Use `IMPORTED_IMPLIB` so that we don't add a `-rpath` entry for stub directories + set(CUDA_IMPORT_PROPERTY IMPORTED_IMPLIB) + set(CUDA_IMPORT_TYPE SHARED) + endif() + endif() mark_as_advanced(CUDA_${lib_name}_LIBRARY) if (NOT TARGET CUDA::${lib_name} AND CUDA_${lib_name}_LIBRARY) - add_library(CUDA::${lib_name} UNKNOWN IMPORTED) + add_library(CUDA::${lib_name} ${CUDA_IMPORT_TYPE} IMPORTED) target_include_directories(CUDA::${lib_name} SYSTEM INTERFACE "${CUDAToolkit_INCLUDE_DIRS}") if(DEFINED CUDAToolkit_MATH_INCLUDE_DIR) string(FIND ${CUDA_${lib_name}_LIBRARY} "math_libs" math_libs) @@ -1030,7 +1039,7 @@ if(CUDAToolkit_FOUND) target_include_directories(CUDA::${lib_name} SYSTEM INTERFACE "${CUDAToolkit_MATH_INCLUDE_DIR}") endif() endif() - set_property(TARGET CUDA::${lib_name} PROPERTY IMPORTED_LOCATION "${CUDA_${lib_name}_LIBRARY}") + set_property(TARGET CUDA::${lib_name} PROPERTY ${CUDA_IMPORT_PROPERTY} "${CUDA_${lib_name}_LIBRARY}") foreach(dep ${arg_DEPS}) if(TARGET CUDA::${dep}) target_link_libraries(CUDA::${lib_name} INTERFACE CUDA::${dep}) |