Move coverage option to test subproject

Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
This commit is contained in:
Cristian Le 2023-11-28 09:56:17 +01:00
parent 3a24ab3c0c
commit 833a836c1c
3 changed files with 14 additions and 12 deletions

View File

@ -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})

View File

@ -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")

View File

@ -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 #
]==============================================================================================]