Better wording
[kdepim.git] / CMakeLists.txt
blob3b5301216463dd96c8995a2a983fdf70cc036093
1 project(kdepim)
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_WEBKIT "Do not use WebKit in the kdepim applications" FALSE)
17 if(KDEPIM_BUILD_STATIC)
18   set(LIBRARY_TYPE STATIC)
19 else()
20   set(LIBRARY_TYPE SHARED)
21 endif()
23 add_definitions( -DDISABLE_NEPOMUK_LEGACY )
24 add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
26 if(KDEPIM_NO_WEBKIT)
27   add_definitions(-DKDEPIM_NO_WEBKIT)
28 endif()
30 # cmake would not find kde for xcompile if that is not set
31 if(WINCE)
32     set(KDE4_DATA_DIR "${CMAKE_PREFIX_PATH}/share/apps")
33     set(LIBRARY_TYPE STATIC)
34     add_definitions(-DKDELIBS_STATIC_LIBS)
35     add_definitions(-DKDEPIM_STATIC_LIBS)
36 endif()
38 if(KDEPIM_ENTERPRISE_BUILD)
39   message(STATUS "Enterprise build is enabled.")
40 endif()
42 # if KDEPIM_ONLY_KLEO is defined, KDEPIM_BUILD_MOBILE and KDEPIM_MOBILE_UI are disabled.
43 if(KDEPIM_ONLY_KLEO)
44  set(KDEPIM_BUILD_MOBILE FALSE)
45  set(KDEPIM_MOBILE_UI FALSE)
46  set(KDEPIM_DEFINITIONS "-DHAVE_CONFIG_H=1")
47  message(STATUS "Only libkleo and Kleopatra will be built.")
48 endif()
50 if(KDEPIM_MOBILE_UI)
51     # Build the mobile applications
52     set(KDEPIM_BUILD_MOBILE TRUE)
53 endif()
55 # config-enterprise.h is needed for both ENTERPRISE_BUILD and BUILD_EVERYTHING
56 configure_file(config-enterprise.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-enterprise.h )
58 ############### generate kdepim-version.h ###############
59 # Support for the GIT revision number in kdepim-version.h
60 if(EXISTS "${kdepim_SOURCE_DIR}/.git")
61   find_program(GIT_EXECUTABLE NAMES git)
62   if(GIT_EXECUTABLE)
63     message(STATUS "Found git: ${GIT_EXECUTABLE}")
64     execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
65                     WORKING_DIRECTORY ${kdepim_SOURCE_DIR}
66                     OUTPUT_VARIABLE kdepim_git_revision)
67     string(REGEX REPLACE "\n" "" kdepim_git_revision "${kdepim_git_revision}")
68     set(kdepim_git_revision "git-${kdepim_git_revision}")
70     execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --oneline --format=%ci
71                     WORKING_DIRECTORY ${kdepim_SOURCE_DIR}
72                     OUTPUT_VARIABLE kdepim_git_last_change)
73     string(REGEX REPLACE " [-0-9:+ ]*\n" "" kdepim_git_last_change "${kdepim_git_last_change}")
74   endif()
75 endif()
77 # KDEPIM_VERSION 
78 # Version scheme: "x.y.z build".
80 # x is the version number.
81 # y is the major release number.
82 # z is the minor release number.
84 # "x.y.z" follow the kdelibs version kdepim is released with.
86 # If "z" is 0, it the version is "x.y"
88 # KDEPIM_DEV_VERSION
89 # is empty for final versions. For development versions "build" is
90 # something like "pre", "alpha1", "alpha2", "beta1", "beta2", "rc1", "rc2".
92 # Examples in chronological order:
94 #    3.0
95 #    3.0.1
96 #    3.1 alpha1
97 #    3.1 beta1
98 #    3.1 beta2
99 #    3.1 rc1
100 #    3.1
101 #    3.1.1
102 #    3.2 pre
103 #    3.2 alpha1
105 # Do NOT add quote
106 set(KDEPIM_DEV_VERSION pre)
108 # add an extra space
109 if(DEFINED KDEPIM_DEV_VERSION)
110   set(KDEPIM_DEV_VERSION " ${KDEPIM_DEV_VERSION}")
111 endif()
113 set(KDEPIM_VERSION "4.10${KDEPIM_DEV_VERSION}")
115 configure_file(kdepim-version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/kdepim-version.h @ONLY)
117 ############### search packages used by KDE ###############
119 # It is needed otherwise it finds the kde4-config of the target platform
120 if(WINCE)
121   find_program(KDE4_KDECONFIG_EXECUTABLE NAMES kde4-config PATHS ${HOST_BINDIR} NO_DEFAULT_PATH)
122 endif()
124 find_package(KDE4 4.7.0 REQUIRED)
125 include(KDE4Defaults)
126 include(MacroLibrary)
127 include(CheckIncludeFiles)
128 include(MacroBoolTo01)
129 find_package(KdepimLibs 4.9.57 REQUIRED)
131 ############### Load the CTest options ###############
133 # CMake is irritating and doesn't allow setting the tests timeout globally.
134 # Let's work around this. The global timeout is now 2 minutes.
135 set(_DartConfigFile "${CMAKE_BINARY_DIR}/DartConfiguration.tcl")
136 if(EXISTS ${_DartConfigFile})
137   set(DartTestingTimeout "120")
138   file(READ ${_DartConfigFile} _DartConfigFile_content)
139   string(REGEX REPLACE "TimeOut: 1500" "TimeOut: ${DartTestingTimeout}" _DartConfigFile_content ${_DartConfigFile_content})
140   file(WRITE ${_DartConfigFile} ${_DartConfigFile_content})
141 endif()
143 # CTestCustom.cmake has to be in the CTEST_BINARY_DIR.
144 # in the KDE build system, this is the same as CMAKE_BINARY_DIR.
145 configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR}/CTestCustom.cmake)
147 ############### search Boost ###############
149 find_package(Boost 1.34.0)
150 macro_log_feature(Boost_FOUND "Boost" "Boost C++ Libraries" "http://www.boost.org" TRUE "1.34.0" "Required by several critical KDEPIM apps.")
152 # Kleopatra needs to know if the topological.hpp header exists (part of Boost_graph).
153 find_path(Boost_TOPOLOGICAL_SORT_DIR NAMES boost/graph/topological_sort.hpp PATHS ${Boost_INCLUDE_DIRS})
154 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")
156 ############### Windows specific ###############
158 if(WIN32)
159   # detect oxygen icon dir at configure time based on KDEDIRS - there may be different package installation locations
160   execute_process(COMMAND "${KDE4_KDECONFIG_EXECUTABLE}" --path icon OUTPUT_VARIABLE _dir ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
161   file(TO_CMAKE_PATH "${_dir}" __dir)
162   find_path(KDE4_ICON_DIR oxygen PATHS
163     ${__dir}
164   )
165   message(STATUS "using oxygen application icons from ${KDE4_ICON_DIR}")
166 else()
167     set (KDE4_ICON_DIR  ${CMAKE_INSTALL_PREFIX}/share/icons)
168 endif()
170 ############### ONLY_KLEO ###############
172 # The KDEPIM_ONLY_KLEO option is true
173 if(KDEPIM_ONLY_KLEO)
174   find_package(QGpgme)
175   macro_log_feature(QGPGME_FOUND "QGpgME" "The QGpgME library" "http://www.kde.org" TRUE "" "QGpgME is required to build Kleopatra.")
177   add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS} ${KDEPIM_DEFINITIONS} -DQT3_SUPPORT_WARNINGS)
178   include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} ${KDEPIMLIBS_INCLUDE_DIRS} ${QT_QTDBUS_INCLUDE_DIR} ${NEPOMUK_CORE_INCLUDE_DIR})
179   include(kleopatra/ConfigureChecks.cmake)
181   add_subdirectory(libkleo)
182   if(Boost_TOPOLOGICAL_SORT_DIR)
183     add_subdirectory(kleopatra)
184   endif()
185 else()
187 # Otherwise...
188 ############### Find the stuff we need ###############
189   set(AKONADI_MIN_VERSION 1.8.0)
190   find_package(Akonadi QUIET NO_MODULE ${AKONADI_MIN_VERSION})
191   macro_log_feature(Akonadi_FOUND "Akonadi" "Akonadi server libraries" "http://pim.kde.org/akonadi" TRUE "${AKONADI_MIN_VERSION}" "Akonadi is required to build KDEPIM")
193   find_package(ZLIB)
194   macro_log_feature(ZLIB_FOUND "ZLib" "The Zlib compression library" "http://www.zlib.net" TRUE "" "")
196   find_package(Strigi)
197   macro_log_feature(STRIGI_FOUND "Strigi" "Index metadata of files" "http://strigi.sourceforge.net" TRUE "" "")
199   find_package(QGpgme)
200   macro_log_feature(QGPGME_FOUND "QGpgME" "The QGpgME library" "http://www.kde.org" FALSE "" "QGpgME is required to build KMail, KOrganizer and Kleopatra")
202   set(SDO_MIN_VERSION 0.10)
203   set(SOPRANO_MIN_VERSION 2.7.56)
205   find_package(SharedDesktopOntologies ${SDO_MIN_VERSION})
206   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.")
208   find_package(Soprano)
209   macro_log_feature(Soprano_FOUND "Soprano" "Semantic Desktop Storing" "http://soprano.sourceforge.net" TRUE "${SOPRANO_MIN_VERSION}" "Soprano is needed for Nepomuk")
210   include(SopranoAddOntology)
212   find_package(Grantlee QUIET NO_MODULE)
213   macro_log_feature(Grantlee_FOUND "Grantlee" "The Grantlee Template System" "http://www.gitorious.org/grantlee/pages/Home" FALSE "" "Templating and theming for KJots and KaddressBook." )
215   find_package(Nepomuk)
216   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")
217   find_package(NepomukCore)
218   macro_log_feature(NepomukCore_FOUND "NepomukCore" "The NepomukCore libraries" "http://www.kde.org" TRUE "" "Nepomuk extends the search and tagging functionalities in KMail and Akonadi")
220   find_package(NepomukWidgets)
221   macro_log_feature(NepomukWidgets_FOUND "NepomukWidgets" "The NepomukWidget libraries" "http://www.kde.org" TRUE "" "Nepomuk extends the search and tagging functionalities in AkonadiConsole")
224   find_package(LibXslt)
225   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.")
227 ############### Desktop vs. Mobile options ##############
229   if(KDEPIM_MOBILE_UI)
230     macro_log_feature(QT_QTDECLARATIVE_FOUND "QtDeclarative" "Qt Declarative (QML) module" "http://qt.nokia.com" TRUE "4.7" "Required for building mobile UI")
231     add_definitions( -DKDEPIM_MOBILE_UI )
232   else()
233     macro_log_feature(QT_QTDECLARATIVE_FOUND "QtDeclarative" "Qt Declarative (QML) module" "http://qt.nokia.com" FALSE "4.7" "Required for building the mobile applications")
234     if(NOT QT_QTDECLARATIVE_FOUND)
235       message(STATUS "The Qt Declarative (QML) module was not found. The mobile applications will not be built.")
236       set(KDEPIM_BUILD_MOBILE FALSE)
237     endif()
238   endif()
240 ############### Needed commands before building anything ###############
242   add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS} ${KDEPIM_DEFINITIONS} ${AKONADI_DEFINITIONS})
244   include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDEPIMLIBS_INCLUDE_DIRS} ${KDE4_INCLUDES} ${QT_QTDBUS_INCLUDE_DIR} ${Boost_INCLUDE_DIR})
246   if(NOT KDEPIMLIBS_KRESOURCES_LIBRARY)
247     add_definitions( -DKDEPIM_NO_KRESOURCES )
248   endif()
250 ############### Macros ###############
252   # generates a D-Bus interface description from a KConfigXT file
253   macro(kcfg_generate_dbus_interface _kcfg _name)
254     add_custom_command(
255       OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}.xml
256       COMMAND ${XSLTPROC_EXECUTABLE} --stringparam interfaceName ${_name}
257       ${KDEPIMLIBS_DATA_DIR}/akonadi-kde/kcfg2dbus.xsl
258       ${_kcfg}
259       > ${CMAKE_CURRENT_BINARY_DIR}/${_name}.xml
260       DEPENDS ${KDEPIMLIBS_DATA_DIR}/akonadi-kde/kcfg2dbus.xsl
261       ${_kcfg}
262       )
263   endmacro(kcfg_generate_dbus_interface)
265 ############### Code used in several places ###############
266 # TODO Remove from the top CMakeLists.
268 # used in knotes, kontact/plugins/knotes, wizard
269   set(libknotesresources_SRCS
270     ${CMAKE_SOURCE_DIR}/knotes/resourcemanager.cpp
271     ${CMAKE_SOURCE_DIR}/knotes/resourcenotes.cpp
272     ${CMAKE_SOURCE_DIR}/knotes/resourcelocal.cpp
273     ${CMAKE_SOURCE_DIR}/knotes/resourcelocalconfig.cpp
274   )
276 # used in knotes, kontact/plugins/knotes
277   set(libknoteseditor_SRCS
278     ${CMAKE_SOURCE_DIR}/knotes/knoteedit.cpp
279   )
281 ############### Now, we add the PIM components ###############
283   include (kleopatra/ConfigureChecks.cmake)
285   # These targets will always be built before anything else.
287   add_subdirectory(ontologies) # must be the first one.
288   add_subdirectory(akonadi_next)
289   add_subdirectory(libkdepim)
290   add_subdirectory(calendarsupport)
291   add_subdirectory(calendarviews)
292   add_subdirectory(incidenceeditor-ng)
293   add_subdirectory(libkdepimdbusinterfaces)
294   add_subdirectory(libkleo)
295   add_subdirectory(libkpgp)
296   add_subdirectory(libksieve)
297   add_subdirectory(kdgantt2)
298   add_subdirectory(icons)
299   add_subdirectory(messagecore)
300   if(NOT WINCE)
301     add_subdirectory(messagelist)
302   else()
303     # We need to compile runtime in kdepim because of the static
304     # linking of korgac and the applications need to link against
305     # plugins like the serializer plugins. If the korgac would
306     # move to runtime this can be avoided
307     add_subdirectory(runtime)
308   endif()
309   add_subdirectory(templateparser)
311   if(QGPGME_FOUND)
312     if(Boost_TOPOLOGICAL_SORT_DIR)
313       macro_optional_add_subdirectory(kleopatra)
314     endif()
315   endif()
317   # The following components depend on QGpgME.
318   set(MESSAGEVIEWER_SUPPORTED TRUE)
319   add_subdirectory(messageviewer)
320   macro_optional_add_subdirectory(messagecomposer)
321   add_subdirectory(mailcommon) # TODO: does this make sense?!?
322   add_subdirectory(mailfilteragent)
323   macro_optional_add_subdirectory(kmail)
325   if(KDEPIM_BUILD_MOBILE)
326     add_subdirectory(mobile)
327   endif()
329   if(KDEPIM_BUILD_EXAMPLES)
330     add_subdirectory(examples)
331   endif()
333   # If kmail is compiled, KMAIL_SUPPORTED is true (used in several places)
334   if(BUILD_kmail)
335     set(KMAIL_SUPPORTED TRUE)
336     add_definitions(-DKMAIL_SUPPORTED)
337   endif()
339   macro_optional_add_subdirectory(korganizer)
340   if(KDEPIM_BUILD_DESKTOP)
341     macro_optional_add_subdirectory(akregator)
342     macro_optional_add_subdirectory(archivemailagent)
343     macro_optional_add_subdirectory(importwizard)
344     macro_optional_add_subdirectory(kaddressbook)
345     macro_optional_add_subdirectory(kmailcvt)
346     macro_optional_add_subdirectory(knotes)
347     macro_optional_add_subdirectory(ksendemail)
348     macro_optional_add_subdirectory(ktnef)
349     macro_optional_add_subdirectory(mailimporter)
350     macro_optional_add_subdirectory(backupmail)
351     macro_optional_add_subdirectory(kalarm)
353     if(KDEPIMLIBS_KCAL_LIBRARY)
354       macro_optional_add_subdirectory(blogilo)
355     endif()
357     if(Grantlee_FOUND)
358       macro_optional_add_subdirectory(kjots)
359     endif()
361     if(KDEPIMLIBS_KRESOURCES_LIBRARY)
362       if(QT_QT3SUPPORT_FOUND)
363         macro_optional_add_subdirectory(knode)
364       endif()
366       if(Q_WS_X11)
367         macro_optional_add_subdirectory(ktimetracker)
368       endif()
370     endif()
371     macro_optional_add_subdirectory(kontact) # must be the last one.
372   endif()
374   macro_optional_add_subdirectory(akonadiconsole)
375   macro_optional_add_subdirectory(console)
376   macro_optional_add_subdirectory(strigi-analyzer)
378   # These targets depend on optional applications
379   if(KDEPIMLIBS_KRESOURCES_LIBRARY)
380     add_subdirectory(kresources) # Must be after KAddressbook
381   endif()
383   add_subdirectory(plugins) # Must be after KMail
385 endif()
387 # doc must be a subdir of kdepim or packagers will kill us
388 macro_optional_add_subdirectory(doc)
391 # We really want to encourage users to enable/install QGpgME from kdepimlibs
392 if(NOT QGPGME_FOUND)
393   # Users must be aware that QGpgMe is really needed
394   message(STATUS "*** WARNING: QGpgME is not installed on your system ***")
395   message(STATUS "*** It is required if you want to use KMail, KOrganizer or Kleopatra ***")
396   message(STATUS "*** You are really encouraged to install it ***")
397 endif()
399 # All done, let's display what we found...
400 macro_display_feature_log()