Skip to content

Commit bb001b7

Browse files
authored
Reduce scope of Thrust linkage in cudax. (#2496)
It's only used for tests, it doesn't need to be linked to all cudax targets.
1 parent 3eee9b2 commit bb001b7

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

cudax/cmake/cudaxBuildTargetList.cmake

-8
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,13 @@ function(_cn_init_target_list)
107107
set(cudax_TARGETS "" CACHE INTERNAL "" FORCE)
108108
endfunction()
109109

110-
# Bring in thrust as a dev dependency, only used in tests:
111-
find_package(Thrust ${cudax_VERSION} EXACT CONFIG
112-
NO_DEFAULT_PATH # Only check the explicit path in HINTS:
113-
HINTS "${CCCL_SOURCE_DIR}/lib/cmake/thrust/"
114-
)
115-
thrust_create_target(cudax::Thrust)
116-
117110
function(_cn_add_target_to_target_list target_name dialect prefix)
118111
add_library(${target_name} INTERFACE)
119112

120113
cudax_set_target_properties(${target_name} ${dialect} ${prefix})
121114

122115
target_link_libraries(${target_name} INTERFACE
123116
cudax::cudax
124-
cudax::Thrust
125117
cudax.compiler_interface_cpp${dialect}
126118
)
127119

cudax/test/CMakeLists.txt

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
include("${cudax_SOURCE_DIR}/cmake/CPM.cmake")
22
CPMAddPackage("gh:catchorg/[email protected]")
33

4+
find_package(Thrust ${cudax_VERSION} EXACT CONFIG
5+
NO_DEFAULT_PATH # Only check the explicit path in HINTS:
6+
HINTS "${CCCL_SOURCE_DIR}/lib/cmake/thrust/"
7+
)
8+
thrust_create_target(cudax.test.thrust)
9+
410
add_library(catch2_main STATIC catch2_helpers/catch2_main.cpp)
511
target_link_libraries(catch2_main PUBLIC Catch2::Catch2)
612

@@ -24,9 +30,16 @@ function(cudax_add_catch2_test target_name_var test_name cn_target) # ARGN=test
2430

2531
add_executable(${test_target} ${test_sources})
2632
target_include_directories(${test_target} PRIVATE "common")
27-
target_link_libraries(${test_target} PRIVATE ${cn_target} Catch2::Catch2 catch2_main)
28-
target_compile_options(${test_target} PRIVATE "-DLIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE")
29-
target_compile_options(${test_target} PRIVATE $<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>:--extended-lambda>)
33+
target_link_libraries(${test_target} PRIVATE
34+
${cn_target}
35+
cudax.test.thrust
36+
Catch2::Catch2
37+
catch2_main
38+
)
39+
target_compile_options(${test_target} PRIVATE
40+
"-DLIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE"
41+
$<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>:--extended-lambda>
42+
)
3043
cudax_clone_target_properties(${test_target} ${cn_target})
3144
set_target_properties(${test_target} PROPERTIES
3245
CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}"

lib/cmake/cudax/cudax-config.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ if (cudax_NO_IMPORTED_TARGETS)
4848
add_library(_cudax_cudax INTERFACE)
4949
add_library(cudax::cudax ALIAS _cudax_cudax)
5050
set(cn_target_name _cudax_cudax)
51-
else()
51+
else()
5252
add_library(cudax::cudax INTERFACE IMPORTED GLOBAL)
5353
set(cn_target_name cudax::cudax)
5454
endif()

0 commit comments

Comments
 (0)