File: CMakeLists.txt

package info (click to toggle)
akonadi 1.7.2-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,424 kB
  • sloc: cpp: 19,474; xml: 904; php: 521; sh: 61; makefile: 16
file content (357 lines) | stat: -rw-r--r-- 13,098 bytes parent folder | download
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
project(Akonadi)

cmake_minimum_required(VERSION 2.6.3 FATAL_ERROR)

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

############### Build Options ###############

include(CTest)
include(CTestConfig.cmake)
option(AKONADI_BUILD_TESTS "Build the Akonadi unit tests." TRUE)
option(AKONADI_BUILD_QSQLITE "Build the Sqlite backend." TRUE)
option(AKONADI_USE_STRIGI_SEARCH "Build Akonadi with strigi as search engine." FALSE)
option(INSTALL_QSQLITE_IN_QT_PREFIX "Install the QSQLite plugin in QT_PLUGIN_DIR" FALSE)
option(STATIC_LIBRARY "Build Akonadi as a static library." FALSE)

if (NOT DEFINED DATABASE_BACKEND)
  set(DATABASE_BACKEND "MYSQL" CACHE STRING "The default database backend to use for Akonadi. Can be either MYSQL, POSTGRES or SQLITE")
endif()

if (AKONADI_BUILD_TESTS)
  enable_testing()
endif (AKONADI_BUILD_TESTS)

if (AKONADI_USE_STRIGI_SEARCH)
  set(AKONADI_DEFINITIONS "-DAKONADI_USE_STRIGI_SEARCH")
  add_definitions(${AKONADI_DEFINITIONS})
  set(SOPRANO_REQUIRED FALSE)
else()
  set(SOPRANO_REQUIRED TRUE)
endif (AKONADI_USE_STRIGI_SEARCH)

if (CMAKE_COMPILER_IS_GNUCXX)
   set(CMAKE_CXX_FLAGS_DEBUGFULL      "-g3 -fno-inline")
   set(CMAKE_C_FLAGS_DEBUGFULL        "-g3 -fno-inline")
endif()

############### CMake Macros ###############

include(MacroLogFeature)
include(InstallSettings)
include(CheckFunctionExists)
include(CheckIncludeFiles)
include(MacroWriteBasicCMakeVersionFile)

############### CTest options ###############
# Set a timeout value of 1 minute per test
set(DART_TESTING_TIMEOUT 60)

# CTestCustom.cmake has to be in the CTEST_BINARY_DIR.
# in the KDE build system, this is the same as CMAKE_BINARY_DIR.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake)

############### The Akonadi version (used in AkonadiConfig.cmake) ###############

set(AKONADI_VERSION_MAJOR "1")
set(AKONADI_VERSION_MINOR "7")
set(AKONADI_VERSION_PATCH "2")
set(AKONADI_VERSION "${AKONADI_VERSION_MAJOR}.${AKONADI_VERSION_MINOR}.${AKONADI_VERSION_PATCH}")
set(AKONADI_VERSION_STRING "${AKONADI_VERSION}")

# If Git is installed and a '.git' directory is found,
# we append the Git revision to AKONADI_VERSION_STRING
if(EXISTS "${Akonadi_SOURCE_DIR}/.git")
  find_program(GIT_EXECUTABLE NAMES git)
  if(GIT_EXECUTABLE)
    message(STATUS "Found git: ${GIT_EXECUTABLE}")
    execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
                    WORKING_DIRECTORY ${Akonadi_SOURCE_DIR}
                    OUTPUT_VARIABLE akonadi_git_revision)
    string(REGEX REPLACE "\n" "" akonadi_git_revision "${akonadi_git_revision}")
    set(AKONADI_VERSION_STRING "${AKONADI_VERSION_STRING} (revision: ${akonadi_git_revision})")
  endif()
endif()


############### Macros ###############

macro(MAKE_INSTALL_PATH_ABSOLUTE out in)
   if (IS_ABSOLUTE "${in}")
      set(${out} "${in}")
   else (IS_ABSOLUTE "${in}")
      set(${out} "\${AKONADI_INSTALL_DIR}/${in}")
   endif (IS_ABSOLUTE "${in}")
endmacro(MAKE_INSTALL_PATH_ABSOLUTE out in)


