diff --git a/CMakeLists.txt b/CMakeLists.txt index a0beae0..a647a60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,8 +52,6 @@ else () option(JSON_VALIDATOR_BUILD_EXAMPLES "JsonValidator: Build examples" ${PROJECT_IS_TOP_LEVEL}) endif () option(JSON_VALIDATOR_SHARED_LIBS "JsonValidator: Build as shared library" ${PROJECT_IS_TOP_LEVEL}) -cmake_dependent_option(JSON_VALIDATOR_TEST_COVERAGE "JsonValidator: Build with test coverage" OFF "JSON_VALIDATOR_BUILD_TESTS" OFF) -mark_as_advanced(JSON_VALIDATOR_TEST_COVERAGE) # Get a default JSON_FETCH_VERSION from environment variables to workaround the CI if (DEFINED ENV{NLOHMANN_JSON_VERSION}) set(JSON_FETCH_VERSION_DEFAULT $ENV{NLOHMANN_JSON_VERSION}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 96cfa0d..f895d66 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,16 +32,6 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR -Wall -Wextra -Wshadow) endif () -if (JSON_VALIDATOR_TEST_COVERAGE) - if (NOT CMAKE_CXX_COMPILER_ID MATCHES "(Clang|GNU)") - message(WARNING - "Coverage flags not known for: ${CMAKE_CXX_COMPILER_ID}.\n" - "Using --coverage as default") - endif () - target_compile_options(nlohmann_json_schema_validator PRIVATE --coverage) - target_link_options(nlohmann_json_schema_validator PUBLIC --coverage) -endif () - # TODO: gcc support for <4.9 should be removed # regex with boost if gcc < 4.9 - default is std::regex if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9df955f..0673a37 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -13,12 +13,26 @@ project(nlohmann_json_schema_validator_test # Options # ]==============================================================================================] +include(CMakeDependentOption) +cmake_dependent_option(JSON_VALIDATOR_TEST_COVERAGE "JsonValidator: Build with test coverage" OFF "nlohmann_json_schema_validator_IS_TOP_LEVEL" OFF) +mark_as_advanced(JSON_VALIDATOR_TEST_COVERAGE) + #[==============================================================================================[ # Project configuration # ]==============================================================================================] include(FetchContent) +if (JSON_VALIDATOR_TEST_COVERAGE) + if (NOT CMAKE_CXX_COMPILER_ID MATCHES "(Clang|GNU)") + message(WARNING + "Coverage flags not known for: ${CMAKE_CXX_COMPILER_ID}.\n" + "Using --coverage as default") + endif () + target_compile_options(nlohmann_json_schema_validator PRIVATE --coverage) + target_link_options(nlohmann_json_schema_validator PUBLIC --coverage) +endif () + #[==============================================================================================[ # External packages # ]==============================================================================================]