mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
CUDA: Factor out helper to filter implicit link libraries
Prepare to use it for other languages.
This commit is contained in:
@@ -439,23 +439,9 @@ elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
|
||||
"set(CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT \"${CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT}\")")
|
||||
endif()
|
||||
|
||||
# CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES is detected above as the list of
|
||||
# libraries that the CUDA compiler implicitly passes to the host linker.
|
||||
# CMake invokes the host linker directly and so needs to pass these libraries.
|
||||
# We filter out those that should not be passed unconditionally both here
|
||||
# and from CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES in CMakeTestCUDACompiler.
|
||||
set(CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES_EXCLUDE
|
||||
# The CUDA runtime libraries are controlled by CMAKE_CUDA_RUNTIME_LIBRARY.
|
||||
cudart cudart.lib
|
||||
cudart_static cudart_static.lib
|
||||
cudadevrt cudadevrt.lib
|
||||
|
||||
# Dependencies of the CUDA static runtime library on Linux hosts.
|
||||
rt
|
||||
pthread
|
||||
dl
|
||||
)
|
||||
list(REMOVE_ITEM CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES ${CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES_EXCLUDE})
|
||||
include(Internal/CMakeCUDAFilterImplicitLibs)
|
||||
# Filter out implicit link libraries that should not be passed unconditionally.
|
||||
cmake_cuda_filter_implicit_libs(CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES)
|
||||
|
||||
if(CMAKE_CUDA_COMPILER_SYSROOT)
|
||||
string(CONCAT _SET_CMAKE_CUDA_COMPILER_SYSROOT
|
||||
|
||||
@@ -114,9 +114,9 @@ if("x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC")
|
||||
set(CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES "${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES}")
|
||||
endif()
|
||||
|
||||
include(Internal/CMakeCUDAFilterImplicitLibs)
|
||||
# Filter out implicit link libraries that should not be passed unconditionally.
|
||||
# See CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES_EXCLUDE in CMakeDetermineCUDACompiler.
|
||||
list(REMOVE_ITEM CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES ${CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES_EXCLUDE})
|
||||
cmake_cuda_filter_implicit_libs(CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES)
|
||||
|
||||
if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
|
||||
include(Internal/CMakeNVCCFilterImplicitInfo)
|
||||
|
||||
20
Modules/Internal/CMakeCUDAFilterImplicitLibs.cmake
Normal file
20
Modules/Internal/CMakeCUDAFilterImplicitLibs.cmake
Normal file
@@ -0,0 +1,20 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
# In CMakeDetermineCUDACompiler and CMakeTestCUDACompiler we detect
|
||||
# libraries that the CUDA compiler implicitly passes to the host linker.
|
||||
# CMake invokes the host linker directly and so needs to pass these libraries.
|
||||
# Filter out implicit link libraries that should not be passed unconditionally.
|
||||
macro(cmake_cuda_filter_implicit_libs _var_CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES)
|
||||
list(REMOVE_ITEM "${_var_CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES}"
|
||||
# The CUDA runtime libraries are controlled by CMAKE_CUDA_RUNTIME_LIBRARY.
|
||||
cudart cudart.lib
|
||||
cudart_static cudart_static.lib
|
||||
cudadevrt cudadevrt.lib
|
||||
|
||||
# Dependencies of the CUDA static runtime library on Linux hosts.
|
||||
rt
|
||||
pthread
|
||||
dl
|
||||
)
|
||||
endmacro()
|
||||
Reference in New Issue
Block a user