Created
June 18, 2023 20:30
-
-
Save hsdk123/bbfdee1a7114d54426a0d56e6bf6d857 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# References: | |
# https://marco-c.github.io/2018/01/09/code-coverage-with-clang-on-windows.html | |
# https://stackoverflow.com/a/10611875 | |
if (SECORE_WITH_COVERAGE) | |
find_library(CLANG_RT_PROFILE_LIBRARY | |
NAMES clang_rt.profile-x86_64 | |
REQUIRED | |
) | |
message(STATUS "CLANG_RT_PROFILE_LIBRARY: ${CLANG_RT_PROFILE_LIBRARY}") | |
endif() | |
#--------------------------------------------------------------------- | |
# Target Functions | |
# Usage: Target to measure coverage | |
function(target_measure_coverage target_name) | |
if (NOT SECORE_WITH_COVERAGE) | |
return() | |
endif() | |
target_compile_options(${target_name} PRIVATE "--coverage") | |
endfunction(target_measure_coverage) | |
# Usage: Executable to log coverage (ex. unit test executable) | |
function(target_coverage_executable target_name) | |
if (NOT SECORE_WITH_COVERAGE) | |
return() | |
endif() | |
target_link_libraries(${target_name} PRIVATE ${CLANG_RT_PROFILE_LIBRARY}) | |
endfunction(target_coverage_executable) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment