From d85bf99bcb52577e065458fdb4486eff7c67456b Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 6 Dec 2023 15:27:14 -0500 Subject: FindCUDAToolkit: Fix stub library representation on reconfigure Since commit 0744c02e24 (FindCUDAToolkit: targets pointing to stubs now use IMPORTED_IMPLIB, 2023-07-24, v3.28.0-rc1~309^2) we recognize CUDA stub libraries and represent them in a special way. However, the logic only works on the first configuration of a build tree when the libraries are first found. Once the results are cached, we incorrectly revert to the non-stub representation. Fix this by recognizing stub libraries based on their path instead. --- Modules/FindCUDAToolkit.cmake | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake index 0a22e63..f1b9684 100644 --- a/Modules/FindCUDAToolkit.cmake +++ b/Modules/FindCUDAToolkit.cmake @@ -1096,11 +1096,13 @@ if(CUDAToolkit_FOUND) 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() + if(CUDA_${lib_name}_LIBRARY MATCHES "/stubs/" AND NOT WIN32) + # Use a SHARED library with IMPORTED_IMPLIB, but not IMPORTED_LOCATION, + # to indicate that the stub is for linkers but not dynamic loaders. + # It will not contribute any RPATH entry. + set(CUDA_IMPORT_PROPERTY IMPORTED_IMPLIB) + set(CUDA_IMPORT_TYPE SHARED) endif() mark_as_advanced(CUDA_${lib_name}_LIBRARY) -- cgit v0.12