Skip to content
8 changes: 7 additions & 1 deletion cmake/script/CoverageInclude.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ separate_arguments(LCOV_OPTS)
set(LCOV_COMMAND ${LCOV_EXECUTABLE} --gcov-tool ${CMAKE_CURRENT_LIST_DIR}/cov_tool_wrapper.sh ${LCOV_OPTS})

find_program(GENHTML_EXECUTABLE genhtml REQUIRED)
set(GENHTML_COMMAND ${GENHTML_EXECUTABLE} --show-details ${LCOV_OPTS})
# If HTML_OPTS is not provided, implicitly pass LCOV_OPTS to genhtml.
separate_arguments(HTML_OPTS)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should separate_arguments(HTML_OPTS) be called after checking if it's defined to avoid modifying an undefined variable?

set(GENHTML_OPTS ${HTML_OPTS})
if(NOT GENHTML_OPTS)
set(GENHTML_OPTS ${LCOV_OPTS})
endif()
set(GENHTML_COMMAND ${GENHTML_EXECUTABLE} --show-details ${GENHTML_OPTS})

find_program(GREP_EXECUTABLE grep REQUIRED)
find_program(AWK_EXECUTABLE awk REQUIRED)
Expand Down
7 changes: 7 additions & 0 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,13 @@ enabled by setting `LCOV_OPTS="--rc branch_coverage=1"`:
cmake -DLCOV_OPTS="--rc branch_coverage=1" -P build/Coverage.cmake
```

HTML_OPTS can be specified to provide an options override to genhtml from the default LCOV_OPTS, the program that generates the
html report from lcov: `HTML_OPTS="--exclude boost"`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested this?

From my understanding, --exclude boost is a lcov option not a genhtml option, so this example will fail.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is an option for both lcov and genhtml - so I've used it as a reference, certainly tested it to filter out the boost entries in the coverage report, however, because there is currently no genhtml distribution in homebrew you need to install a custom binary which may or may not support the same options. In my case the version I'm using doesn't support the same options.

Copy link
Author

@tevio tevio Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be better to provide a reference in the docs for a compatible genhtml implementation that would officially "work" on macOs/windows (if it exists) that would render this OPTS overriding change irrelevant, but I don't know what that is or would look like currently


```
cmake -DHTML_OPTS="--exclude boost" -P build/Coverage.cmake
```

To enable test parallelism:
```
cmake -DJOBS=$(nproc) -P build/Coverage.cmake
Expand Down