• Home
  • Raw
  • Download

Lines Matching +full:- +full:- +full:gcov +full:- +full:options

2 # Copyright (C) 2018-2020 by George Cave - gcave@stablecoder.ca
8 # http://www.apache.org/licenses/LICENSE-2.0
21 # targets: 1 - A blanket instrumentation by calling `add_code_coverage()`, where
23 # instrumented. 2 - Per-target instrumentation by calling
45 # target_code_coverage(theExe) # As an executable target, adds the 'ccov-theExe' target (instrument…
56 # target_code_coverage(theExe) # As an executable target, adds the 'ccov-theExe' target and instrum…
64 …ered.cpp test/*) # As an executable target, the reports will exclude the non-covered.cpp file, and…
67 # Example 3: Target added to the 'ccov' and 'ccov-all' targets
70 # add_code_coverage_all_targets(EXCLUDE test/*) # Adds the 'ccov-all' target set and sets it to exc…
73 … an executable target, adds to the 'ccov' and ccov-all' targets, and the reports will exclude the …
76 # Options
83 find_program(LLVM_COV_PATH llvm-cov)
84 find_program(LLVM_PROFDATA_PATH llvm-profdata)
100 ccov-preprocessing
101 COMMAND ${CMAKE_COMMAND} -E make_directory
103 DEPENDS ccov-clean)
111 message(FATAL_ERROR "llvm-cov not found! Aborting.")
114 execute_process(COMMAND ${LLVM_COV_PATH} --version
116 string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" LLVM_COV_VERSION
122 …de_coverage()/add_code_coverage_all_targets() 'EXCLUDE' option only available on llvm-cov >= 7.0.0"
130 ccov-clean
131 COMMAND ${CMAKE_COMMAND} -E remove -f
133 COMMAND ${CMAKE_COMMAND} -E remove -f
137 ccov-clean
138 COMMAND ${CMAKE_COMMAND} -E rm -f
140 COMMAND ${CMAKE_COMMAND} -E rm -f
144 # Used to get the shared object file list before doing the main all-
147 ccov-libs
161 "Code coverage results with an optimized (non-Debug) build may be misleading"
167 "Code coverage results with an optimized (non-Debug) build may be misleading"
178 add_custom_target(ccov-clean COMMAND ${LCOV_PATH} --directory
179 ${CMAKE_BINARY_DIR} --zerocounters)
190 # GCOV/LCOV:
192 # ccov-${TARGET_NAME} : Generates HTML code coverage report for the associated named target.
193 # ccov-all : Generates HTML code coverage report, merging every target added with 'ALL' parameter i…
195 # LLVM-COV:
197 # ccov-report : Generates HTML code coverage report for every target added with 'AUTO' parameter.
198 # ccov-${TARGET_NAME} : Generates HTML code coverage report.
199 # ccov-report-${TARGET_NAME} : Prints to command line summary per-file coverage information.
200 # ccov-export-${TARGET_NAME} : Exports the coverage report to a JSON file.
201 # ccov-show-${TARGET_NAME} : Prints to command line detailed per-line coverage information.
202 # ccov-all : Generates HTML code coverage report, merging every target added with 'ALL' parameter i…
203 # ccov-all-report : Prints summary per-file coverage information for every target added with ALL' p…
204 # ccov-all-export : Exports the coverage report to a JSON file.
207 # TARGET_NAME - Name of the target to generate code coverage for.
209 # PUBLIC - Sets the visibility for added compile options to targets to PUBLIC instead of the defaul…
210 # INTERFACE - Sets the visibility for added compile options to targets to INTERFACE instead of the …
211 # AUTO - Adds the target to the 'ccov' target so that it can be run in a batch with others easily. …
212 # ALL - Adds the target to the 'ccov-all' and 'ccov-all-report' targets, which merge several execut…
213 # EXTERNAL - For GCC's lcov, allows the profiling of 'external' files from the processing directory
214 …COVERAGE_TARGET_NAME - For executables ONLY, changes the outgoing target name so instead of `ccov-
215 # EXCLUDE <PATTERNS> - Excludes files of the patterns provided from coverage. Note that GCC/lcov ex…
216 # OBJECTS <TARGETS> - For executables ONLY, if the provided targets are shared libraries, adds cove…
217 # ARGS <ARGUMENTS> - For executables ONLY, appends the given arguments to the associated ccov-* exe…
221 set(options AUTO ALL EXTERNAL PUBLIC INTERFACE) variable
225 target_code_coverage "${options}" "${single_value_keywords}"
249 -fprofile-instr-generate -fcoverage-mapping)
251 -fprofile-instr-generate -fcoverage-mapping)
254 target_compile_options(${TARGET_NAME} ${TARGET_VISIBILITY} -fprofile-arcs
255 -ftest-coverage)
256 target_link_libraries(${TARGET_NAME} ${TARGET_VISIBILITY} gcov)
267 ccov-run-${target_code_coverage_COVERAGE_TARGET_NAME}
269 ${CMAKE_COMMAND} -E echo "-object=$<TARGET_FILE:${TARGET_NAME}>" >>
271 DEPENDS ccov-preprocessing ${TARGET_NAME})
273 if(NOT TARGET ccov-libs)
280 add_dependencies(ccov-libs
281 ccov-run-${target_code_coverage_COVERAGE_TARGET_NAME})
297 set(SO_OBJECTS ${SO_OBJECTS} -object=$<TARGET_FILE:${SO_TARGET}>)
306 ccov-run-${target_code_coverage_COVERAGE_TARGET_NAME}
308 ${CMAKE_COMMAND} -E env
312 ${CMAKE_COMMAND} -E echo "-object=$<TARGET_FILE:${TARGET_NAME}>"
315 ${CMAKE_COMMAND} -E echo
319 DEPENDS ccov-preprocessing ccov-libs ${TARGET_NAME})
321 # Merge the generated profile data so llvm-cov can process it
323 ccov-processing-${target_code_coverage_COVERAGE_TARGET_NAME}
325 ${LLVM_PROFDATA_PATH} merge -sparse
326 ${target_code_coverage_COVERAGE_TARGET_NAME}.profraw -o
328 DEPENDS ccov-run-${target_code_coverage_COVERAGE_TARGET_NAME})
334 -ignore-filename-regex='${EXCLUDE_ITEM}')
340 ccov-show-${target_code_coverage_COVERAGE_TARGET_NAME}
343 -instr-profile=${target_code_coverage_COVERAGE_TARGET_NAME}.profdata
344 -show-line-counts-or-regions ${EXCLUDE_REGEX}
345 DEPENDS ccov-processing-${target_code_coverage_COVERAGE_TARGET_NAME})
349 ccov-report-${target_code_coverage_COVERAGE_TARGET_NAME}
352 -instr-profile=${target_code_coverage_COVERAGE_TARGET_NAME}.profdata
354 DEPENDS ccov-processing-${target_code_coverage_COVERAGE_TARGET_NAME})
359 ccov-export-${target_code_coverage_COVERAGE_TARGET_NAME}
362 -instr-profile=${target_code_coverage_COVERAGE_TARGET_NAME}.profdata
363 -format="text" ${EXCLUDE_REGEX} >
365 DEPENDS ccov-processing-${target_code_coverage_COVERAGE_TARGET_NAME})
369 ccov-${target_code_coverage_COVERAGE_TARGET_NAME}
372 -instr-profile=${target_code_coverage_COVERAGE_TARGET_NAME}.profdata
373 -show-line-counts-or-regions
374-output-dir=${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/${target_code_coverage_COVERAGE_TARGET_NAME}
375 -format="html" ${EXCLUDE_REGEX}
376 DEPENDS ccov-processing-${target_code_coverage_COVERAGE_TARGET_NAME})
386 ccov-run-${target_code_coverage_COVERAGE_TARGET_NAME}
388 DEPENDS ccov-preprocessing ${TARGET_NAME})
392 set(EXCLUDE_REGEX ${EXCLUDE_REGEX} --remove ${COVERAGE_INFO}
397 set(EXCLUDE_COMMAND ${LCOV_PATH} ${EXCLUDE_REGEX} --output-file
404 set(EXTERNAL_OPTION --no-external)
410 ccov-capture-${target_code_coverage_COVERAGE_TARGET_NAME}
411 COMMAND ${CMAKE_COMMAND} -E remove -f ${COVERAGE_INFO}
412 COMMAND ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --zerocounters
415 ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --base-directory
416 ${CMAKE_SOURCE_DIR} --capture ${EXTERNAL_OPTION} --output-file
419 DEPENDS ccov-preprocessing ${TARGET_NAME})
422 ccov-capture-${target_code_coverage_COVERAGE_TARGET_NAME}
423 COMMAND ${CMAKE_COMMAND} -E rm -f ${COVERAGE_INFO}
424 COMMAND ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --zerocounters
427 ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --base-directory
428 ${CMAKE_SOURCE_DIR} --capture ${EXTERNAL_OPTION} --output-file
431 DEPENDS ccov-preprocessing ${TARGET_NAME})
436 ccov-${target_code_coverage_COVERAGE_TARGET_NAME}
438 ${GENHTML_PATH} -o
441 DEPENDS ccov-capture-${target_code_coverage_COVERAGE_TARGET_NAME})
445 TARGET ccov-${target_code_coverage_COVERAGE_TARGET_NAME}
457 add_dependencies(ccov ccov-${target_code_coverage_COVERAGE_TARGET_NAME})
461 if(NOT TARGET ccov-report)
462 add_custom_target(ccov-report)
465 ccov-report
466 ccov-report-${target_code_coverage_COVERAGE_TARGET_NAME})
472 if(NOT TARGET ccov-all-processing)
479 add_dependencies(ccov-all-processing
480 ccov-run-${target_code_coverage_COVERAGE_TARGET_NAME})
493 add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
494 add_link_options(-fprofile-instr-generate -fcoverage-mapping)
497 add_compile_options(-fprofile-arcs -ftest-coverage)
498 link_libraries(gcov)
503 # Adds the 'ccov-all' type targets that calls all targets added via
506 # reports. Also adds the ccov-all-capture Generates an all-merged.info file, for
510 # EXCLUDE <PATTERNS> - Excludes files of the patterns provided from coverage. Note that GCC/lcov ex…
525 ccov-all-processing
527 powershell -Command $$FILELIST = Get-Content
528 ${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/profraw.list\; llvm-profdata.exe
529 merge -o ${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/all-merged.profdata
530 -sparse $$FILELIST)
533 ccov-all-processing
535 ${LLVM_PROFDATA_PATH} merge -o
536 ${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/all-merged.profdata -sparse `cat
544 -ignore-filename-regex='${EXCLUDE_ITEM}')
551 ccov-all-report
553 powershell -Command $$FILELIST = Get-Content
554 ${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/binaries.list\; llvm-cov.exe
556 -instr-profile=${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/all-merged.profdata
558 DEPENDS ccov-all-processing)
561 ccov-all-report
565 -instr-profile=${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/all-merged.profdata
567 DEPENDS ccov-all-processing)
573 ccov-all-export
577 -instr-profile=${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/all-merged.profdata
578 -format="text" ${EXCLUDE_REGEX} >
580 DEPENDS ccov-all-processing)
585 ccov-all
587 powershell -Command $$FILELIST = Get-Content
588 ${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/binaries.list\; llvm-cov.exe show
590 -instr-profile=${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/all-merged.profdata
591 -show-line-counts-or-regions
592 -output-dir=${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/all-merged
593 -format="html" ${EXCLUDE_REGEX}
594 DEPENDS ccov-all-processing)
597 ccov-all
601 -instr-profile=${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/all-merged.profdata
602 -show-line-counts-or-regions
603 -output-dir=${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/all-merged
604 -format="html" ${EXCLUDE_REGEX}
605 DEPENDS ccov-all-processing)
610 set(COVERAGE_INFO "${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/all-merged.info")
612 # Nothing required for gcov
613 add_custom_target(ccov-all-processing COMMAND ;)
618 set(EXCLUDE_REGEX ${EXCLUDE_REGEX} --remove ${COVERAGE_INFO}
623 set(EXCLUDE_COMMAND ${LCOV_PATH} ${EXCLUDE_REGEX} --output-file
632 ccov-all-capture
633 COMMAND ${CMAKE_COMMAND} -E remove -f ${COVERAGE_INFO}
634 COMMAND ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --capture
635 --output-file ${COVERAGE_INFO}
637 DEPENDS ccov-preprocessing ccov-all-processing)
640 ccov-all-capture
641 COMMAND ${CMAKE_COMMAND} -E rm -f ${COVERAGE_INFO}
642 COMMAND ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --capture
643 --output-file ${COVERAGE_INFO}
645 DEPENDS ccov-preprocessing ccov-all-processing)
650 ccov-all
651 COMMAND ${GENHTML_PATH} -o ${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/all-merged
652 ${COVERAGE_INFO} -p ${CMAKE_SOURCE_DIR}
653 DEPENDS ccov-all-capture)
658 TARGET ccov-all
662 …"Open ${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/all-merged/index.html in your browser to view the coverag…