CMakeLists.txt 12.1 KB
Newer Older
1
cmake_minimum_required(VERSION 3.5)
2

Laurent Montel's avatar
Laurent Montel committed
3
set(PIM_VERSION "5.15.40")
4
project(Akonadi VERSION ${PIM_VERSION})
Will Stephenson's avatar
Will Stephenson committed
5

Daniel Vrátil's avatar
Daniel Vrátil committed
6
7
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
8

9

10
# ECM setup
Laurent Montel's avatar
Laurent Montel committed
11
set(KF5_MIN_VERSION "5.74.0")
Laurent Montel's avatar
Laurent Montel committed
12

13
find_package(ECM ${KF5_MIN_VERSION} CONFIG REQUIRED)
Laurent Montel's avatar
Laurent Montel committed
14

15
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
Will Stephenson's avatar
Will Stephenson committed
16

17
18
19
20
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)

21
include(GenerateExportHeader)
Daniel Vrátil's avatar
Daniel Vrátil committed
22
include(ECMGenerateHeaders)
23
include(ECMGeneratePriFile)
24

25
include(ECMSetupVersion)
26
include(FeatureSummary)
27
include(CheckIncludeFiles)
28
include(ECMQtDeclareLoggingCategory)
29
include(CheckSymbolExists)
30

31
include(KDEPackageAppTemplates)
Laurent Montel's avatar
Laurent Montel committed
32
include(ECMMarkNonGuiExecutable)
David Faure's avatar
David Faure committed
33
include(ECMAddTests)
34
include(ECMSetupQtPluginMacroNames)
35
36
37

include(AkonadiMacros)

38
set(QT_REQUIRED_VERSION "5.13.0")
Laurent Montel's avatar
Laurent Montel committed
39
set(RELEASE_SERVICE_VERSION "20.11.80")
40
set(AKONADI_FULL_VERSION "${PIM_VERSION} (${RELEASE_SERVICE_VERSION})")
41
42
43

configure_file(akonadifull-version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/akonadifull-version.h @ONLY)

44

45
ecm_setup_version(PROJECT
46
47
    VARIABLE_PREFIX AKONADI
    VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/akonadi_version.h"
48
    PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5AkonadiConfigVersion.cmake"
49
50
51
    SOVERSION 5)

# Find packages
52
53
54
55
56
57
58
find_package(Qt5Core ${QT_REQUIRED_VERSION} REQUIRED COMPONENTS Private)
find_package(Qt5Sql ${QT_REQUIRED_VERSION} REQUIRED COMPONENTS Private)
find_package(Qt5DBus ${QT_REQUIRED_VERSION} REQUIRED)
find_package(Qt5Network ${QT_REQUIRED_VERSION} REQUIRED)
find_package(Qt5Test ${QT_REQUIRED_VERSION} REQUIRED)
find_package(Qt5Widgets ${QT_REQUIRED_VERSION} REQUIRED)
find_package(Qt5Xml ${QT_REQUIRED_VERSION} REQUIRED)
59

60
61
62
63
64
65
66
67
68
69
70
71
find_package(KF5Config ${KF5_MIN_VERSION} CONFIG REQUIRED)
find_package(KF5ConfigWidgets ${KF5_MIN_VERSION} CONFIG REQUIRED)
find_package(KF5CoreAddons ${KF5_MIN_VERSION} CONFIG REQUIRED)
find_package(KF5I18n ${KF5_MIN_VERSION} CONFIG REQUIRED)
find_package(KF5IconThemes ${KF5_MIN_VERSION} CONFIG REQUIRED)
find_package(KF5ItemModels ${KF5_MIN_VERSION} CONFIG REQUIRED)
find_package(KF5ItemViews ${KF5_MIN_VERSION} CONFIG REQUIRED)
find_package(KF5KIO ${KF5_MIN_VERSION} CONFIG REQUIRED)
find_package(KF5WidgetsAddons ${KF5_MIN_VERSION} CONFIG REQUIRED)
find_package(KF5WindowSystem ${KF5_MIN_VERSION} CONFIG REQUIRED)
find_package(KF5XmlGui ${KF5_MIN_VERSION} CONFIG REQUIRED)
find_package(KF5Crash ${KF5_MIN_VERSION} CONFIG REQUIRED)
72
73
74
75
76
77
find_package(Qt5Designer NO_MODULE)
set_package_properties(Qt5Designer PROPERTIES
   PURPOSE "Required to build the Qt Designer plugins"
   TYPE OPTIONAL
)

