1818
1919find_package (CUDAToolkit REQUIRED)
2020
21- # Some tests always build with RDC, so make sure that the sm_XX flags are
22- # compatible. See note in CubCudaConfig.cmake.
23- # TODO once we're using CUDA_ARCHITECTURES, we can setup non-rdc fallback
24- # tests to build for non-rdc arches. But for now, all files in a given directory
25- # must build with the same `CMAKE_CUDA_FLAGS` due to CMake constraints around
26- # how CUDA_FLAGS works.
27- set (CMAKE_CUDA_FLAGS "${CUB_CUDA_FLAGS_BASE} ${CUB_CUDA_FLAGS_RDC} " )
28-
2921# The function below reads the filepath `src`, extracts the %PARAM% comments,
3022# and fills `labels_var` with a list of `label1_value1.label2_value2...`
3123# strings, and puts the corresponding `DEFINITION=value1:DEFINITION=value2`
@@ -144,6 +136,11 @@ function(cub_add_test target_name_var test_name test_src cub_target)
144136 set (config_meta_target ${config_prefix} .tests)
145137
146138 if (is_catch2_test)
139+ set (use_rdc_for_catch2_utils OFF )
140+ if (CUB_ENABLE_RDC_TESTS OR CUB_FORCE_RDC)
141+ set (use_rdc_for_catch2_utils ON )
142+ endif ()
143+
147144 # Per config helper library:
148145 set (config_c2h_target ${config_prefix} .test .catch2_helper)
149146 if (NOT TARGET ${config_c2h_target} )
@@ -162,15 +159,12 @@ function(cub_add_test target_name_var test_name test_src cub_target)
162159 )
163160
164161 cub_clone_target_properties(${config_c2h_target} ${cub_target} )
162+ cub_configure_cuda_target(${config_c2h_target} RDC ${use_rdc_for_catch2_utils} )
165163 target_link_libraries (${config_c2h_target} PRIVATE CUDA::curand ${cub_target} )
166164
167165 if (CUB_IN_THRUST)
168166 thrust_fix_clang_nvcc_build_for(${config_c2h_target} )
169167 endif ()
170-
171- if (CUB_ENABLE_TESTS_WITH_RDC)
172- cub_enable_rdc_for_cuda_target(${config_c2h_target} )
173- endif ()
174168 endif () # config_c2h_target
175169
176170 if (CUB_SEPARATE_CATCH2)
@@ -191,6 +185,7 @@ function(cub_add_test target_name_var test_name test_src cub_target)
191185 Catch2::Catch2
192186 )
193187 cub_clone_target_properties(${config_c2run_target} ${cub_target} )
188+ cub_configure_cuda_target(${config_c2run_target} RDC ${use_rdc_for_catch2_utils} )
194189 add_dependencies (${config_meta_target} ${config_c2run_target} )
195190 target_include_directories (${config_c2run_target} PRIVATE
196191 "${CUB_SOURCE_DIR} /test"
0 commit comments