1+ include (CTest)
12include (DownloadProject)
23
34# Download and configure Catch2 for the tests
@@ -7,6 +8,7 @@ download_project(PROJ Catch2
78 UPDATE_DISCONNECTED 1
89)
910list (APPEND CMAKE_MODULE_PATH ${Catch2_SOURCE_DIR} /contrib)
11+ include (ParseAndAddCatchTests)
1012
1113# Configure Catch2 so that it looks like a proper target
1214add_library (Catch2 INTERFACE )
@@ -20,6 +22,15 @@ target_include_directories(Catch2 INTERFACE
2022option (GFX_TIMSORT_USE_VALGRIND "Whether to run the tests with Valgrind" OFF )
2123set (GFX_TIMSORT_SANITIZE "" CACHE STRING "Comma-separated list of options to pass to -fsanitize" )
2224
25+ # Configure Valgrind
26+ if (${GFX_TIMSORT_USE_VALGRIND} )
27+ find_program (MEMORYCHECK_COMMAND valgrind)
28+ set (MEMORYCHECK_COMMAND_OPTIONS "--leak-check=full --track-origins=yes --error-exitcode=1 --show-reachable=no" )
29+ if (APPLE )
30+ set (MEMORYCHECK_SUPPRESSIONS_FILE ${CMAKE_CURRENT_SOURCE_DIR} /valgrind-osx.supp)
31+ endif ()
32+ endif ()
33+
2334macro (configure_tests target )
2435 # Add required dependencies to tests
2536 target_link_libraries (${target} PRIVATE
@@ -79,26 +90,13 @@ add_executable(cxx_98_tests
7990)
8091configure_tests(cxx_98_tests)
8192target_compile_features (cxx_98_tests PRIVATE cxx_std_98)
93+ ParseAndAddCatchTests(cxx_98_tests)
8294
83- # Tests that require C++11 support to run
95+ # Tests that require C++11 support
8496add_executable (cxx_11_tests
8597 main.cpp
8698 cxx_11_tests.cpp
8799)
88100configure_tests(cxx_11_tests)
89101target_compile_features (cxx_11_tests PRIVATE cxx_std_11)
90-
91- # Configure Valgrind
92- if (${GFX_TIMSORT_USE_VALGRIND} )
93- find_program (MEMORYCHECK_COMMAND valgrind)
94- set (MEMORYCHECK_COMMAND_OPTIONS "--leak-check=full --track-origins=yes --error-exitcode=1 --show-reachable=no" )
95- if (APPLE )
96- set (MEMORYCHECK_SUPPRESSIONS_FILE ${CMAKE_CURRENT_SOURCE_DIR} /valgrind-osx.supp)
97- endif ()
98- endif ()
99-
100- include (CTest)
101- include (ParseAndAddCatchTests)
102-
103- ParseAndAddCatchTests(cxx_98_tests)
104102ParseAndAddCatchTests(cxx_11_tests)
0 commit comments