From e2cba75d9ea2ac3bc0d751fcbf17f11d11dc1f31 Mon Sep 17 00:00:00 2001 From: CCCL Fix Date: Wed, 8 Apr 2026 21:24:05 +0800 Subject: [PATCH] fix(cmake): make CCCL::CUB an IMPORTED target to allow downstream export 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 --- lib/cmake/cccl/cccl-config.cmake | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/cmake/cccl/cccl-config.cmake b/lib/cmake/cccl/cccl-config.cmake index 81a6177d313..de1b6fd3cf0 100644 --- a/lib/cmake/cccl/cccl-config.cmake +++ b/lib/cmake/cccl/cccl-config.cmake @@ -67,10 +67,13 @@ foreach (component IN LISTS components) NO_DEFAULT_PATH # Only check the explicit HINTS below: HINTS "${cccl_cmake_dir}/../cub/" ) - # Can't alias other alias targets, so use the uglified target name instead - # of CUB::CUB: if (TARGET _CUB_CUB AND NOT TARGET CCCL::CUB) - add_library(CCCL::CUB ALIAS _CUB_CUB) + # Create CCCL::CUB as an IMPORTED target (not an ALIAS) so that downstream + # projects can install(EXPORT ...) their own targets that link to CCCL::CUB + # without CMake requiring _CUB_CUB to be in the export set. + # See: https://github.com/NVIDIA/cccl/issues/8069 + add_library(CCCL::CUB INTERFACE IMPORTED GLOBAL) + target_link_libraries(CCCL::CUB INTERFACE CUB::CUB) target_link_libraries(CCCL::CCCL INTERFACE CCCL::CUB) endif() elseif (component_lower STREQUAL "thrust")