From fd5a9b83746055fb050022913202bbba650f21df Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Mon, 25 Dec 2023 17:43:31 +0700 Subject: [PATCH] build: remove GCDA files before linking test targets --- CMakeLists.txt | 9 +++++++++ components/format/CMakeLists.txt | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 297eb90..5e1e2a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,15 @@ if(NOT_SUBPROJECT) if(NOT MSVC) target_compile_options(errors_test PRIVATE --coverage -O0 -fno-exceptions) target_link_options(errors_test PRIVATE --coverage) + + get_target_property(errors_test_SOURCES errors_test SOURCES) + foreach(SOURCE ${errors_test_SOURCES}) + set(GCDA ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/errors_test.dir/${SOURCE}.gcda) + add_custom_command( + TARGET errors_test PRE_LINK + COMMAND ${CMAKE_COMMAND} -E rm -f ${GCDA} + ) + endforeach() endif() catch_discover_tests(errors_test) diff --git a/components/format/CMakeLists.txt b/components/format/CMakeLists.txt index 70a1821..f319250 100644 --- a/components/format/CMakeLists.txt +++ b/components/format/CMakeLists.txt @@ -20,6 +20,15 @@ if(NOT_SUBPROJECT) if(NOT MSVC) target_compile_options(errors_format_test PRIVATE --coverage -O0 -fno-exceptions) target_link_options(errors_format_test PRIVATE --coverage) + + get_target_property(errors_format_test_SOURCES errors_format_test SOURCES) + foreach(SOURCE ${errors_format_test_SOURCES}) + set(GCDA ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/errors_format_test.dir/${SOURCE}.gcda) + add_custom_command( + TARGET errors_format_test PRE_LINK + COMMAND ${CMAKE_COMMAND} -E rm -f ${GCDA} + ) + endforeach() endif() catch_discover_tests(errors_format_test)