summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 38a1328009617802836c19d259f7d467a0891fe5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
project(TelepathyQt4Yell)

cmake_minimum_required(VERSION 2.6)

# CMake policies are used for backwards compatibilty. Setting a policy to a behavior lets newer
# CMake versions where some behaviors changed behave in a way or another. In our specific case,
# From CMake's documentation:
#
# In CMake 2.6.2 and below, CMake Policy settings in scripts loaded by
# the include() and find_package() commands would affect the includer.
# Explicit invocations of cmake_policy(PUSH) and cmake_policy(POP) were
# required to isolate policy changes and protect the includer.  While
# some scripts intend to affect the policies of their includer, most do
# not.  In CMake 2.6.3 and above, include() and find_package() by
# default PUSH and POP an entry on the policy stack around an included
# script, but provide a NO_POLICY_SCOPE option to disable it.  This
# policy determines whether or not to imply NO_POLICY_SCOPE for
# compatibility.  The OLD behavior for this policy is to imply
# NO_POLICY_SCOPE for include() and find_package() commands.  The NEW
# behavior for this policy is to allow the commands to do their default
# cmake_policy PUSH and POP.
#
# This policy was introduced in CMake version 2.6.3.  CMake version
# 2.8.2 warns when the policy is not set and uses OLD behavior.  Use the
# cmake_policy command to set it to OLD or NEW explicitly.
#
# Whenever our cmake_minimum_required version bumps up to 2.7 or 2.6.3, this policy setting can
# hence be removed.
if(POLICY CMP0011)
    cmake_policy(SET CMP0011 NEW)
endif(POLICY CMP0011)

# Making releases:
#   set the new version number:
#     odd minor -> development series
#     even minor -> stable series
#     increment micro for each release within a series
#   set nano_version to 0
#   make the release, tag it
#   set nano_version to 1
set(TP_QT4_YELL_MAJOR_VERSION 0)
set(TP_QT4_YELL_MINOR_VERSION 1)
set(TP_QT4_YELL_MICRO_VERSION 6)
set(TP_QT4_YELL_NANO_VERSION  1)

# This value contains the library's SOVERSION. This value is to be increased everytime an API/ABI break
# occurs, and will be used for the SOVERSION of the generated shared libraries.
set(TP_QT4_YELL_ABI_VERSION 0)
# This variable is used for the library's long version. It is generated dynamically, so don't change its
# value! Change TP_QT4_YELL_ABI_VERSION and TP_QT4_YELL_*_VERSION instead.
if (${TP_QT4_YELL_NANO_VERSION} EQUAL 0)
    set(TP_QT4_YELL_LIBRARY_VERSION ${TP_QT4_YELL_ABI_VERSION}.${TP_QT4_YELL_MAJOR_VERSION}.${TP_QT4_YELL_MINOR_VERSION}.${TP_QT4_YELL_MICRO_VERSION})
else (${TP_QT4_YELL_NANO_VERSION} EQUAL 0)
    set(TP_QT4_YELL_LIBRARY_VERSION ${TP_QT4_YELL_ABI_VERSION}.${TP_QT4_YELL_MAJOR_VERSION}.${TP_QT4_YELL_MINOR_VERSION}.${TP_QT4_YELL_MICRO_VERSION}.${TP_QT4_NANO_VERSION})
endif (${TP_QT4_YELL_NANO_VERSION} EQUAL 0)

set(PACKAGE_NAME telepathy-qt4-yell)

if (${TP_QT4_YELL_NANO_VERSION} EQUAL 0)
    set(PACKAGE_VERSION ${TP_QT4_YELL_MAJOR_VERSION}.${TP_QT4_YELL_MINOR_VERSION}.${TP_QT4_YELL_MICRO_VERSION})
else (${TP_QT4_YELL_NANO_VERSION} EQUAL 0)
    set(PACKAGE_VERSION ${TP_QT4_YELL_MAJOR_VERSION}.${TP_QT4_YELL_MINOR_VERSION}.${TP_QT4_YELL_MICRO_VERSION}.${TP_QT4_YELL_NANO_VERSION})
