Skip to content

Commit 6c0a33e

Browse files
authored
fix(cmake): make CCCL::CUB an IMPORTED target to allow downstream export (#8330)
Previously, CCCL::CUB was created as an ALIAS for the non-IMPORTED _CUB_CUB target. When downstream projects tried to install(EXPORT ...) a target that links to CCCL::CUB, CMake would resolve the alias and complain that _CUB_CUB was not in any export set: CMake Error: install(EXPORT "fooTargets" ...) includes target "foo" which requires target "_CUB_CUB" that is not in any export set. Fix this by creating CCCL::CUB as an INTERFACE IMPORTED GLOBAL target that links to CUB::CUB, mirroring the pattern already used by CCCL::Thrust (created via thrust_create_target as IMPORTED GLOBAL). Since CCCL::CUB is IMPORTED, CMake treats it as an external dependency and does not require it to be included in downstream export sets. Fixes #8069
1 parent cf1a8ef commit 6c0a33e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/cmake/cccl/cccl-config.cmake

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,13 @@ foreach (component IN LISTS components)
6767
NO_DEFAULT_PATH # Only check the explicit HINTS below:
6868
HINTS "${cccl_cmake_dir}/../cub/"
6969
)
70-
# Can't alias other alias targets, so use the uglified target name instead
71-
# of CUB::CUB:
7270
if (TARGET _CUB_CUB AND NOT TARGET CCCL::CUB)
73-
add_library(CCCL::CUB ALIAS _CUB_CUB)
71+
# Create CCCL::CUB as an IMPORTED target (not an ALIAS) so that downstream
72+
# projects can install(EXPORT ...) their own targets that link to CCCL::CUB
73+
# without CMake requiring _CUB_CUB to be in the export set.
74+
# See: https://github.com/NVIDIA/cccl/issues/8069
75+
add_library(CCCL::CUB INTERFACE IMPORTED GLOBAL)
76+
target_link_libraries(CCCL::CUB INTERFACE CUB::CUB)
7477
target_link_libraries(CCCL::CCCL INTERFACE CCCL::CUB)
7578
endif()
7679
elseif (component_lower STREQUAL "thrust")

0 commit comments

Comments
 (0)