September 2018
Intermediate to advanced
606 pages
14h 32m
English
Since Catch2 is a single-header framework, no additional targets have to be defined and built. We only have to make sure that CMake can find catch.hpp, to build test.cpp. For convenience, we placed it in the same directory as test.cpp, but we could have chosen a different location and indicated that location by using target_include_directories. Yet another approach would be to wrap the header into an INTERFACE library. This can be done as illustrated in the Catch2 documentation (https://github.com/catchorg/Catch2/blob/master/docs/build-systems.md#cmake):
# Prepare "Catch" library for other executables set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/catch) add_library(Catch INTERFACE) target_include_directories(Catch INTERFACE ...
Read now
Unlock full access