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/FindCUDAToolkit.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/FindCUDAToolkit.cmake')
-rw-r--r-- | Modules/FindCUDAToolkit.cmake | 15 |
1 files changed, 15 insertions, 0 deletions
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") |