catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
Use CTest to control test suite via BUILD_TESTING
- Commit
a0359980f042418b993f7c632562f4d680872e62- Author
- David Seifert ·
- Committer
- Martin Hořeňovský
- Parents
8d4074aad943
Changes
CMakeLists.txt | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05360548..c8721e05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,11 @@ cmake_minimum_required(VERSION 3.0) +# detect if Catch is being bundled, +# disable testsuite in that case +if(NOT DEFINED PROJECT_NAME) + set(NOT_SUBPROJECT ON) +endif() + project(CatchSelfTest) include(GNUInstallDirs) @@ -287,7 +293,19 @@ SOURCE_GROUP("Surrogates" FILES ${SURROGATE_SOURCES}) # Projects consuming Catch via ExternalProject_Add might want to use install step # without building all of our selftests. -if (NOT NO_SELFTEST) + +if(DEFINED NO_SELFTEST) + message(DEPRECATION "*** CMake option NO_SELFTEST is deprecated; use BUILD_TESTING instead") + if (NO_SELFTEST) + set(BUILD_TESTING OFF CACHE BOOL "Disable Catch2 internal testsuite" FORCE) + else() + set(BUILD_TESTING ON CACHE BOOL "Disable Catch2 internal testsuite" FORCE) + endif() +endif() + +include(CTest) + +if (BUILD_TESTING AND NOT_SUBPROJECT) add_executable(SelfTest ${TEST_SOURCES} ${IMPL_SOURCES} ${REPORTER_SOURCES} ${SURROGATE_SOURCES} ${HEADERS}) target_include_directories(SelfTest PRIVATE ${HEADER_DIR})