summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorRaul Tambre <raul@tambre.ee>2020-06-11 16:50:04 (GMT)
committerRaul Tambre <raul@tambre.ee>2020-06-12 18:49:15 (GMT)
commit8c144fe9adf213bb91474e97b569e55f163dabd1 (patch)
treeffee8441f44384d19102cf42187d3536cecac0b5 /Modules
parent403f8d31e3fed4067b810c683391fc1fdffe815a (diff)
downloadCMake-8c144fe9adf213bb91474e97b569e55f163dabd1.zip
CMake-8c144fe9adf213bb91474e97b569e55f163dabd1.tar.gz
CMake-8c144fe9adf213bb91474e97b569e55f163dabd1.tar.bz2
FindCUDAToolkit: Compute CUDAToolkit_INCLUDE_DIR instead of searching
We can avoid searching for this since CUDAToolkit_TARGET_DIR always contains the include/ directory. But add a warning just in case. Also apply this in CMakeDetermineCUDACompiler for Clang code.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeDetermineCUDACompiler.cmake11
-rw-r--r--Modules/FindCUDAToolkit.cmake11
2 files changed, 14 insertions, 8 deletions
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake
index 205bf07..f31e2e8 100644
--- a/Modules/CMakeDetermineCUDACompiler.cmake
+++ b/Modules/CMakeDetermineCUDACompiler.cmake
@@ -332,10 +332,13 @@ elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "Clang")
message(FATAL_ERROR "Unable to find _CUDA_LIBRARY_DIR based on _CUDA_TARGET_DIR=${_CUDA_TARGET_DIR}")
endif()
- find_path(_CUDA_INCLUDE_DIR
- NAMES cuda_runtime.h
- HINTS "${_CUDA_TARGET_DIR}/include"
- )
+ # _CUDA_TARGET_DIR always points to the directory containing the include directory.
+ # On a scattered installation /usr, on a non-scattered something like /usr/local/cuda or /usr/local/cuda-10.2/targets/aarch64-linux.
+ if(EXISTS "${_CUDA_TARGET_DIR}/include/cuda_runtime.h")
+ set(_CUDA_INCLUDE_DIR "${_CUDA_TARGET_DIR}/include")
+ else()
+ message(FATAL_ERROR "Unable to find cuda_runtime.h in \"${_CUDA_TARGET_DIR}/include\" for _CUDA_INCLUDE_DIR.")
+ endif()
# Clang does not add any CUDA SDK libraries or directories when invoking the host linker.
# Add the CUDA toolkit library directory ourselves so that linking works.
diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake
index 555693b..7ec9cbe 100644
--- a/Modules/FindCUDAToolkit.cmake
+++ b/Modules/FindCUDAToolkit.cmake
@@ -694,10 +694,13 @@ else()
set(_CUDAToolkit_Pop_Prefix True)
endif()
-# Find the include/ directory
-find_path(CUDAToolkit_INCLUDE_DIR
- NAMES cuda_runtime.h
-)
+# CUDAToolkit_TARGET_DIR always points to the directory containing the include directory.
+# On a scattered installation /usr, on a non-scattered something like /usr/local/cuda or /usr/local/cuda-10.2/targets/aarch64-linux.
+if(EXISTS "${CUDAToolkit_TARGET_DIR}/include/cuda_runtime.h")
+ set(CUDAToolkit_INCLUDE_DIR "${CUDAToolkit_TARGET_DIR}/include")
+elseif(NOT CUDAToolkit_FIND_QUIETLY)
+ message(STATUS "Unable to find cuda_runtime.h in \"${CUDAToolkit_TARGET_DIR}/include\" for CUDAToolkit_INCLUDE_DIR.")
+endif()
if(CUDAToolkit_NVCC_EXECUTABLE AND
CUDAToolkit_NVCC_EXECUTABLE STREQUAL CMAKE_CUDA_COMPILER)