summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineCUDACompiler.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-05-22 11:48:19 (GMT)
committerBrad King <brad.king@kitware.com>2020-05-22 12:15:38 (GMT)
commitbcb44ac2ee0609b701fef84bcc333fda9b1c02b9 (patch)
treedc61302c46a26c15b9cf76d9b98e0fd4ad1d36fc /Modules/CMakeDetermineCUDACompiler.cmake
parent23519dd24fc3f6c1c0f80fd57aa99fea1d869962 (diff)
downloadCMake-bcb44ac2ee0609b701fef84bcc333fda9b1c02b9.zip
CMake-bcb44ac2ee0609b701fef84bcc333fda9b1c02b9.tar.gz
CMake-bcb44ac2ee0609b701fef84bcc333fda9b1c02b9.tar.bz2
CUDA: Simplify Clang implicit host linker settings
The purpose of `CMAKE_CUDA_HOST_IMPLICIT_LINK_*` is to capture the extra link libraries and directories that the CUDA compiler passes when invoking the host linker. We need this when using NVCC because CMake drives the host linker directly rather than through NVCC. However, this is not needed with Clang because: * Clang does not pass any CUDA libraries automatically. * We drive linking with the Clang compiler anyway. Drop the detection logic for Clang because it only gives the normal C++ runtime libraries which we do not need here.
Diffstat (limited to 'Modules/CMakeDetermineCUDACompiler.cmake')
-rw-r--r--Modules/CMakeDetermineCUDACompiler.cmake20
1 files changed, 6 insertions, 14 deletions
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake
index f115daa..4a8a268 100644
--- a/Modules/CMakeDetermineCUDACompiler.cmake
+++ b/Modules/CMakeDetermineCUDACompiler.cmake
@@ -137,22 +137,14 @@ elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "Clang")
endif()
endif()
- # Parsing implicit host linker info is as simple as for regular Clang.
- CMAKE_PARSE_IMPLICIT_LINK_INFO("${CMAKE_CUDA_COMPILER_PRODUCED_OUTPUT}"
- CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES
- CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES
- CMAKE_CUDA_HOST_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES
- log
- "${CMAKE_CUDA_IMPLICIT_OBJECT_REGEX}")
-
- # Get SDK directory.
- string(REGEX MATCH "Found CUDA installation: (.+), version" dont_care "${CMAKE_CUDA_COMPILER_PRODUCED_OUTPUT}")
- set(__cuda_directory "${CMAKE_MATCH_1}")
-
- # Clang doesn't add the SDK library directory to the implicit link path. Do it ourselves, so stuff works.
+ # Clang does not add any CUDA SDK libraries or directories when invoking the host linker.
+ # Add the CUDA toolkit library directory ourselves so that linking works.
+ # The CUDA runtime libraries are handled elsewhere by CMAKE_CUDA_RUNTIME_LIBRARY.
include(Internal/CUDAToolkit)
set(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES "${CUDAToolkit_INCLUDE_DIR}")
- list(APPEND CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES "${CUDAToolkit_LIBRARY_DIR}")
+ set(CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES "${CUDAToolkit_LIBRARY_DIR}")
+ set(CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES "")
+ set(CMAKE_CUDA_HOST_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "")
elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
set(_nvcc_log "")
string(REPLACE "\r" "" _nvcc_output_orig "${CMAKE_CUDA_COMPILER_PRODUCED_OUTPUT}")