macro(SET_DEFAULT_DB_BACKEND)
    set ( _backend ${ARGV0} )
    if ( "${_backend}" STREQUAL "SQLITE" )
        set(AKONADI_DATABASE_BACKEND QSQLITE3)
        set(AKONADI_BUILD_QSQLITE TRUE)
    else()
        if ( "${_backend}" STREQUAL "POSTGRES" )
          set(AKONADI_DATABASE_BACKEND QPSQL)
        else()
          set(AKONADI_DATABASE_BACKEND QMYSQL)
        endif ()
    endif()

    message( STATUS "Using default db backend ${AKONADI_DATABASE_BACKEND}" )
endmacro(SET_DEFAULT_DB_BACKEND)

#### DB BACKEND DEFAULT ####
set_default_db_backend( ${DATABASE_BACKEND} )


############### Find what we need ###############

#### Qt4 ####
# Don't use absolute path in Akonadi-qtTargets-$buildType.cmake
# note: this will have no effect with cmake < 2.8
set(QT_USE_IMPORTED_TARGETS TRUE)

set(QT_MIN_VERSION 4.6.0)
find_package(Qt4 REQUIRED)

# Load the custom qt4_add_dbus_interface macro.
# TODO: Add if/endif lines when the macro is available in a cmake version
include(AkonadiMacros)

# We need QtDBus and QtSql
set(QT_USE_QTDBUS TRUE)
set(QT_USE_QTSQL TRUE)
if (NOT QT_QTDBUS_FOUND)
   message(FATAL_ERROR  "Akonadi requires Qt4 with QtDBus module in order to built.")
endif(NOT QT_QTDBUS_FOUND)
if (NOT QT_QTSQL_FOUND)
   message(FATAL_ERROR  "Akonadi requires Qt4 with QtSql module in order to built.")
endif(NOT QT_QTSQL_FOUND)
# properly set up compile flags (QT_DEBUG/QT_NO_DEBUG, ...)
include(${QT_USE_FILE})

if(WINCE)
    find_package(Wcecompat REQUIRED)
    SET(QT_DBUSCPP2XML_EXECUTABLE ${HOST_BINDIR}/qdbuscpp2xml.exe)
    SET(QT_DBUSXML2CPP_EXECUTABLE ${HOST_BINDIR}/qdbusxml2cpp.exe)
    set(STATIC_LIBRARY ON)
endif(WINCE)

if(STATIC_LIBRARY)
  set(LIBRARY_TYPE STATIC)
  set(AKONADI_STATIC_LIBS ON)
  message(STATUS "Building Akonadi as a static library")
else(STATIC_LIBRARY)
  set(LIBRARY_TYPE SHARED)
endif(STATIC_LIBRARY)

#### Soprano ####
if (NOT WINCE)
  find_package(Soprano)
endif(NOT WINCE)

macro_log_feature(Soprano_FOUND "Soprano" "Semantic Desktop Storing" "http://soprano.sourceforge.net" ${SOPRANO_REQUIRED} "" "Soprano is needed for the Nepomuk search backend")

#### Automoc ####
find_package(Automoc4 REQUIRED)

#### SMI ####
set(SHARED_MIME_INFO_MINIMUM_VERSION "0.20")
find_package(SharedMimeInfo REQUIRED)

#### XSLTProc ####
find_program(XSLTPROC_EXECUTABLE xsltproc)
if(NOT XSLTPROC_EXECUTABLE)
  message(FATAL_ERROR "\nThe command line XSLT processor program 'xsltproc'  could not be found.\nPlease install xsltproc.\n")
endif(NOT XSLTPROC_EXECUTABLE)
if(WINCE)
set(XSLTPROC_EXECUTABLE "${HOST_BINDIR}/xsltproc.exe")
endif(WINCE)

#### Boost ####
# In CMake >= 2.8.6, FindBoost.cmake tries to find BoostConfig.cmake which is
# not compatible with CMake's FindBoost. Disable this function.
set (Boost_NO_BOOST_CMAKE TRUE)

if(MSVC)
  set (_ENABLE_EXCEPTIONS -EHsc)
endif(MSVC)

if(NOT WINCE)
    find_package(Boost COMPONENTS program_options)
    macro_log_feature(Boost_FOUND "Boost" "Boost C++ Libraries" "http://www.boost.org" TRUE "" "Akonadi requires the Boost C++ libraries (program_options).")