78
79
option(BUILD_DESIGNERPLUGIN "Build plugin for Qt Designer" ON)
add_feature_info(DESIGNERPLUGIN ${BUILD_DESIGNERPLUGIN} "Build plugin for Qt Designer")
80

Daniel Vrátil's avatar
Daniel Vrátil committed
81
set(Boost_MINIMUM_VERSION "1.34.0")
82
find_package(Boost ${Boost_MINIMUM_VERSION})
Daniel Vrátil's avatar
Daniel Vrátil committed
83
set_package_properties(Boost PROPERTIES
84
    DESCRIPTION "Boost C++ Libraries"
85
    URL "https://www.boost.org"
86
    TYPE REQUIRED
87
)
88

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
set(AccountsQt5_MINIMUM_VERSION "1.15")
find_package(AccountsQt5 ${AccountsQt5_MINIMUM_VERSION})
set_package_properties(AccountsQt5 PROPERTIES
    DESCRIPTION "Qt bindings for the Accounts framework"
    URL "https://gitlab.com/accounts-sso/libaccounts-qt"
    TYPE OPTIONAL
)
set(KAccounts_MINIMUM_VERSION "19.08.0")
find_package(KAccounts ${KAccounts_MINIMUM_VERSION})
set_package_properties(KAccounts PROPERTIES
    DESCRIPTION "KDE library for Accounts framework integration"
    URL "https://cgit.kde.org/kaccounts-integration.git"
    TYPE OPTIONAL
)
if (${AccountsQt5_FOUND} AND ${KAccounts_FOUND})
    set(WITH_ACCOUNTS TRUE)
endif()

107

108
109
if(BUILD_TESTING)
    set(AKONADI_TESTS_EXPORT AKONADICORE_EXPORT)
Laurent Montel's avatar
Laurent Montel committed
110
    set(AKONADIWIDGET_TESTS_EXPORT AKONADIWIDGETS_EXPORT)
111
    add_definitions(-DBUILD_TESTING)
112
endif()
113

114
115
116
117
118
119
120
ecm_setup_qtplugin_macro_names(
    JSON_ARG2
        "AKONADI_AGENTCONFIG_FACTORY"
    CONFIG_CODE_VARIABLE
        PACKAGE_SETUP_AUTOMOC_VARIABLES
)

121
122
123
124
125
126
127
128
# Make sure the KF5Akonadi_DATA_DIR is absolute before passing it to KF5AkonadiConfig.cmake.in
# otherwise build fails either on OSX CI, or for normal users
if (IS_ABSOLUTE "${KDE_INSTALL_DATADIR_KF5}")
    set(KF5Akonadi_DATA_DIR "${KDE_INSTALL_DATADIR_KF5}/akonadi")
else()
    set(KF5Akonadi_DATA_DIR "${CMAKE_INSTALL_PREFIX}/${KDE_INSTALL_DATADIR_KF5}/akonadi")
endif()

129
130
check_symbol_exists(malloc_trim "malloc.h" HAVE_MALLOC_TRIM)

131
132
############### Build Options ###############
option(AKONADI_BUILD_QSQLITE "Build the Sqlite backend." TRUE)
133
option(BUILD_TOOLS "Build and install tools for development and testing purposes." TRUE)
134
option(NO_REGENERATE_MIME "Don't regenerate mime file (developer-only option)" FALSE )
135
option(INSTALL_APPARMOR "Install AppArmor profiles" TRUE)
136
137
138
139

if(BUILD_TESTING)
   set(BUILD_TOOLS TRUE)
endif()
140

Laurent Montel's avatar
Laurent Montel committed
141
set(SMI_MIN_VERSION "1.3")
142
find_package(SharedMimeInfo ${SMI_MIN_VERSION} REQUIRED)
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

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()

find_program(MYSQLD_EXECUTABLE NAMES mysqld
    PATHS /usr/sbin /usr/local/sbin /usr/libexec /usr/local/libexec /opt/mysql/libexec /usr/mysql/bin /opt/mysql/sbin
    DOC "The mysqld executable path. ONLY needed at runtime"
)

if(MYSQLD_EXECUTABLE)
    message(STATUS "MySQL Server found: ${MYSQLD_EXECUTABLE}")
