diff --git a/CMakeLists.txt b/CMakeLists.txt index a026888df..6a3fd3c73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,6 +232,15 @@ add_subdirectory(${xgboost_SOURCE_DIR}/plugin) if (PLUGIN_RMM) 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) #-- library diff --git a/cmake/Utils.cmake b/cmake/Utils.cmake index 98e96e304..08050205c 100644 --- a/cmake/Utils.cmake +++ b/cmake/Utils.cmake @@ -177,7 +177,8 @@ function(xgboost_set_cuda_flags target) set_target_properties(${target} PROPERTIES CUDA_STANDARD 17 CUDA_STANDARD_REQUIRED ON - CUDA_SEPARABLE_COMPILATION OFF) + CUDA_SEPARABLE_COMPILATION OFF + CUDA_RUNTIME_LIBRARY Static) endfunction(xgboost_set_cuda_flags) macro(xgboost_link_nccl target) @@ -279,6 +280,7 @@ macro(xgboost_target_link_libraries target) if (USE_CUDA) xgboost_set_cuda_flags(${target}) + target_link_libraries(${target} PUBLIC CUDA::cudart_static) endif (USE_CUDA) if (PLUGIN_RMM)