1
# - This module creates a new 'lcov' target which generates
2
# a coverage analysis html output.
3
# LCOV is a graphical front-end for GCC's coverage testing tool gcov. Please see
4
# http://ltp.sourceforge.net/coverage/lcov.php
6
# Usage: you must add an option to your CMakeLists.txt to build your application
7
# with coverage support. Then you need to include this file to the lcov target.
10
# IF(BUILD_WITH_COVERAGE)
11
# SET(CMAKE_C_FLAGS "-g -O0 -Wall -fprofile-arcs -ftest-coverage")
12
# SET(CMAKE_CXX_FLAGS "-g -O0 -Wall -fprofile-arcs -ftest-coverage")
13
# SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage -lgcov")
14
# include(${CMAKE_SOURCE_DIR}/cmake/lcov.cmake)
15
# ENDIF(BUILD_WITH_COVERAGE)
16
#=============================================================================
17
# Copyright 2010 ascolab GmbH
19
# Distributed under the OSI-approved BSD License (the "License");
20
# see accompanying file Copyright.txt for details.
22
# This software is distributed WITHOUT ANY WARRANTY; without even the
23
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
24
# See the License for more information.
25
#=============================================================================
26
# (To distributed this file outside of CMake, substitute the full
27
# License text for the above reference.)
37
ADD_CUSTOM_TARGET(lcov)
38
ADD_CUSTOM_COMMAND(TARGET lcov
39
COMMAND mkdir -p coverage
40
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
42
ADD_CUSTOM_COMMAND(TARGET lcov
43
COMMAND lcov --directory . --zerocounters
44
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
46
ADD_CUSTOM_COMMAND(TARGET lcov
48
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
50
ADD_CUSTOM_COMMAND(TARGET lcov
51
COMMAND lcov --directory . --capture --output-file ./coverage/stap_all.info --no-checksum --compat-libtool
52
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
54
ADD_CUSTOM_COMMAND(TARGET lcov
55
COMMAND lcov --directory . -r ./coverage/stap_all.info ${REMOVE_PATTERN} --output-file ./coverage/stap.info
56
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
58
ADD_CUSTOM_COMMAND(TARGET lcov
59
COMMAND genhtml -o ./coverage --title "Code Coverage" --legend --show-details --demangle-cpp ./coverage/stap.info
60
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
62
ADD_CUSTOM_COMMAND(TARGET lcov
63
COMMAND echo "Open ${CMAKE_BINARY_DIR}/coverage/index.html to view the coverage analysis results."
64
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}