diff options
author | Brad King <brad.king@kitware.com> | 2022-12-01 13:02:42 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-12-01 13:02:49 (GMT) |
commit | 2a139018ce0acaabda6a311164f7a34c36cc21d0 (patch) | |
tree | c621ac762d47cc3155210bdc59d6f131a025ebad /Modules | |
parent | 5f7b953342dc1d851e275e890ab39cd93c708c59 (diff) | |
parent | 9d012b1f69c5bcc0fc1ee9452340f490dd2881d9 (diff) | |
download | CMake-2a139018ce0acaabda6a311164f7a34c36cc21d0.zip CMake-2a139018ce0acaabda6a311164f7a34c36cc21d0.tar.gz CMake-2a139018ce0acaabda6a311164f7a34c36cc21d0.tar.bz2 |
Merge topic 'find_cudatoolkit_avoid_nvhpc_symlinks'
9d012b1f69 FindCUDAToolkit: Ensure that paths provided have no symlinks
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7974
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() |