Skip to content

Commit 8906b9f

Browse files
committed
Use 2.x.y structure for tests CMakeLists.txt
1 parent 2110849 commit 8906b9f

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

tests/CMakeLists.txt

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
include(CTest)
12
include(DownloadProject)
23

34
# Download and configure Catch2 for the tests
@@ -7,6 +8,7 @@ download_project(PROJ Catch2
78
UPDATE_DISCONNECTED 1
89
)
910
list(APPEND CMAKE_MODULE_PATH ${Catch2_SOURCE_DIR}/contrib)
11+
include(ParseAndAddCatchTests)
1012

1113
# Configure Catch2 so that it looks like a proper target
1214
add_library(Catch2 INTERFACE)
@@ -20,6 +22,15 @@ target_include_directories(Catch2 INTERFACE
2022
option(GFX_TIMSORT_USE_VALGRIND "Whether to run the tests with Valgrind" OFF)
2123
set(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+
2334
macro(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
)
8091
configure_tests(cxx_98_tests)
8192
target_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
8496
add_executable(cxx_11_tests
8597
main.cpp
8698
cxx_11_tests.cpp
8799
)
88100
configure_tests(cxx_11_tests)
89101
target_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)
104102
ParseAndAddCatchTests(cxx_11_tests)

0 commit comments

Comments
 (0)