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
The LLVM backedn excludes by regex, and the LCOV backend excludes by
glob, which are incompatible with each other. Thus, to better accomodate
workflows that may utilize either/both backends, add new LLVM_EXCLUDE
and LCOV_EXCLUDE that apply only to that backend.
The original EXCLUDE option will still apply to both and can be useful
for items such as full file paths.
Copy file name to clipboardExpand all lines: README.md
+15-4Lines changed: 15 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -192,11 +192,11 @@ To enable any code coverage instrumentation/targets, the single CMake option of
192
192
From this point, there are two primary methods for adding instrumentation to targets:
193
193
1. A blanket instrumentation by calling `add_code_coverage()`, where all targets in that directory and all subdirectories are automatically instrumented.
194
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.
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.
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.
196
196
197
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.
198
198
199
-
**NOTE:** For more options, please check the actual[`code-coverage.cmake`](code-coverage.cmake) file.
199
+
**NOTE:** For more options, please check the documentation for each function in the[`code-coverage.cmake`](code-coverage.cmake) file.
200
200
201
201
#### Example 1 - All targets instrumented
202
202
@@ -235,10 +235,21 @@ target_code_coverage(theExe EXCLUDE non_covered.cpp) # As an executable target,
235
235
#### Example 3: Target added to the 'ccov' and 'ccov-all' targets
236
236
237
237
```
238
-
add_code_coverage_all_targets(EXCLUDE test/*) # Adds the 'ccov-all' target set and sets it to exclude all files in test/ folders.
238
+
# Adds the 'ccov-all' target set and sets it to exclude a specific
239
+
# file and all files in test/ folders.
240
+
add_code_coverage_all_targets(
241
+
EXCLUDE non_covered.cpp
242
+
LCOV_EXCLUDE test/*
243
+
LLVM_EXCLUDE test/.*)
239
244
240
245
add_executable(theExe main.cpp non_covered.cpp)
241
-
target_code_coverage(theExe AUTO ALL EXCLUDE non_covered.cpp test/*) # As an executable target, adds to the 'ccov' and ccov-all' targets, and the reports will exclude the non-covered.cpp file, and any files in a test/ folder.
246
+
# As an executable target, adds to the 'ccov' and ccov-all' targets, and
247
+
# the reports will exclude the non-covered.cpp file, and any files in a test/ folder.
248
+
target_code_coverage(theExe AUTO ALL
249
+
EXCLUDE non_covered.cpp # a file path which applies to both backends
250
+
LCOV_EXCLUDE test/* # the GCC/lcov backend excludes by glob
251
+
LLVM_EXCLUDE test/.* # the clang/LLVM backend exclude by regext
Copy file name to clipboardExpand all lines: code-coverage.cmake
+34-5Lines changed: 34 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -61,13 +61,18 @@
61
61
#
62
62
# ~~~
63
63
# add_executable(theExe main.cpp non_covered.cpp)
64
-
# target_code_coverage(theExe EXCLUDE non_covered.cpp test/*) # As an executable target, the reports will exclude the non-covered.cpp file, and any files in a test/ folder.
64
+
# target_code_coverage(theExe
65
+
# EXCLUDE non_covered.cpp
66
+
# LCOV_EXCLUDE test/*
67
+
# LLVM_EXCLUDE test/.*) # As an executable target, the reports will exclude the non-covered.cpp file, and any files in a test/ folder.
65
68
# ~~~
66
69
#
67
70
# Example 3: Target added to the 'ccov' and 'ccov-all' targets
68
71
#
69
72
# ~~~
70
-
# add_code_coverage_all_targets(EXCLUDE test/*) # Adds the 'ccov-all' target set and sets it to exclude all files in test/ folders.
73
+
# add_code_coverage_all_targets(
74
+
# LCOV_EXCLUDE test/*
75
+
# LLVM_EXCLUDE test/.*)# Adds the 'ccov-all' target set and sets it to exclude all files in test/ folders.
71
76
#
72
77
# add_executable(theExe main.cpp non_covered.cpp)
73
78
# target_code_coverage(theExe AUTO ALL EXCLUDE non_covered.cpp test/*) # As an executable target, adds to the 'ccov' and ccov-all' targets, and the reports will exclude the non-covered.cpp file, and any files in a test/ folder.
@@ -234,7 +239,9 @@ endif()
234
239
# ALL - Adds the target to the 'ccov-all-*' targets created by a prior call to `add_code_coverage_all_targets` Effective on executable targets.
235
240
# EXTERNAL - For GCC's lcov, allows the profiling of 'external' files from the processing directory
236
241
# COVERAGE_TARGET_NAME - For executables ONLY, changes the outgoing target name so instead of `ccov-${TARGET_NAME}` it becomes `ccov-${COVERAGE_TARGET_NAME}`.
237
-
# 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.**
242
+
# EXCLUDE <PATTERNS> - Excludes files of the patterns provided from coverage. Added to any lcov/llvm specific excludes. sNote that GCC/lcov excludes by glob pattern, and clang/LLVM excludes via regex! **These do not copy to the 'all' targets.**
243
+
# LLVM_EXCLUDE <PATTERNS> - Excludes files that match the provided patterns, LLVM excludes by regex patterns.
244
+
# LCOV_EXCLUDE <PATTERNS> - Excludes files that match the provided patterns. LCOV exclude by glob patterns.
238
245
# OBJECTS <TARGETS> - For executables ONLY, if the provided targets are static or shared libraries, adds coverage information to the output
239
246
# PRE_ARGS <ARGUMENTS> - For executables ONLY, prefixes given arguments to the associated ccov-run-${TARGET_NAME} executable call ($<PRE_ARGS> ccov-*)
240
247
# ARGS <ARGUMENTS> - For executables ONLY, appends the given arguments to the associated ccov-run-${TARGET_NAME} executable call (ccov-* $<ARGS>)
# EXCLUDE <PATTERNS> - Excludes files of the patterns provided from coverage. Note that GCC/lcov excludes by glob pattern, and clang/LLVM excludes via regex!
660
+
# LLVM_EXCLUDE <PATTERNS> - Excludes files that match the provided patterns, LLVM excludes by regex patterns.
661
+
# LCOV_EXCLUDE <PATTERNS> - Excludes files that match the provided patterns. LCOV exclude by glob patterns.
0 commit comments