3 # where to look first for cmake modules. This line must be the first one or cmake will use the system's FindFoo.cmake
4 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
6 ############### Build Options ###############
8 option(KDEPIM_BUILD_EXAMPLES "Build the kdepim example applications." FALSE)
9 option(KDEPIM_BUILD_MOBILE "Build the mobile applications. Note that you have to enable KDEPIM_MOBILE_UI if you want to run these applications on a mobile device." TRUE)
10 option(KDEPIM_ENTERPRISE_BUILD "Enable features specific to the enterprise branch, which are normally disabled. Also, it disables many components not needed for Kontact such as the Kolab client." FALSE)
11 option(KDEPIM_MOBILE_UI "Build UI for mobile devices instead of for desktops" FALSE)
12 option(KDEPIM_ONLY_KLEO "Only build Kleopatra. This option will build only libkleo and kleopatra" FALSE)
13 option(KDEPIM_BUILD_STATIC "Build KDEPIM static." FALSE)
14 option(KDEPIM_BUILD_DESKTOP "Build Desktop Applications. Can be deactivated for mobile" TRUE)
15 option(KDEPIM_NO_NEPOMUK "Build the mail libraries and applications without nepomuk dependency" FALSE)
16 option(KDEPIM_NO_WEBKIT "Do not use WebKit in the kdepim applications" FALSE)
18 if(KDEPIM_BUILD_STATIC)
19 set(LIBRARY_TYPE STATIC)
21 set(LIBRARY_TYPE SHARED)
24 add_definitions( -DDISABLE_NEPOMUK_LEGACY )
25 add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
28 add_definitions(-DKDEPIM_NO_NEPOMUK)
32 add_definitions(-DKDEPIM_NO_WEBKIT)
35 # cmake would not find kde for xcompile if that is not set
37 set(KDE4_DATA_DIR "${CMAKE_PREFIX_PATH}/share/apps")
38 set(LIBRARY_TYPE STATIC)
39 add_definitions(-DKDELIBS_STATIC_LIBS)
40 add_definitions(-DKDEPIM_STATIC_LIBS)
43 if(KDEPIM_ENTERPRISE_BUILD)
44 message(STATUS "Enterprise build is enabled.")
47 # if KDEPIM_ONLY_KLEO is defined, KDEPIM_BUILD_MOBILE and KDEPIM_MOBILE_UI are disabled.
49 set(KDEPIM_BUILD_MOBILE FALSE)
50 set(KDEPIM_MOBILE_UI FALSE)
51 set(KDEPIM_DEFINITIONS "-DHAVE_CONFIG_H=1")
52 message(STATUS "Only libkleo and Kleopatra will be built.")
56 # Build the mobile applications
57 set(KDEPIM_BUILD_MOBILE TRUE)
60 # config-enterprise.h is needed for both ENTERPRISE_BUILD and BUILD_EVERYTHING
61 configure_file(config-enterprise.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-enterprise.h )
63 ############### generate kdepim-version.h ###############
64 # Support for the GIT revision number in kdepim-version.h
65 if(EXISTS "${kdepim_SOURCE_DIR}/.git")
66 find_program(GIT_EXECUTABLE NAMES git)
68 message(STATUS "Found git: ${GIT_EXECUTABLE}")
69 execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
70 WORKING_DIRECTORY ${kdepim_SOURCE_DIR}
71 OUTPUT_VARIABLE kdepim_git_revision)
72 string(REGEX REPLACE "\n" "" kdepim_git_revision "${kdepim_git_revision}")
73 set(kdepim_git_revision "git-${kdepim_git_revision}")
75 execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --oneline --format=%ci
76 WORKING_DIRECTORY ${kdepim_SOURCE_DIR}
77 OUTPUT_VARIABLE kdepim_git_last_change)
78 string(REGEX REPLACE " [-0-9:+ ]*\n" "" kdepim_git_last_change "${kdepim_git_last_change}")
83 # Version scheme: "x.y.z build".
85 # x is the version number.
86 # y is the major release number.
87 # z is the minor release number.
89 # "x.y.z" follow the kdelibs version kdepim is released with.
91 # If "z" is 0, it the version is "x.y"
94 # is empty for final versions. For development versions "build" is
95 # something like "pre", "alpha1", "alpha2", "beta1", "beta2", "rc1", "rc2".
97 # Examples in chronological order:
111 set(KDEPIM_DEV_VERSION pre)
114 if(DEFINED KDEPIM_DEV_VERSION)
115 set(KDEPIM_DEV_VERSION " ${KDEPIM_DEV_VERSION}")
118 set(KDEPIM_VERSION "4.9${KDEPIM_DEV_VERSION}")
120 configure_file(kdepim-version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/kdepim-version.h @ONLY)
122 ############### search packages used by KDE ###############
124 # It is needed otherwise it finds the kde4-config of the target platform
126 find_program(KDE4_KDECONFIG_EXECUTABLE NAMES kde4-config PATHS ${HOST_BINDIR} NO_DEFAULT_PATH)
129 find_package(KDE4 4.7.0 REQUIRED)
130 include(KDE4Defaults)
131 include(MacroLibrary)
132 include(CheckIncludeFiles)
133 include(MacroBoolTo01)
134 find_package(KdepimLibs 4.8.43 REQUIRED)
136 ############### Load the CTest options ###############
138 # CMake is irritating and doesn't allow setting the tests timeout globally.
139 # Let's work around this. The global timeout is now 2 minutes.
140 set(_DartConfigFile "${CMAKE_BINARY_DIR}/DartConfiguration.tcl")
141 if(EXISTS ${_DartConfigFile})
142 set(DartTestingTimeout "120")
143 file(READ ${_DartConfigFile} _DartConfigFile_content)
144 string(REGEX REPLACE "TimeOut: 1500" "TimeOut: ${DartTestingTimeout}" _DartConfigFile_content ${_DartConfigFile_content})
145 file(WRITE ${_DartConfigFile} ${_DartConfigFile_content})
148 # CTestCustom.cmake has to be in the CTEST_BINARY_DIR.
149 # in the KDE build system, this is the same as CMAKE_BINARY_DIR.
150 configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR}/CTestCustom.cmake)
152 ############### search Boost ###############
154 find_package(Boost 1.34.0)
155 macro_log_feature(Boost_FOUND "Boost" "Boost C++ Libraries" "http://www.boost.org" TRUE "1.34.0" "Required by several critical KDEPIM apps.")
157 # Kleopatra needs to know if the topological.hpp header exists (part of Boost_graph).
158 find_path(Boost_TOPOLOGICAL_SORT_DIR NAMES boost/graph/topological_sort.hpp PATHS ${Boost_INCLUDE_DIRS})
159 macro_log_feature(Boost_TOPOLOGICAL_SORT_DIR "The Boost Topological_sort header" "topological_sort.hpp (part of Boost_graph)" "http://www.boost.org/" FALSE "" "Necessary to build kleopatra")
161 ############### Windows specific ###############
164 # detect oxygen icon dir at configure time based on KDEDIRS - there may be different package installation locations
165 execute_process(COMMAND "${KDE4_KDECONFIG_EXECUTABLE}" --path icon OUTPUT_VARIABLE _dir ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
166 file(TO_CMAKE_PATH "${_dir}" __dir)
167 find_path(KDE4_ICON_DIR oxygen PATHS
170 message(STATUS "using oxygen application icons from ${KDE4_ICON_DIR}")
172 set (KDE4_ICON_DIR ${CMAKE_INSTALL_PREFIX}/share/icons)
175 ############### ONLY_KLEO ###############
177 # The KDEPIM_ONLY_KLEO option is true
180 macro_log_feature(QGPGME_FOUND "QGpgME" "The QGpgME library" "http://www.kde.org" TRUE "" "QGpgME is required to build Kleopatra.")
182 add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS} ${KDEPIM_DEFINITIONS} -DQT3_SUPPORT_WARNINGS)
183 include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} ${KDEPIMLIBS_INCLUDE_DIRS} ${QT_QTDBUS_INCLUDE_DIR})
184 include(kleopatra/ConfigureChecks.cmake)
186 add_subdirectory(libkleo)
187 if(Boost_TOPOLOGICAL_SORT_DIR)
188 add_subdirectory(kleopatra)
193 ############### Find the stuff we need ###############
194 set(AKONADI_MIN_VERSION 1.4.91)
195 find_package(Akonadi QUIET NO_MODULE ${AKONADI_MIN_VERSION})
196 macro_log_feature(Akonadi_FOUND "Akonadi" "Akonadi server libraries" "http://pim.kde.org/akonadi" TRUE "${AKONADI_MIN_VERSION}" "Akonadi is required to build KDEPIM")
199 macro_log_feature(ZLIB_FOUND "ZLib" "The Zlib compression library" "http://www.zlib.net" TRUE "" "")
202 macro_log_feature(STRIGI_FOUND "Strigi" "Index metadata of files" "http://strigi.sourceforge.net" TRUE "" "")
205 macro_log_feature(QGPGME_FOUND "QGpgME" "The QGpgME library" "http://www.kde.org" FALSE "" "QGpgME is required to build KMail, KOrganizer and Kleopatra")
207 set(SDO_MIN_VERSION 0.9)
208 set(SOPRANO_MIN_VERSION 2.3.70)
210 find_package(SharedDesktopOntologies ${SDO_MIN_VERSION})
211 macro_log_feature(SHAREDDESKTOPONTOLOGIES_FOUND "Shared desktop ontologies" "Desktop ontologies" "http://oscaf.sourceforge.net" TRUE "${SDO_MIN_VERSION}" "Ontologies necessary for the Nepomuk semantic desktop.")
213 find_package(Soprano)
214 macro_log_feature(Soprano_FOUND "Soprano" "Semantic Desktop Storing" "http://soprano.sourceforge.net" TRUE "${SOPRANO_MIN_VERSION}" "Soprano is needed for Nepomuk")
215 include(SopranoAddOntology)
217 find_package(Grantlee QUIET NO_MODULE)
218 macro_log_feature(Grantlee_FOUND "Grantlee" "The Grantlee Template System" "http://www.grantlee.org" FALSE "" "Templating and theming for KJots and KaddressBook." )
220 if(NOT KDEPIM_NO_NEPOMUK)
221 find_package(Nepomuk)
222 macro_log_feature(Nepomuk_FOUND "Nepomuk" "The Nepomuk libraries" "http://www.kde.org" TRUE "" "Nepomuk extends the search and tagging functionalities in KMail and Akonadi")
225 find_package(LibXslt)
226 macro_log_feature(XSLTPROC_EXECUTABLE "xsltproc" "The command line XSLT processor from libxslt" "http://xmlsoft.org/XSLT/" TRUE "" "Required to generate the D-Bus interfaces.")
228 ############### Desktop vs. Mobile options ##############
231 macro_log_feature(QT_QTDECLARATIVE_FOUND "QtDeclarative" "Qt Declarative (QML) module" "http://qt.nokia.com" TRUE "4.7" "Required for building mobile UI")
232 add_definitions( -DKDEPIM_MOBILE_UI )
234 macro_log_feature(QT_QTDECLARATIVE_FOUND "QtDeclarative" "Qt Declarative (QML) module" "http://qt.nokia.com" FALSE "4.7" "Required for building the mobile applications")
235 if(NOT QT_QTDECLARATIVE_FOUND)
236 message(STATUS "The Qt Declarative (QML) module was not found. The mobile applications will not be built.")
237 set(KDEPIM_BUILD_MOBILE FALSE)
241 ############### Needed commands before building anything ###############
243 add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS} ${KDEPIM_DEFINITIONS} ${AKONADI_DEFINITIONS})
245 include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDEPIMLIBS_INCLUDE_DIRS} ${KDE4_INCLUDES} ${QT_QTDBUS_INCLUDE_DIR} ${Boost_INCLUDE_DIR})
247 if(NOT KDEPIMLIBS_KRESOURCES_LIBRARY)
248 add_definitions( -DKDEPIM_NO_KRESOURCES )
251 ############### Macros ###############
253 # generates a D-Bus interface description from a KConfigXT file
254 macro(kcfg_generate_dbus_interface _kcfg _name)
256 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}.xml
257 COMMAND ${XSLTPROC_EXECUTABLE} --stringparam interfaceName ${_name}
258 ${KDEPIMLIBS_DATA_DIR}/akonadi-kde/kcfg2dbus.xsl
260 > ${CMAKE_CURRENT_BINARY_DIR}/${_name}.xml
261 DEPENDS ${KDEPIMLIBS_DATA_DIR}/akonadi-kde/kcfg2dbus.xsl
264 endmacro(kcfg_generate_dbus_interface)
266 ############### Code used in several places ###############
267 # TODO Remove from the top CMakeLists.
269 # used in knotes, kontact/plugins/knotes, wizard
270 set(libknotesresources_SRCS
271 ${CMAKE_SOURCE_DIR}/knotes/resourcemanager.cpp
272 ${CMAKE_SOURCE_DIR}/knotes/resourcenotes.cpp
273 ${CMAKE_SOURCE_DIR}/knotes/resourcelocal.cpp
274 ${CMAKE_SOURCE_DIR}/knotes/resourcelocalconfig.cpp
277 # used in knotes, kontact/plugins/knotes
278 set(libknoteseditor_SRCS
279 ${CMAKE_SOURCE_DIR}/knotes/knoteedit.cpp
282 ############### Now, we add the PIM components ###############
284 include (kleopatra/ConfigureChecks.cmake)
286 # These targets will always be built before anything else.
288 add_subdirectory(ontologies) # must be the first one.
289 add_subdirectory(akonadi_next)
290 add_subdirectory(libkdepim)
291 add_subdirectory(calendarsupport)
292 add_subdirectory(calendarviews)
293 add_subdirectory(incidenceeditor-ng)
294 add_subdirectory(libkdepimdbusinterfaces)
295 add_subdirectory(libkleo)
296 add_subdirectory(libkpgp)
297 add_subdirectory(libksieve)
298 add_subdirectory(kdgantt2)
299 add_subdirectory(icons)
300 add_subdirectory(messagecore)
302 add_subdirectory(messagelist)
304 # We need to compile runtime in kdepim because of the static
305 # linking of korgac and the applications need to link against
306 # plugins like the serializer plugins. If the korgac would
307 # move to runtime this can be avoided
308 add_subdirectory(runtime)
310 add_subdirectory(templateparser)
313 if(Boost_TOPOLOGICAL_SORT_DIR)
314 macro_optional_add_subdirectory(kleopatra)
318 # The following components depend on QGpgME.
319 set(MESSAGEVIEWER_SUPPORTED TRUE)
320 add_subdirectory(messageviewer)
321 macro_optional_add_subdirectory(messagecomposer)
322 add_subdirectory(mailcommon) # TODO: does this make sense?!?
323 add_subdirectory(mailfilteragent)
324 macro_optional_add_subdirectory(kmail)
326 if(KDEPIM_BUILD_MOBILE)
327 add_subdirectory(mobile)
330 if(KDEPIM_BUILD_EXAMPLES)
331 add_subdirectory(examples)
334 # If kmail is compiled, KMAIL_SUPPORTED is true (used in several places)
336 set(KMAIL_SUPPORTED TRUE)
337 add_definitions(-DKMAIL_SUPPORTED)
340 macro_optional_add_subdirectory(korganizer)
341 if(KDEPIM_BUILD_DESKTOP)
342 macro_optional_add_subdirectory(akregator)
343 macro_optional_add_subdirectory(archivemailagent)
344 macro_optional_add_subdirectory(importwizard)
345 macro_optional_add_subdirectory(kaddressbook)
346 macro_optional_add_subdirectory(kmailcvt)
347 macro_optional_add_subdirectory(knotes)
348 macro_optional_add_subdirectory(ksendemail)
349 macro_optional_add_subdirectory(ktnef)
350 macro_optional_add_subdirectory(mailimporter)
351 macro_optional_add_subdirectory(backupmail)
353 if(KDEPIMLIBS_KCAL_LIBRARY)
354 macro_optional_add_subdirectory(blogilo)
358 macro_optional_add_subdirectory(kjots)
361 if(KDEPIMLIBS_KRESOURCES_LIBRARY)
362 macro_optional_add_subdirectory(kalarm)
364 if(QT_QT3SUPPORT_FOUND)
365 macro_optional_add_subdirectory(knode)
369 macro_optional_add_subdirectory(ktimetracker)
373 macro_optional_add_subdirectory(kontact) # must be the last one.
376 macro_optional_add_subdirectory(akonadiconsole)
377 macro_optional_add_subdirectory(console)
378 macro_optional_add_subdirectory(strigi-analyzer)
380 # These targets depend on optional applications
381 if(KDEPIMLIBS_KRESOURCES_LIBRARY)
382 add_subdirectory(kresources) # Must be after KAddressbook
385 add_subdirectory(plugins) # Must be after KMail
389 # doc must be a subdir of kdepim or packagers will kill us
390 macro_optional_add_subdirectory(doc)
393 # We really want to encourage users to enable/install QGpgME from kdepimlibs
395 # Users must be aware that QGpgMe is really needed
396 message(STATUS "*** WARNING: QGpgME is not installed on your system ***")
397 message(STATUS "*** It is required if you want to use KMail, KOrganizer or Kleopatra ***")
398 message(STATUS "*** You are really encouraged to install it ***")
401 # All done, let's display what we found...
402 macro_display_feature_log()