Skip to content

Commit 5bd163a

Browse files
authored
Explicitly specify libcudart_static in CMake config (dmlc#9436)
1 parent 7fc57f3 commit 5bd163a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,15 @@ add_subdirectory(${xgboost_SOURCE_DIR}/plugin)
232232

233233
if (PLUGIN_RMM)
234234
find_package(rmm REQUIRED)
235+
236+
# Patch the rmm targets so they reference the static cudart
237+
# Remove this patch once RMM stops specifying cudart requirement
238+
# (since RMM is a header-only library, it should not specify cudart in its CMake config)
239+
get_target_property(rmm_link_libs rmm::rmm INTERFACE_LINK_LIBRARIES)
240+
list(REMOVE_ITEM rmm_link_libs CUDA::cudart)
241+
list(APPEND rmm_link_libs CUDA::cudart_static)
242+
set_target_properties(rmm::rmm PROPERTIES INTERFACE_LINK_LIBRARIES "${rmm_link_libs}")
243+
get_target_property(rmm_link_libs rmm::rmm INTERFACE_LINK_LIBRARIES)
235244
endif (PLUGIN_RMM)
236245

237246
#-- library

cmake/Utils.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ function(xgboost_set_cuda_flags target)
177177
set_target_properties(${target} PROPERTIES
178178
CUDA_STANDARD 17
179179
CUDA_STANDARD_REQUIRED ON
180-
CUDA_SEPARABLE_COMPILATION OFF)
180+
CUDA_SEPARABLE_COMPILATION OFF
181+
CUDA_RUNTIME_LIBRARY Static)
181182
endfunction(xgboost_set_cuda_flags)
182183

183184
macro(xgboost_link_nccl target)
@@ -279,6 +280,7 @@ macro(xgboost_target_link_libraries target)
279280

280281
if (USE_CUDA)
281282
xgboost_set_cuda_flags(${target})
283+
target_link_libraries(${target} PUBLIC CUDA::cudart_static)
282284
endif (USE_CUDA)
283285

284286
if (PLUGIN_RMM)

0 commit comments

Comments
 (0)