From: Connor Fawcett Date: Tue, 21 May 2024 10:37:25 +0000 (+0100) Subject: cmake: Add gcov --coverage flags when coverage option is set X-Git-Tag: v20.0.0~1822^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1d8dfb5f0c2ed2ee2f8a1ab06b242a33b7d36c6f;p=ceph.git cmake: Add gcov --coverage flags when coverage option is set Signed-off-by: Connor Fawcett Fixes: https://tracker.ceph.com/issues/66158 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index ba5798e0be9f..62aaad94dc83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -637,7 +637,6 @@ if(WITH_BABELTRACE) endif(WITH_BABELTRACE) option(DEBUG_GATHER "C_Gather debugging is enabled" ON) -option(ENABLE_COVERAGE "Coverage is enabled" OFF) option(PG_DEBUG_REFS "PG Ref debugging is enabled" OFF) option(WITH_TESTS "enable the build of ceph-test package scripts/binaries" ON) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4f8ea9593575..6cb049fb7b2a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -263,15 +263,18 @@ if(LINUX OR APPLE) list(APPEND EXTRALIBS ${LIB_RESOLV}) endif() +option(ENABLE_COVERAGE "Coverage is enabled" OFF) if(${ENABLE_COVERAGE}) find_program(HAVE_GCOV gcov) if(NOT HAVE_GCOV) message(FATAL_ERROR "Coverage Enabled but gcov Not Found") endif() add_compile_options( - -fprofile-arcs - -ftest-coverage + --coverage -O0) + add_link_options( + --coverage + ) list(APPEND EXTRALIBS gcov) endif(${ENABLE_COVERAGE})