From 03b931322f8e197807d4dd6c43debaa77cd6f248 Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 19 May 2021 13:22:57 +0200 Subject: [PATCH] cmake: use 'Catch2' as an optional dependency Omit target 'sgnl-test' if Catch2 is unavailable. --- test/CMakeLists.txt | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 80fa67d..4fa512b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,14 +4,16 @@ project(signal-wrangler-test) include(EnableWarnings) include(DefaultBuildRelease) -find_package(Catch2 REQUIRED) +find_package(Catch2 QUIET) -add_executable( - sgnl-test - EXCLUDE_FROM_ALL - "${PROJECT_SOURCE_DIR}/test.cpp") -enable_warnings(sgnl-test PRIVATE) -target_link_libraries(sgnl-test sgnl::sgnl Catch2::Catch2 "-fsanitize=thread") -target_compile_features(sgnl-test PUBLIC cxx_std_17) -target_compile_options(sgnl-test PUBLIC "-fsanitize=thread") +if( Catch2_FOUND ) + add_executable( + sgnl-test + EXCLUDE_FROM_ALL + "${PROJECT_SOURCE_DIR}/test.cpp") + enable_warnings(sgnl-test PRIVATE) + target_link_libraries(sgnl-test sgnl::sgnl Catch2::Catch2 "-fsanitize=thread") + target_compile_features(sgnl-test PUBLIC cxx_std_17) + target_compile_options(sgnl-test PUBLIC "-fsanitize=thread") +endif()