From a103192c4c1a808f37bbdd70f3f21c992fb9d8c8 Mon Sep 17 00:00:00 2001 From: Daniel <d.hornung@indiscale.com> Date: Wed, 13 Oct 2021 16:56:51 +0200 Subject: [PATCH] ENH: Make code coverage optional and depend on available libraries. --- cmake/CodeCoverage.cmake | 12 ++++++++++++ test/CMakeLists.txt | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake index 27c6028..a9b17e2 100644 --- a/cmake/CodeCoverage.cmake +++ b/cmake/CodeCoverage.cmake @@ -136,6 +136,18 @@ include(CMakeParseArguments) option(CODE_COVERAGE_VERBOSE "Verbose information" FALSE) +option(SKIP_CODE_COVERAGE "Skip code coverage" OFF) + +if (SKIP_CODE_COVERAGE) + return() +endif() + +find_library(covlib NAMES gcov lcov) +message(STATUS "covlib: >${covlib}<") +if (${covlib} STREQUAL "covlib-NOTFOUND") + message(Warning "lcov or gcov libraries not found, skipping code coverage.") + return() +endif() # Check prereqs find_program( GCOV_PATH gcov ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 07a2092..a1c2c7a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -88,7 +88,6 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/caosdb_test_utility.h.in include(CodeCoverage) -# TODO: Also test for gcov linking path, or add SKIP_COV option. if (LCOV_PATH) message(STATUS "Found LCOV: ${LCOV_PATH}") target_link_libraries(caosdb gcov) @@ -111,5 +110,7 @@ if (LCOV_PATH) set_target_properties(ccaosdb PROPERTIES COMPILE_FLAGS "${TARGET_CCAOSDB_COMPILE_FLAGS}") else () - message(WARNING "Could not generate code coverage report. Please install lcov.") + if (NOT SKIP_CODE_COVERAGE) + message(WARNING "Could not generate code coverage report. Please install lcov.") + endif() endif () -- GitLab