Correct build when nss/nspr do not provide pkg-config files
[evolution.git] / CMakeLists.txt
blob9eedd4d96b98501dfcc184b191fcb884ef1f53ff
1 # Evolution build script
3 cmake_minimum_required(VERSION 3.1)
4 cmake_policy(VERSION 3.1)
6 project(evolution
7         VERSION 3.29.92
8         LANGUAGES C)
9 set(PROJECT_BUGREPORT "https://gitlab.gnome.org/GNOME/evolution/issues/")
10 set(PROJECT_URL "http://wiki.gnome.org/Apps/Evolution/")
12 # Base Version: This is for API/version tracking for things like
13 # D-Bus server files. This should always be the major/minor of
14 # the stable version or stable version to be.
15 set(BASE_VERSION 3.30)
17 # Used for pkg-config files
18 set(INTERFACE_VERSION 3.0)
20 math(EXPR _is_devel_version "${PROJECT_VERSION_MINOR}%2")
21 if(_is_devel_version EQUAL 1)
22         math(EXPR _minor "${PROJECT_VERSION_MINOR}-1")
23         if(_minor EQUAL -1)
24                 set(_minor 98)
25                 math(EXPR _major "${PROJECT_VERSION_MAJOR}-1")
26         else(_minor EQUAL -1)
27                 set(_major ${PROJECT_VERSION_MAJOR})
28         endif(_minor EQUAL -1)
30         set(STABLE_VERSION "${_major}.${_minor}")
31 else(_is_devel_version EQUAL 1)
32         unset(STABLE_VERSION)
33 endif(_is_devel_version EQUAL 1)
35 # Required for FindIntltool module
36 set(GETTEXT_PACKAGE ${PROJECT_NAME})
37 set(GETTEXT_PO_DIR ${CMAKE_SOURCE_DIR}/po)
39 # Required for 'disttest' and 'ditcheck' of DistTarget module
40 set(PROJECT_DISTCONFIGURE_PARAMS
41         -DENABLE_GTK_DOC=ON
42         -DENABLE_CONTACT_MAPS=ON
43         -DENABLE_INSTALLED_TESTS=ON
44         -DWITH_HELP=ON
45         -DWITH_GLADE_CATALOG=ON
48 # Keep these two definitions in agreement.
49 set(glib_minimum_version 2.46)
50 set(glib_encoded_version GLIB_VERSION_2_46)
52 # Keep these two definitions in agreement.
53 set(gdk_minimum_version 3.22)
54 set(gdk_encoded_version GDK_VERSION_3_22)
56 # Keep these two definitions in agreement.
57 set(soup_minimum_version 2.42)
58 set(soup_encoded_version SOUP_VERSION_2_42)
60 # Warn about API usage that violates our minimum requirements.
61 add_definitions(-DGLIB_VERSION_MAX_ALLOWED=${glib_encoded_version})
62 add_definitions(-DGDK_VERSION_MAX_ALLOWED=${gdk_encoded_version})
63 add_definitions(-DSOUP_VERSION_MAX_ALLOWED=${soup_encoded_version})
65 # These will suppress warnings about newly-deprecated symbols. Ideally
66 # these settings should match our minimum requirements and we will clean
67 # up any new deprecation warnings after bumping our minimum requirements.
68 # But if the warnings get to be overwhelming, use fixed versions instead.
69 add_definitions(-DGLIB_VERSION_MIN_REQUIRED=${glib_encoded_version})
70 add_definitions(-DGDK_VERSION_MIN_REQUIRED=${gdk_encoded_version})
71 add_definitions(-DSOUP_VERSION_MIN_REQUIRED=${soup_encoded_version})
73 set(eds_minimum_version ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
74 set(enchant1_minimum_version 1.6.0)
75 set(enchant2_minimum_version 2.2.0)
76 set(gcr_minimum_version 3.4)
77 set(gdk_pixbuf_minimum_version 2.24.0)
78 set(gnome_desktop_minimum_version 2.91.3)
79 set(gsettings_desktop_schemas_minimum_version 2.91.92)
80 set(libpst_minimum_version 0.6.54)
81 set(libxml_minimum_version 2.7.3)
82 set(shared_mime_info_minimum_version 0.22)
83 set(webkit2gtk_minimum_version 2.16.0)
85 # Optional Packages
86 set(champlain_minimum_version 0.12)
87 set(clutter_gtk_minimum_version 0.90)
88 set(geocode_glib_minimum_version 3.10)
89 set(gladeui_minimum_version 3.10.0)
90 set(gnome_autoar_minimum_version 0.1.1)
91 set(gweather_minimum_version 3.10)
92 set(libcanberra_gtk_minimum_version 0.25)
93 set(libnotify_minimum_version 0.7)
94 set(libunity_minimum_version 7.1.4)
96 # Load modules from the source tree
97 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
99 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
100 # Packagers might want to need different settings for the RPATH related things
101 # From experience, especially CMAKE_BUILD_WITH_INSTALL_RPATH might need to be
102 # switched to ON, if CMake fails to set the right values during make install
103 set(CMAKE_SKIP_RPATH OFF CACHE BOOL INTERNAL)
104 set(CMAKE_SKIP_BUILD_RPATH OFF CACHE BOOL INTERNAL)
105 set(CMAKE_BUILD_WITH_INSTALL_RPATH OFF CACHE BOOL INTERNAL)
106 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON CACHE BOOL INTERNAL)
107 # CMAKE_INSTALL_RPATH is set below
109 # CMake modules
110 include(CheckCCompilerFlag)
111 include(CheckCSourceCompiles)
112 include(CheckCSourceRuns)
113 include(CheckFunctionExists)
114 include(CheckIncludeFile)
115 include(CheckLibraryExists)
117 # Project custom modules
118 include(PrintableOptions)
120 add_printable_variable(LIB_SUFFIX "Library directory suffix, usually defined to '64' for x86_64 systems" "")
121 add_printable_variable_bare(CMAKE_INSTALL_PREFIX)
122 add_printable_variable_path(BIN_INSTALL_DIR "Install directory for binary files, defaults to CMAKE_INSTALL_PREFIX/bin" "")
123 add_printable_variable_path(INCLUDE_INSTALL_DIR "Install directory for header files, defaults to CMAKE_INSTALL_PREFIX/include" "")
124 add_printable_variable_path(LIB_INSTALL_DIR "Install directory for library files, defaults to CMAKE_INSTALL_PREFIX/lib{LIB_SUFFIX}" "")
125 add_printable_variable_path(LIBEXEC_INSTALL_DIR "Install directory for library executable files, defaults to CMAKE_INSTALL_PREFIX/libexec" "")
126 add_printable_variable_path(SHARE_INSTALL_PREFIX "Install directory for shared files, defaults to CMAKE_INSTALL_PREFIX/share" "")
127 add_printable_variable_path(LOCALE_INSTALL_DIR "Install directory for locale files, defaults to SHARE_INSTALL_PREFIX/locale" "")
128 add_printable_variable_path(SYSCONF_INSTALL_DIR "Install directory for system configuration files, defaults to CMAKE_INSTALL_PREFIX/etc" "")
130 macro(ensure_default_value _var _defvalue)
131         if(${_var} STREQUAL "")
132                 set(${_var} ${_defvalue})
133         endif(${_var} STREQUAL "")
134 endmacro(ensure_default_value)
136 ensure_default_value(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin")
137 ensure_default_value(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include")
138 ensure_default_value(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
139 ensure_default_value(LIBEXEC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/libexec")
140 ensure_default_value(SHARE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/share")
141 ensure_default_value(LOCALE_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/locale")
142 ensure_default_value(SYSCONF_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/etc")
144 # ******************************
145 # Special directories
146 # ******************************
148 # If you add something here, consider whether or not you also
149 # need to add it to one or more .pc.in files (for Connector, etc)
151 set(privdatadir "${SHARE_INSTALL_PREFIX}/${PROJECT_NAME}")
152 set(privincludedir "${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}")
153 set(privlibdir "${LIB_INSTALL_DIR}/${PROJECT_NAME}")
154 set(privlibexecdir "${LIBEXEC_INSTALL_DIR}/${PROJECT_NAME}")
156 SET(CMAKE_INSTALL_RPATH "${privlibdir}")
158 if(WIN32)
159         # On Win32 there is no "rpath" mechanism. We install the private
160         # shared libraries in $libdir, meaning the DLLs will actually be in
161         # $bindir. This means just having $bindir in PATH will be enough.
162         set(privsolibdir "${LIB_INSTALL_DIR}")
163 else(WIN32)
164         set(privsolibdir "${privlibdir}")
165 endif(WIN32)
167 set(errordir "${privdatadir}/errors")
168 set(etspecdir "${privdatadir}/etspec")
169 set(evolutionhelpdir "${privdatadir}/help")
170 set(icondir "${privdatadir}/icons")
171 set(imagesdir "${privdatadir}/images")
172 set(moduledir "${privlibdir}/modules")
173 set(plugindir "${privlibdir}/plugins")
174 set(soundsdir "${privdatadir}/sounds")
175 set(uidir "${privdatadir}/ui")
176 set(viewsdir "${privdatadir}/views")
177 set(webextensionsdir "${privlibdir}/web-extensions")
178 set(webextensionswebkiteditordir "${webextensionsdir}/webkit-editor")
180 # ******************************
181 # Dependencies
182 # ******************************
184 include(CodeCoverageGCOV)
185 include(CheckTarget)
186 include(DistTargets)
187 include(EvolutionMacros)
188 include(GLibTools)
189 include(GtkDoc)
190 include(IconCache)
191 include(InstalledTests)
192 include(PkgConfigEx)
193 include(SetupBuildFlags)
194 include(UninstallTarget)
196 include(FindIntltool)
197 include(FindLDAP)
198 include(FindSMIME)
200 add_printable_option(ENABLE_MAINTAINER_MODE "Enable maintainer mode" OFF)
201 add_printable_variable(VERSION_SUBSTRING "Version substring, for packagers" "")
202 add_printable_variable(VERSION_COMMENT "Define if you want a comment appended to the version number" "")
204 if(ENABLE_MAINTAINER_MODE)
205         set(BUILD_TESTING ON)
206 endif(ENABLE_MAINTAINER_MODE)
208 # Setup compiler/linker flags
209 setup_build_flags(${ENABLE_MAINTAINER_MODE})
211 set(MATH_LDFLAGS -lm)
213 CHECK_INCLUDE_FILE(sys/wait.h HAVE_SYS_WAIT_H)
214 CHECK_INCLUDE_FILE(X11/XF86keysym.h HAVE_XFREE)
215 CHECK_FUNCTION_EXISTS(mkdtemp HAVE_MKDTEMP)
216 CHECK_FUNCTION_EXISTS(nl_langinfo HAVE_NL_LANGINFO)
218 # ******************************
219 # executables
220 # ******************************
222 find_program(KILL_PROCESS_COMMAND killall)
223 if(NOT KILL_PROCESS_COMMAND)
224         find_program(KILL_PROCESS_COMMAND pkill)
225         set(KILL_PROCESS_COMMAND_ARGS "-f")
226         set(KILL_PROCESS_COMMAND_ARG_EXACT "-x")
227 else(NOT KILL_PROCESS_COMMAND)
228         set(KILL_PROCESS_COMMAND_ARGS "")
229         set(KILL_PROCESS_COMMAND_ARG_EXACT "-e")
230 endif(NOT KILL_PROCESS_COMMAND)
232 if(NOT KILL_PROCESS_COMMAND)
233         message(WARNING "Could not find a command to kill a process by name")
234 endif(NOT KILL_PROCESS_COMMAND)
236 # ******************************
237 # Check for nl_langinfo features
238 # ******************************
240 CHECK_C_SOURCE_COMPILES("#include <langinfo.h>
241                         int main(void) { char *detail = nl_langinfo (_NL_MEASUREMENT_MEASUREMENT); return 0; }" HAVE__NL_MEASUREMENT_MEASUREMENT)
243 # ******************************
244 # Dependencies
245 # ******************************
247 if(WIN32)
248         set(GIO_UNIX_REQUIREMENT "gio-windows-2.0")
249 else(WIN32)
250         set(GIO_UNIX_REQUIREMENT "gio-unix-2.0")
251 endif(WIN32)
253 add_printable_option(ENABLE_GNOME_DESKTOP "Enable GNOME desktop dependency for thumbnails" ON)
255 if(ENABLE_GNOME_DESKTOP)
256         set(GNOME_DESKTOP_DEPENDENCY "gnome-desktop-3.0")
257         set(HAVE_GNOME_DESKTOP ON)
259         # It's checked for it twice, this one gives a hint to disable the dependency if not found
260         pkg_check_modules_for_option(ENABLE_GNOME_DESKTOP "GNOME desktop dependency for thumbnails" GNOME_DESKTOP ${GNOME_DESKTOP_DEPENDENCY}>=${gnome_desktop_minimum_version})
261 else(ENABLE_GNOME_DESKTOP)
262         set(GNOME_DESKTOP_DEPENDENCY "")
263         set(HAVE_GNOME_DESKTOP OFF)
264 endif(ENABLE_GNOME_DESKTOP)
266 pkg_check_modules(GNOME_PLATFORM REQUIRED
267         cairo-gobject
268         gail-3.0>=${gdk_minimum_version}
269         gcr-3>=${gcr_minimum_version}
270         gdk-pixbuf-2.0>=${gdk_pixbuf_minimum_version}
271         gio-2.0>=${glib_minimum_version}
272         ${GIO_UNIX_REQUIREMENT}
273         gmodule-2.0>=${glib_minimum_version}
274         ${GNOME_DESKTOP_DEPENDENCY}
275         gsettings-desktop-schemas>=${gsettings_desktop_schemas_minimum_version}
276         gtk+-3.0>=${gdk_minimum_version}
277         libxml-2.0>=${libxml_minimum_version}
278         shared-mime-info>=${shared_mime_info_minimum_version}
279         webkit2gtk-4.0>=${webkit2gtk_minimum_version}
282 pkg_check_modules(EVOLUTION_DATA_SERVER REQUIRED
283         camel-1.2>=${eds_minimum_version}
284         libebook-1.2>=${eds_minimum_version}
285         libecal-1.2>=${eds_minimum_version}
286         libedataserver-1.2>=${eds_minimum_version}
287         libedataserverui-1.2>=${eds_minimum_version}
288         libebackend-1.2>=${eds_minimum_version}
291 pkg_check_modules(A11Y REQUIRED atk)
292 pkg_check_modules(LIBSOUP REQUIRED libsoup-2.4>=${soup_minimum_version})
293 pkg_check_modules(WEB_EXTENSION REQUIRED webkit2gtk-4.0>=${webkit2gtk_minimum_version})
295 # ******************************
296 # Enchant - support both, but better to use the same as the dependencies (gtkspell3, webkitgtk+,...)
297 # ******************************
299 add_printable_option(WITH_ENCHANT_VERSION "Set Enchant version to use, values are: 'auto' (default), 1 or 2" "auto")
301 if(WITH_ENCHANT_VERSION STREQUAL "1")
302         pkg_check_modules(ENCHANT REQUIRED enchant>=${enchant1_minimum_version})
303 else(WITH_ENCHANT_VERSION STREQUAL "1")
304         if(WITH_ENCHANT_VERSION STREQUAL "2")
305                 pkg_check_modules(ENCHANT REQUIRED enchant-2>=${enchant2_minimum_version})
306         else(WITH_ENCHANT_VERSION STREQUAL "2")
307                 pkg_check_modules(ENCHANT enchant>=${enchant1_minimum_version})
308                 if(ENCHANT_FOUND)
309                         set(WITH_ENCHANT_VERSION "auto (enchant-1)")
310                 else(ENCHANT_FOUND)
311                         unset(ENCHANT_FOUND)
312                         pkg_check_modules(ENCHANT enchant-2>=${enchant2_minimum_version})
313                         if(ENCHANT_FOUND)
314                                 set(WITH_ENCHANT_VERSION "auto (enchant-2)")
315                         else(ENCHANT_FOUND)
316                                 message(FATAL_ERROR "Cannot find enchant 1 neither enchant 2, or new-enough version. Install either of them "
317                                                     "or specify which to use with -DWITH_ENCHANT_VERSION=auto|1|2, where 'auto' is the default")
318                         endif(ENCHANT_FOUND)
319                 endif(ENCHANT_FOUND)
320         endif(WITH_ENCHANT_VERSION STREQUAL "2")
321 endif(WITH_ENCHANT_VERSION STREQUAL "1")
323 # ******************************
324 # Canberra / Canberra-GTK Sound
325 # ******************************
327 add_printable_option(ENABLE_CANBERRA "Enable Canberra and Canberra-GTK sound" ON)
329 if(ENABLE_CANBERRA)
330         pkg_check_modules_for_option(ENABLE_CANBERRA "Canberra and Canberra-GTK sound" CANBERRA libcanberra-gtk3>=${libcanberra_gtk_minimum_version})
331         set(HAVE_CANBERRA ON)
332 endif(ENABLE_CANBERRA)
334 # ******************************
335 # Archives Integration / gnome-autoar
336 # ******************************
338 add_printable_option(ENABLE_AUTOAR "Enable archives support in attachments" ON)
340 if(ENABLE_AUTOAR)
341         pkg_check_modules_for_option(ENABLE_AUTOAR "archives support in attachments" AUTOAR
342                 gnome-autoar-0>=${gnome_autoar_minimum_version}
343                 gnome-autoar-gtk-0>=${gnome_autoar_minimum_version}
344         )
345         set(HAVE_AUTOAR ON)
346 endif(ENABLE_AUTOAR)
348 # ******************************
349 # User Documentation
350 # ******************************
352 add_printable_option(WITH_HELP "Build user documentation" ON)
354 if(WITH_HELP)
355         find_program(ITSTOOL itstool)
356         if(NOT ITSTOOL)
357                 message(FATAL_ERROR "Cannot find itstool, either install it or disable help build by adding -DWITH_HELP=OFF argument to cmake command")
358         endif(NOT ITSTOOL)
359 endif(WITH_HELP)
361 # ******************************
362 # iconv checking
363 # ******************************
365 set(CMAKE_REQUIRED_LIBRARIES "-liconv")
366 CHECK_C_SOURCE_COMPILES("#include <iconv.h>
367                         #include <stdlib.h>
368                         int main(void) { iconv_t cd; cd = iconv_open (\"UTF-8\", \"ISO-8859-1\"); return 0; }" HAVE_LIBICONV)
369 unset(CMAKE_REQUIRED_LIBRARIES)
371 if(HAVE_LIBICONV)
372         set(ICONV_LIBS "-liconv")
373         set(HAVE_ICONV ON)
374 else(HAVE_LIBICONV)
375         set(ICONV_LIBS "")
376         CHECK_FUNCTION_EXISTS(iconv HAVE_ICONV)
377 endif(HAVE_LIBICONV)
379 if(NOT HAVE_ICONV)
380         message(FATAL_ERROR "You need to install a working iconv implementation, such as ftp://ftp.gnu.org/pub/gnu/libiconv")
381 endif(NOT HAVE_ICONV)
383 set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBS})
384 file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/" _binary_dir_with_separator)
385 CHECK_C_SOURCE_RUNS("#define ICONV_DETECT_BUILD_DIR \"${_binary_dir_with_separator}\"
386                      #include \"${CMAKE_SOURCE_DIR}/iconv-detect.c\"" _correct_iconv)
387 unset(_binary_dir_with_separator)
388 unset(CMAKE_REQUIRED_LIBRARIES)
390 if(NOT _correct_iconv)
391         message(FATAL_ERROR "You need to install a working iconv implementation, such as ftp://ftp.gnu.org/pub/gnu/libiconv")
392 endif(NOT _correct_iconv)
394 # ******************************
395 # Timezone checks
396 # ******************************
398 CHECK_C_SOURCE_COMPILES("#include <time.h>
399                         int main(void) { struct tm tm; tm.tm_gmtoff = 1; return 0; }" HAVE_TM_GMTOFF)
401 CHECK_C_SOURCE_COMPILES("#include <time.h>
402                         int main(void) { timezone = 1; return 0; }" HAVE_TIMEZONE)
404 CHECK_C_SOURCE_COMPILES("#include <time.h>
405                         int main(void) { altzone = 1; return 0; }" HAVE_ALTZONE)
407 if((NOT HAVE_TM_GMTOFF) AND (NOT HAVE_TIMEZONE))
408         message(FATAL_ERROR "Unable to find a way to determine timezone")
409 endif((NOT HAVE_TM_GMTOFF) AND (NOT HAVE_TIMEZONE))
411 # ******************************
412 # iso-codes
413 # ******************************
415 pkg_check_exists(HAVE_ISO_CODES iso-codes)
416 if(HAVE_ISO_CODES)
417         pkg_check_at_least_version(HAVE_ISO_CODES iso-codes 0.49)
418         if(HAVE_ISO_CODES)
419                 pkg_check_variable(_iso_codes_domains iso-codes domains)
420                 if(NOT ((_iso_codes_domains MATCHES "639") AND (_iso_codes_domains MATCHES "3166")))
421                         message(WARNING "iso-codes detected, but either iso-639 or iso-3166 domains not found in '${_iso_codes_domains}'")
422                         set(HAVE_ISO_CODES OFF)
423                 else()
424                         pkg_check_variable(ISO_CODES_PREFIX iso-codes prefix)
425                 endif()
426         else(HAVE_ISO_CODES)
427                 set(HAVE_ISO_CODES OFF)
428                 message(WARNING "iso-codes detected, but version 0.49 or later is required due to licensing")
429         endif(HAVE_ISO_CODES)
430 endif(HAVE_ISO_CODES)
432 # ******************************
433 # TNEF implementation
434 # ******************************
436 add_printable_option(ENABLE_YTNEF "Enable yTNEF library usage" ON)
438 if(ENABLE_YTNEF)
439         set(TNEF_LDFLAGS -lytnef)
441         set(CMAKE_REQUIRED_LIBRARIES ${TNEF_LDFLAGS})
442         CHECK_C_SOURCE_COMPILES("#include <stdio.h>
443                                 #include <ytnef.h>
444                                 int main(void) { TNEFStruct *tnef; return 0; }" HAVE_YTNEF_H)
446         if(NOT HAVE_YTNEF_H)
447                 CHECK_C_SOURCE_COMPILES("#include <stdio.h>
448                                         #include <libytnef/ytnef.h>
449                                         int main(void) { TNEFStruct *tnef; return 0; }" HAVE_LIBYTNEF_YTNEF_H)
450         endif(NOT HAVE_YTNEF_H)
451         unset(CMAKE_REQUIRED_LIBRARIES)
453         if((NOT HAVE_YTNEF_H) AND (NOT HAVE_LIBYTNEF_YTNEF_H))
454                 message(FATAL_ERROR "Cannot find ytnef library, either install it or disable use of it by adding -DENABLE_YTNEF=OFF argument to cmake command")
455         endif((NOT HAVE_YTNEF_H) AND (NOT HAVE_LIBYTNEF_YTNEF_H))
456 endif(ENABLE_YTNEF)
458 # ******************************
459 # Bogofilter (spam filter)
460 # ******************************
462 add_printable_variable_path(WITH_BOGOFILTER "Enable spam filtering using Bogofilter (defaults to /usr/bin/bogofilter)" ON)
464 string(LENGTH "${CMAKE_BINARY_DIR}" bindirlen)
465 string(LENGTH "${WITH_BOGOFILTER}" maxlen)
466 if(maxlen LESS bindirlen)
467         set(substr "***")
468 else(maxlen LESS bindirlen)
469         string(SUBSTRING "${WITH_BOGOFILTER}" 0 ${bindirlen} substr)
470 endif(maxlen LESS bindirlen)
471 string(TOUPPER "${WITH_BOGOFILTER}" optupper)
473 set(BOGOFILTER_COMMAND "")
474 if(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
475         set(WITH_BOGOFILTER ON)
476 elseif(("${optupper}" STREQUAL "OFF") OR ("${optupper}" STREQUAL "NO"))
477         set(WITH_BOGOFILTER OFF)
478 else()
479         set(BOGOFILTER_COMMAND "${WITH_BOGOFILTER}")
480         set(WITH_BOGOFILTER ON)
481 endif()
483 if(WITH_BOGOFILTER)
484         if(BOGOFILTER_COMMAND STREQUAL "")
485                 set(BOGOFILTER_COMMAND "$ENV{BOGOFILTER}")
486         endif(BOGOFILTER_COMMAND STREQUAL "")
487         if(BOGOFILTER_COMMAND STREQUAL "")
488                 set(BOGOFILTER_COMMAND "/usr/bin/bogofilter")
489         endif(BOGOFILTER_COMMAND STREQUAL "")
490 endif(WITH_BOGOFILTER)
492 unset(bindirlen)
493 unset(maxlen)
494 unset(substr)
495 unset(optupper)
497 # ******************************
498 # SpamAssassin (spam filter)
499 # ******************************
501 add_printable_variable_path(WITH_SPAMASSASSIN "Enable spam filtering using SpamAssassin (defaults to /usr/bin/spamassassin)" ON)
502 add_printable_variable_path(WITH_SA_LEARN "Full path command where sa-learn is located (defaults to /usr/bin/sa-learn)" ON)
504 string(LENGTH "${CMAKE_BINARY_DIR}" bindirlen)
505 string(LENGTH "${WITH_SPAMASSASSIN}" maxlen)
506 if(maxlen LESS bindirlen)
507         set(substr "***")
508 else(maxlen LESS bindirlen)
509         string(SUBSTRING "${WITH_SPAMASSASSIN}" 0 ${bindirlen} substr)
510 endif(maxlen LESS bindirlen)
511 string(TOUPPER "${WITH_SPAMASSASSIN}" optupper)
513 set(SPAMASSASSIN_COMMAND "")
514 if(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
515         set(WITH_SPAMASSASSIN ON)
516 elseif(("${optupper}" STREQUAL "OFF") OR ("${optupper}" STREQUAL "NO"))
517         set(WITH_SPAMASSASSIN OFF)
518 else()
519         set(SPAMASSASSIN_COMMAND "${WITH_SPAMASSASSIN}")
520         set(WITH_SPAMASSASSIN ON)
521 endif()
523 if(WITH_SPAMASSASSIN)
524         if(SPAMASSASSIN_COMMAND STREQUAL "")
525                 set(SPAMASSASSIN_COMMAND "$ENV{SPAMASSASSIN}")
526         endif(SPAMASSASSIN_COMMAND STREQUAL "")
527         if(SPAMASSASSIN_COMMAND STREQUAL "")
528                 set(SPAMASSASSIN_COMMAND "/usr/bin/spamassassin")
529         endif(SPAMASSASSIN_COMMAND STREQUAL "")
531         string(LENGTH "${WITH_SA_LEARN}" maxlen)
532         if(maxlen LESS bindirlen)
533                 set(substr "***")
534         else(maxlen LESS bindirlen)
535                 string(SUBSTRING "${WITH_SA_LEARN}" 0 ${bindirlen} substr)
536         endif(maxlen LESS bindirlen)
537         string(TOUPPER "${WITH_SA_LEARN}" optupper)
539         set(SA_LEARN_COMMAND "")
540         if(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
541                 set(WITH_SA_LEARN ON)
542         elseif(("${optupper}" STREQUAL "OFF") OR ("${optupper}" STREQUAL "NO"))
543                 set(WITH_SA_LEARN OFF)
544         else()
545                 set(SA_LEARN_COMMAND "${WITH_SA_LEARN}")
546                 set(WITH_SA_LEARN ON)
547         endif()
549         if(SA_LEARN_COMMAND STREQUAL "")
550                 set(SA_LEARN_COMMAND "$ENV{SA_LEARN}")
551         endif(SA_LEARN_COMMAND STREQUAL "")
552         if(SA_LEARN_COMMAND STREQUAL "")
553                 set(SA_LEARN_COMMAND "/usr/bin/sa-learn")
554         endif(SA_LEARN_COMMAND STREQUAL "")
555 endif(WITH_SPAMASSASSIN)
557 unset(bindirlen)
558 unset(maxlen)
559 unset(substr)
560 unset(optupper)
562 # ******************************
563 # CERT_UI Flags
564 # ******************************
566 # Here we want the Mozilla flags to go *before* the other ones,
567 # especially the mozilla-nss -I flags to go before the gnutls ones,
568 # as both gnutls and mozilla-nss have a header called "pkcs12.h" which is
569 # included in smime/lib/e-pkcs12.c. It wants the Mozilla NSS one.
571 set(CERT_UI_INCLUDES ${MANUAL_NSPR_INCLUDES} ${MANUAL_NSS_INCLUDES})
572 set(CERT_UI_LIBS ${MANUAL_NSPR_LIBS} ${MANUAL_NSS_LIBS})
574 # ******************************
575 # Libnotify
576 # ******************************
578 pkg_check_modules(LIBNOTIFY libnotify>=${libnotify_minimum_version})
579 set(HAVE_LIBNOTIFY ${LIBNOTIFY_FOUND})
581 # ******************************
582 # Libunity
583 # ******************************
585 pkg_check_modules(LIBUNITY unity>=${libunity_minimum_version})
586 set(HAVE_LIBUNITY ${LIBUNITY_FOUND})
588 # ******************************
589 # libical tweaks
590 # ******************************
592 set(CMAKE_REQUIRED_DEFINITIONS ${EVOLUTION_DATA_SERVER_CFLAGS_OTHER})
593 set(CMAKE_REQUIRED_INCLUDES ${EVOLUTION_DATA_SERVER_INCLUDE_DIRS})
594 set(CMAKE_REQUIRED_LIBRARIES ${EVOLUTION_DATA_SERVER_LDFLAGS})
596 CHECK_C_SOURCE_COMPILES("#include <libical/ical.h>
597                         int main(void) {
598                                 ical_set_unknown_token_handling_setting (ICAL_DISCARD_TOKEN);
599                                 return 0;
600                         }" HAVE_ICAL_UNKNOWN_TOKEN_HANDLING)
602 CHECK_C_SOURCE_COMPILES("#include <libical/ical.h>
603                         int main(void) {
604                                 icaltzutil_set_exact_vtimezones_support (0);
605                                 return 0;
606                         }" HAVE_ICALTZUTIL_SET_EXACT_VTIMEZONES_SUPPORT)
608 CHECK_C_SOURCE_COMPILES("#include <libical/ical.h>
609                         int main(void) {
610                                 icalparameter *param;
611                                 param = icalproperty_get_first_parameter (NULL, ICAL_FILENAME_PARAMETER);
612                                 icalparameter_get_filename (param);
613                                 icalparameter_new_filename (NULL);
614                                 return 0;
615                         }" HAVE_ICAL_FILENAME_PARAMETER)
617 CHECK_C_SOURCE_COMPILES("#include <libical/ical.h>
618                         int main(void) {
619                                 icalproperty *prop;
620                                 prop = icalcomponent_get_first_property (NULL, ICAL_COLOR_PROPERTY);
621                                 icalproperty_get_color (prop);
622                                 icalproperty_set_color (prop, \"white\");
623                                 prop = icalproperty_new_color (NULL);
624                                 return 0;
625                         }" HAVE_ICAL_COLOR_PROPERTY)
627 unset(CMAKE_REQUIRED_DEFINITIONS)
628 unset(CMAKE_REQUIRED_INCLUDES)
629 unset(CMAKE_REQUIRED_LIBRARIES)
631 # ******************************
632 # gtkspell
633 # ******************************
635 add_printable_option(ENABLE_GTKSPELL "Enable gtkspell usage" ON)
637 if(ENABLE_GTKSPELL)
638         pkg_check_modules_for_option(ENABLE_GTKSPELL "gtkspell usage" GTKSPELL gtkspell3-3.0)
639         set(HAVE_GTKSPELL ON)
640 endif(ENABLE_GTKSPELL)
642 # ******************************
643 # gnu_get_libc_version()
644 # ******************************
646 CHECK_C_SOURCE_COMPILES("#include <gnu/libc-version.h>
647                         int main(void) { const gchar *libc_version = gnu_get_libc_version (); return 0; }" HAVE_GNU_GET_LIBC_VERSION)
649 # ******************************
650 # Plugins
651 # ******************************
653 add_printable_variable(ENABLE_PLUGINS "Enable plugins (no/base/all)" "all")
655 set(plugins_base
656         publish-calendar
658 set(plugins_standard
659         attachment-reminder
660         bbdb
661         dbx-import
662         email-custom-header
663         external-editor
664         face
665         mail-to-task
666         mailing-list-actions
667         mail-notification
668         save-calendar
669         templates
672 # ******************************************************************
673 # The following plugins have additional library dependencies.
674 # They must be explicitly disabled if the libraries are not present.
675 # ******************************************************************
677 # text-highlight
679 add_printable_option(ENABLE_TEXT_HIGHLIGHT "Enable text-highlight plugin" ON)
681 if(ENABLE_TEXT_HIGHLIGHT)
682         find_program(HIGHLIGHT_COMMAND highlight)
684         if(NOT HIGHLIGHT_COMMAND)
685                 message(FATAL_ERROR "The 'highlight' program not found; either give it into PATH or disable higlight plugin with -DENABLE_TEXT_HIGHLIGHT=OFF")
686         endif(NOT HIGHLIGHT_COMMAND)
687 endif(ENABLE_TEXT_HIGHLIGHT)
689 # weather calendar
691 add_printable_option(ENABLE_WEATHER "Enable weather calendars" ON)
693 if(ENABLE_WEATHER)
694         pkg_check_modules_for_option(ENABLE_WEATHER "weather calendar" GWEATHER gweather-3.0>=${gweather_minimum_version})
695 endif(ENABLE_WEATHER)
697 # maps in Contacts preview
699 add_printable_option(ENABLE_CONTACT_MAPS "Enable contact maps" OFF)
701 if(ENABLE_CONTACT_MAPS)
702         pkg_check_modules_for_option(ENABLE_CONTACT_MAPS "contact maps" CHAMPLAIN champlain-gtk-0.12>=${champlain_minimum_version})
703         pkg_check_modules_for_option(ENABLE_CONTACT_MAPS "contact maps" GEO geocode-glib-1.0>=${geocode_glib_minimum_version})
704         pkg_check_modules_for_option(ENABLE_CONTACT_MAPS "contact maps" CLUTTER_GTK clutter-gtk-1.0>=${clutter_gtk_minimum_version})
705 endif(ENABLE_CONTACT_MAPS)
707 # pst-import plugin
709 add_printable_option(ENABLE_PST_IMPORT "Enable pst-import plugin" ON)
711 if(ENABLE_PST_IMPORT)
712         pkg_check_modules_for_option(ENABLE_PST_IMPORT "pst-import plugin" LIBPST libpst>=${libpst_minimum_version})
713         list(APPEND plugins_standard pst-import)
714 endif(ENABLE_PST_IMPORT)
716 # Finish plugins build setup
717 set(build_plugins)
719 if(ENABLE_PLUGINS STREQUAL "" OR ENABLE_PLUGINS STREQUAL "all")
720         set(build_plugins ${plugins_base} ${plugins_standard})
721 elseif(ENABLE_PLUGINS STREQUAL "base")
722         set(build_plugins ${plugins_base})
723 elseif(NOT ENABLE_PLUGINS STREQUAL "no")
724         message(FATAL_ERROR "Incorrect value for ENABLE_PLUGINS (${ENABLE_PLUGINS}), use either \"no\", or \"base\" or \"all\" value")
725 endif()
727 # ******************************
728 # Glade catalog
729 # ******************************
731 add_printable_option(WITH_GLADE_CATALOG "Install the catalog files for Glade 3 (for maintainers only)" OFF)
733 if(WITH_GLADE_CATALOG)
734         pkg_check_modules_for_option(WITH_GLADE_CATALOG "Glade 3 catalog files" GLADEUI gladeui-2.0>=${gladeui_minimum_version})
735 endif(WITH_GLADE_CATALOG)
737 # Generate the ${PROJECT_NAME}-config.h file
738 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/config.h.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.h)
740 print_build_options()
742 # The shell_private_requirements is used by the evolution-shell.pc.in
743 if(ENABLE_GNOME_DESKTOP)
744         set(shell_private_requirements "Requires.private: ${GNOME_DESKTOP_DEPENDENCY}")
745 else(ENABLE_GNOME_DESKTOP)
746         set(shell_private_requirements "")
747 endif(ENABLE_GNOME_DESKTOP)
749 # The shell_privlibdir_rpath_flags is used by the evolution-shell.pc.in
750 # and if set, then should be preceded with a space.
751 if(NOT WIN32)
752         set(shell_privlibdir_rpath_flags  " -Wl,-R${privlibdir}")
753 endif(NOT WIN32)
755 add_pkgconfig_file(evolution-calendar.pc.in evolution-calendar-${INTERFACE_VERSION}.pc)
756 add_pkgconfig_file(evolution-mail.pc.in evolution-mail-${INTERFACE_VERSION}.pc)
757 add_pkgconfig_file(evolution-shell.pc.in evolution-shell-${INTERFACE_VERSION}.pc)
759 add_subdirectory(data)
760 add_subdirectory(po)
761 add_subdirectory(src)
762 add_subdirectory(tests)
764 if(ENABLE_GTK_DOC)
765         add_subdirectory(docs)
766 endif(ENABLE_GTK_DOC)
768 if(WITH_HELP)
769         add_subdirectory(help)
770 endif(WITH_HELP)