else()
    message(STATUS "MySQL Server wasn't found. it is required to use the MySQL backend.")
endif()

find_path(POSTGRES_PATH NAMES pg_ctl
    HINTS /usr/lib${LIB_SUFFIX}/postgresql/8.4/bin
          /usr/lib${LIB_SUFFIX}/postgresql/9.0/bin
          /usr/lib${LIB_SUFFIX}/postgresql/9.1/bin
          DOC "The pg_ctl executable path. ONLY needed at runtime by the PostgreSQL backend"
)

if(POSTGRES_PATH)
    message(STATUS "PostgreSQL Server found.")
else()
    message(STATUS "PostgreSQL wasn't found. it is required to use the Postgres backend.")
endif()


if("${DATABASE_BACKEND}" STREQUAL "SQLITE")
    set(SQLITE_TYPE "REQUIRED")
else()
    set(SQLITE_TYPE "OPTIONAL")
endif()

180
if(AKONADI_BUILD_QSQLITE)
181
182
183
    set(SQLITE_MIN_VERSION 3.6.23)
    find_package(Sqlite ${SQLITE_MIN_VERSION})
    set_package_properties(Sqlite PROPERTIES
184
        URL "https://www.sqlite.org"
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
        DESCRIPTION "The Sqlite database library"
        TYPE ${SQLITE_TYPE}
        PURPOSE "Required by the Sqlite backend"
    )
endif()

find_program(XMLLINT_EXECUTABLE xmllint)
if(NOT XMLLINT_EXECUTABLE)
    message(STATUS "xmllint not found, skipping akonadidb.xml schema validation")
endif()

check_include_files(unistd.h HAVE_UNISTD_H)
if(HAVE_UNISTD_H)
    add_definitions(-DHAVE_UNISTD_H)
endif()
200

201
202
203
204
205
206
if (IS_ABSOLUTE "${DBUS_INTERFACES_INSTALL_DIR}")
    set(AKONADI_DBUS_INTERFACES_INSTALL_DIR "${DBUS_INTERFACES_INSTALL_DIR}")
else()
    set(AKONADI_DBUS_INTERFACES_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${DBUS_INTERFACES_INSTALL_DIR}")
endif()

207
208
209
210
if (IS_ABSOLUTE "${KDE_INSTALL_INCLUDEDIR_KF5}")
    set(AKONADI_INCLUDE_DIR "${KDE_INSTALL_INCLUDEDIR_KF5}")
else()
    set(AKONADI_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/${KDE_INSTALL_INCLUDEDIR_KF5}")
Raymond Wooninck's avatar
Raymond Wooninck committed
211
endif()
212

Christophe Giboudeaux's avatar
Christophe Giboudeaux committed
213
214
############### Build Options ###############

215
include(CTest)  # Calls enable_testing().
Bertjan Broeksema's avatar
Bertjan Broeksema committed
216
include(CTestConfig.cmake)
217

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

222
223
224
225
226
227
############### 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.
Christophe Giboudeaux's avatar
Christophe Giboudeaux committed
228
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake COPYONLY)
229

230
231
232
############### Macros ###############

macro(SET_DEFAULT_DB_BACKEND)
233
234
    set(_backend ${ARGV0})
    if("${_backend}" STREQUAL "SQLITE")
235
        set(AKONADI_DATABASE_BACKEND QSQLITE3)
236
        set(AKONADI_BUILD_QSQLITE TRUE)
237
    else()
238
        if("${_backend}" STREQUAL "POSTGRES")
239
240
241
          set(AKONADI_DATABASE_BACKEND QPSQL)
        else()
          set(AKONADI_DATABASE_BACKEND QMYSQL)
242
        endif()
243
244
    endif()

245
    message(STATUS "Using default db backend ${AKONADI_DATABASE_BACKEND}")
246
    add_definitions(-DAKONADI_DATABASE_BACKEND="${AKONADI_DATABASE_BACKEND}")
247
endmacro()
248
249

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

252
############### Compilers flags ###############
Christophe Giboudeaux's avatar
Christophe Giboudeaux committed
253

254
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER MATCHES "icc" OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
255
    set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -Wno-long-long -std=iso9899:1990 -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wall -Wextra -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
256
257
258
259
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wundef -Wcast-align -Wchar-subscripts -Wall -Wextra -Wpointer-arith -Wformat-security -fno-common -pedantic")
    if ((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10))
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy")
    endif()
Daniel Vrátil's avatar
Daniel Vrátil committed
260

261
262
263
    set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 -fno-inline" CACHE STRING "Flags used by the C++ compiler during debugfull builds." FORCE)
    set(CMAKE_C_FLAGS_DEBUGFULL   "-g3 -fno-inline" CACHE STRING "Flags used by the C compiler during debugfull builds." FORCE)
    mark_as_advanced(CMAKE_CXX_FLAGS_DEBUGFULL CMAKE_C_FLAGS_DEBUGFULL)
264
265
266
267
elseif (MSVC)
    # This sets the __cplusplus macro to a real value based on the version of C++ specified by
    # the /std switch. Without it MSVC keeps reporting C++98, so feature detection doesn't work.
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
268
endif()
Will Stephenson's avatar
Will Stephenson committed
269

270

Volker Krause's avatar
Volker Krause committed
271
if(MSVC)
272
    set(_ENABLE_EXCEPTIONS -EHsc)
273
274
else()
    set(_ENABLE_EXCEPTIONS -fexceptions)
Volker Krause's avatar
Volker Krause committed
275
276
endif()

277
278
279
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_ENABLE_EXCEPTIONS}")

