Debian Codegraph @

tests/CMakeLists.txt

raw
1 find_package(Threads)
2
3 find_package(Catch2 QUIET)
4
5 if (NOT Catch2_FOUND)
6 include(FetchContent)
7
8 FetchContent_Declare(
9 Catch2
10 GIT_REPOSITORY https://github.com/catchorg/Catch2.git
11 GIT_TAG v2.13.9)
12
13 FetchContent_MakeAvailable(Catch2)
14
15 list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/contrib)
16 endif()
17
18 add_executable(
19 unit_tests
20 buffer.cpp
21 message.cpp
22 context.cpp
23 socket.cpp
24 socket_ref.cpp
25 poller.cpp
26 active_poller.cpp
27 multipart.cpp
28 recv_multipart.cpp
29 send_multipart.cpp
30 codec_multipart.cpp
31 monitor.cpp
32 utilities.cpp
33 )
34
35 target_include_directories(unit_tests PUBLIC ${CATCH_MODULE_PATH})
36 target_link_libraries(
37 unit_tests
38 PRIVATE Catch2::Catch2
39 PRIVATE cppzmq
40 PRIVATE ${CMAKE_THREAD_LIBS_INIT}
41 )
42
43 OPTION (COVERAGE "Enable gcda file generation needed by lcov" OFF)
44
45 if (COVERAGE)
46 target_compile_options(unit_tests PRIVATE --coverage)
47 target_link_options(unit_tests PRIVATE --coverage)
48 message(STATUS "Coverage enabled")
49 endif()
50
51 include(CTest)
52 include(Catch)
53 catch_discover_tests(unit_tests)