Updated the Tools menu to reflect current build.
[kdepim.git] / CMakeLists.txt
blobe6cd732ef5b924b91c6d70dab1e0f396034a17dc
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_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." FALSE)
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_package(Git)
62   if(GIT_FOUND)
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, the version is "x.y"
88 # KDEPIM_DEV_VERSION is empty for final versions.
89 # For development versions "build" is something like "pre", "alpha1", "alpha2", "beta1", "beta2", "rc1", "rc2".
91 # Examples in chronological order:
92 # 3.0, 3.0.1, 3.1 alpha1, 3.1 beta1, 3.1 beta2, 3.1 rc1, 3.1, 3.1.1, 3.2 pre, 3.2 alpha1
94 # Do NOT add quote
95 set(KDEPIM_DEV_VERSION)
97 # add an extra space
98 if(DEFINED KDEPIM_DEV_VERSION)
99   set(KDEPIM_DEV_VERSION " ${KDEPIM_DEV_VERSION}")
100 endif()
102 set(KDEPIM_VERSION "4.11${KDEPIM_DEV_VERSION}")
104 configure_file(kdepim-version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/kdepim-version.h @ONLY)
106 ############### search packages used by KDE ###############
108 # It is needed otherwise it finds the kde4-config of the target platform
109 if(WINCE)
110   find_program(KDE4_KDECONFIG_EXECUTABLE NAMES kde4-config PATHS ${HOST_BINDIR} NO_DEFAULT_PATH)
111 endif()
113 find_package(KDE4 4.10 REQUIRED)
114 include(KDE4Defaults)
116 find_package(KdepimLibs 4.11.0)
117 set_package_properties(KdepimLibs PROPERTIES DESCRIPTION "The KDEPIM libraries" URL "http://www.kde.org" TYPE REQUIRED)
119 ############### Load the CTest options ###############
121 # CMake is irritating and doesn't allow setting the tests timeout globally.
122 # Let's work around this. The global timeout is now 2 minutes.
123 set(_DartConfigFile "${CMAKE_BINARY_DIR}/DartConfiguration.tcl")
124 if(EXISTS ${_DartConfigFile})
125   set(DartTestingTimeout "120")
126   file(READ ${_DartConfigFile} _DartConfigFile_content)
127   string(REGEX REPLACE "TimeOut: 1500" "TimeOut: ${DartTestingTimeout}" _DartConfigFile_content ${_DartConfigFile_content})
128   file(WRITE ${_DartConfigFile} ${_DartConfigFile_content})
129 endif()
131 # CTestCustom.cmake has to be in the CTEST_BINARY_DIR.
132 # in the KDE build system, this is the same as CMAKE_BINARY_DIR.
133 configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR}/CTestCustom.cmake)
135 ############### search Boost ###############
137 find_package(Boost 1.34.0)
138 set_package_properties(Boost PROPERTIES DESCRIPTION "Boost C++ Libraries" URL "http://www.boost.org" TYPE REQUIRED PURPOSE "Boost is required for building most KDEPIM applications")
140 # Kleopatra needs to know if the topological.hpp header exists (part of Boost_graph).
141 find_path(Boost_TOPOLOGICAL_SORT_DIR NAMES boost/graph/topological_sort.hpp PATHS ${Boost_INCLUDE_DIRS})
142 if(Boost_TOPOLOGICAL_SORT_DIR)
143   message(STATUS "The Boost Topological_sort header was found. Building Kleopatra")
144 else()
145   message(STATUS "The Boost Topological_sort header was NOT found. Kleopatra will not be built")
146 endif()
148 ############### Windows specific ###############
150 if(WIN32)
151   # detect oxygen icon dir at configure time based on KDEDIRS - there may be different package installation locations
152   execute_process(COMMAND "${KDE4_KDECONFIG_EXECUTABLE}" --path icon OUTPUT_VARIABLE _dir ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
153   file(TO_CMAKE_PATH "${_dir}" __dir)
154   find_path(KDE4_ICON_DIR oxygen PATHS
155     ${__dir}
156   )
157   message(STATUS "using oxygen application icons from ${KDE4_ICON_DIR}")
158 else()
159     set (KDE4_ICON_DIR  ${CMAKE_INSTALL_PREFIX}/share/icons)
160 endif()
162 ############### ONLY_KLEO ###############
164 # If the KDEPIM_ONLY_KLEO option is true
165 if(KDEPIM_ONLY_KLEO)
166   find_package(QGpgme)
167   set_package_properties(QGpgme PROPERTIES DESCRIPTION "The QGpgME library" URL "http://www.kde.org" TYPE REQUIRED PURPOSE "QGpgME is required to build Kleopatra.")
169   add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS} ${KDEPIM_DEFINITIONS} -DQT3_SUPPORT_WARNINGS)
170   include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} ${KDEPIMLIBS_INCLUDE_DIRS} ${QT_QTDBUS_INCLUDE_DIR})
171   include(kleopatra/ConfigureChecks.cmake)
173   add_subdirectory(libkleo)
174   if(Boost_TOPOLOGICAL_SORT_DIR)
175     add_subdirectory(kleopatra)
176   endif()
177 else()
179 # Otherwise...
180 ############### Find the stuff we need ###############
181   # Akonadi
182   find_package(Akonadi 1.9.51 QUIET CONFIG)
183   set_package_properties(Akonadi PROPERTIES DESCRIPTION "Akonadi server libraries" URL "http://pim.kde.org/akonadi" TYPE REQUIRED PURPOSE "Akonadi is required to build KDEPIM")
185   find_package(ZLIB)
186   set_package_properties(ZLIB PROPERTIES DESCRIPTION "The Zlib compression library" URL "http://www.zlib.net" TYPE REQUIRED)
188   # Strigi is required only if AKONADI_USE_STRIGI_SEARCH is true in AkonadiConfig.cmake
189   if(AKONADI_USE_STRIGI_SEARCH)
190     find_package(Strigi)
191     set_package_properties(Strigi PROPERTIES URL "https://projects.kde.org/strigi" TYPE REQUIRED PURPOSE "Metadata indexing")
192   endif()
194   find_package(QGpgme)
195   set_package_properties(QGpgme PROPERTIES DESCRIPTION "The QGpgMe library" URL "http://www.kde.org" TYPE RECOMMENDED PURPOSE "QGpgME is required to build KMail, KOrganizer and Kleopatra")
197   find_package(SharedDesktopOntologies 0.11)
198   set_package_properties(SharedDesktopOntologies PROPERTIES DESCRIPTION "Shared Desktop Ontologies" URL "http://sourceforge.net/projects/oscaf/" TYPE REQUIRED PURPOSE "Ontologies necessary for the Nepomuk semantic desktop")
200   find_package(Soprano 2.9.0)
201   set_package_properties(Soprano PROPERTIES DESCRIPTION "C++/Qt4 framework for RDF data" URL "http://soprano.sourceforge.net" TYPE REQUIRED PURPOSE "Storage of semantic data")
202   include(SopranoAddOntology)
204   find_package(Grantlee 0.3.0 QUIET CONFIG)
205   set_package_properties(Grantlee PROPERTIES DESCRIPTION "The Grantlee Template System" URL "http://www.gitorious.org/grantlee/pages/Home" TYPE REQUIRED PURPOSE "Grantlee is requires for kmail and templating, theming for KJots, KaddressBook and MessageViewer(KMail)." )
207   find_package(NepomukCore QUIET CONFIG)
208   set_package_properties(NepomukCore PROPERTIES DESCRIPTION "The Nepomuk Core libraries" URL "http://www.kde.org" TYPE REQUIRED PURPOSE "Nepomuk extends the search and tagging functionalities in KMail and Akonadi")
210   find_package(NepomukWidgets QUIET CONFIG)
211   set_package_properties(NepomukWidgets PROPERTIES DESCRIPTION "The NepomukWidget libraries" URL "http://www.kde.org" TYPE RECOMMENDED PURPOSE "Nepomuk-widgets is needed for building Akonadiconsole")
213   # Xsltproc
214   find_package(Xsltproc)
215   set_package_properties(Xsltproc PROPERTIES DESCRIPTION "XSLT processor from libxslt" TYPE REQUIRED PURPOSE "Required to generate D-Bus interfaces.")
217 ############### Desktop vs. Mobile options ##############
219   if(KDEPIM_MOBILE_UI)
220     add_definitions( -DKDEPIM_MOBILE_UI )
221     if(NOT QT_QTDECLARATIVE_FOUND)
222       message(FATAL_ERROR "The QtDeclarative (QML) module is required for building the mobile UI")
223     endif()
224   else()
225     if(NOT QT_QTDECLARATIVE_FOUND)
226       message(STATUS "The Qt Declarative (QML) module was not found. The mobile applications will not be built.")
227       set(KDEPIM_BUILD_MOBILE FALSE)
228     endif()
229   endif()
231 ############### Needed commands before building anything ###############
233   add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS} ${KDEPIM_DEFINITIONS} ${AKONADI_DEFINITIONS})
235   include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDEPIMLIBS_INCLUDE_DIRS} ${KDE4_INCLUDES} ${QT_QTDBUS_INCLUDE_DIR} ${Boost_INCLUDE_DIR})
237   if(NOT KDEPIMLIBS_KRESOURCES_LIBRARY)
238     add_definitions( -DKDEPIM_NO_KRESOURCES )
239   endif()
241 ############### Code used in several places ###############
242 # TODO Remove from the top CMakeLists.
244 # used in knotes, kontact/plugins/knotes, wizard
245   set(libknotesresources_SRCS
246     ${CMAKE_SOURCE_DIR}/knotes/resourcemanager.cpp
247     ${CMAKE_SOURCE_DIR}/knotes/resourcenotes.cpp
248     ${CMAKE_SOURCE_DIR}/knotes/resourcelocal.cpp
249     ${CMAKE_SOURCE_DIR}/knotes/resourcelocalconfig.cpp
250   )
252 # used in knotes, kontact/plugins/knotes
253   set(libknoteseditor_SRCS
254     ${CMAKE_SOURCE_DIR}/knotes/knoteedit.cpp
255   )
257 ############### Now, we add the PIM components ###############
259   include (kleopatra/ConfigureChecks.cmake)
261   # These targets will always be built before anything else.
263   add_subdirectory(ontologies) # must be the first one.
264   add_subdirectory(akonadi_next)
265   add_subdirectory(libkdepim)
266   add_subdirectory(calendarsupport)
267   add_subdirectory(calendarviews)
268   add_subdirectory(incidenceeditor-ng)
269   add_subdirectory(libkdepimdbusinterfaces)
270   add_subdirectory(libkleo)
271   add_subdirectory(libkpgp)
272   add_subdirectory(libksieve)
273   add_subdirectory(kdgantt2)
274   add_subdirectory(icons)
275   add_subdirectory(composereditor-ng)
276   add_subdirectory(grammar)
277   add_subdirectory(messagecore)
278   if(NOT WINCE)
279     add_subdirectory(messagelist)
280   else()
281     # We need to compile runtime in kdepim because of the static
282     # linking of korgac and the applications need to link against
283     # plugins like the serializer plugins. If the korgac would
284     # move to runtime this can be avoided
285     add_subdirectory(runtime)
286   endif()
287   add_subdirectory(templateparser)
289   if(QGPGME_FOUND)
290     if(Boost_TOPOLOGICAL_SORT_DIR)
291       macro_optional_add_subdirectory(kleopatra)
292     endif()
293   endif()
295   # The following components depend on QGpgME.
296   set(MESSAGEVIEWER_SUPPORTED TRUE)
297   add_subdirectory(messageviewer)
298   macro_optional_add_subdirectory(messagecomposer)
299   add_subdirectory(pimcommon)
300   add_subdirectory(mailcommon) # TODO: does this make sense?!?
301   add_subdirectory(mailfilteragent)
302   macro_optional_add_subdirectory(kmail)
303   macro_optional_add_subdirectory(headerthemeeditor)
305   if(KDEPIM_BUILD_MOBILE)
306     add_subdirectory(mobile)
307   endif()
309   if(KDEPIM_BUILD_EXAMPLES)
310     add_subdirectory(examples)
311   endif()
313   # If kmail is compiled, KMAIL_SUPPORTED is true (used in several places)
314   if(BUILD_kmail)
315     set(KMAIL_SUPPORTED TRUE)
316     add_definitions(-DKMAIL_SUPPORTED)
317   endif()
319   macro_optional_add_subdirectory(pimactivity)
320   macro_optional_add_subdirectory(korganizer)
321   if(KDEPIM_BUILD_DESKTOP)
322     macro_optional_add_subdirectory(akregator)
323     macro_optional_add_subdirectory(archivemailagent)
324     macro_optional_add_subdirectory(sendlateragent)
325     macro_optional_add_subdirectory(importwizard)
326     macro_optional_add_subdirectory(kaddressbook)
327     macro_optional_add_subdirectory(kmailcvt)
328     macro_optional_add_subdirectory(knotes)
329     macro_optional_add_subdirectory(ksendemail)
330     macro_optional_add_subdirectory(ktnef)
331     macro_optional_add_subdirectory(mailimporter)
332     macro_optional_add_subdirectory(pimsettingexporter)
333     macro_optional_add_subdirectory(kalarm)
335     if(KDEPIMLIBS_KCAL_LIBRARY)
336       macro_optional_add_subdirectory(blogilo)
337     endif()
339     macro_optional_add_subdirectory(kjots)
341     if(KDEPIMLIBS_KRESOURCES_LIBRARY)
342       if(QT_QT3SUPPORT_FOUND)
343         macro_optional_add_subdirectory(knode)
344       endif()
346       if(Q_WS_X11)
347         macro_optional_add_subdirectory(ktimetracker)
348       endif()
350     endif()
351     macro_optional_add_subdirectory(kontact) # must be the last one.
352   endif()
354   if(NepomukWidgets_FOUND)
355     macro_optional_add_subdirectory(akonadiconsole)
356   endif()
357   macro_optional_add_subdirectory(console)
358   if(Strigi_FOUND)
359     macro_optional_add_subdirectory(strigi-analyzer)
360   endif()
362   # These targets depend on optional applications
363   if(KDEPIMLIBS_KRESOURCES_LIBRARY)
364     add_subdirectory(kresources) # Must be after KAddressbook
365   endif()
367   add_subdirectory(plugins) # Must be after KMail
369 endif()
371 # doc must be a subdir of kdepim or packagers will kill us
372 macro_optional_add_subdirectory(doc)
374 # All done, let's display what we found...
375 feature_summary(WHAT ALL
376                      INCLUDE_QUIET_PACKAGES
377                      FATAL_ON_MISSING_REQUIRED_PACKAGES
378                )