Explicitly specify libcudart_static in CMake config (#9436)

This commit is contained in:
Philip Hyunsu Cho 2023-08-05 14:15:44 -07:00 committed by GitHub
parent 7fc57f3974
commit 5bd163aa25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -232,6 +232,15 @@ add_subdirectory(${xgboost_SOURCE_DIR}/plugin)
if (PLUGIN_RMM) if (PLUGIN_RMM)
find_package(rmm REQUIRED) find_package(rmm REQUIRED)
# Patch the rmm targets so they reference the static cudart
# Remove this patch once RMM stops specifying cudart requirement
# (since RMM is a header-only library, it should not specify cudart in its CMake config)
get_target_property(rmm_link_libs rmm::rmm INTERFACE_LINK_LIBRARIES)
list(REMOVE_ITEM rmm_link_libs CUDA::cudart)
list(APPEND rmm_link_libs CUDA::cudart_static)
set_target_properties(rmm::rmm PROPERTIES INTERFACE_LINK_LIBRARIES "${rmm_link_libs}")
get_target_property(rmm_link_libs rmm::rmm INTERFACE_LINK_LIBRARIES)
endif (PLUGIN_RMM) endif (PLUGIN_RMM)
#-- library #-- library

View File

@ -177,7 +177,8 @@ function(xgboost_set_cuda_flags target)
set_target_properties(${target} PROPERTIES set_target_properties(${target} PROPERTIES
CUDA_STANDARD 17 CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED ON CUDA_STANDARD_REQUIRED ON
CUDA_SEPARABLE_COMPILATION OFF) CUDA_SEPARABLE_COMPILATION OFF
CUDA_RUNTIME_LIBRARY Static)
endfunction(xgboost_set_cuda_flags) endfunction(xgboost_set_cuda_flags)
macro(xgboost_link_nccl target) macro(xgboost_link_nccl target)
@ -279,6 +280,7 @@ macro(xgboost_target_link_libraries target)
if (USE_CUDA) if (USE_CUDA)
xgboost_set_cuda_flags(${target}) xgboost_set_cuda_flags(${target})
target_link_libraries(${target} PUBLIC CUDA::cudart_static)
endif (USE_CUDA) endif (USE_CUDA)
if (PLUGIN_RMM) if (PLUGIN_RMM)