diff options
author | Raul Tambre <raul@tambre.ee> | 2020-06-06 15:36:22 (GMT) |
---|---|---|
committer | Raul Tambre <raul@tambre.ee> | 2020-06-12 18:49:15 (GMT) |
commit | 403f8d31e3fed4067b810c683391fc1fdffe815a (patch) | |
tree | d9c8555ef5f4a08f71149763dfb87c6e57a45bb8 /Modules/CMakeDetermineCUDACompiler.cmake | |
parent | 6636693134ab855dc1c253e40ab73e1489543152 (diff) | |
download | CMake-403f8d31e3fed4067b810c683391fc1fdffe815a.zip CMake-403f8d31e3fed4067b810c683391fc1fdffe815a.tar.gz CMake-403f8d31e3fed4067b810c683391fc1fdffe815a.tar.bz2 |
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.
Diffstat (limited to 'Modules/CMakeDetermineCUDACompiler.cmake')
-rw-r--r-- | Modules/CMakeDetermineCUDACompiler.cmake | 12 |
1 files changed, 12 insertions, 0 deletions
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) |