diff --git a/CMakeLists.txt b/CMakeLists.txt index 76494710..42c8a031 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ include(CMakePackageConfigHelpers) include(CTest) option(CATCH_USE_VALGRIND "Perform SelfTests with Valgrind" OFF) +option(CATCH_BUILD_TESTING "Build SelfTest project" ON) option(CATCH_BUILD_EXAMPLES "Build documentation examples" OFF) option(CATCH_ENABLE_COVERAGE "Generate coverage for codecov.io" OFF) option(CATCH_ENABLE_WERROR "Enable all warnings as errors" ON) @@ -35,7 +36,7 @@ if(USE_WMAIN) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ENTRY:wmainCRTStartup") endif() -if (BUILD_TESTING AND NOT_SUBPROJECT) +if (BUILD_TESTING AND CATCH_BUILD_TESTING AND NOT_SUBPROJECT) add_subdirectory(projects) endif() diff --git a/docs/cmake-integration.md b/docs/cmake-integration.md index 7120d163..5f57c276 100644 --- a/docs/cmake-integration.md +++ b/docs/cmake-integration.md @@ -171,6 +171,10 @@ automatically discovered. Defaults to `OFF`. Catch2's CMake project also provides some options for other projects that consume it. These are +* `CATCH_BUILD_TESTING` -- When `ON`, Catch2's SelfTest project will be +built. Defaults to `ON`. Note that Catch2 also obeys `BUILD_TESTING` CMake +variable, so _both_ of them need to be `ON` for the SelfTest to be built, +and either of them can be set to `OFF` to disable building SelfTest. * `CATCH_BUILD_EXAMPLES` -- When `ON`, Catch2's usage examples will be built. Defaults to `OFF`. * `CATCH_INSTALL_DOCS` -- When `ON`, Catch2's documentation will be