cmake: use 'Catch2' as an optional dependency

Omit target 'sgnl-test' if Catch2 is unavailable.
This commit is contained in:
Tom 2021-05-19 13:22:57 +02:00
parent c33d45b92f
commit 03b931322f

View File

@ -4,14 +4,16 @@ project(signal-wrangler-test)
include(EnableWarnings) include(EnableWarnings)
include(DefaultBuildRelease) include(DefaultBuildRelease)
find_package(Catch2 REQUIRED) find_package(Catch2 QUIET)
add_executable( if( Catch2_FOUND )
sgnl-test add_executable(
EXCLUDE_FROM_ALL sgnl-test
"${PROJECT_SOURCE_DIR}/test.cpp") EXCLUDE_FROM_ALL
enable_warnings(sgnl-test PRIVATE) "${PROJECT_SOURCE_DIR}/test.cpp")
target_link_libraries(sgnl-test sgnl::sgnl Catch2::Catch2 "-fsanitize=thread") enable_warnings(sgnl-test PRIVATE)
target_compile_features(sgnl-test PUBLIC cxx_std_17) target_link_libraries(sgnl-test sgnl::sgnl Catch2::Catch2 "-fsanitize=thread")
target_compile_options(sgnl-test PUBLIC "-fsanitize=thread") target_compile_features(sgnl-test PUBLIC cxx_std_17)
target_compile_options(sgnl-test PUBLIC "-fsanitize=thread")
endif()