@@ -159,21 +159,7 @@ if(CODE_COVERAGE AND NOT CODE_COVERAGE_ADDED)
159159 endif ()
160160
161161 # Targets
162- if (${CMAKE_VERSION} VERSION_LESS "3.17.0" )
163- add_custom_target (
164- ccov-clean
165- COMMAND
166- ${CMAKE_COMMAND} -E remove -f #
167- ${CMAKE_COVERAGE_DATA_DIRECTORY} /objects/*
168- ${CMAKE_COVERAGE_DATA_DIRECTORY} /profraw/*)
169- else ()
170- add_custom_target (
171- ccov-clean
172- COMMAND
173- ${CMAKE_COMMAND} -E rm -f #
174- ${CMAKE_COVERAGE_DATA_DIRECTORY} /objects/*
175- ${CMAKE_COVERAGE_DATA_DIRECTORY} /profraw/*)
176- endif ()
162+ add_custom_target (ccov-clean)
177163
178164 # Used to get the shared object file list before doing the main all-
179165 # processing
@@ -377,6 +363,20 @@ function(target_code_coverage TARGET_NAME)
377363 endif ()
378364 endforeach ()
379365
366+ if (${CMAKE_VERSION} VERSION_LESS "3.17.0" )
367+ add_custom_target (
368+ ccov-clean-${target_code_coverage_COVERAGE_TARGET_NAME}
369+ COMMAND ${CMAKE_COMMAND} -E remove -f
370+ ${target_code_coverage_COVERAGE_TARGET_NAME} .profraw)
371+ else ()
372+ add_custom_target (
373+ ccov-clean-${target_code_coverage_COVERAGE_TARGET_NAME}
374+ COMMAND ${CMAKE_COMMAND} -E rm -f
375+ ${target_code_coverage_COVERAGE_TARGET_NAME} .profraw)
376+ endif ()
377+ add_dependencies (ccov-clean
378+ ccov-clean-${target_code_coverage_COVERAGE_TARGET_NAME} )
379+
380380 # Run the executable, generating raw profile data Make the run data
381381 # available for further processing. Separated to allow Windows to run this
382382 # target serially.
@@ -500,6 +500,8 @@ function(target_code_coverage TARGET_NAME)
500500 COMMAND ${CMAKE_COMMAND} -E rm -f ${COVERAGE_INFO}
501501 COMMAND ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --zerocounters)
502502 endif ()
503+ add_dependencies (ccov-clean
504+ ccov-clean-${target_code_coverage_COVERAGE_TARGET_NAME} )
503505
504506 # Run the executable, generating coverage information
505507 add_custom_command (
@@ -765,15 +767,14 @@ function(add_code_coverage_all_targets)
765767 add_custom_target (
766768 ccov-all -clean
767769 COMMAND ${CMAKE_COMMAND} -E remove -f ${COVERAGE_INFO}
768- COMMAND ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --zerocounters
769- DEPENDS ccov-all -processing)
770+ COMMAND ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --zerocounters)
770771 else ()
771772 add_custom_target (
772773 ccov-all -clean
773774 COMMAND ${CMAKE_COMMAND} -E rm -f ${COVERAGE_INFO}
774- COMMAND ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --zerocounters
775- DEPENDS ccov-all -processing)
775+ COMMAND ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --zerocounters)
776776 endif ()
777+ add_dependencies (ccov-clean ccov-all -clean)
777778
778779 add_custom_command (
779780 OUTPUT ${COVERAGE_INFO}
0 commit comments