Skip to content

Instantly share code, notes, and snippets.

@hsdk123
Created June 18, 2023 20:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hsdk123/bbfdee1a7114d54426a0d56e6bf6d857 to your computer and use it in GitHub Desktop.
Save hsdk123/bbfdee1a7114d54426a0d56e6bf6d857 to your computer and use it in GitHub Desktop.
# 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