@@ -5,23 +5,28 @@ FetchContent_Declare(
55 GIT_TAG v2.13.10
66)
77FetchContent_MakeAvailable (catch)
8+
89set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH } ;${CMAKE_SOURCE_DIR } /tests/CMake/Modules/)
910include (ParseAndAddCatchTests )
1011
11- # Define a function to automate adding benchamrks
12- function (automate_add_benchmarks target_name source_file )
12+ # Usage: add_blast_target(target_name source_file [TEST | BENCH])
13+ function (add_blast_target target_name source_file type )
1314 add_executable (${target_name} ${source_file} )
1415 target_compile_features (${target_name} PUBLIC cxx_std_17 )
15- target_link_libraries (${target_name} PUBLIC Catch2::Catch2 blast TracyClient )
16- target_compile_definitions (${target_name} PUBLIC TRACY_ENABLE TRACY_NO_EXIT )
17- endfunction ()
1816
19- # Define a function to automate adding tests
20- function (automate_add_tests target_name source_file )
21- add_executable (${target_name} ${source_file} )
22- target_compile_features (${target_name} PUBLIC cxx_std_17 )
23- target_link_libraries (${target_name} PRIVATE Catch2::Catch2 blast TracyClient )
24- add_test (NAME ${target_name} _test COMMAND ${target_name} )
17+ # Base dependencies
18+ target_link_libraries (${target_name} PRIVATE Catch2::Catch2 blast )
19+
20+ # Conditional Tracy logic
21+ if (ENABLE_TRACY)
22+ target_link_libraries (${target_name} PRIVATE TracyClient )
23+ target_compile_definitions (${target_name} PRIVATE TRACY_ENABLE TRACY_NO_EXIT )
24+ endif ()
25+
26+ # If marked as a TEST, register it with CTest
27+ if ("${type} " STREQUAL "TEST" )
28+ add_test (NAME ${target_name} _test COMMAND ${target_name} )
29+ endif ()
2530endfunction ()
2631
2732# note: Add new benchmark files as follows :
@@ -38,6 +43,8 @@ set(BENCHMARKS
3843 # bench_paper_gradients benchmarks/bench_paper_gradients.cpp
3944 # bench_constraints benchmarks/bench_constraints.cpp
4045 # bench_functions benchmarks/bench_functions.cpp
46+
47+ bench_optimization_methods benchmarks/bench_optimization_methods.cpp
4148)
4249
4350# note: Add new tests files as follows :
@@ -75,20 +82,16 @@ set(TESTS
7582 test_bspline trajectory/test_bsplines.cpp
7683)
7784
78- add_executable (bench_optimization_methods benchmarks/bench_optimization_methods.cpp )
79- target_compile_features (bench_optimization_methods PUBLIC cxx_std_17 )
80- target_link_libraries (bench_optimization_methods PUBLIC blast )
81-
8285# Loop through and add benchmarks
8386while (BENCHMARKS)
8487 list (POP_FRONT BENCHMARKS target_name)
8588 list (POP_FRONT BENCHMARKS source_file)
86- automate_add_benchmarks (${target_name} ${source_file} )
89+ add_blast_target (${target_name} ${source_file} "BENCH" )
8790endwhile ()
8891
8992# Loop through and add tests
9093while (TESTS)
9194 list (POP_FRONT TESTS target_name)
9295 list (POP_FRONT TESTS source_file)
93- automate_add_tests (${target_name} ${source_file} )
96+ add_blast_target (${target_name} ${source_file} "TEST" )
9497endwhile ()
0 commit comments