From 0ba2d950e21f6193e73a080e433f191729fa8936 Mon Sep 17 00:00:00 2001 From: Stepan Fomenko Date: Thu, 21 Jan 2021 16:47:32 +0300 Subject: [PATCH] Add code coverage info support --- CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f1273c74..0285a7b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ option(ICU "ICU support for convert codepages" ${_ICU_DEFAULT}) option(STD_IOSTREAM "Building with std iostream operators support" OFF) option(INTROSPECTION "Build with introspection" OFF) option(TESTS "Build tests and perform their before install step" OFF) +option(COVERAGE "Build project with coverage info" OFF) set(PIP_UTILS 1) set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(CMAKE_CXX_STANDARD 11) @@ -215,6 +216,18 @@ else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall") endif() +set(PIP_COVERAGE "no") +if (COVERAGE) + find_program(GCOV_EXECUTABLE gcov) + if (GCOV_EXECUTABLE) + set(PIP_COVERAGE "yes") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") + else() + message(STATUS "GCOV_EXECUTABLE: not found") + endif() +endif() + # Check if std::iostream operators support set(PIP_STD_IOSTREAM "no") @@ -595,6 +608,7 @@ message(" std::iostream: ${PIP_STD_IOSTREAM}") message(" ICU strings : ${PIP_ICU}") message(" Timer types : ${PIP_TIMERS}") message(" Introspection: ${PIP_INTROSPECTION}") +message(" Coverage : ${PIP_COVERAGE}") if(INTROSPECTION) message(STATUS " Warning: Introspection reduces the performance!") endif()