diff options
| author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2026-01-09 13:13:26 +0100 |
|---|---|---|
| committer | Sander Vrijders <sander@ouroboros.rocks> | 2026-01-12 08:12:45 +0100 |
| commit | 3f373b06b05083d9395250379a2978b5f6085002 (patch) | |
| tree | c6edaa135feac5336ec0e6601772ad6f513c8a2f /cmake/compiler.cmake | |
| parent | 5b11550644b0ce7a79b967b6aabb1a59b86d5ca2 (diff) | |
| download | ouroboros-3f373b06b05083d9395250379a2978b5f6085002.tar.gz ouroboros-3f373b06b05083d9395250379a2978b5f6085002.zip | |
build: Add build target to generate coverage report
This adds a 'make coverage' option to conveniently summarize test
coverage. If lcov is installed, it will also automatically generate
the HTML summary.
Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'cmake/compiler.cmake')
| -rw-r--r-- | cmake/compiler.cmake | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index 4fa0e2ea..6258cca0 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -31,6 +31,18 @@ test_and_set_c_compiler_flag_global(-Wdeclaration-after-statement) test_and_set_c_compiler_flag_global(-Winfinite-recursion) test_and_set_c_compiler_flag_global(-fmax-errors=5) +set(DISABLE_COVERAGE ON CACHE BOOL "Disable code coverage analysis") + +if (NOT DISABLE_COVERAGE) + test_and_set_c_compiler_flag_global(-g) + test_and_set_c_compiler_flag_global(--coverage) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") + set(ENABLE_COVERAGE ON) +else() + set(ENABLE_COVERAGE OFF) +endif() + if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (Release, Debug, DebugASan, DebugTSan, DebugLSan, DebugUSan, DebugAnalyzer)" FORCE) |
