fix mismatch gcov error

This commit is contained in:
Jose Luis Blanco-Claraco
2025-11-16 10:35:59 +01:00
parent 17c3b26ffb
commit 89c2ce4f7e
2 changed files with 8 additions and 8 deletions

View File

@@ -99,7 +99,7 @@ jobs:
run: |
# 1. Capture coverage data from the build directory
# lcov finds all the .gcno and .gcda files
lcov --capture --directory build/ --output-file coverage.info
lcov --capture --directory build/ --output-file coverage.info --ignore-errors mismatch
# 2. Filter to *only* include the main header file
# This fulfills your request to not include examples/tests

View File

@@ -3,6 +3,11 @@
# ----------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_FLAGS_COVERAGE "-g -O0 --coverage" CACHE STRING "Flags for C++ coverage build")
set(CMAKE_C_FLAGS_COVERAGE "-g -O0 --coverage" CACHE STRING "Flags for C coverage build")
set(CMAKE_EXE_LINKER_FLAGS_COVERAGE "--coverage" CACHE STRING "Linker flags for coverage build")
set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE "--coverage" CACHE STRING "Linker flags for coverage build")
# Extract library version into "NANOFLANN_VERSION"
# -----------------------------------------------------
# Look for: "#define NANOFLANN_VERSION 0xABC"
@@ -26,13 +31,8 @@ if (CMAKE_COMPILER_IS_GNUCXX)
# The -Wno-variadic-macros was needed for Eigen3, StdVector.h
add_compile_options(-Wall -Wshadow -Wno-long-long -Wno-variadic-macros)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Coverage")
message(STATUS "Coverage build enabled. Adding gcov flags.")
# Add gcov flags, ensure no optimization (-O0), and include debug symbols (-g)
add_compile_options(-g -O0 --coverage)
add_link_options(--coverage)
elseif (NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
# Keep original logic for Release builds
# Apply Release optimizations ONLY if it's not Debug and not Coverage
if (NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Coverage")
add_compile_options(-O2 -mtune=native)
endif()