@@ -430,7 +430,7 @@ function(target_code_coverage TARGET_NAME)
430
430
# Capture coverage data
431
431
if (${CMAKE_VERSION} VERSION_LESS "3.17.0" )
432
432
add_custom_target (
433
- ccov-capture -${target_code_coverage_COVERAGE_TARGET_NAME}
433
+ ccov-clean -${target_code_coverage_COVERAGE_TARGET_NAME}
434
434
COMMAND ${CMAKE_COMMAND} -E remove -f ${COVERAGE_INFO}
435
435
COMMAND ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --zerocounters
436
436
COMMAND
@@ -444,7 +444,7 @@ function(target_code_coverage TARGET_NAME)
444
444
DEPENDS ${TARGET_NAME} )
445
445
else ()
446
446
add_custom_target (
447
- ccov-capture -${target_code_coverage_COVERAGE_TARGET_NAME}
447
+ ccov-clean -${target_code_coverage_COVERAGE_TARGET_NAME}
448
448
COMMAND ${CMAKE_COMMAND} -E rm -f ${COVERAGE_INFO}
449
449
COMMAND ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --zerocounters
450
450
COMMAND
@@ -458,9 +458,18 @@ function(target_code_coverage TARGET_NAME)
458
458
DEPENDS ${TARGET_NAME} )
459
459
endif ()
460
460
461
- # Generates HTML output of the coverage information for perusal
462
461
add_custom_target (
463
- ccov-${target_code_coverage_COVERAGE_TARGET_NAME}
462
+ ccov-capture-${target_code_coverage_COVERAGE_TARGET_NAME}
463
+ COMMAND
464
+ ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --base-directory
465
+ ${CMAKE_SOURCE_DIR} --capture ${EXTERNAL_OPTION} --output -file
466
+ ${COVERAGE_INFO}
467
+ COMMAND ${EXCLUDE_COMMAND}
468
+ DEPENDS )
469
+
470
+ # Only generates HTML output of the coverage information for perusal
471
+ add_custom_target (
472
+ ccov-html-${target_code_coverage_COVERAGE_TARGET_NAME}
464
473
COMMAND
465
474
${GENHTML_PATH} -o
466
475
${CMAKE_COVERAGE_OUTPUT_DIRECTORY} /${target_code_coverage_COVERAGE_TARGET_NAME}
@@ -469,6 +478,15 @@ function(target_code_coverage TARGET_NAME)
469
478
${CMAKE_COMMAND} -E echo
470
479
"Open ${CMAKE_COVERAGE_OUTPUT_DIRECTORY} /${target_code_coverage_COVERAGE_TARGET_NAME} /index.html in your browser to view the coverage report."
471
480
DEPENDS ccov-capture-${target_code_coverage_COVERAGE_TARGET_NAME} )
481
+
482
+ # Generates HTML output of the coverage information for perusal
483
+ add_custom_target (
484
+ ccov-${target_code_coverage_COVERAGE_TARGET_NAME}
485
+ COMMAND
486
+ DEPENDS
487
+ ccov-clean-${target_code_coverage_COVERAGE_TARGET_NAME}
488
+ ccov-run-${target_code_coverage_COVERAGE_TARGET_NAME}
489
+ ccov-html-${target_code_coverage_COVERAGE_TARGET_NAME} )
472
490
endif ()
473
491
474
492
# AUTO
@@ -478,6 +496,11 @@ function(target_code_coverage TARGET_NAME)
478
496
endif ()
479
497
add_dependencies (ccov ccov-${target_code_coverage_COVERAGE_TARGET_NAME} )
480
498
499
+ if (NOT TARGET ccov-html)
500
+ add_custom_target (ccov-html)
501
+ endif ()
502
+ add_dependencies (ccov-html ccov-html-${target_code_coverage_COVERAGE_TARGET_NAME} )
503
+
481
504
if (NOT CMAKE_C_COMPILER_ID MATCHES "GNU" AND NOT CMAKE_CXX_COMPILER_ID
482
505
MATCHES "GNU" )
483
506
if (NOT TARGET ccov-report)
@@ -666,31 +689,45 @@ function(add_code_coverage_all_targets)
666
689
# Capture coverage data
667
690
if (${CMAKE_VERSION} VERSION_LESS "3.17.0" )
668
691
add_custom_target (
669
- ccov-all -capture
692
+ ccov-all -clean
670
693
COMMAND ${CMAKE_COMMAND} -E remove -f ${COVERAGE_INFO}
671
694
COMMAND ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --capture
672
695
--output -file ${COVERAGE_INFO}
673
696
COMMAND ${EXCLUDE_COMMAND}
674
697
DEPENDS ccov-all -processing)
675
698
else ()
676
699
add_custom_target (
677
- ccov-all -capture
700
+ ccov-all -clean
678
701
COMMAND ${CMAKE_COMMAND} -E rm -f ${COVERAGE_INFO}
679
702
COMMAND ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --capture
680
703
--output -file ${COVERAGE_INFO}
681
704
COMMAND ${EXCLUDE_COMMAND}
682
705
DEPENDS ccov-all -processing)
683
706
endif ()
684
707
685
- # Generates HTML output of all targets for perusal
686
708
add_custom_target (
687
- ccov-all
709
+ ccov-all -capture
710
+ COMMAND ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --capture
711
+ --output -file ${COVERAGE_INFO}
712
+ COMMAND ${EXCLUDE_COMMAND}
713
+ DEPENDS )
714
+
715
+ # Only generates HTML output of all targets for perusal
716
+ add_custom_target (
717
+ ccov-all -html
688
718
COMMAND ${GENHTML_PATH} -o ${CMAKE_COVERAGE_OUTPUT_DIRECTORY} /all -merged
689
719
${COVERAGE_INFO} -p ${CMAKE_SOURCE_DIR}
690
720
COMMAND
691
721
${CMAKE_COMMAND} -E echo
692
722
"Open ${CMAKE_COVERAGE_OUTPUT_DIRECTORY} /all-merged/index.html in your browser to view the coverage report."
693
723
DEPENDS ccov-all -capture)
724
+
725
+ # Generates HTML output of all targets for perusal
726
+ add_custom_target (
727
+ ccov-all
728
+ COMMAND
729
+ DEPENDS ccov-preprocessing ccov-all -processing ccov-all -clean ccov-all -html)
730
+
694
731
endif ()
695
732
endif ()
696
733
endfunction ()
0 commit comments