endif (${TP_QT4_YELL_NANO_VERSION} EQUAL 0)

# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is
# checked
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")

# Default build type is RelWithDebInfo for release versions and Debug for developement
# versions
if(NOT CMAKE_BUILD_TYPE)
    if(TP_QT4_YELL_NANO_VERSION EQUAL 0)
        set(CMAKE_BUILD_TYPE RelWithDebInfo)
    else(TP_QT4_YELL_NANO_VERSION EQUAL 0)
        set(CMAKE_BUILD_TYPE Debug)
    endif(TP_QT4_YELL_NANO_VERSION EQUAL 0)
endif(NOT CMAKE_BUILD_TYPE)

# This file contains all the needed initialization macros
include(TelepathyDefaults)

# TelepathyQt4Yell specific defines needed to trigger deprecation warnings
if (CXX_DEPRECATED_DECLARATIONS)
    set(DEPRECATED_DECLARATIONS_FLAGS "${DEPRECATED_DECLARATIONS_FLAGS} -DTELEPATHY_QT4_YELL_DEPRECATED_WARNINGS")
endif (CXX_DEPRECATED_DECLARATIONS)

# This file contains all macros used in the buildsystem
include(TpQt4Macros)

include(Doxygen)
include(MacroLogFeature)

# external dependencies

# Required dependencies
# Find qt4 version >= 4.5
set (QT_MIN_VERSION "4.5.0")
find_package(Qt4 REQUIRED)
set (TELEPATHYQT4_MIN_VERSION "0.5.14")
find_package(TelepathyQt4 ${TELEPATHYQT4_MIN_VERSION} REQUIRED)

include_directories(${CMAKE_SOURCE_DIR}
                    ${CMAKE_BINARY_DIR}
                    ${QT_INCLUDES}
                    ${TELEPATHY_QT4_INCLUDE_DIR})

add_definitions(-DQT_NO_CAST_FROM_ASCII)

set(ENABLE_DEBUG_OUTPUT ON CACHE BOOL "If activated, compiles support for printing debug output to stderr")
if (ENABLE_DEBUG_OUTPUT)
    add_definitions(-DENABLE_DEBUG)
endif (ENABLE_DEBUG_OUTPUT)

# Find python version >= 2.5
find_package(PythonLibrary REQUIRED)
set(REQUIRED_PY 2.5)
if(${PYTHON_SHORT_VERSION} VERSION_GREATER ${REQUIRED_PY} OR ${PYTHON_SHORT_VERSION} VERSION_EQUAL ${REQUIRED_PY})
    message(STATUS "Python ${PYTHON_SHORT_VERSION} found")
else(${PYTHON_SHORT_VERSION} VERSION_GREATER ${REQUIRED_PY} OR ${PYTHON_SHORT_VERSION} VERSION_EQUAL ${REQUIRED_PY})
    message(SEND_ERROR "Python >= ${REQUIRED_PY} is required")
endif(${PYTHON_SHORT_VERSION} VERSION_GREATER ${REQUIRED_PY} OR ${PYTHON_SHORT_VERSION} VERSION_EQUAL ${REQUIRED_PY})

# Check for Qt4 Glib support
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES})
set(CMAKE_REQUIRED_DEFINITIONS "")
set(CMAKE_REQUIRED_FLAGS "")

CHECK_CXX_SOURCE_COMPILES("
#include <QtCore/QtGlobal>
int main()
{
#if defined(QT_NO_GLIB)
#error \"Qt was compiled with Glib disabled\"
#endif
return 0;
}"
QT4_GLIB_SUPPORT)
macro_log_feature(QT4_GLIB_SUPPORT "Qt4 Glib Support"
                  "QtCore library using Glib's main event loop"
                  "http://qt.nokia.com/" FALSE ""
                  "Needed, together with Telepathy-Glib, to build most of the unit tests")

