CUDA: Refactor implicit library filtering
Filter CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES just after it is computed. Re-use the same exclusion list for filtering CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES to avoid duplication.
This commit is contained in:
parent
5c7ca6f8a8
commit
16bed00712
@ -269,6 +269,24 @@ elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
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_static
|
||||||
|
cudadevrt
|
||||||
|
|
||||||
|
# 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})
|
||||||
|
|
||||||
if(CMAKE_CUDA_COMPILER_SYSROOT)
|
if(CMAKE_CUDA_COMPILER_SYSROOT)
|
||||||
string(CONCAT _SET_CMAKE_CUDA_COMPILER_SYSROOT
|
string(CONCAT _SET_CMAKE_CUDA_COMPILER_SYSROOT
|
||||||
"set(CMAKE_CUDA_COMPILER_SYSROOT \"${CMAKE_CUDA_COMPILER_SYSROOT}\")\n"
|
"set(CMAKE_CUDA_COMPILER_SYSROOT \"${CMAKE_CUDA_COMPILER_SYSROOT}\")\n"
|
||||||
|
@ -67,21 +67,9 @@ else()
|
|||||||
set(CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES "${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES}")
|
set(CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES "${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Remove the following libraries from CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES and
|
# Filter out implicit link libraries that should not be passed unconditionally.
|
||||||
# CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES
|
# See CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES_EXCLUDE in CMakeDetermineCUDACompiler.
|
||||||
#
|
list(REMOVE_ITEM CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES ${CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES_EXCLUDE})
|
||||||
# - cudart
|
|
||||||
# - cudart_static
|
|
||||||
# - cudadevrt
|
|
||||||
#
|
|
||||||
# Additionally on Linux:
|
|
||||||
# - rt
|
|
||||||
# - pthread
|
|
||||||
# - dl
|
|
||||||
#
|
|
||||||
# These are controlled by CMAKE_CUDA_RUNTIME_LIBRARY
|
|
||||||
list(REMOVE_ITEM CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES cudart cudart_static cudadevrt rt pthread dl)
|
|
||||||
list(REMOVE_ITEM CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES cudart cudart_static cudadevrt rt pthread dl)
|
|
||||||
|
|
||||||
if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
|
if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
|
||||||
# Remove the CUDA Toolkit include directories from the set of
|
# Remove the CUDA Toolkit include directories from the set of
|
||||||
|
Loading…
Reference in New Issue
Block a user