summaryrefslogtreecommitdiffstats
path: root/Modules/FindCUDAToolkit.cmake
diff options
context:
space:
mode:
authorSteven Hahn <hahnse@ornl.gov>2021-10-04 18:20:24 (GMT)
committerSteven Hahn <hahnse@ornl.gov>2021-10-05 18:44:39 (GMT)
commit32574814c78fb67cbe23dd1352ca304ec804d4e2 (patch)
tree02653ba9a40beed851fbcc3a8907b71684cafe64 /Modules/FindCUDAToolkit.cmake
parent3d192b09d139bc53903b981ba39d6cee46798cda (diff)
downloadCMake-32574814c78fb67cbe23dd1352ca304ec804d4e2.zip
CMake-32574814c78fb67cbe23dd1352ca304ec804d4e2.tar.gz
CMake-32574814c78fb67cbe23dd1352ca304ec804d4e2.tar.bz2
FindCUDAToolkit: Fix missing sibling include directory for math libraries
Fixes: #22706
Diffstat (limited to 'Modules/FindCUDAToolkit.cmake')
-rw-r--r--Modules/FindCUDAToolkit.cmake19
1 files changed, 19 insertions, 0 deletions
diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake
index 92042d2..d22a676 100644
--- a/Modules/FindCUDAToolkit.cmake
+++ b/Modules/FindCUDAToolkit.cmake
@@ -742,6 +742,19 @@ elseif(NOT CUDAToolkit_FIND_QUIETLY)
message(STATUS "Unable to find cuda_runtime.h in \"${CUDAToolkit_TARGET_DIR}/include\" for CUDAToolkit_INCLUDE_DIR.")
endif()
+# The NVHPC layout moves math library headers and libraries to a sibling directory.
+# Create a separate variable so this directory can be selectively added to math targets.
+if(NOT EXISTS "${CUDAToolkit_INCLUDE_DIR}/cublas_v2.h")
+ set(CUDAToolkit_MATH_INCLUDE_DIR "${CUDAToolkit_TARGET_DIR}/../../math_libs/include")
+ cmake_path(NORMAL_PATH CUDAToolkit_MATH_INCLUDE_DIR)
+ if(NOT EXISTS "${CUDAToolkit_MATH_INCLUDE_DIR}/cublas_v2.h")
+ if(NOT CUDAToolkit_FIND_QUIETLY)
+ message(STATUS "Unable to find cublas_v2.h in either \"${CUDAToolkit_INCLUDE_DIR}\" or \"${CUDAToolkit_MATH_INCLUDE_DIR}\"")
+ endif()
+ unset(CUDAToolkit_MATH_INCLUDE_DIR)
+ endif()
+endif()
+
if(CUDAToolkit_NVCC_EXECUTABLE AND
CMAKE_CUDA_COMPILER_VERSION AND
CUDAToolkit_NVCC_EXECUTABLE STREQUAL CMAKE_CUDA_COMPILER)
@@ -854,6 +867,12 @@ if(CUDAToolkit_FOUND)
if (NOT TARGET CUDA::${lib_name} AND CUDA_${lib_name}_LIBRARY)
add_library(CUDA::${lib_name} UNKNOWN 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)
+ if(NOT ${math_libs} EQUAL -1)
+ 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}")
foreach(dep ${arg_DEPS})
if(TARGET CUDA::${dep})