From 1d8dfb5f0c2ed2ee2f8a1ab06b242a33b7d36c6f Mon Sep 17 00:00:00 2001 From: Connor Fawcett Date: Tue, 21 May 2024 11:37:25 +0100 Subject: [PATCH] cmake: Add gcov --coverage flags when coverage option is set Signed-off-by: Connor Fawcett Fixes: https://tracker.ceph.com/issues/66158 --- CMakeLists.txt | 1 - src/CMakeLists.txt | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba5798e0be9..62aaad94dc8 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 4f8ea959357..6cb049fb7b2 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}) -- 2.39.5