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.
This commit is contained in:
Brad King
2023-12-06 15:27:14 -05:00
parent 618fdc1c42
commit d85bf99bcb

View File

@@ -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)