Skip to content

Commit 5732f6b

Browse files
authored
More fine grained build configuration for CLI topols (#921)
Grant more fine grained control of how the CLI tools are built, e.g. if only benchmarks are required, don't build the validation tools and vice versa. Also allows to build the CLI validation tools without building unit and integration CI tests. This will be helpful in order to set up the benchmarks across different hardware platforms with minimal dependencies.
1 parent dcf26b8 commit 5732f6b

File tree

6 files changed

+79
-72
lines changed

6 files changed

+79
-72
lines changed

CMakeLists.txt

+13-5
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,9 @@ option(
9898
FALSE
9999
)
100100

101-
# Need test functionality and svg display for command line tools
101+
# Need test utils for the example detector generation
102102
if(DETRAY_BUILD_CLI_TOOLS)
103-
set(DETRAY_BUILD_TESTING ON)
104-
set(DETRAY_SVG_DISPLAY ON)
103+
set(DETRAY_BUILD_TEST_UTILS ON)
105104
endif()
106105

107106
# Convenience option to build tests
@@ -110,7 +109,7 @@ if(DETRAY_BUILD_ALL_TESTS)
110109
set(DETRAY_BUILD_INTEGRATIONTESTS ON)
111110
endif()
112111

113-
# Alias flag to build the tests
112+
# Alias flag to enable tests in detray (pulls in google test and triggers the build of executables that depend on it)
114113
if(BUILD_TESTING AND (DETRAY_BUILD_UNITTESTS OR DETRAY_BUILD_INTEGRATIONTESTS))
115114
set(DETRAY_BUILD_TESTING ON)
116115
endif()
@@ -308,7 +307,16 @@ cmake_dependent_option(
308307
"BUILD_TESTING AND DETRAY_BUILD_TESTING"
309308
OFF
310309
)
311-
if(DETRAY_BUILD_TESTING OR DETRAY_BUILD_TEST_UTILS)
310+
311+
# Test utils and validation tools can also be required standalone
312+
# (e.g. in ACTS detray plugin)
313+
if(
314+
DETRAY_BUILD_TESTING
315+
OR DETRAY_BUILD_TEST_UTILS
316+
OR DETRAY_BUILD_VALIDATION_TOOLS
317+
OR DETRAY_BUILD_BENCHMARKS
318+
OR DETRAY_BUILD_CLI_TOOLS
319+
)
312320
add_subdirectory(tests)
313321
endif()
314322

tests/CMakeLists.txt

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Detray library, part of the ACTS project (R&D line)
22
#
3-
# (c) 2021-2024 CERN for the benefit of the ACTS project
3+
# (c) 2021-2025 CERN for the benefit of the ACTS project
44
#
55
# Mozilla Public License Version 2.0
66

@@ -96,7 +96,7 @@ if(DETRAY_BUILD_BENCHMARKS)
9696
add_subdirectory(benchmarks)
9797
endif()
9898

99-
# Build tool executables
99+
# Build test executables
100100
if(DETRAY_BUILD_TESTING)
101101
# Build host and device specific test code
102102
add_subdirectory(include/detray/test/cpu)
@@ -111,13 +111,13 @@ if(DETRAY_BUILD_TESTING)
111111
if(DETRAY_BUILD_INTEGRATIONTESTS)
112112
add_subdirectory(integration_tests)
113113
endif()
114+
endif()
114115

115-
# Build the command line tools (also required for the host jacobian
116-
# validation integration test)
117-
if(
118-
(DETRAY_BUILD_INTEGRATIONTESTS AND DETRAY_BUILD_HOST)
119-
OR DETRAY_BUILD_CLI_TOOLS
120-
)
121-
add_subdirectory(tools)
122-
endif()
116+
# Build the command line tools (also required for the host jacobian
117+
# validation integration test)
118+
if(
119+
(DETRAY_BUILD_INTEGRATIONTESTS AND DETRAY_BUILD_HOST)
120+
OR DETRAY_BUILD_CLI_TOOLS
121+
)
122+
add_subdirectory(tools)
123123
endif()

tests/include/detray/test/device/cuda/material_validation.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "detray/tracks/tracks.hpp"
1313

1414
// Detray test include(s)
15-
#include "detray/test/common/fixture_base.hpp"
1615
#include "detray/test/common/material_validation_config.hpp"
1716
#include "detray/test/cpu/material_validation.hpp"
1817
#include "detray/test/validation/material_validation_utils.hpp"

tests/tools/CMakeLists.txt

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Detray library, part of the ACTS project (R&D line)
22
#
3-
# (c) 2021-2024 CERN for the benefit of the ACTS project
3+
# (c) 2021-2025 CERN for the benefit of the ACTS project
44
#
55
# Mozilla Public License Version 2.0
66

@@ -18,13 +18,7 @@ target_include_directories(
1818

1919
target_link_libraries(
2020
detray_tools
21-
INTERFACE
22-
Boost::program_options
23-
vecmem::core
24-
detray::test_common
25-
detray::io
26-
detray::csv_io
27-
detray::test_utils
21+
INTERFACE Boost::program_options vecmem::core detray::io detray::test_utils
2822
)
2923

3024
add_subdirectory(src)

tests/tools/src/cpu/CMakeLists.txt

+24-22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Detray library, part of the ACTS project(R& D line)
22
#
3-
#(c) 2023-2024 CERN for the benefit of the ACTS project
3+
#(c) 2023-2025 CERN for the benefit of the ACTS project
44
#
55
#Mozilla Public License Version 2.0
66

@@ -29,28 +29,30 @@ detray_add_executable(generate_telescope_detector
2929
detray::io detray::test_utils detray::core_array
3030
)
3131

32-
# Build the visualization executable.
33-
detray_add_executable(detector_display
34-
"detector_display.cpp"
35-
LINK_LIBRARIES Boost::program_options detray::core_array detray::tools
36-
detray::svgtools
37-
)
38-
39-
# Build the detector validation executable.
40-
detray_add_executable(detector_validation
41-
"detector_validation.cpp"
42-
LINK_LIBRARIES GTest::gtest GTest::gtest_main
43-
Boost::program_options detray::core_array detray::tools detray::test_utils
44-
detray::svgtools
45-
)
32+
if(DETRAY_SVG_DISPLAY)
33+
# Build the visualization executable.
34+
detray_add_executable(detector_display
35+
"detector_display.cpp"
36+
LINK_LIBRARIES Boost::program_options detray::core_array detray::io detray::tools
37+
detray::svgtools
38+
)
39+
endif()
4640

47-
# Build the material validation executable.
48-
detray_add_executable(material_validation
49-
"material_validation.cpp"
50-
LINK_LIBRARIES GTest::gtest GTest::gtest_main
51-
Boost::program_options detray::core_array detray::tools detray::test_utils
52-
detray::svgtools
53-
)
41+
if(DETRAY_BUILD_TESTING)
42+
# Build the detector validation executable.
43+
detray_add_executable(detector_validation
44+
"detector_validation.cpp"
45+
LINK_LIBRARIES GTest::gtest GTest::gtest_main
46+
Boost::program_options detray::core_array detray::test_cpu detray::tools
47+
)
48+
49+
# Build the material validation executable.
50+
detray_add_executable(material_validation
51+
"material_validation.cpp"
52+
LINK_LIBRARIES GTest::gtest GTest::gtest_main
53+
Boost::program_options detray::core_array detray::test_cpu detray::tools
54+
)
55+
endif()
5456

5557
if(DETRAY_BUILD_BENCHMARKS)
5658
# Look for openMP, which is used for the CPU propagation benchmark

tests/tools/src/cuda/CMakeLists.txt

+30-26
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Detray library, part of the ACTS project(R& D line)
22
#
3-
#(c) 2024 CERN for the benefit of the ACTS project
3+
#(c) 2024-2025 CERN for the benefit of the ACTS project
44
#
55
#Mozilla Public License Version 2.0
66

@@ -13,30 +13,34 @@ include(CMakeFindDependencyMacro)
1313

1414
find_dependency(Boost COMPONENTS program_options REQUIRED)
1515

16-
# Build the detector validation executable.
17-
detray_add_executable(detector_validation_cuda
18-
"detector_validation_cuda.cpp"
19-
LINK_LIBRARIES GTest::gtest GTest::gtest_main
20-
Boost::program_options detray::test_cuda detray::tools
21-
)
22-
23-
# Build the material cuda validation executable.
24-
detray_add_executable(material_validation_cuda
25-
"material_validation_cuda.cpp"
26-
LINK_LIBRARIES GTest::gtest GTest::gtest_main
27-
Boost::program_options detray::test_cuda detray::tools
28-
)
29-
30-
# Build benchmarks for multiple algebra plugins
31-
# Currently vc and smatrix is not supported on device
32-
set(algebra_plugins "array")
33-
if(DETRAY_EIGEN_PLUGIN)
34-
list(APPEND algebra_plugins "eigen")
35-
endif()
16+
if(DETRAY_BUILD_TESTING)
17+
# Build the detector validation executable.
18+
detray_add_executable(detector_validation_cuda
19+
"detector_validation_cuda.cpp"
20+
LINK_LIBRARIES GTest::gtest GTest::gtest_main
21+
Boost::program_options detray::test_cuda detray::tools
22+
)
3623

37-
foreach(algebra ${algebra_plugins})
38-
detray_add_executable(propagation_benchmark_cuda_${algebra}
39-
"propagation_benchmark_cuda.cpp"
40-
LINK_LIBRARIES detray::benchmark_cuda_${algebra} vecmem::cuda detray::tools detray::test_utils
24+
# Build the material cuda validation executable.
25+
detray_add_executable(material_validation_cuda
26+
"material_validation_cuda.cpp"
27+
LINK_LIBRARIES GTest::gtest GTest::gtest_main
28+
Boost::program_options detray::test_cuda detray::tools
4129
)
42-
endforeach()
30+
endif()
31+
32+
if(DETRAY_BUILD_BENCHMARKS)
33+
# Build benchmarks for multiple algebra plugins
34+
# Currently vc and smatrix is not supported on device
35+
set(algebra_plugins "array")
36+
if(DETRAY_EIGEN_PLUGIN)
37+
list(APPEND algebra_plugins "eigen")
38+
endif()
39+
40+
foreach(algebra ${algebra_plugins})
41+
detray_add_executable(propagation_benchmark_cuda_${algebra}
42+
"propagation_benchmark_cuda.cpp"
43+
LINK_LIBRARIES detray::benchmark_cuda_${algebra} vecmem::cuda detray::tools detray::test_utils
44+
)
45+
endforeach()
46+
endif()

0 commit comments

Comments
 (0)