summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-02-15 15:29:19 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-02-15 15:29:24 (GMT)
commitc1e90c55448b62fd65521ae3b45f9cf043b05779 (patch)
tree46bd7336610f6f8980af4ec8af287164b0ea623d
parent26eae560ff1b0c718c89eda75a11f8f5be8b0ca7 (diff)
parent9ea66b2d86ba0449c41357c172fdf54a91424dfc (diff)
downloadCMake-c1e90c55448b62fd65521ae3b45f9cf043b05779.zip
CMake-c1e90c55448b62fd65521ae3b45f9cf043b05779.tar.gz
CMake-c1e90c55448b62fd65521ae3b45f9cf043b05779.tar.bz2
Merge topic 'cuda-nvcc-output' into release-3.20
9ea66b2d86 CUDA: Capture all nvcc output when extracting toolkit root Acked-by: Kitware Robot <kwrobot@kitware.com> Reviewed-by: Raul Tambre <raul@tambre.ee> Tested-by: Raul Tambre <raul@tambre.ee> Acked-by: Rong Ou <rong.ou@gmail.com> Merge-request: !5804
-rw-r--r--Modules/CMakeDetermineCUDACompiler.cmake7
-rw-r--r--Modules/FindCUDA.cmake7
-rw-r--r--Modules/FindCUDAToolkit.cmake7
3 files changed, 12 insertions, 9 deletions
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake
index 468b8a1..dd539b7 100644
--- a/Modules/CMakeDetermineCUDACompiler.cmake
+++ b/Modules/CMakeDetermineCUDACompiler.cmake
@@ -175,14 +175,15 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN)
# 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_NVCC_EXECUTABLE} "-v" "__cmake_determine_cuda" ERROR_VARIABLE NVCC_ERR)
- if(NVCC_ERR MATCHES "TOP=([^\r\n]*)")
+ execute_process(COMMAND ${_CUDA_NVCC_EXECUTABLE} "-v" "__cmake_determine_cuda"
+ OUTPUT_VARIABLE _CUDA_NVCC_OUT ERROR_VARIABLE _CUDA_NVCC_OUT)
+ if(_CUDA_NVCC_OUT MATCHES "TOP=([^\r\n]*)")
get_filename_component(CMAKE_CUDA_COMPILER_TOOLKIT_ROOT "${CMAKE_MATCH_1}" ABSOLUTE)
else()
get_filename_component(CMAKE_CUDA_COMPILER_TOOLKIT_ROOT "${_CUDA_NVCC_EXECUTABLE}" DIRECTORY)
get_filename_component(CMAKE_CUDA_COMPILER_TOOLKIT_ROOT "${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}" DIRECTORY)
endif()
- unset(NVCC_ERR)
+ unset(_CUDA_NVCC_OUT)
set(CMAKE_CUDA_DEVICE_LINKER "${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/bin/nvlink${CMAKE_EXECUTABLE_SUFFIX}")
set(CMAKE_CUDA_FATBINARY "${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/bin/fatbinary${CMAKE_EXECUTABLE_SUFFIX}")
diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake
index 3d10aef..620e32a 100644
--- a/Modules/FindCUDA.cmake
+++ b/Modules/FindCUDA.cmake
@@ -837,14 +837,15 @@ if(NOT CUDA_TOOLKIT_ROOT_DIR AND NOT CMAKE_CROSSCOMPILING)
# 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]*)")
+ execute_process(COMMAND ${CUDA_TOOLKIT_ROOT_DIR_NVCC} "-v" "__cmake_determine_cuda"
+ OUTPUT_VARIABLE _CUDA_NVCC_OUT ERROR_VARIABLE _CUDA_NVCC_OUT)
+ if(_CUDA_NVCC_OUT MATCHES "TOP=([^\r\n]*)")
get_filename_component(CUDA_TOOLKIT_ROOT_DIR "${CMAKE_MATCH_1}" ABSOLUTE CACHE)
else()
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)
+ unset(_CUDA_NVCC_OUT)
string(REGEX REPLACE "[/\\\\]?bin[64]*[/\\\\]?$" "" CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR})
# We need to force this back into the cache.
diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake
index 256c98f..de2b068 100644
--- a/Modules/FindCUDAToolkit.cmake
+++ b/Modules/FindCUDAToolkit.cmake
@@ -522,13 +522,14 @@ else()
# If NVCC exists then invoke it to find the toolkit location.
# This allows us to support wrapper scripts (e.g. ccache or colornvcc), CUDA Toolkit,
# NVIDIA HPC SDK, and distro's splayed layouts
- execute_process(COMMAND ${CUDAToolkit_NVCC_EXECUTABLE} "-v" "__cmake_determine_cuda" ERROR_VARIABLE NVCC_ERR)
- if(NVCC_ERR MATCHES "TOP=([^\r\n]*)")
+ execute_process(COMMAND ${CUDAToolkit_NVCC_EXECUTABLE} "-v" "__cmake_determine_cuda"
+ OUTPUT_VARIABLE _CUDA_NVCC_OUT ERROR_VARIABLE _CUDA_NVCC_OUT)
+ if(_CUDA_NVCC_OUT MATCHES "TOP=([^\r\n]*)")
get_filename_component(CUDAToolkit_BIN_DIR "${CMAKE_MATCH_1}/bin" ABSOLUTE)
else()
get_filename_component(CUDAToolkit_BIN_DIR "${CUDAToolkit_NVCC_EXECUTABLE}" DIRECTORY)
endif()
- unset(NVCC_ERR)
+ unset(_CUDA_NVCC_OUT)
mark_as_advanced(CUDAToolkit_BIN_DIR)
set(CUDAToolkit_BIN_DIR "${CUDAToolkit_BIN_DIR}" CACHE PATH "" FORCE)