endif(NOT WINCE)

# should be handled by FindBoost.cmake ->  cmake bug #8335
if(WIN32 AND NOT Boost_USE_STATIC_LIBS)
  add_definitions(-DBOOST_DYN_LINK)
  add_definitions(-DBOOST_PROGRAM_OPTIONS_DYN_LINK)
endif(WIN32 AND NOT Boost_USE_STATIC_LIBS)


#### Sqlite ####
# If Sqlite is the default backend, it cannot be optional.
if ("${DATABASE_BACKEND}" STREQUAL "SQLITE")
  set (SQLITE_REQUIRED "TRUE")
else()
  set (SQLITE_REQUIRED "FALSE")
endif()

if(AKONADI_BUILD_QSQLITE)
  set(SQLITE_MIN_VERSION 3.6.23)
  find_package(Sqlite)
  macro_log_feature(SQLITE_FOUND "Sqlite" "Sqlite database library" "http://www.sqlite.org" ${SQLITE_REQUIRED} "${SQLITE_MIN_VERSION}" "")
endif()

############### Compilers flags ###############

option(CMAKE_COMPILE_GCOV "Build with coverage support." FALSE)
if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER MATCHES "icc")
  set (_ENABLE_EXCEPTIONS -fexceptions)
  set (CMAKE_C_FLAGS     "${CMAKE_C_FLAGS} -Wno-long-long -std=iso9899:1990 -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wformat-security -fno-check-new -fno-common")
  if(CMAKE_COMPILE_GCOV)
    set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
  endif(CMAKE_COMPILE_GCOV)
endif (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER MATCHES "icc")

add_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII)
add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)


############### Configure checks ###############

set (AKONADI_SYSTEM_LIBS)

check_include_files(execinfo.h HAVE_EXECINFO_H)
if (HAVE_EXECINFO_H)
  check_function_exists(backtrace BACKTRACE_IN_LIBC)
  if (NOT BACKTRACE_IN_LIBC)
    find_library (EXECINFO_LIBRARY NAMES execinfo)
    if (EXECINFO_LIBRARY)
      set (AKONADI_SYSTEM_LIBS ${AKONADI_SYSTEM_LIBS} ${EXECINFO_LIBRARY})
    endif (EXECINFO_LIBRARY)
  endif (NOT BACKTRACE_IN_LIBC)
endif (HAVE_EXECINFO_H)

check_include_files(unistd.h HAVE_UNISTD_H)

