Skip to content

Commit 97a898f

Browse files
committed
Default genhtml opts to LCOV_OPTS; respect explicitly empty HTML_OPTS
1 parent e3e917f commit 97a898f

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

cmake/script/CoverageInclude.cmake.in

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,17 @@ set(LCOV_COMMAND ${LCOV_EXECUTABLE} --gcov-tool ${CMAKE_CURRENT_LIST_DIR}/cov_to
2626
find_program(GENHTML_EXECUTABLE genhtml REQUIRED)
2727

2828
# HTML_OPTS is optionally passed via -D flag.
29-
# If HTML_OPTS is not provided, implicitly pass LCOV_OPTS to genhtml.
29+
# If HTML_OPTS is not provided at all, implicitly pass LCOV_OPTS to genhtml.
30+
# If HTML_OPTS is provided but empty (e.g. -DHTML_OPTS=""), use an empty list
31+
# and do NOT inherit LCOV_OPTS.
32+
set(_HTML_OPTS_WAS_DEFINED FALSE)
33+
if(DEFINED HTML_OPTS)
34+
set(_HTML_OPTS_WAS_DEFINED TRUE)
35+
endif()
3036
separate_arguments(HTML_OPTS)
31-
set(GENHTML_OPTS ${HTML_OPTS})
32-
if(NOT GENHTML_OPTS)
37+
if(_HTML_OPTS_WAS_DEFINED)
38+
set(GENHTML_OPTS ${HTML_OPTS})
39+
else()
3340
set(GENHTML_OPTS ${LCOV_OPTS})
3441
endif()
3542
set(GENHTML_COMMAND ${GENHTML_EXECUTABLE} --show-details ${GENHTML_OPTS})

doc/developer-notes.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,10 +508,15 @@ enabled by setting `LCOV_OPTS="--rc branch_coverage=1"`:
508508
cmake -DLCOV_OPTS="--rc branch_coverage=1" -P build/Coverage.cmake
509509
```
510510

511-
HTML_OPTS can override the genhtml options (which default to LCOV_OPTS).
511+
HTML_OPTS can override the genhtml options (which default to LCOV_OPTS). If HTML_OPTS is omitted, LCOV_OPTS are implicitly passed to genhtml. If HTML_OPTS is provided but empty (e.g. -DHTML_OPTS=""), no options are passed to genhtml and LCOV_OPTS are not inherited.
512512

513+
Examples:
513514
```
514-
cmake -DHTML_OPTS="--exclude boost" -P build/Coverage.cmake
515+
# Override genhtml options explicitly
516+
cmake -DHTML_OPTS="--title 'Knots Coverage'" -P build/Coverage.cmake
517+
518+
# Provide an empty override: pass nothing to genhtml (do not inherit LCOV_OPTS)
519+
cmake -DHTML_OPTS="" -P build/Coverage.cmake
515520
```
516521

517522
To enable test parallelism:

0 commit comments

Comments
 (0)