diff options
author | Robert Maynard <rmaynard@nvidia.com> | 2022-11-30 14:49:52 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-11-30 21:39:00 (GMT) |
commit | 9d012b1f69c5bcc0fc1ee9452340f490dd2881d9 (patch) | |
tree | 1ad12226587c3020f92ffe2f908de54e46d37f21 /Modules | |
parent | f72c405d4ee4ad4775a10a944774b91f49726dad (diff) | |
download | CMake-9d012b1f69c5bcc0fc1ee9452340f490dd2881d9.zip CMake-9d012b1f69c5bcc0fc1ee9452340f490dd2881d9.tar.gz CMake-9d012b1f69c5bcc0fc1ee9452340f490dd2881d9.tar.bz2 |
FindCUDAToolkit: Ensure that paths provided have no symlinks
Fixes: #24188
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FindCUDAToolkit.cmake | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake index a4cebe4..5df31da 100644 --- a/Modules/FindCUDAToolkit.cmake +++ b/Modules/FindCUDAToolkit.cmake @@ -894,8 +894,25 @@ mark_as_advanced(CUDA_CUDART if(CUDAToolkit_FOUND) set(CUDAToolkit_INCLUDE_DIRS ${CUDAToolkit_INCLUDE_DIR}) get_filename_component(CUDAToolkit_LIBRARY_DIR ${CUDA_CUDART} DIRECTORY ABSOLUTE) + + # Build search paths without any symlinks + file(REAL_PATH "${CUDAToolkit_LIBRARY_DIR}" _cmake_search_dir) + set(CUDAToolkit_LIBRARY_SEARCH_DIRS "${_cmake_search_dir}") + + # Detect we are in a splayed nvhpc toolkit layout and add extra + # search paths without symlinks + if(CUDAToolkit_LIBRARY_DIR MATCHES ".*/cuda/${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR}/lib64$") + # Search location for math_libs/ + file(REAL_PATH "${CUDAToolkit_LIBRARY_DIR}/../../../" _cmake_search_dir) + list(APPEND CUDAToolkit_LIBRARY_SEARCH_DIRS "${_cmake_search_dir}") + + # Search location for extras like cupti + file(REAL_PATH "${CUDAToolkit_LIBRARY_DIR}/../" _cmake_search_dir) + list(APPEND CUDAToolkit_LIBRARY_SEARCH_DIRS "${_cmake_search_dir}") + endif() endif() + #----------------------------------------------------------------------------- # Construct import targets if(CUDAToolkit_FOUND) @@ -907,21 +924,21 @@ if(CUDAToolkit_FOUND) find_library(CUDA_${lib_name}_LIBRARY NAMES ${search_names} - HINTS ${CUDAToolkit_LIBRARY_DIR} + HINTS ${CUDAToolkit_LIBRARY_SEARCH_DIRS} ENV CUDA_PATH PATH_SUFFIXES nvidia/current lib64 lib/x64 lib + # Support NVHPC splayed math library layout + math_libs/${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR}/lib64 + math_libs/lib64 ${arg_EXTRA_PATH_SUFFIXES} ) # 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_DIR} + HINTS ${CUDAToolkit_LIBRARY_SEARCH_DIRS} ENV CUDA_PATH PATH_SUFFIXES lib64/stubs lib/x64/stubs lib/stubs stubs - # Support NVHPC splayed math library layout - ../../math_libs/${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR}/lib64 - ../../math_libs/lib64 ) mark_as_advanced(CUDA_${lib_name}_LIBRARY) @@ -1054,11 +1071,15 @@ if(CUDAToolkit_FOUND) if(CUDAToolkit_CUPTI_INCLUDE_DIR) _CUDAToolkit_find_and_add_import_lib(cupti - EXTRA_PATH_SUFFIXES ../extras/CUPTI/lib64/ + EXTRA_PATH_SUFFIXES extras/CUPTI/lib64/ + extras/CUPTI/lib/ + ../extras/CUPTI/lib64/ ../extras/CUPTI/lib/ EXTRA_INCLUDE_DIRS "${CUDAToolkit_CUPTI_INCLUDE_DIR}") _CUDAToolkit_find_and_add_import_lib(cupti_static - EXTRA_PATH_SUFFIXES ../extras/CUPTI/lib64/ + EXTRA_PATH_SUFFIXES extras/CUPTI/lib64/ + extras/CUPTI/lib/ + ../extras/CUPTI/lib64/ ../extras/CUPTI/lib/ EXTRA_INCLUDE_DIRS "${CUDAToolkit_CUPTI_INCLUDE_DIR}") endif() |