diff options
author | Matt Clarkson <mattyclarkson@gmail.com> | 2015-04-30 14:28:04 +0100 |
---|---|---|
committer | Matt Clarkson <mattyclarkson@gmail.com> | 2015-05-13 09:17:38 +0100 |
commit | 36c1eb6975827e89a906e2dae90e92ee4a0f2bfb (patch) | |
tree | 3bd56feea83445c78b42a1a277802aa7e2e50085 /CMakeLists.txt | |
parent | 3314aa43c215b1543a8d0330af4954f0c29792ae (diff) | |
download | google-benchmark-36c1eb6975827e89a906e2dae90e92ee4a0f2bfb.tar.gz |
Coverage support with LCOV and GCOV
This patch adds a `coverage` target that allows coverage statisitics to be
retrieved for the project. It requires that lcov and gcov is installed and
that the generator is unix makefiles but this can be improved upon in
future releases.
To make it work use the coverage build type:
```
cmake -DCMAKE_BUILD_TYPE=Coverage .
make coverage
```
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f09cea..20aec17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,27 @@ if (BENCHMARK_ENABLE_LTO) endif() endif() +# Coverage build type +set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING + "Flags used by the C++ compiler during coverage builds." + FORCE) +set(CMAKE_EXE_LINKER_FLAGS_COVERAGE + "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING + "Flags used for linking binaries during coverage builds." + FORCE) +set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE + "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING + "Flags used by the shared libraries linker during coverage builds." + FORCE) +mark_as_advanced( + CMAKE_CXX_FLAGS_COVERAGE + CMAKE_EXE_LINKER_FLAGS_COVERAGE + CMAKE_SHARED_LINKER_FLAGS_COVERAGE) +set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING + "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Coverage." + FORCE) +add_cxx_compiler_flag(--coverage COVERAGE) + # C++ feature checks cxx_feature_check(STD_REGEX) cxx_feature_check(GNU_POSIX_REGEX) |