# set the output paths
set (EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
if (WIN32)
  set(LIBRARY_OUTPUT_PATH   ${EXECUTABLE_OUTPUT_PATH})
else (WIN32)
  set(LIBRARY_OUTPUT_PATH   ${CMAKE_BINARY_DIR}/lib)
endif (WIN32)

# Set up RPATH handling, so the libs are found if they are installed to a non-standard location.
# By default cmake builds the targets with full RPATH to everything in the build directory,
# but then removes the RPATH when installing.
# These two options below make it set the RPATH of the installed targets to all
# RPATH directories outside the current CMAKE_BINARY_DIR and also the library
# install directory, but only if this directory is not a default system library directory. Alex
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${LIB_INSTALL_DIR}" _isSystemLibDir)
if("${_isSystemLibDir}" STREQUAL "-1")
  set(CMAKE_INSTALL_RPATH "${LIB_INSTALL_DIR}")
endif("${_isSystemLibDir}" STREQUAL "-1")

if (NOT DEFINED AKONADI_BUNDLE_PATH)
  set(AKONADI_BUNDLE_PATH "/Applications/KDE4")
endif (NOT DEFINED AKONADI_BUNDLE_PATH)

if(APPLE)
   message(STATUS "MacOS Bundle Path: ${AKONADI_BUNDLE_PATH}")
   set(CMAKE_INSTALL_NAME_DIR ${LIB_INSTALL_DIR})
endif(APPLE)

############### Prepare AkonadiConfig.cmake ###############

# all the following variables are put into AkonadiConfig.cmake, so
# they are usable by projects using Akonadi.
make_install_path_absolute(AKONADI_BIN_DIR             ${BIN_INSTALL_DIR})
make_install_path_absolute(AKONADI_INCLUDE_DIR         ${INCLUDE_INSTALL_DIR})
make_install_path_absolute(AKONADI_LIB_DIR             ${LIB_INSTALL_DIR})
make_install_path_absolute(AKONADI_CONFIG_DIR          ${CONFIG_INSTALL_DIR})
make_install_path_absolute(AKONADI_DBUS_INTERFACES_DIR ${DBUS_INTERFACES_INSTALL_DIR})
make_install_path_absolute(AKONADI_DBUS_SERVICES_DIR   ${DBUS_SERVICES_INSTALL_DIR})
make_install_path_absolute(AKONADI_XDG_MIME_DIR        ${XDG_MIME_INSTALL_DIR})


############### Generate files ###############
# Used in configure_file() and install(EXPORT). Must be set before setting the AkonadiConfig.cmake vars.
set(AKONADI_TARGET_PREFIX Akonadi__)

if (Soprano_FOUND)
  set(HAVE_SOPRANO TRUE)
endif (Soprano_FOUND)
configure_file(akonadi-prefix.h.cmake ${Akonadi_BINARY_DIR}/akonadi-prefix.h)
configure_file(config-akonadi.h.cmake ${Akonadi_BINARY_DIR}/config-akonadi.h)
configure_file(AkonadiConfig.cmake.in "${Akonadi_BINARY_DIR}/AkonadiConfig.cmake" @ONLY)

if (NOT WIN32)
  configure_file(${Akonadi_SOURCE_DIR}/akonadi.pc.cmake ${Akonadi_BINARY_DIR}/akonadi.pc @ONLY)
endif (NOT WIN32)

# this file is used by to check if the installed version can be used.
macro_write_basic_cmake_version_file(${Akonadi_BINARY_DIR}/AkonadiConfigVersion.cmake
                                     ${AKONADI_VERSION_MAJOR} ${AKONADI_VERSION_MINOR} ${AKONADI_VERSION_PATCH})

############### build targets ###############

include_directories(${Akonadi_SOURCE_DIR} ${Akonadi_BINARY_DIR} ${QT_INCLUDES} ${Boost_INCLUDE_DIR})

add_subdirectory(interfaces)
add_subdirectory(libs)
set( AKONADI_PROTOCOLINTERNALS_LIBS ${akonadiprotocolinternals_LIB_DEPENDS} akonadiprotocolinternals)

add_subdirectory(shared)
add_subdirectory(agentserver)

if (XSLTPROC_EXECUTABLE)
   add_subdirectory(server)
endif (XSLTPROC_EXECUTABLE)

add_subdirectory(rds)
if (SQLITE_FOUND)
  option(SQLITE_LINK_STATIC "link libsqlite3 statically" FALSE)
  add_subdirectory(qsqlite)
endif (SQLITE_FOUND)

############### install stuff ###############

install(FILES ${Akonadi_BINARY_DIR}/AkonadiConfigVersion.cmake
              ${Akonadi_BINARY_DIR}/AkonadiConfig.cmake
        DESTINATION ${LIB_INSTALL_DIR}/cmake/Akonadi )

install(FILES akonadi-mime.xml DESTINATION ${XDG_MIME_INSTALL_DIR})
update_xdg_mimetypes(${XDG_MIME_INSTALL_DIR})

if(NOT WIN32)
  install(FILES ${Akonadi_BINARY_DIR}/akonadi.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
endif(NOT WIN32)

############### CPack setup ##################

SET(CPACK_PACKAGE_NAME "akonadi")
SET(CPACK_PACKAGE_VERSION_MAJOR "${AKONADI_VERSION_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${AKONADI_VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${AKONADI_VERSION_PATCH}")

set(CPACK_SOURCE_GENERATOR "TBZ2")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "akonadi-${AKONADI_VERSION_MAJOR}.${AKONADI_VERSION_MINOR}.${AKONADI_VERSION_PATCH}")
set(CPACK_SOURCE_IGNORE_FILES "/\\\\.svn/" "/\\\\.git/" "makechangelog")

include(CPack) # needs to happen after the above variables are set!


macro_display_feature_log()

# Install the file with the exported targets
install(EXPORT akonadiLibraryTargets
        NAMESPACE ${AKONADI_TARGET_PREFIX}
        DESTINATION ${LIB_INSTALL_DIR}/cmake/Akonadi
        FILE AkonadiTargetsWithPrefix.cmake )