Skip to content

Commit

Permalink
Ensure the targets that Thrust creates are global. (#1182)
Browse files Browse the repository at this point in the history
When using CCCL via `add_subdirectory` the CCCL::Thrust target isn't visible to consumers.
This is due to the fact that it is non-global and therefore scoped to the
CCCL source directory.

All other `CCCL::` targets are global so this brings everything inline
  • Loading branch information
robertmaynard authored Dec 8, 2023
1 parent b69e201 commit 7654911
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/cmake/cccl/cccl-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ foreach(component IN LISTS components)
DEVICE_OPTION_DOC
"Device system for CCCL::Thrust target."
ADVANCED
GLOBAL
)
target_link_libraries(CCCL::CCCL INTERFACE CCCL::Thrust)
endif()
Expand Down
8 changes: 7 additions & 1 deletion thrust/thrust/cmake/thrust-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
# [HOST <default system>] # Optionally change the default backend
# [DEVICE <default system>] # Optionally change the default backend
# [ADVANCED] # Optionally mark options as advanced
# [GLOBAL] # Optionally mark the target as GLOBAL
# )
#
# # Use a custom TBB, CUB, and/or OMP
Expand Down Expand Up @@ -107,6 +108,7 @@ set(THRUST_VERSION_COUNT ${${CMAKE_FIND_PACKAGE_NAME}_VERSION_COUNT} CACHE INTER
function(thrust_create_target target_name)
thrust_debug("Assembling target ${target_name}. Options: ${ARGN}" internal)
set(options
GLOBAL
ADVANCED
FROM_OPTIONS
IGNORE_CUB_VERSION_CHECK
Expand Down Expand Up @@ -180,7 +182,11 @@ function(thrust_create_target target_name)
# We can just create an INTERFACE IMPORTED target here instead of going
# through _thrust_declare_interface_alias as long as we aren't hanging any
# Thrust/CUB include paths directly on ${target_name}.
add_library(${target_name} INTERFACE IMPORTED)
set(TCT_AS_GLOBAL )
if (TCT_GLOBAL)
set(TCT_AS_GLOBAL GLOBAL)
endif()
add_library(${target_name} INTERFACE IMPORTED ${TCT_AS_GLOBAL})
target_link_libraries(${target_name}
INTERFACE
Thrust::${TCT_HOST}::Host
Expand Down

0 comments on commit 7654911

Please sign in to comment.