@@ -85,7 +85,12 @@ find_program(LLVM_PROFDATA_PATH llvm-profdata)
85
85
find_program (LCOV_PATH lcov)
86
86
find_program (GENHTML_PATH genhtml)
87
87
# Hide behind the 'advanced' mode flag for GUI/ccmake
88
- mark_as_advanced (FORCE LLVM_COV_PATH LLVM_PROFDATA_PATH LCOV_PATH GENHTML_PATH)
88
+ mark_as_advanced (
89
+ FORCE
90
+ LLVM_COV_PATH
91
+ LLVM_PROFDATA_PATH
92
+ LCOV_PATH
93
+ GENHTML_PATH)
89
94
90
95
# Variables
91
96
set (CMAKE_COVERAGE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /ccov)
@@ -112,8 +117,11 @@ if(CODE_COVERAGE AND NOT CODE_COVERAGE_ADDED)
112
117
# Version number checking for 'EXCLUDE' compatibility
113
118
execute_process (COMMAND ${LLVM_COV_PATH} --version
114
119
OUTPUT_VARIABLE LLVM_COV_VERSION_CALL_OUTPUT)
115
- string (REGEX MATCH "[0-9]+\\ .[0-9]+\\ .[0-9]+" LLVM_COV_VERSION
116
- ${LLVM_COV_VERSION_CALL_OUTPUT} )
120
+ string (
121
+ REGEX MATCH
122
+ "[0-9]+\\ .[0-9]+\\ .[0-9]+"
123
+ LLVM_COV_VERSION
124
+ ${LLVM_COV_VERSION_CALL_OUTPUT} )
117
125
118
126
if (LLVM_COV_VERSION VERSION_LESS "7.0.0" )
119
127
message (
@@ -142,7 +150,10 @@ if(CODE_COVERAGE AND NOT CODE_COVERAGE_ADDED)
142
150
143
151
if (CMAKE_BUILD_TYPE )
144
152
string (TOUPPER ${CMAKE_BUILD_TYPE} upper_build_type)
145
- if (NOT ${upper_build_type} STREQUAL "DEBUG" )
153
+ if (NOT
154
+ ${upper_build_type}
155
+ STREQUAL
156
+ "DEBUG" )
146
157
message (
147
158
WARNING
148
159
"Code coverage results with an optimized (non-Debug) build may be misleading"
@@ -212,8 +223,11 @@ function(target_code_coverage TARGET_NAME)
212
223
set (single_value_keywords COVERAGE_TARGET_NAME)
213
224
set (multi_value_keywords EXCLUDE OBJECTS ARGS)
214
225
cmake_parse_arguments (
215
- target_code_coverage "${options} " "${single_value_keywords} "
216
- "${multi_value_keywords} " ${ARGN} )
226
+ target_code_coverage
227
+ "${options} "
228
+ "${single_value_keywords} "
229
+ "${multi_value_keywords} "
230
+ ${ARGN} )
217
231
218
232
# Set the visibility of target functions to PUBLIC, INTERFACE or default to
219
233
# PRIVATE.
@@ -313,9 +327,10 @@ function(target_code_coverage TARGET_NAME)
313
327
# Merge the generated profile data so llvm-cov can process it
314
328
add_custom_target (
315
329
ccov-processing-${target_code_coverage_COVERAGE_TARGET_NAME}
316
- COMMAND ${LLVM_PROFDATA_PATH} merge -sparse
317
- ${target_code_coverage_COVERAGE_TARGET_NAME} .profraw -o
318
- ${target_code_coverage_COVERAGE_TARGET_NAME} .profdata
330
+ COMMAND
331
+ ${LLVM_PROFDATA_PATH} merge -sparse
332
+ ${target_code_coverage_COVERAGE_TARGET_NAME} .profraw -o
333
+ ${target_code_coverage_COVERAGE_TARGET_NAME} .profdata
319
334
DEPENDS ccov-run-${target_code_coverage_COVERAGE_TARGET_NAME} )
320
335
321
336
# Ignore regex only works on LLVM >= 7
@@ -368,8 +383,11 @@ function(target_code_coverage TARGET_NAME)
368
383
369
384
# Generate exclusion string for use
370
385
foreach (EXCLUDE_ITEM ${target_code_coverage_EXCLUDE} )
371
- set (EXCLUDE_REGEX ${EXCLUDE_REGEX} --remove ${COVERAGE_INFO}
372
- '${EXCLUDE_ITEM} ')
386
+ set (EXCLUDE_REGEX
387
+ ${EXCLUDE_REGEX}
388
+ --remove
389
+ ${COVERAGE_INFO}
390
+ '${EXCLUDE_ITEM} ')
373
391
endforeach ()
374
392
375
393
if (EXCLUDE_REGEX)
@@ -473,8 +491,12 @@ endfunction()
473
491
function (add_code_coverage_all_targets)
474
492
# Argument parsing
475
493
set (multi_value_keywords EXCLUDE )
476
- cmake_parse_arguments (add_code_coverage_all_targets "" ""
477
- "${multi_value_keywords} " ${ARGN} )
494
+ cmake_parse_arguments (
495
+ add_code_coverage_all_targets
496
+ ""
497
+ ""
498
+ "${multi_value_keywords} "
499
+ ${ARGN} )
478
500
479
501
if (CODE_COVERAGE)
480
502
if (CMAKE_C_COMPILER_ID MATCHES "(Apple)?[Cc]lang"
@@ -539,8 +561,11 @@ function(add_code_coverage_all_targets)
539
561
# Exclusion regex string creation
540
562
set (EXCLUDE_REGEX)
541
563
foreach (EXCLUDE_ITEM ${add_code_coverage_all_targets_EXCLUDE} )
542
- set (EXCLUDE_REGEX ${EXCLUDE_REGEX} --remove ${COVERAGE_INFO}
543
- '${EXCLUDE_ITEM} ')
564
+ set (EXCLUDE_REGEX
565
+ ${EXCLUDE_REGEX}
566
+ --remove
567
+ ${COVERAGE_INFO}
568
+ '${EXCLUDE_ITEM} ')
544
569
endforeach ()
545
570
546
571
if (EXCLUDE_REGEX)
0 commit comments