Browse Source

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.
Brad King 5 years ago
parent
commit
bcb44ac2ee
1 changed files with 6 additions and 14 deletions
  1. 6 14
      Modules/CMakeDetermineCUDACompiler.cmake

+ 6 - 14
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}")