############### Configure files #############
280

281
configure_file(config-akonadi.h.cmake ${Akonadi_BINARY_DIR}/config-akonadi.h)
282

Christophe Giboudeaux's avatar
Christophe Giboudeaux committed
283
############### build targets ###############
284

285
add_definitions(-DTRANSLATION_DOMAIN=\"libakonadi5\")
286

287
288
289
290
291
include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_BINARY_DIR}
    src
)
292
add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x054A00)
293
#add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050f00)
294
add_definitions(-DQT_NO_EMIT)
295

296
add_subdirectory(src)
297
add_subdirectory(icons)
298

299
300
add_subdirectory(templates)

301
302
303
304
305
306
307
308
if(BUILD_TOOLS)
    # add testrunner (application for managing a self-contained
    # test environment)
    add_subdirectory(autotests/libs/testrunner)
    add_subdirectory(autotests/libs/testresource)
    add_subdirectory(autotests/libs/testsearchplugin)
endif()

309
if(BUILD_TESTING)
310
311
    add_subdirectory(autotests)
    add_subdirectory(tests)
312
endif()
313

314
315
316
if(INSTALL_APPARMOR)
   add_subdirectory(apparmor)
endif()
Christophe Giboudeaux's avatar
Christophe Giboudeaux committed
317
318

############### install stuff ###############
319
320

install(FILES akonadi-mime.xml DESTINATION ${XDG_MIME_INSTALL_DIR})
321
322
323
if (NOT NO_REGENERATE_MIME)
   update_xdg_mimetypes(${XDG_MIME_INSTALL_DIR})
endif()   
324

325
############### CMake Config Files ###############
326

327
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5Akonadi")
328

329
configure_package_config_file(
330
331
    "${CMAKE_CURRENT_SOURCE_DIR}/KF5AkonadiConfig.cmake.in"
    "${CMAKE_CURRENT_BINARY_DIR}/KF5AkonadiConfig.cmake"
332
    INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
333
334
335
    PATH_VARS AKONADI_DBUS_INTERFACES_INSTALL_DIR
              AKONADI_INCLUDE_DIR
              KF5Akonadi_DATA_DIR
336
337
338
)

install(FILES
339
340
341
    "${CMAKE_CURRENT_BINARY_DIR}/KF5AkonadiConfig.cmake"
    "${CMAKE_CURRENT_BINARY_DIR}/KF5AkonadiConfigVersion.cmake"
    "${CMAKE_CURRENT_SOURCE_DIR}/KF5AkonadiMacros.cmake"
342
343
344
    DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
    COMPONENT Devel
)
345

346
install(EXPORT
347
    KF5AkonadiTargets
348
    DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
349
    FILE KF5AkonadiTargets.cmake
350
    NAMESPACE KF5::)
351

352
ecm_qt_install_logging_categories(
Laurent Montel's avatar
Laurent Montel committed
353
354
355
356
        EXPORT AKONADI
        FILE akonadi.categories
        DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}
        )
357

Daniel Vrátil's avatar
Daniel Vrátil committed
358
install(FILES
359
    ${CMAKE_CURRENT_BINARY_DIR}/akonadi_version.h
360
    DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel
361
)
362

363
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)