You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- ccov-report-${TARGET_NAME} : Prints to command line summary per-file coverage information.
170
+
- ccov-export-${TARGET_NAME} : Exports the coverage report to a JSON file.
171
+
- ccov-show-${TARGET_NAME} : Prints to command line detailed per-line coverage information.
172
+
- ccov-report : Generates HTML code coverage report for every target added with 'AUTO' parameter.
173
+
174
+
#### Via `add_code_coverage_all_targets`
175
+
176
+
Targets added:
177
+
- ccov-all-run : Re-runs all tagged executables, collecting fresh coverage data
178
+
- ccov-all-html : Generates an HTML report of all tagged executable coverage data merged into one
179
+
- ccov-all : Generates an HTML report of all tagged executable coverage data merged into one (same as ccov-all-html)
180
+
181
+
LLVM-based coverage targets added:
182
+
- ccov-all-report : Generates an HTML report of all tagged executable coverage data merged into one and displays it in the CLI
183
+
- ccov-all-export : Exports coverage data in JSON format for use in CI environments or similar
184
+
185
+
GCC-based coverage targets added:
186
+
- ccov-all-capture : Generates an all-merged.info file, for use with coverage dashboards (e.g. codecov.io, coveralls).
172
187
173
188
### Usage
174
189
175
190
To enable any code coverage instrumentation/targets, the single CMake option of `CODE_COVERAGE` needs to be set to 'ON', either by GUI, ccmake, or on the command line ie `-DCODE_COVERAGE=ON`.
176
191
177
192
From this point, there are two primary methods for adding instrumentation to targets:
178
193
1. A blanket instrumentation by calling `add_code_coverage()`, where all targets in that directory and all subdirectories are automatically instrumented.
179
-
2. Per-target instrumentation by calling `target_code_coverage(<TARGET_NAME>)`, where the target is given and thus only that target is instrumented. This applies to both libraries and executables.
194
+
2. Per-target instrumentation by calling `target_code_coverage(<TARGET_NAME>)`, where the target is given and thus only that target is instrumented and executables have ccov* targets created. This applies to both libraries and executables.
180
195
3. Automatically add coverage for each target with `-DCCOV_TARGETS_HOOK=On` and `-DCCOV_TARGETS_HOOK_ARGS=...` for default values, requires `add_code_coverage()` or similar.
181
196
182
197
To add coverage targets, such as calling `make ccov` to generate the actual coverage information for perusal or consumption, call `target_code_coverage(<TARGET_NAME>)` on an *executable* target.
# ccov-report-${TARGET_NAME} : Prints to command line summary per-file coverage information.
238
236
# ccov-export-${TARGET_NAME} : Exports the coverage report to a JSON file.
239
237
# ccov-show-${TARGET_NAME} : Prints to command line detailed per-line coverage information.
240
-
# ccov-all : Generates HTML code coverage report, merging every target added with 'ALL' parameter into a single detailed report.
241
-
# ccov-all-report : Prints summary per-file coverage information for every target added with ALL' parameter to the command line.
242
-
# ccov-all-export : Exports the coverage report to a JSON file.
238
+
# ccov-report : Generates HTML code coverage report for every target added with 'AUTO' parameter.
243
239
#
244
-
# Required:
240
+
# Required Parameters:
245
241
# TARGET_NAME - Name of the target to generate code coverage for.
246
-
# Optional:
242
+
#
243
+
# Optional Parameters:
247
244
# PUBLIC - Sets the visibility for added compile options to targets to PUBLIC instead of the default of PRIVATE.
248
245
# INTERFACE - Sets the visibility for added compile options to targets to INTERFACE instead of the default of PRIVATE.
249
246
# PLAIN - Do not set any target visibility (backward compatibility with old cmake projects)
250
247
# AUTO - Adds the target to the 'ccov' target so that it can be run in a batch with others easily. Effective on executable targets.
251
-
# ALL - Adds the target to the 'ccov-all' and 'ccov-all-report' targets, which merge several executable targets coverage data to a single report. Effective on executable targets.
248
+
# ALL - Adds the target to the 'ccov-all-*' targets created by a prior call to `add_code_coverage_all_targets` Effective on executable targets.
252
249
# EXTERNAL - For GCC's lcov, allows the profiling of 'external' files from the processing directory
253
250
# COVERAGE_TARGET_NAME - For executables ONLY, changes the outgoing target name so instead of `ccov-${TARGET_NAME}` it becomes `ccov-${COVERAGE_TARGET_NAME}`.
254
251
# EXCLUDE <PATTERNS> - Excludes files of the patterns provided from coverage. Note that GCC/lcov excludes by glob pattern, and clang/LLVM excludes via regex! **These do not copy to the 'all' targets.**
255
252
# OBJECTS <TARGETS> - For executables ONLY, if the provided targets are static or shared libraries, adds coverage information to the output
256
-
# PRE_ARGS <ARGUMENTS> - For executables ONLY, prefixes given arguments to the associated ccov-* executable call ($<PRE_ARGS> ccov-*)
257
-
# ARGS <ARGUMENTS> - For executables ONLY, appends the given arguments to the associated ccov-* executable call (ccov-* $<ARGS>)
253
+
# PRE_ARGS <ARGUMENTS> - For executables ONLY, prefixes given arguments to the associated ccov-run-${TARGET_NAME} executable call ($<PRE_ARGS> ccov-*)
254
+
# ARGS <ARGUMENTS> - For executables ONLY, appends the given arguments to the associated ccov-run-${TARGET_NAME} executable call (ccov-* $<ARGS>)
# Adds code coverage instrumentation to all targets in the current directory and
616
-
# any subdirectories. To add coverage instrumentation to only specific targets,
613
+
# any subdirectories.
614
+
#
615
+
# To add coverage instrumentation to only specific targets, or to add targets,
617
616
# use `target_code_coverage`.
617
+
#
618
+
# @WARNING: Does not add targets to collect coverage data from executables, use
619
+
# `target_code_coverage` to do so.
618
620
function(add_code_coverage)
619
621
if(NOT CODE_COVERAGE)
620
622
return()
@@ -633,13 +635,23 @@ function(add_code_coverage)
633
635
endif()
634
636
endfunction()
635
637
636
-
# Adds the 'ccov-all' type targets that calls all targets added via
638
+
# Adds several 'ccov-all-*' type targets that operates on all targets added via
637
639
# `target_code_coverage` with the `ALL` parameter, but merges all the coverage
638
-
# data from them into a single large report instead of the numerous smaller
639
-
# reports. Also adds the ccov-all-capture Generates an all-merged.info file, for
640
-
# use with coverage dashboards (e.g. codecov.io, coveralls).
640
+
# data into a single large report instead of numerous smaller reports.
641
641
# ~~~
642
-
# Optional:
642
+
# Targets added:
643
+
# ccov-all-run : Re-runs all tagged executables, collecting fresh coverage data
644
+
# ccov-all-html : Generates an HTML report of all tagged executable coverage data merged into one
645
+
# ccov-all : Generates an HTML report of all tagged executable coverage data merged into one (same as ccov-all-html)
646
+
#
647
+
# LLVM-based coverage targets added:
648
+
# ccov-all-report : Generates an HTML report of all tagged executable coverage data merged into one and displays it in the CLI
649
+
# ccov-all-export : Exports coverage data in JSON format for use in CI environments or similar
650
+
#
651
+
# GCC-based coverage targets added:
652
+
# ccov-all-capture : Generates an all-merged.info file, for use with coverage dashboards (e.g. codecov.io, coveralls).
653
+
#
654
+
# Optional Parameters:
643
655
# EXCLUDE <PATTERNS> - Excludes files of the patterns provided from coverage. Note that GCC/lcov excludes by glob pattern, and clang/LLVM excludes via regex!
0 commit comments