Skip to content

Commit 5ea5027

Browse files
committed
fix: make nvtx3 bundling conditional on rmm absorption
1 parent 8918aed commit 5ea5027

3 files changed

Lines changed: 22 additions & 16 deletions

File tree

cpp/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,20 @@ foreach(_dep IN LISTS _absorbed_deps)
10991099
set(_${_dep}_link ${_dep}::${_dep})
11001100
endforeach()
11011101
if(BUILD_SHARED_LIBS)
1102+
# When rmm is a static library being absorbed via whole-archive, strip nvtx3 from its public
1103+
# interface. We bundle nvtx3 headers directly into cudf's install tree, so consumers get them from
1104+
# cudf's include path without needing the nvtx3 target or find_dependency(nvtx3).
1105+
get_target_property(_rmm_type rmm::rmm TYPE)
1106+
if(_rmm_type STREQUAL "STATIC_LIBRARY")
1107+
get_target_property(_rmm_real rmm::rmm ALIASED_TARGET)
1108+
if(_rmm_real)
1109+
get_target_property(_rmm_libs ${_rmm_real} INTERFACE_LINK_LIBRARIES)
1110+
if(_rmm_libs)
1111+
list(REMOVE_ITEM _rmm_libs nvtx3::nvtx3-cpp)
1112+
set_property(TARGET ${_rmm_real} PROPERTY INTERFACE_LINK_LIBRARIES ${_rmm_libs})
1113+
endif()
1114+
endif()
1115+
endif()
11021116
foreach(_dep IN LISTS _absorbed_deps)
11031117
get_target_property(_target_type ${_dep}::${_dep} TYPE)
11041118
if(NOT _target_type STREQUAL "STATIC_LIBRARY")

cpp/cmake/thirdparty/get_nvtx.cmake

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@
99
function(find_and_configure_nvtx)
1010
include(${rapids-cmake-dir}/cpm/nvtx3.cmake)
1111

12-
# nvtx3 headers are bundled directly into cudf's install tree, so we only need the build-side
13-
# export set for configure-time target resolution. No INSTALL_EXPORT_SET — consumers get headers
14-
# from cudf's include directory without needing find_dependency(nvtx3).
15-
rapids_cpm_nvtx3(BUILD_EXPORT_SET cudf-exports ${CUDF_EXCLUDE_DEPS_FROM_ALL_FLAG})
12+
# nvtx3 is private for cudf, but it is a public dependency of rmm. When rmm is absorbed into
13+
# libcudf via whole-archive, rmm's public transitive deps (including nvtx3-cpp) are promoted into
14+
# cudf's public interface. CMake's export validation requires that nvtx3-cpp be in an export set.
15+
rapids_cpm_nvtx3(
16+
BUILD_EXPORT_SET cudf-exports INSTALL_EXPORT_SET cudf-exports
17+
${CUDF_EXCLUDE_DEPS_FROM_ALL_FLAG}
18+
)
1619

17-
# Propagate source dir to parent scope for header installation.
20+
# Propagate source dir to parent scope (needed for header installation in standalone builds)
1821
set(nvtx3_SOURCE_DIR
1922
"${nvtx3_SOURCE_DIR}"
2023
PARENT_SCOPE

cpp/cmake/thirdparty/get_rmm.cmake

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,6 @@ function(find_and_configure_rmm BUILD_SHARED EXCLUDE_FROM_ALL)
2121
list(APPEND _rmm_args INSTALL_EXPORT_SET cudf-exports)
2222
endif()
2323
rapids_cpm_rmm(${_rmm_args} ${_exclude_flag} CPM_ARGS OPTIONS "BUILD_SHARED_LIBS ${BUILD_SHARED}")
24-
# Remove nvtx3 from rmm's public interface. Since rmm is absorbed into libcudf via whole-archive
25-
# and we bundle nvtx3 headers directly, consumers don't need the nvtx3 target. This prevents the
26-
# absorption loop from promoting nvtx3 into cudf's installed interface.
27-
get_target_property(_rmm_real_target rmm::rmm ALIASED_TARGET)
28-
if(_rmm_real_target)
29-
get_target_property(_rmm_iface_libs ${_rmm_real_target} INTERFACE_LINK_LIBRARIES)
30-
if(_rmm_iface_libs)
31-
list(REMOVE_ITEM _rmm_iface_libs nvtx3::nvtx3-cpp)
32-
set_property(TARGET ${_rmm_real_target} PROPERTY INTERFACE_LINK_LIBRARIES ${_rmm_iface_libs})
33-
endif()
34-
endif()
3524

3625
# If rmm was found as a pre-existing shared library (e.g. conda), we need find_dependency(rmm) in
3726
# the installed config even when EXCLUDE_FROM_ALL is set. EXCLUDE_FROM_ALL controls whether CPM-

0 commit comments

Comments
 (0)