diff options
author | Aleix Pol <aleixpol@kde.org> | 2014-09-11 10:48:06 +0200 |
---|---|---|
committer | Aleix Pol <aleixpol@kde.org> | 2014-09-11 11:03:55 +0200 |
commit | 6ab50fa9e27c4710beb2641fd510dfce08cc2719 (patch) | |
tree | 8c959d5bd290f6b21f27793a09d2f080cb86c7c0 /modules | |
parent | a4ae63d26665c814a452d4949a067a6bab45152e (diff) | |
download | extra-cmake-modules-6ab50fa9e27c4710beb2641fd510dfce08cc2719.tar.gz extra-cmake-modules-6ab50fa9e27c4710beb2641fd510dfce08cc2719.tar.bz2 |
Make code coverage possible in any KDE project
Introduces a BUILD_COVERAGE option from a ECMCoverageOption file so that
projects can easily enable code coverage in their applications.
Furthermore, KDECompilerSettings does include that by default, so all
proper KDE projects have the option by default.
REVIEW: 120118
Diffstat (limited to 'modules')
-rw-r--r-- | modules/ECMCoverageOption.cmake | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/modules/ECMCoverageOption.cmake b/modules/ECMCoverageOption.cmake new file mode 100644 index 00000000..8d435de8 --- /dev/null +++ b/modules/ECMCoverageOption.cmake @@ -0,0 +1,36 @@ +#.rst: +# ECMCoverageOption +# -------------------- +# +# Creates a BUILD_COVERAGE option, so the project can be built with code coverage +# support. +# +# :: +# +# BUILD_COVERAGE +# +# If it's on, the project will be compiled with code coverage support, using +# gcov. Otherwise, it will be built normally. +# +# :: +# +# +#============================================================================= +# Copyright 2014 Aleix Pol Gonzalez <aleixpol@kde.org> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file COPYING-CMAKE-SCRIPTS for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of extra-cmake-modules, substitute the full +# License text for the above reference.) + +option(BUILD_COVERAGE "Build the project with gcov support" OFF) + +if(BUILD_COVERAGE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov") +endif() |