~charlesk/indicator-location/use-properties-cpp

« back to all changes in this revision

Viewing changes to cmake/lcov.cmake

  • Committer: Charles Kerr
  • Date: 2013-08-25 16:08:19 UTC
  • mto: This revision was merged to the branch mainline in revision 40.
  • Revision ID: charles.kerr@canonical.com-20130825160819-oo2xg8ditjfydgv0
add initial framework for test coverage

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
5
 
#
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.
8
 
#
9
 
# Example:
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
18
 
#
19
 
# Distributed under the OSI-approved BSD License (the "License");
20
 
# see accompanying file Copyright.txt for details.
21
 
#
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.)
28
 
 
29
 
set(REMOVE_PATTERN
30
 
    q*.h
31
 
    *.moc
32
 
    moc_*.cpp
33
 
    locale_facets.h
34
 
    new)
35
 
 
36
 
## lcov target
37
 
ADD_CUSTOM_TARGET(lcov)
38
 
ADD_CUSTOM_COMMAND(TARGET lcov
39
 
    COMMAND mkdir -p coverage
40
 
    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
41
 
    )
42
 
ADD_CUSTOM_COMMAND(TARGET lcov
43
 
    COMMAND lcov --directory . --zerocounters
44
 
    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
45
 
    )
46
 
ADD_CUSTOM_COMMAND(TARGET lcov
47
 
    COMMAND make test
48
 
    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
49
 
    )
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}
53
 
    )
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}
57
 
    )
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}
61
 
    )
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}
65
 
    )
66