@@ -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,14 +458,32 @@ 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}
467
476
${COVERAGE_INFO}
468
477
DEPENDS ccov-capture-${target_code_coverage_COVERAGE_TARGET_NAME} )
478
+
479
+ # Generates HTML output of the coverage information for perusal
480
+ add_custom_target (
481
+ ccov-${target_code_coverage_COVERAGE_TARGET_NAME}
482
+ COMMAND
483
+ DEPENDS
484
+ ccov-clean-${target_code_coverage_COVERAGE_TARGET_NAME}
485
+ ccov-run-${target_code_coverage_COVERAGE_TARGET_NAME}
486
+ ccov-html-${target_code_coverage_COVERAGE_TARGET_NAME} )
469
487
endif ()
470
488
471
489
add_custom_command (
@@ -483,6 +501,11 @@ function(target_code_coverage TARGET_NAME)
483
501
endif ()
484
502
add_dependencies (ccov ccov-${target_code_coverage_COVERAGE_TARGET_NAME} )
485
503
504
+ if (NOT TARGET ccov-html )
505
+ add_custom_target (ccov-html )
506
+ endif ()
507
+ add_dependencies (ccov-html ccov-html-${target_code_coverage_COVERAGE_TARGET_NAME} )
508
+
486
509
if (NOT CMAKE_C_COMPILER_ID MATCHES "GNU" AND NOT CMAKE_CXX_COMPILER_ID
487
510
MATCHES "GNU" )
488
511
if (NOT TARGET ccov-report )
@@ -671,29 +694,42 @@ function(add_code_coverage_all_targets)
671
694
# Capture coverage data
672
695
if (${CMAKE_VERSION} VERSION_LESS "3.17.0" )
673
696
add_custom_target (
674
- ccov-all-capture
697
+ ccov-all-clean
675
698
COMMAND ${CMAKE_COMMAND} -E remove -f ${COVERAGE_INFO}
676
699
COMMAND ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --capture
677
700
--output-file ${COVERAGE_INFO}
678
701
COMMAND ${EXCLUDE_COMMAND}
679
702
DEPENDS ccov-all-processing )
680
703
else ()
681
704
add_custom_target (
682
- ccov-all-capture
705
+ ccov-all-clean
683
706
COMMAND ${CMAKE_COMMAND} -E rm -f ${COVERAGE_INFO}
684
707
COMMAND ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --capture
685
708
--output-file ${COVERAGE_INFO}
686
709
COMMAND ${EXCLUDE_COMMAND}
687
710
DEPENDS ccov-all-processing )
688
711
endif ()
689
712
690
- # Generates HTML output of all targets for perusal
691
713
add_custom_target (
692
- ccov-all
714
+ ccov-all-capture
715
+ COMMAND ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --capture
716
+ --output-file ${COVERAGE_INFO}
717
+ COMMAND ${EXCLUDE_COMMAND}
718
+ DEPENDS )
719
+
720
+ # Only generates HTML output of all targets for perusal
721
+ add_custom_target (
722
+ ccov-all-html
693
723
COMMAND ${GENHTML_PATH} -o ${CMAKE_COVERAGE_OUTPUT_DIRECTORY} /all-merged
694
724
${COVERAGE_INFO} -p ${CMAKE_SOURCE_DIR}
695
725
DEPENDS ccov-all-capture )
696
726
727
+ # Generates HTML output of all targets for perusal
728
+ add_custom_target (
729
+ ccov-all
730
+ COMMAND
731
+ DEPENDS ccov-preprocessing ccov-all-processing ccov-all-clean ccov-all-html )
732
+
697
733
endif ()
698
734
699
735
add_custom_command (
0 commit comments