diff options
author | Brad King <brad.king@kitware.com> | 2021-02-09 13:21:11 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-02-09 13:21:17 (GMT) |
commit | 9b9075f7237c92acb70a9495b55f8ca356cf90fa (patch) | |
tree | 54d41d6f59f3e1178648c3bd1c1cb3b01978d743 /Modules/FindCUDA.cmake | |
parent | 18fa819e26c30038e93b0af1f5bbe17d2a776227 (diff) | |
parent | 3cef91a32159bd3e311b5c1d76798ae40a156ccb (diff) | |
download | CMake-9b9075f7237c92acb70a9495b55f8ca356cf90fa.zip CMake-9b9075f7237c92acb70a9495b55f8ca356cf90fa.tar.gz CMake-9b9075f7237c92acb70a9495b55f8ca356cf90fa.tar.bz2 |
Merge topic 'cuda_support_nvcc_from_hpctoolkit'
3cef91a321 CUDA: Always extract CUDA Toolkit root from nvcc verbose output
Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Raul Tambre <raul@tambre.ee>
Tested-by: Raul Tambre <raul@tambre.ee>
Merge-request: !5777
Diffstat (limited to 'Modules/FindCUDA.cmake')
-rw-r--r-- | Modules/FindCUDA.cmake | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 240f0a5..3d10aef 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -834,21 +834,18 @@ if(NOT CUDA_TOOLKIT_ROOT_DIR AND NOT CMAKE_CROSSCOMPILING) ) if (CUDA_TOOLKIT_ROOT_DIR_NVCC) - # If NVCC is a symlink due to a wrapper script (e.g. ccache or colornvcc), then invoke it to find the - # real non-scattered toolkit. - if(IS_SYMLINK ${CUDA_TOOLKIT_ROOT_DIR_NVCC}) - execute_process(COMMAND ${CUDA_TOOLKIT_ROOT_DIR_NVCC} "-v" "__cmake_determine_cuda" ERROR_VARIABLE NVCC_ERR) - if(NVCC_ERR MATCHES " _HERE_=([^\r\n]*)") - set(CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR "${CMAKE_MATCH_1}") - else() - message(FATAL_ERROR "Could not execute nvcc with -v.") - endif() - unset(NVCC_ERR) + # Given that NVCC can be provided by multiple different sources (NVIDIA HPC SDK, CUDA Toolkit, distro) + # each of which has a different layout, we need to extract the CUDA toolkit root from the compiler + # itself, allowing us to support numerous different scattered toolkit layouts + execute_process(COMMAND ${CUDA_TOOLKIT_ROOT_DIR_NVCC} "-v" "__cmake_determine_cuda" ERROR_VARIABLE NVCC_ERR) + if(NVCC_ERR MATCHES "TOP=([^\r\n]*)") + get_filename_component(CUDA_TOOLKIT_ROOT_DIR "${CMAKE_MATCH_1}" ABSOLUTE CACHE) else() - get_filename_component(CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR "${CUDA_TOOLKIT_ROOT_DIR_NVCC}" DIRECTORY) + get_filename_component(CUDA_TOOLKIT_ROOT_DIR "${CUDA_TOOLKIT_ROOT_DIR_NVCC}" DIRECTORY) + get_filename_component(CUDA_TOOLKIT_ROOT_DIR "${CUDA_TOOLKIT_ROOT_DIR}" DIRECTORY CACHE) endif() + unset(NVCC_ERR) - get_filename_component(CUDA_TOOLKIT_ROOT_DIR "${CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR}" DIRECTORY CACHE) string(REGEX REPLACE "[/\\\\]?bin[64]*[/\\\\]?$" "" CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR}) # We need to force this back into the cache. set(CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR} CACHE PATH "Toolkit location." FORCE) |