From 5fdade98a97a4d7bab4da2ced59e47038b97c003 Mon Sep 17 00:00:00 2001 From: Philip Hyunsu Cho Date: Thu, 25 Jul 2024 00:41:56 -0700 Subject: [PATCH] Allow building with CCCL that's newer than CTK (#10633) --- cmake/Utils.cmake | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cmake/Utils.cmake b/cmake/Utils.cmake index f508d27e18cb..b12302a166c0 100644 --- a/cmake/Utils.cmake +++ b/cmake/Utils.cmake @@ -108,7 +108,20 @@ function(xgboost_set_cuda_flags target) target_compile_definitions(${target} PRIVATE -DXGBOOST_USE_NVTX=1) endif() - target_link_libraries(${target} PRIVATE CCCL::CCCL) + # Use CCCL we find before CUDA Toolkit to make sure we get newer headers as intended + # The CUDA Toolkit includes its own copy of CCCL that often lags the latest releases + # (and would be picked up otherwise) + if(BUILD_STATIC_LIB) + # If the downstream user is statically linking with libxgboost, it needs to + # explicitly link with CCCL and CUDA runtime. + target_link_libraries(${target} + PUBLIC CCCL::CCCL CUDA::cudart_static) + else() + # If the downstream user is dynamically linking with libxgboost, it does not + # need to link with CCCL and CUDA runtime. + target_link_libraries(${target} + PRIVATE CCCL::CCCL CUDA::cudart_static) + endif() target_compile_definitions(${target} PRIVATE -DXGBOOST_USE_CUDA=1) target_include_directories( ${target} PRIVATE @@ -239,7 +252,6 @@ macro(xgboost_target_link_libraries target) if(USE_CUDA) xgboost_set_cuda_flags(${target}) - target_link_libraries(${target} PUBLIC CUDA::cudart_static) endif() if(PLUGIN_RMM)