Created
October 17, 2019 02:30
-
-
Save gengjiawen/8ca54e38fff384b9ea229dbb087c9d5f to your computer and use it in GitHub Desktop.
CMake
This file contains hidden or 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
# Code Coverage Configuration | |
add_library(coverage_config INTERFACE) | |
option(CODE_COVERAGE "Enable coverage reporting" ON) | |
if(CODE_COVERAGE AND CMAKE_C_COMPILER_ID MATCHES "AppleClang|GNU|Clang") | |
# Add required flags (GCC & LLVM/Clang) | |
target_compile_options(coverage_config INTERFACE | |
-O0 # no optimization | |
-g # generate debug info | |
--coverage # sets all required flags | |
) | |
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) | |
target_link_options(coverage_config INTERFACE --coverage) | |
else() | |
target_link_libraries(coverage_config INTERFACE --coverage) | |
endif() | |
endif() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment