Skip to content

Commit

Permalink
update cmake for catch2
Browse files Browse the repository at this point in the history
  • Loading branch information
albestro committed Jun 30, 2021
1 parent 1ae57c9 commit 197f8d2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 40 deletions.
29 changes: 16 additions & 13 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
find_package(Threads)

project(cppzmq-test CXX)
find_package(Catch2 QUIET)

# place binaries and libraries according to GNU standards
if (Catch2_FOUND)
include(Catch)
else()
include(FetchContent)

include(GNUInstallDirs)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.13.4)

include(CTest)
include(cmake/catch.cmake)
include(${CATCH_MODULE_PATH}/Catch.cmake)
FetchContent_MakeAvailable(Catch2)

find_package(Threads)
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/contrib)
endif()

add_executable(
unit_tests
Expand All @@ -32,11 +34,10 @@ add_executable(
utilities.cpp
)

add_dependencies(unit_tests catch)

target_include_directories(unit_tests PUBLIC ${CATCH_MODULE_PATH})
target_link_libraries(
unit_tests
PRIVATE Catch2::Catch2
PRIVATE cppzmq
PRIVATE ${CMAKE_THREAD_LIBS_INIT}
)
Expand All @@ -48,4 +49,6 @@ if (COVERAGE)
target_link_libraries(unit_tests PRIVATE --coverage)
endif()

include(CTest)
include(Catch)
catch_discover_tests(unit_tests)
27 changes: 0 additions & 27 deletions tests/cmake/catch.cmake

This file was deleted.

0 comments on commit 197f8d2

Please sign in to comment.