find_package(GLIB2)
find_package(GObject)
find_package(DBus)
find_package(DBusGLib)
find_package(LibXml2)

find_program(GLIB_GENMARSHAL glib-genmarshal)

# Find tp-farstream
set(TELEPATHY_FARSTREAM "0.0.0.1")
find_package(TelepathyFarstream)
macro_log_feature(TELEPATHYFARSTREAM_FOUND "Telepathy-Farstream"
                  "A Framework for dealing with audio/video conferencing protocols"
                  "http://farsight.freedesktop.org/wiki/" FALSE "0.0.0.1"
                  "Needed, together with GStreamer, to build telepathy-qt4-yell-farstream and some additional examples")

# Find GStreamer
find_package(GStreamer)
macro_log_feature(GSTREAMER_FOUND "GStreamer"
                  "An open source multimedia framework"
                  "Needed, together with Tp-Farstream, to build telepathy-qt4-yell-farstream and some additional examples"
                  "http://www.gstreamer.net/" FALSE)

# Find telepathy-glib
set(TELEPATHY_GLIB_MIN_VERSION 0.13.0)
find_package(TelepathyGlib)
macro_log_feature(TELEPATHYGLIB_FOUND "Telepathy-glib"
                  "Glib bindings for Telepathy"
                  "http://telepathy.freedesktop.org/" FALSE "0.13.0"
                  "Needed, together with Qt Glib integration, to build most of the unit tests")

# Build TelepathyQt4-Farstream only if GStreamer, TelepathyFarstream and all of their dependencies were found
if (TELEPATHYFARSTREAM_FOUND AND TELEPATHYGLIB_FOUND AND GSTREAMER_FOUND AND GLIB2_FOUND AND GOBJECT_FOUND AND DBUS_FOUND AND LIBXML2_FOUND)
    set (FARSTREAM_COMPONENTS_FOUND 1)
else (TELEPATHYFARSTREAM_FOUND AND TELEPATHYGLIB_FOUND AND GSTREAMER_FOUND AND GLIB2_FOUND AND GOBJECT_FOUND AND DBUS_FOUND AND LIBXML2_FOUND)
    set (FARSTREAM_COMPONENTS_FOUND 0)
endif (TELEPATHYFARSTREAM_FOUND AND TELEPATHYGLIB_FOUND AND GSTREAMER_FOUND AND GLIB2_FOUND AND GOBJECT_FOUND AND DBUS_FOUND AND LIBXML2_FOUND)

# Enable glib-based tests only if Qt4 has GLib support and Telepathy-glib was found
if(QT4_GLIB_SUPPORT AND TELEPATHYGLIB_FOUND AND GLIB2_FOUND AND DBUS_FOUND)
    set(ENABLE_TP_GLIB_TESTS 1)
else(QT4_GLIB_SUPPORT AND TELEPATHYGLIB_FOUND AND GLIB2_FOUND AND DBUS_FOUND)
    set(ENABLE_TP_GLIB_TESTS 0)
endif(QT4_GLIB_SUPPORT AND TELEPATHYGLIB_FOUND AND GLIB2_FOUND AND DBUS_FOUND)

# Add the source subdirectories
add_subdirectory(TelepathyQt4Yell)
add_subdirectory(tests)
add_subdirectory(tools)

# Generate config.h
configure_file(${CMAKE_SOURCE_DIR}/config.h.in ${CMAKE_BINARY_DIR}/config.h)

# Create the uninstall target
configure_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
    "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
    IMMEDIATE @ONLY)

add_custom_target(uninstall
    "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")

# Display the feature log
macro_display_feature_log()

add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/FIXME.out
                   COMMAND egrep
                   ARGS -A 5 '[F]IXME|[T]ODO|[X]XX' ${CMAKE_SOURCE_DIR}/TelepathyQt4Yell/*.[ch]*
                        > FIXME.out || true)
add_custom_target(check-local DEPENDS ${CMAKE_BINARY_DIR}/FIXME.out)

include(TelepathyDist)