1 # Evolution-Data-Server build script
3 cmake_minimum_required(VERSION 3.1)
4 cmake_policy(VERSION 3.1)
6 project(evolution-data-server
9 set(CMAKE_CXX_STANDARD 14)
10 set(PROJECT_BUGREPORT "https://gitlab.gnome.org/GNOME/evolution-data-server/issues/")
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 # This number is meaningless, but we're now stuck with it in our
18 # library names for backward compatibility.
21 # Required for FindIntltool module
22 set(GETTEXT_PACKAGE ${PROJECT_NAME})
23 set(GETTEXT_PO_DIR ${CMAKE_SOURCE_DIR}/po)
25 # Required for 'disttest' and 'ditcheck' of DistTarget module
26 set(PROJECT_DISTCONFIGURE_PARAMS
30 -DENABLE_INTROSPECTION=ON
31 -DENABLE_VALA_BINDINGS=ON
32 -DENABLE_INSTALLED_TESTS=ON
34 -DWITH_PRIVATE_DOCS=ON
37 # ******************************
39 # ******************************
40 set(ADDRESS_BOOK_DBUS_SERVICE_NAME "org.gnome.evolution.dataserver.AddressBook9")
41 set(CALENDAR_DBUS_SERVICE_NAME "org.gnome.evolution.dataserver.Calendar7")
42 set(SOURCES_DBUS_SERVICE_NAME "org.gnome.evolution.dataserver.Sources5")
43 set(USER_PROMPTER_DBUS_SERVICE_NAME "org.gnome.evolution.dataserver.UserPrompter0")
45 # ******************************
47 # ******************************
48 set(LIBCAMEL_CURRENT 62)
49 set(LIBCAMEL_REVISION 0)
52 set(LIBEBACKEND_CURRENT 10)
53 set(LIBEBACKEND_REVISION 0)
54 set(LIBEBACKEND_AGE 0)
56 set(LIBEDATASERVER_CURRENT 23)
57 set(LIBEDATASERVER_REVISION 0)
58 set(LIBEDATASERVER_AGE 0)
60 set(LIBEDATASERVERUI_CURRENT 2)
61 set(LIBEDATASERVERUI_REVISION 0)
62 set(LIBEDATASERVERUI_AGE 0)
64 set(LIBEBOOK_CURRENT 19)
65 set(LIBEBOOK_REVISION 1)
68 set(LIBEBOOK_CONTACTS_CURRENT 2)
69 set(LIBEBOOK_CONTACTS_REVISION 0)
70 set(LIBEBOOK_CONTACTS_AGE 0)
72 set(LIBEDATABOOK_CURRENT 25)
73 set(LIBEDATABOOK_REVISION 0)
74 set(LIBEDATABOOK_AGE 0)
76 set(LIBECAL_CURRENT 19)
77 set(LIBECAL_REVISION 0)
80 set(LIBEDATACAL_CURRENT 29)
81 set(LIBEDATACAL_REVISION 0)
82 set(LIBEDATACAL_AGE 0)
84 # Keep these two definitions in agreement.
85 set(glib_minimum_version 2.46)
86 set(glib_encoded_version GLIB_VERSION_2_46)
88 # Keep these two definitions in agreement.
89 set(gdk_minimum_version 3.10)
90 set(gdk_encoded_version GDK_VERSION_3_10)
92 # Keep these two definitions in agreement.
93 set(soup_minimum_version 2.42)
94 set(soup_encoded_version SOUP_VERSION_2_42)
96 # Warn about API usage that violates our minimum requirements.
97 add_definitions(-DGLIB_VERSION_MAX_ALLOWED=${glib_encoded_version})
98 add_definitions(-DGDK_VERSION_MAX_ALLOWED=${gdk_encoded_version})
99 add_definitions(-DSOUP_VERSION_MAX_ALLOWED=${soup_encoded_version})
101 # These will suppress warnings about newly-deprecated symbols. Ideally
102 # these settings should match our minimum requirements and we will clean
103 # up any new deprecation warnings after bumping our minimum requirements.
104 # But if the warnings get to be overwhelming, use fixed versions instead.
105 add_definitions(-DGLIB_VERSION_MIN_REQUIRED=${glib_encoded_version})
106 add_definitions(-DGDK_VERSION_MIN_REQUIRED=${gdk_encoded_version})
107 add_definitions(-DSOUP_VERSION_MIN_REQUIRED=${soup_encoded_version})
109 set(gcr_minimum_version 3.4)
110 set(libgdata_minimum_version 0.15.1)
111 set(libical_minimum_version 2.0)
112 set(libsecret_minimum_version 0.5)
113 set(libxml_minimum_version 2.0.0)
114 set(sqlite_minimum_version 3.7.17)
117 set(goa_minimum_version 3.8)
118 set(gweather_minimum_version 3.10)
119 set(libaccounts_glib_minimum_version 1.4)
120 set(libsignon_glib_minimum_version 1.8)
121 set(json_glib_minimum_version 1.0.4)
122 set(webkit2gtk_minimum_version 2.11.91)
123 set(libcanberra_gtk_minimum_version 0.25)
125 # Load modules from the source tree
126 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
128 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
129 # Packagers might want to need different settings for the RPATH related things
130 # From experience, especially CMAKE_BUILD_WITH_INSTALL_RPATH might need to be
131 # switched to ON, if CMake fails to set the right values during make install
132 set(CMAKE_SKIP_RPATH OFF CACHE BOOL INTERNAL)
133 set(CMAKE_SKIP_BUILD_RPATH OFF CACHE BOOL INTERNAL)
134 set(CMAKE_BUILD_WITH_INSTALL_RPATH OFF CACHE BOOL INTERNAL)
135 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON CACHE BOOL INTERNAL)
136 # CMAKE_INSTALL_RPATH is set below
139 include(CheckCCompilerFlag)
140 include(CheckCSourceCompiles)
141 include(CheckCSourceRuns)
142 include(CheckFunctionExists)
143 include(CheckIncludeFile)
144 include(CheckLibraryExists)
146 # Project custom modules
147 include(PrintableOptions)
149 add_printable_variable(LIB_SUFFIX "Library directory suffix, usually defined to '64' for x86_64 systems" "")
150 add_printable_variable_bare(CMAKE_INSTALL_PREFIX)
151 add_printable_variable_path(BIN_INSTALL_DIR "Install directory for binary files, defaults to CMAKE_INSTALL_PREFIX/bin" "")
152 add_printable_variable_path(INCLUDE_INSTALL_DIR "Install directory for header files, defaults to CMAKE_INSTALL_PREFIX/include" "")
153 add_printable_variable_path(LIB_INSTALL_DIR "Install directory for library files, defaults to CMAKE_INSTALL_PREFIX/lib{LIB_SUFFIX}" "")
154 add_printable_variable_path(LIBEXEC_INSTALL_DIR "Install directory for library executable files, defaults to CMAKE_INSTALL_PREFIX/libexec" "")
155 add_printable_variable_path(SHARE_INSTALL_PREFIX "Install directory for shared files, defaults to CMAKE_INSTALL_PREFIX/share" "")
156 add_printable_variable_path(LOCALE_INSTALL_DIR "Install directory for locale files, defaults to SHARE_INSTALL_PREFIX/locale" "")
157 add_printable_variable_path(SYSCONF_INSTALL_DIR "Install directory for system configuration files, defaults to CMAKE_INSTALL_PREFIX/etc" "")
159 macro(ensure_default_value _var _defvalue)
160 if(${_var} STREQUAL "")
161 set(${_var} ${_defvalue})
162 endif(${_var} STREQUAL "")
163 endmacro(ensure_default_value)
165 ensure_default_value(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin")
166 ensure_default_value(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include")
167 ensure_default_value(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
168 ensure_default_value(LIBEXEC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/libexec")
169 ensure_default_value(SHARE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/share")
170 ensure_default_value(LOCALE_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/locale")
171 ensure_default_value(SYSCONF_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/etc")
173 # ******************************
174 # Special directories
175 # ******************************
177 # If you add something here, consider whether or not you also
178 # need to add it to one or more .pc.in files (for Connector, etc)
180 set(privdatadir "${SHARE_INSTALL_PREFIX}/${PROJECT_NAME}")
181 set(privincludedir "${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}")
182 set(privlibdir "${LIB_INSTALL_DIR}/${PROJECT_NAME}")
183 set(privlibexecdir "${LIBEXEC_INSTALL_DIR}/${PROJECT_NAME}")
185 SET(CMAKE_INSTALL_RPATH "${privlibdir}")
188 # On Win32 there is no "rpath" mechanism. We install the private
189 # shared libraries in $libdir, meaning the DLLs will actually be in
190 # $bindir. This means just having $bindir in PATH will be enough.
191 set(privsolibdir "${LIB_INSTALL_DIR}")
193 set(privsolibdir "${privlibdir}")
196 set(imagesdir "${SHARE_INSTALL_PREFIX}/pixmaps/${PROJECT_NAME}")
197 set(moduledir "${privlibdir}/registry-modules")
198 set(credentialmoduledir "${privlibdir}/credential-modules")
199 set(uimoduledir "${privlibdir}/ui-modules")
200 set(ebook_backenddir "${privlibdir}/addressbook-backends")
201 set(ecal_backenddir "${privlibdir}/calendar-backends")
202 set(ro_sourcesdir "${privdatadir}/ro-sources")
203 set(rw_sourcesdir "${privdatadir}/rw-sources")
204 set(camel_providerdir "${privlibdir}/camel-providers")
206 # *******************
207 # D-BUS service stuff
208 # *******************
209 set(servicelibexecdir "${LIBEXEC_INSTALL_DIR}")
210 if(WIN32 AND (NOT ("$ENV{WIN32_SERVICELIBEXECDIR}" STREQUAL "")))
212 # D-Bus requires Windows full path, not Unix-like, like the one provided by MSYS
214 AC_SUBST(WIN32_SERVICELIBEXECDIR)
215 set(servicelibexecdir "$ENV{WIN32_SERVICELIBEXECDIR}")
216 endif(WIN32 AND (NOT ("$ENV{WIN32_SERVICELIBEXECDIR}" STREQUAL "")))
218 add_printable_variable_path(WITH_DBUS_SERVICE_DIR "Set directory for D-Bus service files" "${SHARE_INSTALL_PREFIX}/dbus-1/services")
220 # It is correct for this to be in ${CMAKE_INSTALL_PREFIX}/lib, even on systems where that
221 # does not match ${LIB_INSTALL_DIR}. This is what systemd uses on such platforms.
223 add_printable_variable_path(WITH_SYSTEMDUSERUNITDIR "Set directory for systemd user units, or 'no' to disable" "${CMAKE_INSTALL_PREFIX}/lib/systemd/user")
225 string(LENGTH "${CMAKE_BINARY_DIR}" bindirlen)
226 string(LENGTH "${WITH_SYSTEMDUSERUNITDIR}" maxlen)
227 if(maxlen LESS bindirlen)
229 else(maxlen LESS bindirlen)
230 string(SUBSTRING "${WITH_SYSTEMDUSERUNITDIR}" 0 ${bindirlen} substr)
231 endif(maxlen LESS bindirlen)
232 string(TOUPPER "${WITH_SYSTEMDUSERUNITDIR}" optupper)
234 if(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
235 set(WITH_SYSTEMD_USER_UNITS ON)
236 set(WITH_SYSTEMDUSERUNITDIR "${CMAKE_INSTALL_PREFIX}/lib/systemd/user")
237 elseif(NOT WITH_SYSTEMDUSERUNITDIR)
238 set(WITH_SYSTEMD_USER_UNITS OFF)
240 set(WITH_SYSTEMD_USER_UNITS ON)
248 # ******************************
250 # ******************************
252 include(CodeCoverageGCOV)
256 include(GObjectIntrospection)
258 include(InstalledTests)
260 include(SetupBuildFlags)
261 include(UninstallTarget)
263 include(FindIntltool)
266 include(FindPhonenumber)
269 add_printable_option(ENABLE_MAINTAINER_MODE "Enable maintainer mode" OFF)
270 add_printable_option(WITH_PRIVATE_DOCS "Build documentation for private libraries (requires -DENABLE-GTK-DOC=ON" OFF)
272 if(ENABLE_MAINTAINER_MODE)
273 set(BUILD_TESTING ON)
274 endif(ENABLE_MAINTAINER_MODE)
276 # Setup compiler/linker flags
277 setup_build_flags(${ENABLE_MAINTAINER_MODE})
279 CHECK_INCLUDE_FILE(com_err.h HAVE_COM_ERR_H)
280 CHECK_INCLUDE_FILE(et/com_err.h HAVE_ET_COM_ERR_H)
281 CHECK_INCLUDE_FILE(sys/wait.h HAVE_SYS_WAIT_H)
282 CHECK_INCLUDE_FILE(wspiapi.h HAVE_WSPIAPI_H)
283 CHECK_INCLUDE_FILE(zlib.h HAVE_ZLIB_H)
284 CHECK_FUNCTION_EXISTS(fsync HAVE_FSYNC)
285 CHECK_FUNCTION_EXISTS(strptime HAVE_STRPTIME)
286 CHECK_FUNCTION_EXISTS(nl_langinfo HAVE_NL_LANGINFO)
288 # ******************************
289 # required executables
290 # ******************************
292 find_program(GPERF gperf)
294 message(FATAL_ERROR "You need gperf to build ${PROJECT_NAME}")
297 # ******************************
298 # db_load checking, it's optional
299 # ******************************
301 find_program(DB_LOAD NAMES db_load db4_load db_load-4 db5_load db_load-5)
305 set(HAVE_DB_LOAD OFF)
306 message(WARNING "db_load not found, some unit tests will not be run")
309 # ******************************
310 # deflateInit is a #define, use deflateEnd instead
311 # ******************************
313 CHECK_LIBRARY_EXISTS(z deflateEnd "" deflateEnd_exists)
316 message(FATAL_ERROR "zlib.h not found")
317 endif(NOT HAVE_ZLIB_H)
318 if(NOT deflateEnd_exists)
319 message(FATAL_ERROR "zlib doesn't provide deflateEnd")
320 endif(NOT deflateEnd_exists)
322 pkg_check_modules(GNOME_PLATFORM REQUIRED
323 gio-2.0>=${glib_minimum_version}
324 gmodule-2.0>=${glib_minimum_version}
325 libxml-2.0>=${libxml_minimum_version}
326 libsoup-2.4>=${soup_minimum_version}
330 pkg_check_modules(GIO_UNIX gio-windows-2.0)
332 pkg_check_modules(GIO_UNIX gio-unix-2.0)
335 # *******************
337 # *******************
339 # ICU started shipping pkg-config files but it's not present
340 # on many systems, if we don't find the pkg-config
341 # file then let's fallback on a manual check
342 pkg_check_modules(ICU icu-i18n)
345 CHECK_INCLUDE_FILE(unicode/ucol.h HAVE_UNICODE_UCOL_H)
346 if(NOT HAVE_UNICODE_UCOL_H)
347 message(FATAL_ERROR "ICU unicode/ucol.h not found; icu-i18n is required")
348 endif(HAVE_UNICODE_UCOL_H)
350 set(CMAKE_REQUIRED_LIBRARIES "-licui18n -licuuc -licudata")
351 CHECK_C_SOURCE_COMPILES("#include <unicode/ucol.h>
352 int main(void) { ucol_open (\"\", NULL); return 0; }" HAVE_UCOL_OPEN)
353 unset(CMAKE_REQUIRED_LIBRARIES)
356 set(ICU_CFLAGS -D_REENTRANT)
357 set(ICU_LIBS "-licui18n -licuuc -licudata")
359 message(FATAL_ERROR "Failed to find icu-i18n, install its development files or build them first")
360 endif(HAVE_UCOL_OPEN)
363 # *************************
365 # *************************
367 add_printable_option(ENABLE_GTK "Enable gtk+ support" ON)
370 pkg_check_modules_for_option(ENABLE_GTK "GTK+ support" GTK gtk+-3.0>=${gdk_minimum_version})
371 pkg_check_modules_for_option(ENABLE_GTK "GTK+ support" GCR gcr-3>=${gcr_minimum_version})
376 # **************************************************************
377 # Check for WebKitGTK+ and json-glib for OAuth2 authentications
378 # **************************************************************
380 add_printable_option(ENABLE_OAUTH2 "Enable built-in OAuth2 authentications" ON)
383 pkg_check_modules_for_option(ENABLE_OAUTH2 "OAuth2 authentication support" OAUTH2_JSON_GLIB
384 json-glib-1.0>=${json_glib_minimum_version}
387 pkg_check_modules_for_option(ENABLE_OAUTH2 "OAuth2 authentication support" OAUTH2_WEBKIT2GTK
388 webkit2gtk-4.0>=${webkit2gtk_minimum_version}
391 add_printable_variable(WITH_GOOGLE_CLIENT_ID "Google OAuth 2.0 client id" "")
392 add_printable_variable(WITH_GOOGLE_CLIENT_SECRET "Google OAuth 2.0 client secret" "")
394 if(WITH_GOOGLE_CLIENT_ID STREQUAL "")
395 set(WITH_GOOGLE_CLIENT_ID "590402290962-2i0b7rqma8b9nmtfrcp7fa06g6cf7g74.apps.googleusercontent.com")
396 endif(WITH_GOOGLE_CLIENT_ID STREQUAL "")
398 if(WITH_GOOGLE_CLIENT_SECRET STREQUAL "")
399 set(WITH_GOOGLE_CLIENT_SECRET "mtfUe5W8Aal9DcgVipOY1T9G")
400 endif(WITH_GOOGLE_CLIENT_SECRET STREQUAL "")
402 add_printable_variable(WITH_OUTLOOK_CLIENT_ID "Outlook.com OAuth 2.0 client id" "")
403 add_printable_variable(WITH_OUTLOOK_CLIENT_SECRET "Outlook.com OAuth 2.0 client secret" "")
405 if(WITH_OUTLOOK_CLIENT_ID STREQUAL "")
406 set(WITH_OUTLOOK_CLIENT_ID "cc6e0693-0e26-4220-8322-9d363e308fc6")
407 endif(WITH_OUTLOOK_CLIENT_ID STREQUAL "")
409 # Outlook.com requires client secret only for Web applications
410 #if(WITH_OUTLOOK_CLIENT_SECRET STREQUAL "")
411 # set(WITH_OUTLOOK_CLIENT_SECRET "")
412 #endif(WITH_OUTLOOK_CLIENT_SECRET STREQUAL "")
415 # ******************************************
416 # Check whether to build examples/demos
417 # ******************************************
419 add_printable_option(ENABLE_EXAMPLES "Enable the build of examples" ON)
422 pkg_check_modules_for_option(ENABLE_EXAMPLES "build the example program(s)" EXAMPLES
427 set(BUILD_EXAMPLES 1)
428 endif(ENABLE_EXAMPLES)
430 # *******************************
431 # Check for GNOME Online Accounts
432 # *******************************
434 add_printable_option(ENABLE_GOA "Enable GNOME Online Accounts support" ON)
437 pkg_check_modules_for_option(ENABLE_GOA "GNOME Online Accounts support" GOA goa-1.0>=${goa_minimum_version})
442 # ********************************
443 # Check for Ubuntu Online Accounts
444 # ********************************
446 add_printable_option(ENABLE_UOA "Enable Ubuntu Online Accounts support" ON)
449 pkg_check_modules_for_option(ENABLE_UOA "Ubuntu Online Accounts support" LIBACCOUNTS_GLIB libaccounts-glib>=${libaccounts_glib_minimum_version})
450 pkg_check_modules_for_option(ENABLE_UOA "Ubuntu Online Accounts support" LIBSIGNON_GLIB libsignon-glib>=${libsignon_glib_minimum_version})
451 pkg_check_modules_for_option(ENABLE_UOA "Ubuntu Online Accounts support" JSON_GLIB json-glib-1.0)
452 pkg_check_modules_for_option(ENABLE_UOA "Ubuntu Online Accounts support" REST rest-0.7)
457 # **********************************************
458 # Check if backend per process should be enabled
459 # **********************************************
461 add_printable_option(ENABLE_BACKEND_PER_PROCESS "Enable backend per process support" OFF)
463 # ***********************************
464 # Check for libsecret and gcr-base
465 # ***********************************
468 pkg_check_modules(LIBSECRET REQUIRED libsecret-unstable>=${libsecret_minimum_version})
469 pkg_check_modules(GCR_BASE REQUIRED gcr-base-3>=${gcr_minimum_version})
472 # ******************************
474 # ******************************
475 add_printable_variable(WITH_LIBDB "Prefix where libdb is installed" ON)
476 add_printable_variable(WITH_LIBDB_CFLAGS "Arguments required to compile with libdb" "")
477 add_printable_variable(WITH_LIBDB_LIBS "Arguments required to link with libdb" "")
479 if(WITH_LIBDB STREQUAL "")
481 endif(WITH_LIBDB STREQUAL "")
484 if(NOT (WITH_LIBDB OR ("${WITH_LIBDB}" STREQUAL "YES")))
485 set(LIBDB_CFLAGS "-I${WITH_LIBDB}/include")
486 set(LIBDB_LIBS "-L${WITH_LIBDB}/lib -ldb")
487 else(NOT (WITH_LIBDB OR ("${WITH_LIBDB}" STREQUAL "YES")))
488 if(("${WITH_LIBDB_CFLAGS}" STREQUAL "") AND ("${WITH_LIBDB_LIBS}" STREQUAL ""))
490 set(LIBDB_LIBS "-ldb")
491 else(("${WITH_LIBDB_CFLAGS}" STREQUAL "") AND ("${WITH_LIBDB_LIBS}" STREQUAL ""))
492 set(LIBDB_CFLAGS ${WITH_LIBDB_CFLAGS})
493 set(LIBDB_LIBS ${WITH_LIBDB_LIBS})
494 endif(("${WITH_LIBDB_CFLAGS}" STREQUAL "") AND ("${WITH_LIBDB_LIBS}" STREQUAL ""))
495 endif(NOT (WITH_LIBDB OR ("${WITH_LIBDB}" STREQUAL "YES")))
497 set(CMAKE_REQUIRED_FLAGS ${LIBDB_CFLAGS})
498 set(CMAKE_REQUIRED_LIBRARIES ${LIBDB_LIBS})
499 CHECK_C_SOURCE_COMPILES("#include <db.h>
500 int main(void) { db_create(NULL, NULL, 0); return 0; }" HAVE_LIBDB)
501 unset(CMAKE_REQUIRED_FLAGS)
502 unset(CMAKE_REQUIRED_LIBRARIES)
505 message(FATAL_ERROR "libdb not found. Use -DWITH_LIBDB=PATH to specify the library prefix, or use -DWITH_LIBDB_CFLAGS=-I/path/to/db/include and -DWITH_LIBDB_LIBS=/path/to/db/lib to specify arguments for compiling and linking. If you want to disable libdb, please use -DWITH_LIBDB=OFF")
506 endif(NOT HAVE_LIBDB)
509 # ******************************
511 # ******************************
513 set(CMAKE_REQUIRED_LIBRARIES "-liconv")
514 CHECK_C_SOURCE_COMPILES("#include <iconv.h>
516 int main(void) { iconv_t cd; cd = iconv_open (\"UTF-8\", \"ISO-8859-1\"); return 0; }" HAVE_LIBICONV)
517 unset(CMAKE_REQUIRED_LIBRARIES)
520 set(ICONV_LIBS "-liconv")
524 CHECK_FUNCTION_EXISTS(iconv HAVE_ICONV)
528 message(FATAL_ERROR "You need to install a working iconv implementation, such as ftp://ftp.gnu.org/pub/gnu/libiconv")
529 endif(NOT HAVE_ICONV)
531 set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBS})
532 file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/" _binary_dir_with_separator)
533 CHECK_C_SOURCE_RUNS("#define ICONV_DETECT_BUILD_DIR \"${_binary_dir_with_separator}\"
534 #include \"${CMAKE_SOURCE_DIR}/iconv-detect.c\"" _correct_iconv)
535 unset(_binary_dir_with_separator)
536 unset(CMAKE_REQUIRED_LIBRARIES)
538 if(NOT _correct_iconv)
539 message(FATAL_ERROR "You need to install a working iconv implementation, such as ftp://ftp.gnu.org/pub/gnu/libiconv")
540 endif(NOT _correct_iconv)
542 # ******************************
543 # Backtraces for debugging
544 # ******************************
546 add_printable_option(ENABLE_BACKTRACES "Enable backtraces for camel_pointer_tracker" OFF)
548 if(ENABLE_BACKTRACES)
549 CHECK_C_SOURCE_COMPILES("#include <execinfo.h>
550 int main(void) { void *bt[1]; backtrace_symbols (bt, backtrace (bt, 1)); return 0; }" HAVE_BACKTRACE_SYMBOLS)
552 if(HAVE_BACKTRACE_SYMBOLS)
553 set(CMAKE_REQUIRED_LIBRARIES -ldw)
554 CHECK_C_SOURCE_COMPILES("#include <elfutils/libdwfl.h>
558 Dwarf_Addr module_low_addr;
561 dwfl_standard_find_debuginfo;
562 dwfl_linux_proc_find_elf;
564 dwfl_linux_proc_report (NULL, 1);
565 dwfl_report_end (NULL, NULL, NULL);
567 dwfl_module_addrname (NULL, NULL);
568 dwfl_module_getsrc (NULL, NULL);
569 dwfl_lineinfo (NULL, NULL, NULL, NULL, NULL, NULL);
570 DWARF_CB_ABORT; DWARF_CB_OK;
571 dwfl_getmodules (NULL, NULL, NULL, 0);
572 return 0; }" _have_elfdwlf)
573 unset(CMAKE_REQUIRED_LIBRARIES)
576 set(HAVE_ELFUTILS_LIBDWFL ON)
577 set(LIBDWFL_LIBS "-ldw")
579 endif(HAVE_BACKTRACE_SYMBOLS)
580 endif(ENABLE_BACKTRACES)
582 # ******************************
583 # Check for nl_langinfo features
584 # ******************************
586 CHECK_C_SOURCE_COMPILES("#include <langinfo.h>
587 int main(void) { char *detail = nl_langinfo (CODESET); return 0; }" HAVE_CODESET)
589 CHECK_C_SOURCE_COMPILES("#include <langinfo.h>
590 int main(void) { char *detail = nl_langinfo (_NL_ADDRESS_COUNTRY_AB2); return 0; }" HAVE__NL_ADDRESS_COUNTRY_AB2)
592 # *******************************************************
593 # Check to see if strftime supports the use of %l and %k
594 # *******************************************************
596 CHECK_C_SOURCE_RUNS("
600 int main(int argc, char **argv) {
606 timeinfo=localtime(&rawtime);
608 strftime(buf, 10, \"%lx%k\", timeinfo);
610 if (!buf[0] || buf[0] == 'x' || strstr(buf, \"l\") || strstr(buf, \"k\"))
615 # ******************************
617 # ******************************
619 if("$ENV{SENDMAIL_PATH}" STREQUAL "")
620 find_program(SENDMAIL_PATH sendmail /usr/sbin /usr/lib)
621 if(NOT SENDMAIL_PATH)
622 set(SENDMAIL_PATH "/usr/sbin/sendmail")
623 message(WARNING "sendmail not found, defaulting to ${SENDMAIL_PATH}")
624 endif(NOT SENDMAIL_PATH)
625 else("$ENV{SENDMAIL_PATH}" STREQUAL "")
626 set(SENDMAIL_PATH $ENV{SENDMAIL_PATH})
627 endif("$ENV{SENDMAIL_PATH}" STREQUAL "")
629 # ******************************
631 # ******************************
633 CHECK_C_SOURCE_COMPILES("#include <time.h>
634 int main(void) { struct tm tm; tm.tm_gmtoff = 1; return 0; }" HAVE_TM_GMTOFF)
636 CHECK_C_SOURCE_COMPILES("#include <time.h>
637 int main(void) { timezone = 1; return 0; }" HAVE_TIMEZONE)
639 CHECK_C_SOURCE_COMPILES("#include <time.h>
640 int main(void) { altzone = 1; return 0; }" HAVE_ALTZONE)
642 if((NOT HAVE_TM_GMTOFF) AND (NOT HAVE_TIMEZONE))
643 message(FATAL_ERROR "Unable to find a way to determine timezone")
644 endif((NOT HAVE_TM_GMTOFF) AND (NOT HAVE_TIMEZONE))
646 # ******************************
647 # gethostbyaddr_r prototype
648 # ******************************
650 CHECK_C_SOURCE_COMPILES("#include <sys/types.h>
651 #include <sys/socket.h>
652 #include <netinet/in.h>
654 #define BUFSIZE (sizeof(struct hostent)+10)
658 char buffer[BUFSIZE];
661 (void)gethostbyaddr_r (\"www.ximian.com\", 14, AF_INET, &hent, buffer, bufsize, &h_errno);
663 }" GETHOSTBYADDR_R_SEVEN_ARGS)
665 # ******************************
666 # gethostbyname_r prototype
667 # ******************************
669 CHECK_C_SOURCE_COMPILES("#include <sys/types.h>
670 #include <sys/socket.h>
671 #include <netinet/in.h>
673 #define BUFSIZE (sizeof(struct hostent)+10)
677 char buffer[BUFSIZE];
680 (void)gethostbyname_r (\"www.ximian.com\", &hent, buffer, bufsize, &h_errno);
682 }" GETHOSTBYNAME_R_FIVE_ARGS)
684 # ******************************
685 # IPv6 support and getaddrinfo calls
686 # ******************************
688 add_printable_option(ENABLE_IPV6 "Enable IPv6 support" ON)
690 CHECK_C_SOURCE_COMPILES("#include <sys/types.h>
691 #include <sys/socket.h>
692 #include <netinet/in.h>
698 #define NI_MAXHOST 1025
702 #define NI_MAXSERV 32
705 struct addrinfo hints, *res;
706 struct sockaddr_in6 sin6;
708 char host[NI_MAXHOST];
709 char serv[NI_MAXSERV];
711 getaddrinfo (\"www.ximian.com\", NULL, &hints, &res);
713 getnameinfo((struct sockaddr *)&sin6, sizeof(sin6), host, sizeof(host), serv, sizeof(serv), 0);
717 if(NOT have_addrinfo)
718 set(NEED_ADDRINFO ON)
720 message(FATAL_ERROR "System doesn't support necessary interfaces for IPv6 support. Use -DENABLE_IPV6=OFF to disable IPv6 support.")
722 else(NOT have_addrinfo)
724 CHECK_C_SOURCE_COMPILES("#include <sys/types.h>
725 #include <sys/socket.h>
726 #include <netinet/in.h>
730 struct addrinfo hints;
731 hints.ai_flags = AI_ADDRCONFIG;
733 }" HAVE_AI_ADDRCONFIG)
735 endif(NOT have_addrinfo)
737 # **********************************
738 # Weather calendar backend support
739 # **********************************
741 add_printable_option(ENABLE_WEATHER "Build the weather calendar backend" ON)
744 pkg_check_modules_for_option(ENABLE_WEATHER "weather calendar backend" LIBGWEATHER gweather-3.0>=${gweather_minimum_version})
746 set(CMAKE_REQUIRED_INCLUDES ${LIBGWEATHER_INCLUDE_DIRS})
747 set(CMAKE_REQUIRED_LIBRARIES ${LIBGWEATHER_LDFLAGS})
748 CHECK_C_SOURCE_COMPILES("#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
749 #include <libgweather/gweather.h>
750 #undef GWEATHER_I_KNOW_THIS_IS_UNSTABLE
753 gweather_info_new (NULL);
755 }" HAVE_ONE_ARG_GWEATHER_INFO_NEW)
756 unset(CMAKE_REQUIRED_INCLUDES)
757 unset(CMAKE_REQUIRED_LIBRARIES)
758 endif(ENABLE_WEATHER)
760 # ************************************************
761 # evolution-alarm-notify : Canberra-GTK for Sound
762 # ************************************************
764 add_printable_option(ENABLE_CANBERRA "Enable Canberra-GTK for sound in evolution-alarm-notify" ON)
767 pkg_check_modules_for_option(ENABLE_CANBERRA "Canberra-GTK for sound in evolution-alarm-notify" CANBERRA libcanberra-gtk3>=${libcanberra_gtk_minimum_version})
768 set(HAVE_CANBERRA ON)
769 endif(ENABLE_CANBERRA)
771 # ******************************
773 # ******************************
775 add_printable_option(ENABLE_DOT_LOCKING "Enable support for locking mail files with dot locking" ON)
777 if(WIN32 AND ENABLE_DOT_LOCKING)
778 message(WARNING "Auto-disabling dot locking for mail files for this platform")
779 set(ENABLE_DOT_LOCKING OFF)
780 set(USE_DOT_LOCKING OFF)
781 else(WIN32 AND ENABLE_DOT_LOCKING)
782 set(USE_DOT_LOCKING ${ENABLE_DOT_LOCKING})
783 endif(WIN32 AND ENABLE_DOT_LOCKING)
785 add_printable_variable(ENABLE_FILE_LOCKING "Enable support for locking mail files with file locking (one of fcntl/flock/no)" "fcntl")
788 if (${ENABLE_FILE_LOCKING} STREQUAL "fcntl")
789 set(USE_FCNTL_LOCKING ON)
790 elseif(${ENABLE_FILE_LOCKING} STREQUAL "flock")
791 set(USE_FLOCK_LOCKING ON)
795 # ******************************
797 # ******************************
800 if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
802 endif(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
804 add_printable_option(ENABLE_BROKEN_SPOOL "Use SunOS/Solaris sendmail which has a broken spool format" ${defval})
808 # ******************************
810 # ******************************
811 pkg_check_modules(SQLITE3 REQUIRED sqlite3>=${sqlite_minimum_version})
813 # ******************************
815 # ******************************
817 add_printable_option(ENABLE_GOOGLE "Enable Google support" ON)
819 pkg_check_modules_for_option(ENABLE_GOOGLE "Google" LIBGDATA libgdata>=${libgdata_minimum_version})
820 set(HAVE_LIBGDATA ON)
822 set(CMAKE_REQUIRED_DEFINITIONS ${LIBGDATA_CFLAGS_OTHER})
823 set(CMAKE_REQUIRED_INCLUDES ${LIBGDATA_INCLUDE_DIRS})
824 set(CMAKE_REQUIRED_LIBRARIES ${LIBGDATA_LDFLAGS})
826 CHECK_C_SOURCE_COMPILES("#include <gdata/gdata.h>
828 gdata_feed_get_next_page_token (NULL);
829 gdata_query_next_page (NULL);
831 }" HAVE_LIBGDATA_TASKS_PAGINATION_FUNCTIONS)
833 unset(CMAKE_REQUIRED_DEFINITIONS)
834 unset(CMAKE_REQUIRED_INCLUDES)
835 unset(CMAKE_REQUIRED_LIBRARIES)
838 # ******************************
839 # Checks for large file support
840 # ******************************
842 add_printable_option(ENABLE_LARGEFILE "Enable support for large files" ON)
845 CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
848 set(CMAKE_REQUIRED_FLAGS "-DHAVE_UNISTD_H")
851 CHECK_C_SOURCE_COMPILES("#ifdef HAVE_UNISTD_H
857 }" have_off64_t_bare)
858 if(NOT have_off64_t_bare)
859 CHECK_C_SOURCE_COMPILES("#define _LARGEFILE64_SOURCE
866 }" have_off64_t_with_largefile64_source)
867 endif(NOT have_off64_t_bare)
869 CHECK_C_SOURCE_COMPILES("#include <sys/types.h>
870 #include <sys/stat.h>
873 int fd = open (\"__o_largefile\", O_CREAT | O_RDWR | O_LARGEFILE, 0644);
875 }" have_o_largefile_bare)
876 if(NOT have_o_largefile_bare)
877 CHECK_C_SOURCE_COMPILES("#define _LARGEFILE64_SOURCE
878 #include <sys/types.h>
879 #include <sys/stat.h>
882 int fd = open (\"__o_largefile\", O_CREAT | O_RDWR | O_LARGEFILE, 0644);
884 }" have_o_largefile_with_largefile64_source)
885 endif(NOT have_o_largefile_bare)
887 set(HAVE_O_LARGEFILE ON)
888 if(have_o_largefile_with_largefile64_source)
889 add_definitions(-D_LARGEFILE64_SOURCE=1)
890 elseif(NOT have_o_largefile_bare)
891 set(HAVE_O_LARGEFILE OFF)
893 unset(CMAKE_REQUIRED_FLAGS)
894 else(ENABLE_LARGEFILE)
895 set(HAVE_O_LARGEFILE OFF)
896 endif(ENABLE_LARGEFILE)
898 # ******************************
899 # libical tweaks, part I
900 # ******************************
902 pkg_check_at_least_version(HAVE_LIBICAL_2_0 libical 2.0)
905 # libical.pc from libical-0.43 has a bug in its CFlags.
906 # It wants apps to include <libical/ical*.h> but it's CFlags make it difficult
907 # to differentiate between <libical/ical.h> and <ical.h>
908 # We have fixed all our instances to use <libical/ical.h>.
909 # Work-around the buggy CFlags for the 0.43 version.
911 pkg_check_exact_version(libical_is_0_43 libical 0.43)
913 pkg_check_variable(LIBICAL_EXTRA_CFLAGS libical includedir)
914 endif(libical_is_0_43)
916 # ******************************
918 # ******************************
920 pkg_check_modules(SOUP REQUIRED libsoup-2.4)
921 pkg_check_modules(DATA_SERVER REQUIRED gio-2.0 gmodule-2.0 libsecret-1 libxml-2.0 libsoup-2.4 ${mozilla_nspr} ${mozilla_nss})
922 set(E_DATA_SERVER_INCLUDES ${E_DATA_SERVER_INCLUDES} ${MANUAL_NSPR_INCLUDES} ${MANUAL_NSS_INCLUDES})
923 set(E_DATA_SERVER_LDFLAGS ${E_DATA_SERVER_LDFLAGS} ${MANUAL_NSPR_LIBS} ${MANUAL_NSS_LIBS})
925 pkg_check_modules(BACKEND REQUIRED gio-2.0 gmodule-2.0 libsecret-1 libsoup-2.4 libxml-2.0)
926 pkg_check_modules(ADDRESSBOOK REQUIRED gio-2.0 libxml-2.0 libsoup-2.4 libsecret-1)
927 pkg_check_modules(CALENDAR REQUIRED gio-2.0 libical>=${libical_minimum_version} libsoup-2.4 libxml-2.0 libsecret-1)
928 set(CALENDAR_CFLAGS ${CALENDAR_CFLAGS} ${LIBICAL_EXTRA_CFLAGS})
930 pkg_check_modules(CAMEL REQUIRED gio-2.0 gmodule-2.0 ${mozilla_nss} ${mozilla_nspr} sqlite3>=${sqlite_minimum_version})
931 set(CAMEL_CFLAGS ${CAMEL_CFLAGS} ${KRB5_CFLAGS} ${MANUAL_NSS_CFLAGS} ${MANUAL_NSPR_CFLAGS} ${ICU_CFLAGS})
932 set(CAMEL_LDFLAGS ${CAMEL_LDFLAGS} -lz ${KRB5_LDFLAGS} ${MANUAL_NSS_LIBS} ${MANUAL_NSPR_LIBS} ${ICU_LDFLAGS})
934 if(NOT (MANUAL_NSPR_INCLUDES STREQUAL ""))
935 list(APPEND CAMEL_INCLUDE_DIRS ${MANUAL_NSPR_INCLUDES})
936 endif(NOT (MANUAL_NSPR_INCLUDES STREQUAL ""))
938 if(NOT (MANUAL_NSS_INCLUDES STREQUAL ""))
939 list(APPEND CAMEL_INCLUDE_DIRS ${MANUAL_NSS_INCLUDES})
940 endif(NOT (MANUAL_NSS_INCLUDES STREQUAL ""))
942 # ******************************
943 # libical tweaks, part II (re-using CALENDAR modules)
944 # ******************************
946 set(CMAKE_REQUIRED_DEFINITIONS ${CALENDAR_CFLAGS_OTHER})
947 set(CMAKE_REQUIRED_INCLUDES ${CALENDAR_INCLUDE_DIRS})
948 set(CMAKE_REQUIRED_LIBRARIES ${CALENDAR_LDFLAGS})
950 CHECK_C_SOURCE_COMPILES("#include <libical/ical.h>
952 ical_set_unknown_token_handling_setting (ICAL_DISCARD_TOKEN);
954 }" HAVE_ICAL_UNKNOWN_TOKEN_HANDLING)
956 CHECK_C_SOURCE_COMPILES("#include <libical/ical.h>
958 icaltzutil_set_exact_vtimezones_support (0);
960 }" HAVE_ICALTZUTIL_SET_EXACT_VTIMEZONES_SUPPORT)
962 CHECK_C_SOURCE_COMPILES("#include <libical/ical.h>
964 icalproperty_status_to_string (ICAL_STATUS_DELETED);
966 }" HAVE_ICAL_STATUS_DELETED)
968 unset(CMAKE_REQUIRED_DEFINITIONS)
969 unset(CMAKE_REQUIRED_INCLUDES)
970 unset(CMAKE_REQUIRED_LIBRARIES)
972 # ******************************
974 # ******************************
976 add_printable_option(ENABLE_VALA_BINDINGS "Build the experimental Vala bindings" OFF)
978 if(ENABLE_VALA_BINDINGS)
979 if(NOT ENABLE_INTROSPECTION)
980 message(FATAL_ERROR "Vala bindings require introspection generation to be enabled, use -DENABLE_INTROSPECTION=ON to enable it, or disable Vala bindings with -DENABLE_VALA_BINDINGS=OFF")
981 endif(NOT ENABLE_INTROSPECTION)
983 find_program(VALAC valac)
985 message(FATAL_ERROR "The valac not found. Install it or disable Vala bindings with -DENABLE_VALA_BINDINGS=OFF")
988 find_program(VAPIGEN vapigen)
990 message(FATAL_ERROR "The vapigen not found. Install it or disable Vala bindings with -DENABLE_VALA_BINDINGS=OFF")
993 endif(ENABLE_VALA_BINDINGS)
995 # Generate the ${PROJECT_NAME}-config.h file
996 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/config.h.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.h)
998 print_build_options()
1000 add_pkgconfig_file(evolution-data-server.pc.in evolution-data-server-${API_VERSION}.pc)
1002 add_subdirectory(data)
1003 add_subdirectory(po)
1004 add_subdirectory(src)
1005 add_subdirectory(tests)
1008 add_subdirectory(docs)
1009 endif(ENABLE_GTK_DOC)