Commit 589a0984 authored by Jenkins's avatar Jenkins

New upstream version 0.2.20161109

parent 61b9eef3
project(telepathy-ofono)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
set(TELEPATHY_OFONO telepathy-ofono)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Standard install paths
include(GNUInstallDirs)
# Check for include files
include(CheckIncludeFileCXX)
include(EnableCoverageReport)
#####################################################################
# Enable code coverage calculation with gcov/gcovr/lcov
# Usage:
# * Switch build type to coverage (use ccmake or cmake-gui)
# * Invoke make, make test, make coverage
# * Find html report in subdir coveragereport
# * Find xml report feasible for jenkins in coverage.xml
#####################################################################
IF(CMAKE_BUILD_TYPE MATCHES [cC][oO][vV][eE][rR][aA][gG][eE])
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftest-coverage -fprofile-arcs" )
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftest-coverage -fprofile-arcs" )
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -coverage" )
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -coverage" )
ENABLE_COVERAGE_REPORT(TARGETS ${TELEPATHY_OFONO})
ENDIF(CMAKE_BUILD_TYPE MATCHES [cC][oO][vV][eE][rR][aA][gG][eE])
find_package(LibPhoneNumber REQUIRED)
find_package(Qt5Core)
find_package(Qt5DBus)
find_package(Qt5Network)
add_definitions(-DQT_NO_KEYWORDS)
find_package(PkgConfig REQUIRED)
pkg_check_modules(TP_QT5 REQUIRED TelepathyQt5)
pkg_check_modules(SQLITE3 REQUIRED sqlite3)
pkg_check_modules(MC_PLUGINS REQUIRED mission-control-plugins)
pkg_check_modules(PULSEAUDIO libpulse)
if (PULSEAUDIO_FOUND)
add_definitions(-DUSE_PULSEAUDIO)
set(USE_PULSEAUDIO ON)
include_directories(${PULSEAUDIO_INCLUDE_DIRS})
endif (PULSEAUDIO_FOUND)
find_program(DBUS_RUNNER dbus-test-runner)
if(NOT DAEMON_DIR)
set(DAEMON_DIR lib/telepathy)
endif(NOT DAEMON_DIR)
set(CMAKE_AUTOMOC ON)
include_directories(${TP_QT5_INCLUDE_DIRS})
include_directories(${Qt5Core_INCLUDE_DIRS})
include_directories(${Qt5DBus_INCLUDE_DIRS})
include_directories(${SQLITE3_INCLUDE_DIRS})
include_directories(${LibPhoneNumber_INCLUDE_DIRS})
include_directories(/usr/include/telepathy-qt5/)
include_directories(/usr/include/ofono-qt/)
find_library(TELEPATHY_QT5_LIBRARIES telepathy-qt5)
find_library(TELEPATHY_QT5_SERVICE_LIBRARIES telepathy-qt5-service)
find_library(OFONO_QT_LIBRARIES ofono-qt)
qt5_add_resources(telepathyfono_RES sqlitetelepathyofono.qrc countrycodes.qrc)
# update the .qrc file automatically when there are new schema files
file(GLOB QRC_RESOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/schema/*.sql ${CMAKE_CURRENT_SOURCE_DIR}/schema/*.info)
set(QRC_FILE ${CMAKE_CURRENT_SOURCE_DIR}/sqlitetelepathyofono.qrc)
add_custom_command(
OUTPUT ${QRC_FILE}
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/update_qrc.sh ${QRC_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${QRC_RESOURCE_FILES}
)
add_custom_target(qrc_update DEPENDS ${QRC_FILE} schema_update)
set(TELEPATHY_OFONO_SRC
main.cpp
protocol.cpp
connection.cpp
ofonotextchannel.cpp
ofonocallchannel.cpp
ofonoconferencecallchannel.cpp
emergencymodeiface.cpp
voicemailiface.cpp
audiooutputsiface.cpp
mmsdmanager.cpp
mmsdservice.cpp
mmsdmessage.cpp
mmsgroupcache.cpp
pendingmessagesmanager.cpp
phoneutils.cpp
powerdaudiomodemediator.cpp
powerddbus.cpp
sqlitedatabase.cpp
ussdiface.cpp
${telepathyfono_RES})
if(USE_PULSEAUDIO)
add_executable(${TELEPATHY_OFONO} qpulseaudioengine.cpp ${TELEPATHY_OFONO_SRC})
else(USE_PULSEAUDIO)
add_executable(${TELEPATHY_OFONO} ${TELEPATHY_OFONO_SRC})
endif(USE_PULSEAUDIO)
qt5_use_modules(${TELEPATHY_OFONO} Core DBus Sql)
add_dependencies(${TELEPATHY_OFONO} schema_update qrc_update)
enable_testing()
target_link_libraries(${TELEPATHY_OFONO} ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES} ${WAUDIO_LIBRARIES} -ltelepathy-qt5 ${TELEPATHY_QT5_SERVICE_LIBRARIES} ${Qt5Network_LIBRARIES} ${OFONO_QT_LIBRARIES} ${PULSEAUDIO_LIBRARIES} ${SQLITE3_LIBRARIES} ${LibPhoneNumber_LIBRARIES})
install(TARGETS ${TELEPATHY_OFONO} DESTINATION ${DAEMON_DIR})
configure_file(ofono.service.in org.freedesktop.Telepathy.ConnectionManager.ofono.service)
install (FILES ofono.manager DESTINATION share/telepathy/managers)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Telepathy.ConnectionManager.ofono.service DESTINATION share/dbus-1/services)
add_subdirectory(schema)
add_subdirectory(tests)
add_subdirectory(mc-plugin)
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
/**
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Tiago Salem Herrmann <tiago.herrmann@canonical.com>
*/
#include <QDebug>
#include <TelepathyQt/Constants>
#include <TelepathyQt/DBusObject>
#include "audiooutputsiface.h"
QDBusArgument &operator<<(QDBusArgument &argument, const AudioOutput &output)
{
argument.beginStructure();
argument << output.id << output.type << output.name;
argument.endStructure();
return argument;
}
const QDBusArgument &operator>>(const QDBusArgument &argument, AudioOutput &output)
{
argument.beginStructure();
argument >> output.id >> output.type >> output.name;
argument.endStructure();
return argument;
}
// Chan.I.AudioOutputs
BaseChannelAudioOutputsInterface::Adaptee::Adaptee(BaseChannelAudioOutputsInterface *interface)
: QObject(interface),
mInterface(interface)
{
qDBusRegisterMetaType<AudioOutput>();
qDBusRegisterMetaType<AudioOutputList>();
}
struct TP_QT_NO_EXPORT BaseChannelAudioOutputsInterface::Private {
Private(BaseChannelAudioOutputsInterface *parent)
: adaptee(new BaseChannelAudioOutputsInterface::Adaptee(parent)) {
}
AudioOutputList audioOutputs;
QString activeAudioOutput;
SetActiveAudioOutputCallback setActiveAudioOutputCB;
BaseChannelAudioOutputsInterface::Adaptee *adaptee;
};
BaseChannelAudioOutputsInterface::Adaptee::~Adaptee()
{
}
void BaseChannelAudioOutputsInterface::Adaptee::setActiveAudioOutput(const QString &id, const ChannelInterfaceAudioOutputsAdaptor::SetActiveAudioOutputContextPtr &context)
{
if (!mInterface->mPriv->setActiveAudioOutputCB.isValid()) {
context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
return;
}
Tp::DBusError error;
mInterface->mPriv->setActiveAudioOutputCB(id, &error);
if (error.isValid()) {
context->setFinishedWithError(error.name(), error.message());
return;
}
context->setFinished();
}
BaseChannelAudioOutputsInterface::BaseChannelAudioOutputsInterface()
: AbstractChannelInterface(TP_QT_IFACE_CHANNEL_AUDIOOUTPUTS),
mPriv(new Private(this))
{
}
BaseChannelAudioOutputsInterface::~BaseChannelAudioOutputsInterface()
{
delete mPriv;
}
QString BaseChannelAudioOutputsInterface::activeAudioOutput() const
{
return mPriv->activeAudioOutput;
}
AudioOutputList BaseChannelAudioOutputsInterface::audioOutputs() const
{
return mPriv->audioOutputs;
}
void BaseChannelAudioOutputsInterface::setSetActiveAudioOutputCallback(const SetActiveAudioOutputCallback &cb)
{
mPriv->setActiveAudioOutputCB = cb;
}
void BaseChannelAudioOutputsInterface::setActiveAudioOutput(const QString &id)
{
mPriv->activeAudioOutput = id;
Q_EMIT mPriv->adaptee->activeAudioOutputChanged(id);
}
void BaseChannelAudioOutputsInterface::setAudioOutputs(const AudioOutputList &outputs)
{
mPriv->audioOutputs = outputs;
Q_EMIT mPriv->adaptee->audioOutputsChanged(outputs);
}
QVariantMap BaseChannelAudioOutputsInterface::immutableProperties() const
{
QVariantMap map;
return map;
}
void BaseChannelAudioOutputsInterface::createAdaptor()
{
(void) new ChannelInterfaceAudioOutputsAdaptor(dbusObject()->dbusConnection(),
mPriv->adaptee, dbusObject());
}
ChannelInterfaceAudioOutputsAdaptor::ChannelInterfaceAudioOutputsAdaptor(const QDBusConnection& bus, QObject* adaptee, QObject* parent)
: Tp::AbstractAdaptor(bus, adaptee, parent)
{
connect(adaptee, SIGNAL(audioOutputsChanged(AudioOutputList)), SIGNAL(AudioOutputsChanged(AudioOutputList)));
connect(adaptee, SIGNAL(activeAudioOutputChanged(QString)), SIGNAL(ActiveAudioOutputChanged(QString)));
}
ChannelInterfaceAudioOutputsAdaptor::~ChannelInterfaceAudioOutputsAdaptor()
{
}
void ChannelInterfaceAudioOutputsAdaptor::SetActiveAudioOutput(const QString &id, const QDBusMessage& dbusMessage)
{
if (!adaptee()->metaObject()->indexOfMethod("setActiveAudioOutput(QString,ChannelInterfaceAudioOutputsAdaptor::SetActiveAudioOutputContextPtr)") == -1) {
dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented")));
return;
}
SetActiveAudioOutputContextPtr ctx = SetActiveAudioOutputContextPtr(
new Tp::MethodInvocationContext< >(dbusConnection(), dbusMessage));
QMetaObject::invokeMethod(adaptee(), "setActiveAudioOutput",
Q_ARG(QString, id),
Q_ARG(ChannelInterfaceAudioOutputsAdaptor::SetActiveAudioOutputContextPtr, ctx));
return;
}
QString ChannelInterfaceAudioOutputsAdaptor::ActiveAudioOutput() const
{
return qvariant_cast< QString >(adaptee()->property("activeAudioOutput"));
}
AudioOutputList ChannelInterfaceAudioOutputsAdaptor::AudioOutputs() const
{
return qvariant_cast< AudioOutputList >(adaptee()->property("audioOutputs"));
}
/**
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Tiago Salem Herrmann <tiago.herrmann@canonical.com>
*/
#ifndef OFONOAUDIOOUTPUTSIFACE_H
#define OFONOAUDIOOUTPUTSIFACE_H
// telepathy-qt
#include <TelepathyQt/Constants>
#include <TelepathyQt/BaseChannel>
#include <TelepathyQt/AbstractAdaptor>
#include <TelepathyQt/DBusError>
#include <TelepathyQt/Callbacks>
#include "dbustypes.h"
#define TP_QT_IFACE_CHANNEL_AUDIOOUTPUTS "com.canonical.Telephony.AudioOutputs"
class BaseChannelAudioOutputsInterface;
typedef Tp::SharedPtr<BaseChannelAudioOutputsInterface> BaseChannelAudioOutputsInterfacePtr;
class TP_QT_EXPORT BaseChannelAudioOutputsInterface : public Tp::AbstractChannelInterface
{
Q_OBJECT
Q_DISABLE_COPY(BaseChannelAudioOutputsInterface)
public:
static BaseChannelAudioOutputsInterfacePtr create() {
return BaseChannelAudioOutputsInterfacePtr(new BaseChannelAudioOutputsInterface());
}
template<typename BaseChannelAudioOutputsInterfaceSubclass>
static Tp::SharedPtr<BaseChannelAudioOutputsInterfaceSubclass> create() {
return Tp::SharedPtr<BaseChannelAudioOutputsInterfaceSubclass>(
new BaseChannelAudioOutputsInterfaceSubclass());
}
QVariantMap immutableProperties() const;
virtual ~BaseChannelAudioOutputsInterface();
AudioOutputList audioOutputs() const;
QString activeAudioOutput() const;
typedef Tp::Callback2<void, QString, Tp::DBusError*> SetActiveAudioOutputCallback;
void setSetActiveAudioOutputCallback(const SetActiveAudioOutputCallback &cb);
public Q_SLOTS:
void setActiveAudioOutput(const QString &id);
void setAudioOutputs(const AudioOutputList &outputs);
protected:
BaseChannelAudioOutputsInterface();
private:
void createAdaptor();
class Adaptee;
friend class Adaptee;
struct Private;
friend struct Private;
Private *mPriv;
};
class TP_QT_EXPORT ChannelInterfaceAudioOutputsAdaptor : public Tp::AbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", TP_QT_IFACE_CHANNEL_AUDIOOUTPUTS)
Q_CLASSINFO("D-Bus Introspection", ""
" <interface name=\"com.canonical.Telephony.AudioOutputs\">\n"
" <property access=\"read\" type=\"s\" name=\"ActiveAudioOutput\"/>\n"
" <property access=\"read\" type=\"a(sss)\" name=\"AudioOutputs\"/>\n"
" <method name=\"SetActiveAudioOutput\">\n"
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
" </method>\n"
" <signal name=\"AudioOutputsChanged\">\n"
" <arg type=\"a(sss)\" name=\"outputs\"/>\n"
" </signal>\n"
" <signal name=\"ActiveAudioOutputChanged\">\n"
" <arg type=\"s\" name=\"id\"/>\n"
" </signal>\n"
" </interface>\n"
"")
Q_PROPERTY(AudioOutputList AudioOutputs READ AudioOutputs)
Q_PROPERTY(QString ActiveAudioOutput READ ActiveAudioOutput)
public:
ChannelInterfaceAudioOutputsAdaptor(const QDBusConnection& dbusConnection, QObject* adaptee, QObject* parent);
virtual ~ChannelInterfaceAudioOutputsAdaptor();
typedef Tp::MethodInvocationContextPtr< > SetActiveAudioOutputContextPtr;
public: // PROPERTIES
QString ActiveAudioOutput() const;
AudioOutputList AudioOutputs() const;
public Q_SLOTS: // METHODS
void SetActiveAudioOutput(const QString &id, const QDBusMessage& dbusMessage);
Q_SIGNALS: // SIGNALS
void AudioOutputsChanged(const AudioOutputList &outputs);
void ActiveAudioOutputChanged(const QString &id);
};
class TP_QT_NO_EXPORT BaseChannelAudioOutputsInterface::Adaptee : public QObject
{
Q_OBJECT
Q_PROPERTY(AudioOutputList audioOutputs READ audioOutputs)
Q_PROPERTY(QString activeAudioOutput READ activeAudioOutput)
public:
Adaptee(BaseChannelAudioOutputsInterface *interface);
~Adaptee();
AudioOutputList audioOutputs() const
{
return mInterface->audioOutputs();
}
QString activeAudioOutput() const
{
return mInterface->activeAudioOutput();
}
private Q_SLOTS:
void setActiveAudioOutput(const QString &id, const ChannelInterfaceAudioOutputsAdaptor::SetActiveAudioOutputContextPtr &context);
Q_SIGNALS:
void activeAudioOutputChanged(const QString &id);
void audioOutputsChanged(const AudioOutputList &outputs);
public:
BaseChannelAudioOutputsInterface *mInterface;
};
#endif
# - Creates a special coverage build type and target on GCC.
#
# Defines a function ENABLE_COVERAGE_REPORT which generates the coverage target
# for selected targets. Optional arguments to this function are used to filter
# unwanted results using globbing expressions. Moreover targets with tests for
# the source code can be specified to trigger regenerating the report if the
# test has changed
#
# ENABLE_COVERAGE_REPORT(TARGETS target... [FILTER filter...] [TESTS test targets...])
#
# To generate a coverage report first build the project with
# CMAKE_BUILD_TYPE=coverage, then call make test and afterwards make coverage.
#
# The coverage report is based on gcov. Depending on the availability of lcov
# a HTML report will be generated and/or an XML report of gcovr is found.
# The generated coverage target executes all found solutions. Special targets
# exist to create e.g. only the xml report: coverage-xml.
#
# Copyright (C) 2010 by Johannes Wienke <jwienke at techfak dot uni-bielefeld dot de>
#
# This program is free software; you can redistribute it
# and/or modify it under the terms of the GNU General
# Public License as published by the Free Software Foundation;
# either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
INCLUDE(ParseArguments)
FIND_PACKAGE(Lcov)
FIND_PACKAGE(gcovr)
FUNCTION(ENABLE_COVERAGE_REPORT)
# argument parsing
PARSE_ARGUMENTS(ARG "FILTER;TARGETS;TESTS" "" ${ARGN})
SET(COVERAGE_RAW_FILE "${CMAKE_BINARY_DIR}/coverage.raw.info")
SET(COVERAGE_FILTERED_FILE "${CMAKE_BINARY_DIR}/coverage.info")
SET(COVERAGE_REPORT_DIR "${CMAKE_BINARY_DIR}/coveragereport")
SET(COVERAGE_XML_FILE "${CMAKE_BINARY_DIR}/coverage.xml")
SET(COVERAGE_XML_COMMAND_FILE "${CMAKE_BINARY_DIR}/coverage-xml.cmake")
# decide if there is any tool to create coverage data
SET(TOOL_FOUND FALSE)
IF(LCOV_FOUND OR GCOVR_FOUND)
SET(TOOL_FOUND TRUE)
ENDIF()
IF(NOT TOOL_FOUND)
MESSAGE(STATUS "Cannot enable coverage targets because neither lcov nor gcovr are found.")
ENDIF()
STRING(TOLOWER "${CMAKE_BUILD_TYPE}" COVERAGE_BUILD_TYPE)
IF(CMAKE_COMPILER_IS_GNUCXX AND TOOL_FOUND AND "${COVERAGE_BUILD_TYPE}" MATCHES "coverage")
MESSAGE(STATUS "Coverage support enabled for targets: ${ARG_TARGETS}")
# create coverage build type
SET(CMAKE_CXX_FLAGS_COVERAGE ${CMAKE_CXX_FLAGS_DEBUG} PARENT_SCOPE)
SET(CMAKE_C_FLAGS_COVERAGE ${CMAKE_C_FLAGS_DEBUG} PARENT_SCOPE)
SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} coverage PARENT_SCOPE)
# instrument targets
SET_TARGET_PROPERTIES(${ARG_TARGETS} PROPERTIES COMPILE_FLAGS --coverage
LINK_FLAGS --coverage)
# html report
IF (LCOV_FOUND)
MESSAGE(STATUS "Enabling HTML coverage report")
# set up coverage target
ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_RAW_FILE}