2
# Copyright (C) 2013 Canonical Ltd
4
# This program is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License version 3 as
6
# published by the Free Software Foundation.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
# Authored by: Michi Henning <michi.henning@canonical.com>
19
-------------------------------------------------------------------------------------
20
NOTE: Before making changes to the code, please read the README file in its entirety!
21
-------------------------------------------------------------------------------------
27
See debian/control for the list of packages required to build and test the code.
39
By default, the code is built in release mode. To build a debug version, use
43
$ cmake -DCMAKE_BUILD_TYPE=debug ..
46
For a release version, use -DCMAKE_BUILD_TYPE=release
48
To build with the flags for coverage testing enabled:
52
$ cmake -DCMAKE_BUILD_TYPE=coverage
55
If you do not have libunity-api installed, build it from source and install it somewhere, then set
56
PKG_CONFIG_PATH to include the lib/<arch>/pkgconfig directory.
64
Note that "make test" alone is dangerous because it does not rebuild
65
any tests if either the library or the test files themselves need
66
rebuilding. It's not possible to fix this with cmake because cmake cannot
67
add build dependencies to built-in targets. To make sure that everything
68
is up-to-date, run "make" before running "make test"!
70
To run the tests with valgrind:
74
To get coverage output:
79
This drops the coverage tests into the coveragereport directory. (The coverage target is available
80
only if the code was built with -DCMAKE_BUILD_TYPE=coverage.)
82
Note that, with gcc 4.7.2 and cmake 2.8.10, you may get a bunch of
83
warnings. To fix this, you can build cmake 2.8.10 with the following patch:
85
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=61ace1df2616e472d056b302e4269cbf112fb020#patch1
87
Unfortunately, it is not possibly to get 100% coverage for some files,
88
mainly due to gcc's generation of two destructors for dynamic and non-
89
dynamic instances. For abstract base classes and for classes that
90
prevent stack and static allocation, this causes one of the destructors
91
to be reported as uncovered.
93
There are also issues with some functions in header files that are
94
incorrectly reported as uncovered due to inlining, as well as
95
the impossibility of covering defensive assert(false) statements,
96
such as an assert in the default branch of a switch, where the
97
switch is meant to handle all possible cases explicitly.
99
If you run a binary and get lots of warnings about a "merge mismatch for summaries",
100
this is caused by having made changes to the source that add or remove code
101
that was previously run, so the new coverage output cannot sensibly be merged
102
into the old coverage output. You can get rid of this problem by running
104
$ make clean-coverage
106
This deletes all the .gcda files, allowing the merge to succeed again.
108
If lcov complains about unrecognized lines involving '=====',
109
you can patch geninfo and gcovr as explained here:
111
https://bugs.launchpad.net/gcovr/+bug/1086695/comments/2
113
To run the static C++ checks:
121
To get files that form part of an installation, run a "make install"
122
in the build directory. By default, this installs them in the "install"
123
subdirectory of the build directory. If you want to install into a
124
different directory, use
126
$ cmake -DCMAKE_INSTALL_PREFIX=/usr/local # Or wherever...