From f486b45619af7ddc4a930188e84359b1103b776c Mon Sep 17 00:00:00 2001 From: Kai Buschulte Date: Tue, 28 Jun 2022 16:05:17 +0200 Subject: [PATCH] CMake: introduce a coverage target to produce coverage information while running the tests, call cmake with the following options: cmake -DCMAKE_C_FLAGS=-coverage -DCMAKE_CXX_FLAGS=-coverage Signed-off-by: Kai Buschulte --- test/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c1282179..9489ccb3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,3 +2,10 @@ add_subdirectory(broker) add_subdirectory(client) add_subdirectory(lib) add_subdirectory(unit) + +add_custom_target(coverage + COMMAND lcov --quiet --capture --directory . --output-file ${PROJECT_BINARY_DIR}/coverage.info --no-external + COMMAND genhtml --quiet ${PROJECT_BINARY_DIR}/coverage.info --output-directory ${PROJECT_BINARY_DIR}/coverage + COMMENT "Generating coverage.info and coverage/index.html in ${PROJECT_BINARY_DIR}" + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} +)