mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 10:50:16 -06:00
FindCUDAToolkit: Add CUDAToolkit_LIBRARY_ROOT
On scattered installations version.txt and nvvm are located at this location. This may be useful to users and will allow us in the future to parse version.txt instead of invoking nvcc to figure out the CUDA toolkit version. We also add it to CMakeDetermineCUDACompiler in preparation for future use by Clang code.
This commit is contained in:
@@ -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
|
||||
---------------------
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user