File tree Expand file tree Collapse file tree 2 files changed +16
-40
lines changed Expand file tree Collapse file tree 2 files changed +16
-40
lines changed Original file line number Diff line number Diff line change 1
- cmake_minimum_required ( VERSION 3.0 FATAL_ERROR )
1
+ find_package ( Threads )
2
2
3
- project ( cppzmq-test CXX )
3
+ find_package ( Catch2 QUIET )
4
4
5
- # place binaries and libraries according to GNU standards
5
+ if (Catch2_FOUND )
6
+ include (Catch )
7
+ else ()
8
+ include (FetchContent )
6
9
7
- include ( GNUInstallDirs )
8
- set ( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /${CMAKE_INSTALL_LIBDIR} )
9
- set ( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /${CMAKE_INSTALL_LIBDIR} )
10
- set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /${CMAKE_INSTALL_BINDIR} )
10
+ FetchContent_Declare (
11
+ Catch2
12
+ GIT_REPOSITORY https://github.com/catchorg/Catch2.git
13
+ GIT_TAG v2.13.4 )
11
14
12
- include (CTest )
13
- include (cmake/catch.cmake )
14
- include (${CATCH_MODULE_PATH} /Catch.cmake )
15
+ FetchContent_MakeAvailable (Catch2 )
15
16
16
- find_package (Threads )
17
+ list (APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR} /contrib )
18
+ endif ()
17
19
18
20
add_executable (
19
21
unit_tests
@@ -32,11 +34,10 @@ add_executable(
32
34
utilities.cpp
33
35
)
34
36
35
- add_dependencies (unit_tests catch )
36
-
37
37
target_include_directories (unit_tests PUBLIC ${CATCH_MODULE_PATH} )
38
38
target_link_libraries (
39
39
unit_tests
40
+ PRIVATE Catch2::Catch2
40
41
PRIVATE cppzmq
41
42
PRIVATE ${CMAKE_THREAD_LIBS_INIT}
42
43
)
@@ -48,4 +49,6 @@ if (COVERAGE)
48
49
target_link_libraries (unit_tests PRIVATE --coverage )
49
50
endif ()
50
51
52
+ include (CTest )
53
+ include (Catch )
51
54
catch_discover_tests (unit_tests )
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments