summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/release/3.18.rst4
-rw-r--r--Modules/CMakeDetermineCUDACompiler.cmake12
-rw-r--r--Modules/FindCUDAToolkit.cmake15
3 files changed, 31 insertions, 0 deletions
diff --git a/Help/release/3.18.rst b/Help/release/3.18.rst
index 71f9d85..027ef5c 100644
--- a/Help/release/3.18.rst
+++ b/Help/release/3.18.rst
@@ -194,6 +194,10 @@ Modules
.. _`SWIG-Fortran`: https://github.com/swig-fortran/swig
+* The :module:`FindCUDAToolkit` module gained the variable
+ ``CUDAToolkit_LIBRARY_ROOT``, which is the directory containing the ``nvvm``
+ directory and ``version.txt``.
+
Generator Expressions
---------------------
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake
index 830a0e9..205bf07 100644
--- a/Modules/CMakeDetermineCUDACompiler.cmake
+++ b/Modules/CMakeDetermineCUDACompiler.cmake
@@ -286,6 +286,17 @@ elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "Clang")
get_filename_component(_CUDA_ROOT_DIR "${_CUDA_NVCC_EXECUTABLE}" DIRECTORY)
get_filename_component(_CUDA_ROOT_DIR "${_CUDA_ROOT_DIR}" DIRECTORY ABSOLUTE)
+ # _CUDA_LIBRARY_ROOT contains the device library and version file.
+ # In a non-scattered installation this is equivalent to _CUDA_ROOT_DIR.
+ # We first check for a non-scattered installation to prefer it over a scattered installation.
+ if(EXISTS "${_CUDA_ROOT_DIR}/version.txt")
+ set(_CUDA_LIBRARY_ROOT "${_CUDA_ROOT_DIR}")
+ elseif(CMAKE_SYSROOT_LINK AND EXISTS "${CMAKE_SYSROOT_LINK}/usr/lib/cuda/version.txt")
+ set(_CUDA_LIBRARY_ROOT "${CMAKE_SYSROOT_LINK}/usr/lib/cuda")
+ elseif(EXISTS "${CMAKE_SYSROOT}/usr/lib/cuda/version.txt")
+ set(_CUDA_LIBRARY_ROOT "${CMAKE_SYSROOT}/usr/lib/cuda")
+ endif()
+
# Find target directory. Account for crosscompiling.
if(CMAKE_CROSSCOMPILING)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a")
@@ -338,6 +349,7 @@ elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "Clang")
unset(_CUDA_INCLUDE_DIR CACHE)
unset(_CUDA_NVCC_EXECUTABLE CACHE)
unset(_CUDA_LIBRARY_DIR)
+ unset(_CUDA_LIBRARY_ROOT)
unset(_CUDA_ROOT_DIR)
unset(_CUDA_TARGET_DIR)
unset(_CUDA_TARGET_NAME)
diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake
index e1616c6..555693b 100644
--- a/Modules/FindCUDAToolkit.cmake
+++ b/Modules/FindCUDAToolkit.cmake
@@ -421,6 +421,10 @@ Result variables
The path to the CUDA Toolkit library directory that contains the CUDA
Runtime library ``cudart``.
+``CUDAToolkit_LIBRARY_ROOT``
+ The path to the CUDA Toolkit directory containing the nvvm directory and
+ version.txt.
+
``CUDAToolkit_TARGET_DIR``
The path to the CUDA Toolkit directory including the target architecture
when cross-compiling. When not cross-compiling this will be equivalant to
@@ -638,6 +642,17 @@ endif()
get_filename_component(CUDAToolkit_ROOT_DIR ${CUDAToolkit_BIN_DIR} DIRECTORY ABSOLUTE)
+# CUDAToolkit_LIBRARY_ROOT contains the device library and version file.
+# In a non-scattered installation this is equivalent to CUDAToolkit_ROOT_DIR.
+# We first check for a non-scattered installation to prefer it over a scattered installation.
+if(EXISTS "${CUDAToolkit_ROOT_DIR}/version.txt")
+ set(CUDAToolkit_LIBRARY_ROOT "${CUDAToolkit_ROOT_DIR}")
+elseif(CMAKE_SYSROOT_LINK AND EXISTS "${CMAKE_SYSROOT_LINK}/usr/lib/cuda/version.txt")
+ set(CUDAToolkit_LIBRARY_ROOT "${CMAKE_SYSROOT_LINK}/usr/lib/cuda")
+elseif(EXISTS "${CMAKE_SYSROOT}/usr/lib/cuda/version.txt")
+ set(CUDAToolkit_LIBRARY_ROOT "${CMAKE_SYSROOT}/usr/lib/cuda")
+endif()
+
# Handle cross compilation
if(CMAKE_CROSSCOMPILING)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a")