2019-08-07 05:06:55 +00:00
|
|
|
# Testing library
|
|
|
|
FetchContent_Declare(
|
2020-08-05 16:17:00 -04:00
|
|
|
catch
|
2020-08-03 18:16:52 -04:00
|
|
|
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
2021-06-24 12:06:36 -04:00
|
|
|
GIT_TAG v2.13.6)
|
2020-08-05 16:17:00 -04:00
|
|
|
FetchContent_MakeAvailable(catch)
|
2019-08-07 05:06:55 +00:00
|
|
|
# Adds Catch2::Catch2
|
|
|
|
|
|
|
|
# Tests need to be added as executables first
|
|
|
|
add_executable(testlib testlib.cpp)
|
|
|
|
|
|
|
|
# I'm using C++17 in the test
|
|
|
|
target_compile_features(testlib PRIVATE cxx_std_17)
|
|
|
|
|
|
|
|
# Should be linked to the main library, as well as the Catch2 testing library
|
|
|
|
target_link_libraries(testlib PRIVATE modern_library Catch2::Catch2)
|
|
|
|
|
|
|
|
# If you register a test, then ctest and make test will run it.
|
|
|
|
# You can also run examples and check the output, as well.
|
|
|
|
add_test(NAME testlibtest COMMAND testlib) # Command can be a target
|