[evolution/wip/cmake] Some initial work with configure.ac port to CMakeLists.txt



commit 63c6c77c6da21d001ce81f05f98acfd775789c13
Author: Milan Crha <mcrha redhat com>
Date:   Fri Sep 30 16:50:56 2016 +0200

    Some initial work with configure.ac port to CMakeLists.txt

 .gitignore                                      |    1 +
 CMakeLists.txt                                  |  679 +++++++++++++++++++++++
 addressbook/gui/widgets/e-contact-map-window.c  |    5 +-
 addressbook/gui/widgets/e-contact-map-window.h  |    4 +-
 addressbook/gui/widgets/e-contact-map.c         |    4 +-
 addressbook/gui/widgets/e-contact-map.h         |    4 +-
 addressbook/gui/widgets/eab-contact-display.c   |    4 +-
 addressbook/gui/widgets/eab-contact-formatter.c |    4 +-
 cmake/cmake_uninstall.cmake.in                  |   21 +
 cmake/modules/CheckTarget.cmake                 |   21 +
 cmake/modules/CodeCoverageGCOV.cmake            |   45 ++
 cmake/modules/DistTargets.cmake                 |   86 +++
 cmake/modules/FindIntltool.cmake                |  209 +++++++
 cmake/modules/FindLDAP.cmake                    |  133 +++++
 cmake/modules/FindSMIME.cmake                   |  146 +++++
 cmake/modules/GLibTools.cmake                   |  251 +++++++++
 cmake/modules/GObjectIntrospection.cmake        |  233 ++++++++
 cmake/modules/GtkDoc.cmake                      |  150 +++++
 cmake/modules/InstalledTests.cmake              |   45 ++
 cmake/modules/PkgConfigEx.cmake                 |   90 +++
 cmake/modules/PrintableOptions.cmake            |   74 +++
 cmake/modules/SetupBuildFlags.cmake             |   80 +++
 cmake/modules/UninstallTarget.cmake             |   13 +
 cmake/verify-news-file.sh                       |   39 ++
 composer/e-composer-actions.c                   |    2 +-
 composer/e-msg-composer.c                       |   10 +-
 config.h.in                                     |  127 +++++
 e-util/e-spell-text-view.c                      |   18 +-
 em-format/e-mail-part-secure-button.c           |    8 +-
 enumtypes.c.template                            |   37 --
 enumtypes.h.template                            |   24 -
 evolution-calendar.pc.in                        |   13 +-
 evolution-mail.pc.in                            |   13 +-
 evolution-shell.pc.in                           |   15 +-
 iconv-detect.c                                  |   66 ++-
 libemail-engine/e-mail-folder-utils.c           |    2 +-
 libemail-engine/e-mail-session-utils.c          |    2 +-
 libemail-engine/mail-ops.c                      |    2 +-
 mail/e-mail-config-security-page.c              |   16 +-
 modules/addressbook/e-book-shell-view-actions.c |    6 +-
 modules/mdn/evolution-mdn.c                     |    2 +-
 shell/killev.c                                  |   22 +-
 shell/main.c                                    |    6 +-
 43 files changed, 2560 insertions(+), 172 deletions(-)
---
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..378eac2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+build
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..5c3087b
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,679 @@
+# Evolution-Data-Server build script
+
+cmake_minimum_required(VERSION 3.0)
+cmake_policy(VERSION 3.0)
+
+project(evolution
+       VERSION 3.23.1
+       LANGUAGES C CXX)
+set(PROJECT_BUGREPORT "http://bugzilla.gnome.org/enter_bug.cgi?product=Evolution";)
+set(PROJECT_URL "http://wiki.gnome.org/Apps/Evolution/";)
+
+# Base Version: This is for API/version tracking for things like
+# D-Bus server files. This should always be the major/minor of
+# the stable version or stable version to be.
+set(BASE_VERSION 3.24)
+
+# Used for pkg-config files
+set(INTERFACE_VERSION 3.0)
+
+math(EXPR _is_devel_version "${PROJECT_VERSION_MINOR}%2")
+if(_is_devel_version EQUAL 1)
+       math(EXPR _minor "${PROJECT_VERSION_MINOR}-1")
+       if(_minor EQUAL -1)
+               set(_minor 98)
+               math(EXPR _major "${PROJECT_VERSION_MAJOR}-1")
+       else(_minor EQUAL -1)
+               set(_major ${PROJECT_VERSION_MAJOR})
+       endif(_minor EQUAL -1)
+
+       set(STABLE_VERSION "${_major}.${_minor}")
+else(_is_devel_version EQUAL 1)
+       unset(STABLE_VERSION)
+endif(_is_devel_version EQUAL 1)
+
+# Required for FindIntltool module
+set(GETTEXT_PACKAGE ${PROJECT_NAME}-${BASE_VERSION})
+set(GETTEXT_PO_DIR ${CMAKE_SOURCE_DIR}/po)
+
+# Required for 'disttest' and 'ditcheck' of DistTarget module
+set(PROJECT_DISTCONFIGURE_PARAMS
+       -DENABLE_GTK_DOC=ON
+       -DWITH_HELP=ON
+)
+
+# Keep these two definitions in agreement.
+set(glib_minimum_version 2.46)
+set(glib_encoded_version GLIB_VERSION_2_46)
+
+# Keep these two definitions in agreement.
+set(gdk_minimum_version 3.10)
+set(gdk_encoded_version GDK_VERSION_3_10)
+
+# Keep these two definitions in agreement.
+set(soup_minimum_version 2.42)
+set(soup_encoded_version SOUP_VERSION_2_42)
+
+# Warn about API usage that violates our minimum requirements.
+add_definitions(-DGLIB_VERSION_MAX_ALLOWED=${glib_encoded_version})
+add_definitions(-DGDK_VERSION_MAX_ALLOWED=${gdk_encoded_version})
+add_definitions(-DSOUP_VERSION_MAX_ALLOWED=${soup_encoded_version})
+
+# These will suppress warnings about newly-deprecated symbols. Ideally
+# these settings should match our minimum requirements and we will clean
+# up any new deprecation warnings after bumping our minimum requirements.
+# But if the warnings get to be overwhelming, use fixed versions instead.
+add_definitions(-DGLIB_VERSION_MIN_REQUIRED=${glib_encoded_version})
+add_definitions(-DGDK_VERSION_MIN_REQUIRED=${gdk_encoded_version})
+add_definitions(-DSOUP_VERSION_MIN_REQUIRED=${soup_encoded_version})
+
+set(eds_minimum_version ${PROJECT_VERSION})
+set(enchant_minimum_version 1.1.7)
+set(gcr_minimum_version 3.4)
+set(gdk_pixbuf_minimum_version 2.24.0)
+set(gnome_desktop_minimum_version 2.91.3)
+set(gsettings_desktop_schemas_minimum_version 2.91.92)
+set(libpst_minimum_version 0.6.54)
+set(libxml_minimum_version 2.7.3)
+set(shared_mime_info_minimum_version 0.22)
+set(webkit2gtk_minimum_version 2.13.90)
+
+# Optional Packages
+set(champlain_minimum_version 0.12)
+set(clutter_gtk_minimum_version 0.90)
+set(geocode_glib_minimum_version 3.10)
+set(gladeui_minimum_version 3.10.0)
+set(gnome_autoar_minimum_version 0.1.1)
+set(gweather_minimum_version 3.10)
+set(libcanberra_gtk_minimum_version 0.25)
+set(libnotify_minimum_version 0.7)
+
+# Load modules from the source tree
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
+
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+set(CMAKE_SKIP_BUILD_RPATH OFF)
+set(CMAKE_BUILD_WITH_INSTALL_RPATH OFF)
+set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
+# CMAKE_INSTALL_RPATH is set below
+
+# CMake modules
+include(CheckCCompilerFlag)
+include(CheckCSourceCompiles)
+include(CheckCSourceRuns)
+include(CheckFunctionExists)
+include(CheckIncludeFile)
+include(CheckLibraryExists)
+
+# Project custom modules
+include(PrintableOptions)
+
+add_printable_variable(LIB_SUFFIX "Library directory suffix, usually defined to '64' for x86_64 systems" "")
+add_printable_variable_bare(CMAKE_INSTALL_PREFIX)
+add_printable_variable_path(BIN_INSTALL_DIR "Install directory for binary files, defaults to 
CMAKE_INSTALL_PREFIX/bin" "${CMAKE_INSTALL_PREFIX}/bin")
+add_printable_variable_path(INCLUDE_INSTALL_DIR "Install directory for header files, defaults to 
CMAKE_INSTALL_PREFIX/include" "${CMAKE_INSTALL_PREFIX}/include")
+add_printable_variable_path(LIB_INSTALL_DIR "Install directory for library files, defaults to 
CMAKE_INSTALL_PREFIX/lib{LIB_SUFFIX}" "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
+add_printable_variable_path(LIBEXEC_INSTALL_DIR "Install directory for library executable files, defaults to 
CMAKE_INSTALL_PREFIX/libexec" "${CMAKE_INSTALL_PREFIX}/libexec")
+add_printable_variable_path(SHARE_INSTALL_DIR "Install directory for shared files, defaults to 
CMAKE_INSTALL_PREFIX/share" "${CMAKE_INSTALL_PREFIX}/share")
+add_printable_variable_path(LOCALE_INSTALL_DIR "Install directory for locale files, defaults to 
SHARE_INSTALL_DIR/locale" "${SHARE_INSTALL_DIR}/locale")
+add_printable_variable_path(SYSCONF_INSTALL_DIR "Install directory for system configuration files, defaults 
to CMAKE_INSTALL_PREFIX/etc" "${CMAKE_INSTALL_PREFIX}/etc")
+
+# ******************************
+# Special directories
+# ******************************
+
+# If you add something here, consider whether or not you also
+# need to add it to one or more .pc.in files (for Connector, etc)
+
+set(privdatadir "${SHARE_INSTALL_DIR}/${PROJECT_NAME}")
+set(privincludedir "${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}")
+set(privlibdir "${LIB_INSTALL_DIR}/${PROJECT_NAME}")
+set(privlibexecdir "${LIBEXEC_INSTALL_DIR}/${PROJECT_NAME}")
+
+SET(CMAKE_INSTALL_RPATH "${LIB_INSTALL_DIR}:${privlibdir}")
+
+if(WIN32)
+       # On Win32 there is no "rpath" mechanism. We install the private
+       # shared libraries in $libdir, meaning the DLLs will actually be in
+       # $bindir. This means just having $bindir in PATH will be enough.
+       set(privsolibdir "${LIB_INSTALL_DIR}")
+else(WIN32)
+       set(privsolibdir "${privlibdir}")
+endif(WIN32)
+
+set(errordir "${privdatadir}/errors")
+set(etspecdir "${privdatadir}/etspec")
+set(evolutionhelpdir "${privdatadir}/help")
+set(icondir "${privdatadir}/icons")
+set(imagesdir "${privdatadir}/images")
+set(moduledir "${privlibdir}/modules")
+set(plugindir "${privlibdir}/plugins")
+set(uidir "${privdatadir}/ui")
+set(viewsdir "${privdatadir}/views")
+set(webextensionsdir "${privlibdir}/web-extensions")
+set(webextensionswebkiteditordir "${webextensionsdir}/webkit-editor")
+
+# ******************************
+# Dependencies
+# ******************************
+
+include(CodeCoverageGCOV)
+include(CheckTarget)
+include(DistTargets)
+include(GLibTools)
+include(GObjectIntrospection)
+include(GtkDoc)
+include(InstalledTests)
+include(PkgConfigEx)
+include(SetupBuildFlags)
+include(UninstallTarget)
+
+include(FindIntltool)
+include(FindLDAP)
+include(FindSMIME)
+
+add_printable_option(ENABLE_MAINTAINER_MODE "Enable maintainer mode" OFF)
+add_printable_variable(VERSION_SUBSTRING "Version substring, for packagers" "")
+add_printable_variable(VERSION_COMMENT "Define if you want a comment appended to the version number" "")
+
+if(ENABLE_MAINTAINER_MODE)
+       set(BUILD_TESTING ON)
+endif(ENABLE_MAINTAINER_MODE)
+
+# Setup compiler/linker flags
+setup_build_flags(${ENABLE_MAINTAINER_MODE})
+
+CHECK_INCLUDE_FILE(sys/wait.h HAVE_SYS_WAIT_H)
+CHECK_INCLUDE_FILE(X11/XF86keysym.h HAVE_XFREE)
+CHECK_FUNCTION_EXISTS(mkdtemp HAVE_MKDTEMP)
+CHECK_FUNCTION_EXISTS(nl_langinfo HAVE_NL_LANGINFO)
+
+# ******************************
+# executables
+# ******************************
+
+find_program(KILL_PROCESS_COMMAND killall)
+if(NOT KILL_PROCESS_COMMAND)
+       find_program(KILL_PROCESS_COMMAND pkill)
+endif(NOT KILL_PROCESS_COMMAND)
+
+if(NOT KILL_PROCESS_COMMAND)
+       message(WARNING "Could not find a command to kill a process by name")
+endif(NOT KILL_PROCESS_COMMAND)
+
+# ******************************
+# Check for nl_langinfo features
+# ******************************
+
+CHECK_C_SOURCE_COMPILES("#include <langinfo.h>
+                       int main(void) { char *detail = nl_langinfo (_NL_MEASUREMENT_MEASUREMENT); return 0; 
}" HAVE__NL_MEASUREMENT_MEASUREMENT)
+
+# ******************************
+# Dependencies
+# ******************************
+
+if(WIN32)
+       set(GIO_UNIX_REQUIREMENT "gio-windows-2.0")
+else(WIN32)
+       set(GIO_UNIX_REQUIREMENT "gio-unix-2.0")
+endif(WIN32)
+
+add_printable_option(ENABLE_GNOME_DESKTOP "Enable GNOME desktop dependency for thumbnails" ON)
+
+if(ENABLE_GNOME_DESKTOP)
+       set(GNOME_DESKTOP_DEPENDENCY "gnome-desktop-3.0>=${gnome_desktop_minimum_version}")
+       set(HAVE_GNOME_DESKTOP ON)
+
+       # It's checked for it twice, this one gives a hint to disable the dependency if not found
+       pkg_check_modules_for_option(ENABLE_GNOME_DESKTOP "GNOME desktop dependency for thumbnails" 
GNOME_DESKTOP ${GNOME_DESKTOP_DEPENDENCY})
+else(ENABLE_GNOME_DESKTOP)
+       set(GNOME_DESKTOP_DEPENDENCY "")
+       set(HAVE_GNOME_DESKTOP OFF)
+endif(ENABLE_GNOME_DESKTOP)
+
+pkg_check_modules(GNOME_PLATFORM
+       cairo-gobject
+       gail-3.0>=${gdk_minimum_version}
+       gcr-3>=${gcr_minimum_version}
+       gdk-pixbuf-2.0>=${gdk_pixbuf_minimum_version}
+       gio-2.0>=${glib_minimum_version}
+       ${GIO_UNIX_REQUIREMENT}
+       gmodule-2.0>=${glib_minimum_version}
+       ${GNOME_DESKTOP_DEPENDENCY}
+       gsettings-desktop-schemas>=${gsettings_desktop_schemas_minimum_version}
+       gtk+-3.0>=${gdk_minimum_version}
+       libxml-2.0>=${libxml_minimum_version}
+       shared-mime-info>=${shared_mime_info_minimum_version}
+       webkit2gtk-4.0>=${webkit2gtk_minimum_version}
+)
+
+pkg_check_modules(EVOLUTION_DATA_SERVER
+       camel-1.2>=${eds_minimum_version}
+       libebook-1.2>=${eds_minimum_version}
+       libecal-1.2>=${eds_minimum_version}
+       libedataserver-1.2>=${eds_minimum_version}
+       libedataserverui-1.2>=${eds_minimum_version}
+       libebackend-1.2>=${eds_minimum_version}
+)
+
+pkg_check_modules(A11Y atk)
+pkg_check_modules(ENCHANT enchant>=${enchant_minimum_version})
+pkg_check_modules(LIBSOUP libsoup-2.4>=${soup_minimum_version})
+pkg_check_modules(WEB_EXTENSION webkit2gtk-4.0>=${webkit2gtk_minimum_version})
+
+# ******************************
+# Canberra / Canberra-GTK Sound
+# ******************************
+
+add_printable_option(ENABLE_CANBERRA "Enable Canberra and Canberra-GTK sound" ON)
+
+if(ENABLE_CANBERRA)
+       pkg_check_modules_for_option(ENABLE_CANBERRA "Canberra and Canberra-GTK sound" CANBERRA 
libcanberra-gtk3>=${libcanberra_gtk_minimum_version})
+       set(HAVE_CANBERRA ON)
+endif(ENABLE_CANBERRA)
+
+# ******************************
+# Archives Integration / gnome-autoar
+# ******************************
+
+add_printable_option(ENABLE_AUTOAR "Enable archives support in attachments" ON)
+
+if(ENABLE_AUTOAR)
+       pkg_check_modules_for_option(ENABLE_AUTOAR "archives support in attachments" AUTOAR
+               gnome-autoar-0>=${gnome_autoar_minimum_version}
+               gnome-autoar-gtk-0>=${gnome_autoar_minimum_version}
+       )
+       set(HAVE_AUTOAR ON)
+endif(ENABLE_AUTOAR)
+
+# ******************************
+# User Documentation
+# ******************************
+
+add_printable_option(WITH_HELP "Build user documentation" ON)
+
+# ******************************
+# iconv checking
+# ******************************
+
+set(CMAKE_REQUIRED_LIBRARIES "-liconv")
+CHECK_C_SOURCE_COMPILES("#include <iconv.h>
+                       #include <stdlib.h>
+                       int main(void) { iconv_t cd; cd = iconv_open (\"UTF-8\", \"ISO-8859-1\"); return 0; 
}" HAVE_LIBICONV)
+unset(CMAKE_REQUIRED_LIBRARIES)
+
+if(HAVE_LIBICONV)
+       set(ICONV_LIBS "-liconv")
+       set(HAVE_ICONV ON)
+else(HAVE_LIBICONV)
+       set(ICONV_LIBS "")
+       CHECK_FUNCTION_EXISTS(iconv HAVE_ICONV)
+endif(HAVE_LIBICONV)
+
+if(NOT HAVE_ICONV)
+       message(FATAL_ERROR "You need to install a working iconv implementation, such as 
ftp://ftp.gnu.org/pub/gnu/libiconv";)
+endif(NOT HAVE_ICONV)
+
+set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBS})
+CHECK_C_SOURCE_RUNS("#include \"${CMAKE_SOURCE_DIR}/iconv-detect.c\"" _correct_iconv)
+unset(CMAKE_REQUIRED_LIBRARIES)
+
+if(NOT _correct_iconv)
+       message(FATAL_ERROR "You need to install a working iconv implementation, such as 
ftp://ftp.gnu.org/pub/gnu/libiconv";)
+endif(NOT _correct_iconv)
+
+# ******************************
+# Timezone checks
+# ******************************
+
+CHECK_C_SOURCE_COMPILES("#include <time.h>
+                       int main(void) { struct tm tm; tm.tm_gmtoff = 1; return 0; }" HAVE_TM_GMTOFF)
+
+CHECK_C_SOURCE_COMPILES("#include <time.h>
+                       int main(void) { timezone = 1; return 0; }" HAVE_TIMEZONE)
+
+CHECK_C_SOURCE_COMPILES("#include <time.h>
+                       int main(void) { altzone = 1; return 0; }" HAVE_ALTZONE)
+
+if((NOT HAVE_TM_GMTOFF) AND (NOT HAVE_TIMEZONE))
+       message(FATAL_ERROR "Unable to find a way to determine timezone")
+endif((NOT HAVE_TM_GMTOFF) AND (NOT HAVE_TIMEZONE))
+
+# ******************************
+# iso-codes
+# ******************************
+
+pkg_check_exists(HAVE_ISO_CODES iso-codes)
+if(HAVE_ISO_CODES)
+       pkg_check_at_least_version(HAVE_ISO_CODES iso-codes 0.49)
+       if(HAVE_ISO_CODES)
+               pkg_check_variable(_iso_codes_domains iso-codes domains)
+               if(NOT ((_iso_codes_domains MATCHES "639") AND (_iso_codes_domains MATCHES "3166")))
+                       message(WARNING "iso-codes detected, but either iso-639 or iso-3166 domains not found 
in '${_iso_codes_domains}'")
+                       set(HAVE_ISO_CODES OFF)
+               else()
+                       pkg_check_variable(ISO_CODES_PREFIX iso-codes prefix)
+               endif()
+       else(HAVE_ISO_CODES)
+               set(HAVE_ISO_CODES OFF)
+               message(WARNING "iso-codes detected, but version 0.49 or later is required due to licensing")
+       endif(HAVE_ISO_CODES)
+endif(HAVE_ISO_CODES)
+
+# ******************************
+# libcryptui, aka Seahorse
+# ******************************
+
+add_printable_option(ENABLE_LIBCRYPTUI "Enable libcryptui usage" ON)
+
+if(ENABLE_LIBCRYPTUI)
+       pkg_check_modules_for_option(ENABLE_LIBCRYPTUI "libcryptui usage" LIBCRYPTUI cryptui-0.0)
+       set(HAVE_AUTOAR ON)
+endif(ENABLE_LIBCRYPTUI)
+
+# ******************************
+# TNEF implementation
+# ******************************
+
+set(HAVE_LIBYTNEF_YTNEF_H OFF)
+
+CHECK_C_SOURCE_COMPILES("#include <stdio.h>
+                       #include <ytnef.h>
+                       int main(void) { TNEFStruct *tnef; return 0; }" HAVE_YTNEF_H)
+
+if(NOT HAVE_YTNEF_H)
+       CHECK_C_SOURCE_COMPILES("#include <stdio.h>
+                               #include <libytnef/ytnef.h>
+                               int main(void) { TNEFStruct *tnef; return 0; }" HAVE_LIBYTNEF_YTNEF_H)
+endif(NOT HAVE_YTNEF_H)
+
+if(HAVE_YTNEF_H OR HAVE_LIBYTNEF_YTNEF_H)
+       set(HAVE_TNEF ON)
+endif(HAVE_YTNEF_H OR HAVE_LIBYTNEF_YTNEF_H)
+
+# ******************************
+# Bogofilter (spam filter)
+# ******************************
+
+add_printable_variable_path(WITH_BOGOFILTER "Enable spam filtering using Bogofilter (defaults to 
/usr/bin/bogofilter)" ON)
+
+string(LENGTH "${CMAKE_BINARY_DIR}" bindirlen)
+string(SUBSTRING "${WITH_BOGOFILTER}" 0 ${bindirlen} substr)
+string(TOUPPER "${WITH_BOGOFILTER}" optupper)
+
+set(BOGOFILTER_COMMAND "")
+if(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+       set(WITH_BOGOFILTER ON)
+elseif(("${optupper}" STREQUAL "OFF") OR ("${optupper}" STREQUAL "NO"))
+       set(WITH_BOGOFILTER OFF)
+else()
+       set(BOGOFILTER_COMMAND "${WITH_BOGOFILTER}")
+       set(WITH_BOGOFILTER ON)
+endif()
+
+if(WITH_BOGOFILTER)
+       if(BOGOFILTER_COMMAND STREQUAL "")
+               set(BOGOFILTER_COMMAND "$ENV{BOGOFILTER}")
+       endif(BOGOFILTER_COMMAND STREQUAL "")
+       if(BOGOFILTER_COMMAND STREQUAL "")
+               set(BOGOFILTER_COMMAND "/usr/bin/bogofilter")
+       endif(BOGOFILTER_COMMAND STREQUAL "")
+endif(WITH_BOGOFILTER)
+
+unset(bindirlen)
+unset(substr)
+unset(optupper)
+
+# ******************************
+# SpamAssassin (spam filter)
+# ******************************
+
+add_printable_variable_path(WITH_SPAMASSASSIN "Enable spam filtering using SpamAssassin (defaults to 
/usr/bin/spamassassin)" ON)
+add_printable_variable_path(WITH_SA_LEARN "Full path command where sa-learn is located (defaults to 
/usr/bin/sa-learn)" ON)
+
+string(LENGTH "${CMAKE_BINARY_DIR}" bindirlen)
+string(SUBSTRING "${WITH_SPAMASSASSIN}" 0 ${bindirlen} substr)
+string(TOUPPER "${WITH_SPAMASSASSIN}" optupper)
+
+set(SPAMASSASSIN_COMMAND "")
+if(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+       set(WITH_SPAMASSASSIN ON)
+elseif(("${optupper}" STREQUAL "OFF") OR ("${optupper}" STREQUAL "NO"))
+       set(WITH_SPAMASSASSIN OFF)
+else()
+       set(SPAMASSASSIN_COMMAND "${WITH_SPAMASSASSIN}")
+       set(WITH_SPAMASSASSIN ON)
+endif()
+
+if(WITH_SPAMASSASSIN)
+       if(SPAMASSASSIN_COMMAND STREQUAL "")
+               set(SPAMASSASSIN_COMMAND "$ENV{SPAMASSASSIN}")
+       endif(SPAMASSASSIN_COMMAND STREQUAL "")
+       if(SPAMASSASSIN_COMMAND STREQUAL "")
+               set(SPAMASSASSIN_COMMAND "/usr/bin/spamassassin")
+       endif(SPAMASSASSIN_COMMAND STREQUAL "")
+
+       string(SUBSTRING "${WITH_SA_LEARN}" 0 ${bindirlen} substr)
+       string(TOUPPER "${WITH_SA_LEARN}" optupper)
+
+       set(SA_LEARN_COMMAND "")
+       if(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+               set(WITH_SA_LEARN ON)
+       elseif(("${optupper}" STREQUAL "OFF") OR ("${optupper}" STREQUAL "NO"))
+               set(WITH_SA_LEARN OFF)
+       else()
+               set(SA_LEARN_COMMAND "${WITH_SA_LEARN}")
+               set(WITH_SA_LEARN ON)
+       endif()
+
+       if(SA_LEARN_COMMAND STREQUAL "")
+               set(SA_LEARN_COMMAND "$ENV{SA_LEARN}")
+       endif(SA_LEARN_COMMAND STREQUAL "")
+       if(SA_LEARN_COMMAND STREQUAL "")
+               set(SA_LEARN_COMMAND "/usr/bin/sa-learn")
+       endif(SA_LEARN_COMMAND STREQUAL "")
+endif(WITH_SPAMASSASSIN)
+
+unset(bindirlen)
+unset(substr)
+unset(optupper)
+
+# ******************************
+# CERT_UI Flags
+# ******************************
+#
+# Here we want the Mozilla flags to go *before* the other ones,
+# especially the mozilla-nss -I flags to go before the gnutls ones,
+# as both gnutls and mozilla-nss have a header called "pkcs12.h" which is
+# included in smime/lib/e-pkcs12.c. It wants the Mozilla NSS one.
+
+set(CERT_UI_INCLUDES "${MANUAL_NSPR_INCLUDES}")
+set(CERT_UI_LIBS "${MANUAL_NSPR_LIBS}")
+
+# ******************************
+# Libnotify
+# ******************************
+
+pkg_check_modules(LIBNOTIFY libnotify>=${libnotify_minimum_version})
+set(HAVE_LIBNOTIFY ${LIBNOTIFY_FOUND})
+
+# ******************************
+# libical tweaks
+# ******************************
+
+set(CMAKE_REQUIRED_FLAGS "${EVOLUTION_DATA_SERVER_CFLAGS}")
+set(CMAKE_REQUIRED_INCLUDES "${EVOLUTION_DATA_SERVER_INCLUDE_DIRS}")
+set(CMAKE_REQUIRED_LIBRARIES "${EVOLUTION_DATA_SERVER_LDFLAGS}")
+
+CHECK_C_SOURCE_COMPILES("#include <libical/ical.h>
+                       int main(void) {
+                               ical_set_unknown_token_handling_setting (ICAL_DISCARD_TOKEN);
+                               return 0;
+                       }" HAVE_ICAL_UNKNOWN_TOKEN_HANDLING)
+
+CHECK_C_SOURCE_COMPILES("#include <libical/ical.h>
+                       int main(void) {
+                               icaltzutil_set_exact_vtimezones_support (0);
+                               return 0;
+                       }" HAVE_ICALTZUTIL_SET_EXACT_VTIMEZONES_SUPPORT)
+
+unset(CMAKE_REQUIRED_FLAGS)
+unset(CMAKE_REQUIRED_LIBRARIES)
+
+# ******************************
+# gtkspell
+# ******************************
+
+add_printable_option(ENABLE_GTKSPELL "Enable gtkspell usage" ON)
+
+if(ENABLE_GTKSPELL)
+       pkg_check_modules_for_option(ENABLE_GTKSPELL "gtkspell usage" GTKSPELL gtkspell3-3.0)
+       set(HAVE_GTKSPELL ON)
+endif(ENABLE_GTKSPELL)
+
+# ******************************
+# gnu_get_libc_version()
+# ******************************
+
+CHECK_C_SOURCE_COMPILES("#include <gnu/libc-version.h>
+                       int main(void) { const gchar *libc_version = gnu_get_libc_version (); return 0; }" 
HAVE_GNU_GET_LIBC_VERSION)
+
+# ******************************
+# Plugins
+# ******************************
+
+add_printable_variable(ENABLE_PLUGINS "Enable plugins (no/base/all)" "all")
+
+set(plugins_base
+       publish-calendar
+)
+set(plugins_standard
+       attachment-reminder
+       bbdb
+       dbx-import
+       email-custom-header
+       external-editor
+       face
+       mail-to-task
+       mailing-list-actions
+       mail-notification
+       save-calendar
+       templates
+)
+
+# ******************************************************************
+# The following plugins have additional library dependencies.
+# They must be explicitly disabled if the libraries are not present.
+# ******************************************************************
+
+# test-highlight
+
+add_printable_option(ENABLE_TEXT_HIGHLIGHT "Enable text-highlight plugin" ON)
+
+if(ENABLE_TEXT_HIGHLIGHT)
+       find_program(HIGHLIGHT_COMMAND highlight)
+
+       if(NOT HIGHLIGHT_COMMAND)
+               message(FATAL_ERROR "The 'highlight' program not found; either give it into PATH or disable 
higlight plugin with -DENABLE_TEXT_HIGHLIGHT=OFF")
+       endif(NOT HIGHLIGHT_COMMAND)
+endif(ENABLE_TEXT_HIGHLIGHT)
+
+# weather calendar
+
+add_printable_option(ENABLE_WEATHER "Enable weather calendars" ON)
+
+if(ENABLE_WEATHER)
+       pkg_check_modules_for_option(ENABLE_WEATHER "weather calendar" GWEATHER 
gweather-3.0>=${gweather_minimum_version})
+endif(ENABLE_WEATHER)
+
+# maps in Contacts preview
+
+add_printable_option(ENABLE_CONTACT_MAPS "Enable contact maps" OFF)
+
+if(ENABLE_CONTACT_MAPS)
+       pkg_check_modules_for_option(ENABLE_CONTACT_MAPS "contact maps" CHAMPLAIN 
champlain-gtk-0.12>=${champlain_minimum_version})
+       pkg_check_modules_for_option(ENABLE_CONTACT_MAPS "contact maps" GEO 
geocode-glib-1.0>=${geocode_glib_minimum_version})
+       pkg_check_modules_for_option(ENABLE_CONTACT_MAPS "contact maps" CLUTTER_GTK 
clutter-gtk-1.0>=${clutter_gtk_minimum_version})
+endif(ENABLE_CONTACT_MAPS)
+
+# pst-import plugin
+
+add_printable_option(ENABLE_PST_IMPORT "Enable pst-import plugin" ON)
+
+if(ENABLE_PST_IMPORT)
+       pkg_check_modules_for_option(ENABLE_PST_IMPORT "pst-import plugin" LIBPST 
libpst>=${libpst_minimum_version})
+       list(APPEND standard_plugins pst-import)
+endif(ENABLE_PST_IMPORT)
+
+# Finish plugins build setup
+set(build_plugins)
+
+if(ENABLE_PLUGINS STREQUAL "" OR ENABLE_PLUGINS STREQUAL "all")
+       set(build_plugins ${plugins_base} ${plugins_standard})
+elseif(ENABLE_PLUGINS STREQUAL "base")
+       set(build_plugins ${plugins_base})
+elseif(NOT ENABLE_PLUGINS STREQUAL "no")
+       message(FATAL_ERROR "Incorret value for ENABLE_PLUGINS (${ENABLE_PLUGINS}), use either \"no\", or 
\"base\" or \"all\" value")
+endif()
+
+# ******************************
+# Glade catalog
+# ******************************
+
+add_printable_option(WITH_GLADE_CATALOG "Install the catalog files for Glade 3 (for maintainers only)" OFF)
+
+if(WITH_GLADE_CATALOG)
+       pkg_check_modules_for_option(WITH_GLADE_CATALOG "Glade 3 catalog files" GLADEUI 
gladeui-2.0>=${gladeui_minimum_version})
+endif(WITH_GLADE_CATALOG)
+
+# Generate the config.h file
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/config.h.in ${CMAKE_BINARY_DIR}/config.h)
+
+add_definitions(-DHAVE_CONFIG_H=1)
+
+print_build_options()
+
+# The shell_private_requirements is used by the evolution-shell.pc.in
+if(ENABLE_GNOME_DESKTOP)
+       set(shell_private_requirements "Requires.private: ${GNOME_DESKTOP_DEPENDENCY}")
+else(ENABLE_GNOME_DESKTOP)
+       set(shell_private_requirements "")
+endif(ENABLE_GNOME_DESKTOP)
+
+add_pkgconfig_file(evolution-calendar.pc.in evolution-calendar-${INTERFACE_VERSION}.pc)
+add_pkgconfig_file(evolution-mail.pc.in evolution-mail-${INTERFACE_VERSION}.pc)
+add_pkgconfig_file(evolution-shell.pc.in evolution-shell-${INTERFACE_VERSION}.pc)
+
+add_appdata_file(evolution.appdata.xml.in evolution.appdata.xml)
+
+#add_subdirectory(data)
+#add_subdirectory(libgnomecanvas)
+#add_subdirectory(e-util)
+#add_subdirectory(libemail-engine)
+#add_subdirectory(shell)
+#add_subdirectory(em-format)
+#add_subdirectory(addressbook)
+#add_subdirectory(composer)
+#add_subdirectory(mail)
+#add_subdirectory(calendar)
+#add_subdirectory(art)
+#add_subdirectory(web-extensions)
+#add_subdirectory(plugins)
+#add_subdirectory(modules)
+#add_subdirectory(doc)
+#add_subdirectory(ui)
+#add_subdirectory(views)
+#add_subdirectory(po)
+#add_subdirectory(sounds)
+
+#if(WITH_HELP)
+#      add_subdirectory(help)
+#endif(WITH_HELP)
+
+#if(GLADE_CATALOG)
+#      add_subdirectory(maint)
+#endif(GLADE_CATALOG)
+
+#if(ENABLE_SMIME)
+#      add_subdirectory(smime)
+#endif(ENABLE_SMIME)
diff --git a/addressbook/gui/widgets/e-contact-map-window.c b/addressbook/gui/widgets/e-contact-map-window.c
index 292d5f3..caa21d6 100644
--- a/addressbook/gui/widgets/e-contact-map-window.c
+++ b/addressbook/gui/widgets/e-contact-map-window.c
@@ -18,11 +18,10 @@
  */
 
 #ifdef HAVE_CONFIG_H
-/* This defines WITH_CONTACT_MAPS. */
 #include <config.h>
 #endif
 
-#ifdef WITH_CONTACT_MAPS
+#ifdef ENABLE_CONTACT_MAPS
 
 #include "e-contact-map-window.h"
 
@@ -505,4 +504,4 @@ e_contact_map_window_load_addressbook (EContactMapWindow *map,
        g_free (query_string);
 }
 
-#endif /* WITH_CONTACT_MAPS */
+#endif /* ENABLE_CONTACT_MAPS */
diff --git a/addressbook/gui/widgets/e-contact-map-window.h b/addressbook/gui/widgets/e-contact-map-window.h
index 9a0838a..d9ce49c 100644
--- a/addressbook/gui/widgets/e-contact-map-window.h
+++ b/addressbook/gui/widgets/e-contact-map-window.h
@@ -20,7 +20,7 @@
 #ifndef E_CONTACT_MAP_WINDOW_H
 #define E_CONTACT_MAP_WINDOW_H
 
-#ifdef WITH_CONTACT_MAPS
+#ifdef ENABLE_CONTACT_MAPS
 
 #include <gtk/gtk.h>
 
@@ -75,6 +75,6 @@ void          e_contact_map_window_load_addressbook
 
 G_END_DECLS
 
-#endif /* WITH_CONTACT_MAPS */
+#endif /* ENABLE_CONTACT_MAPS */
 
 #endif /* E_CONTACT_MAP_WINDOW_H */
diff --git a/addressbook/gui/widgets/e-contact-map.c b/addressbook/gui/widgets/e-contact-map.c
index fde0e8b..963a58e 100644
--- a/addressbook/gui/widgets/e-contact-map.c
+++ b/addressbook/gui/widgets/e-contact-map.c
@@ -20,7 +20,7 @@
 #include <config.h>
 #endif
 
-#ifdef WITH_CONTACT_MAPS
+#ifdef ENABLE_CONTACT_MAPS
 
 #include "e-contact-map.h"
 
@@ -490,4 +490,4 @@ e_contact_map_get_view (EContactMap *map)
        return gtk_champlain_embed_get_view (GTK_CHAMPLAIN_EMBED (map));
 }
 
-#endif /* WITH_CONTACT_MAPS */
+#endif /* ENABLE_CONTACT_MAPS */
diff --git a/addressbook/gui/widgets/e-contact-map.h b/addressbook/gui/widgets/e-contact-map.h
index cd04f7d..8ca2502 100644
--- a/addressbook/gui/widgets/e-contact-map.h
+++ b/addressbook/gui/widgets/e-contact-map.h
@@ -20,7 +20,7 @@
 #ifndef E_CONTACT_MAP_H
 #define E_CONTACT_MAP_H
 
-#ifdef WITH_CONTACT_MAPS
+#ifdef ENABLE_CONTACT_MAPS
 
 #include <gtk/gtk.h>
 
@@ -90,6 +90,6 @@ ChamplainView *       e_contact_map_get_view          (EContactMap *map);
 
 G_END_DECLS
 
-#endif /* WITH_CONTACT_MAPS */
+#endif /* ENABLE_CONTACT_MAPS */
 
 #endif /* E_CONTACT_MAP_H */
diff --git a/addressbook/gui/widgets/eab-contact-display.c b/addressbook/gui/widgets/eab-contact-display.c
index 967cee7..d40e867 100644
--- a/addressbook/gui/widgets/eab-contact-display.c
+++ b/addressbook/gui/widgets/eab-contact-display.c
@@ -322,7 +322,7 @@ contact_display_link_clicked (EWebView *web_view,
                link_clicked (web_view, uri);
 }
 
-#ifdef WITH_CONTACT_MAPS
+#ifdef ENABLE_CONTACT_MAPS
 /* XXX Clutter event handling workaround. Clutter-gtk propagates events down
  *     to parent widgets.  In this case it leads to GtkHTML scrolling up and
  *     down while user's trying to zoom in the champlain widget. This
@@ -518,7 +518,7 @@ eab_contact_display_init (EABContactDisplay *display)
        web_view = E_WEB_VIEW (display);
        ui_manager = e_web_view_get_ui_manager (web_view);
 
-#ifdef WITH_CONTACT_MAPS
+#ifdef ENABLE_CONTACT_MAPS
        g_signal_connect (
                web_view, "create-plugin-widget",
                G_CALLBACK (contact_display_object_requested), display);
diff --git a/addressbook/gui/widgets/eab-contact-formatter.c b/addressbook/gui/widgets/eab-contact-formatter.c
index d2e217b..198f417 100644
--- a/addressbook/gui/widgets/eab-contact-formatter.c
+++ b/addressbook/gui/widgets/eab-contact-formatter.c
@@ -777,7 +777,7 @@ accum_address_map (GString *buffer,
                    EContact *contact,
                    gint map_type)
 {
-#ifdef WITH_CONTACT_MAPS
+#ifdef ENABLE_CONTACT_MAPS
        g_string_append (buffer, "<tr><td colspan=\"3\">");
 
        if (map_type == E_CONTACT_ADDRESS_WORK) {
@@ -793,7 +793,7 @@ accum_address_map (GString *buffer,
        }
 
        g_string_append (buffer, "</td></tr>");
-#endif /* WITH_CONTACT_MAPS */
+#endif /* ENABLE_CONTACT_MAPS */
 }
 
 static void
diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in
new file mode 100644
index 0000000..2037e36
--- /dev/null
+++ b/cmake/cmake_uninstall.cmake.in
@@ -0,0 +1,21 @@
+if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+  message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+
+file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
+string(REGEX REPLACE "\n" ";" files "${files}")
+foreach(file ${files})
+  message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
+  if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+    exec_program(
+      "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+      OUTPUT_VARIABLE rm_out
+      RETURN_VALUE rm_retval
+      )
+    if(NOT "${rm_retval}" STREQUAL 0)
+      message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
+    endif(NOT "${rm_retval}" STREQUAL 0)
+  else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+    message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
+  endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+endforeach(file)
diff --git a/cmake/modules/CheckTarget.cmake b/cmake/modules/CheckTarget.cmake
new file mode 100644
index 0000000..71824a9
--- /dev/null
+++ b/cmake/modules/CheckTarget.cmake
@@ -0,0 +1,21 @@
+# CheckTarget.cmake
+#
+# Defines a custom target 'check', which gathers test programs like 'make check'
+# This is taken from https://cmake.org/Wiki/CMakeEmulateMakeCheck
+#
+# What you do is to call command:
+# add_check_test(_name)
+#   where _name is the name of the test, as defined by add_executable().
+#   Note it is a good idea to use EXCLUDE_FROM_ALL within the add_executable().
+
+include(CTest)
+
+# Disable this to not have verbose tests
+set(CMAKE_CTEST_COMMAND ${CMAKE_CTEST_COMMAND} -V)
+
+add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
+
+macro(add_check_test _name)
+       add_test(NAME ${_name} COMMAND ${_name})
+       add_dependencies(check ${_name})
+endmacro(add_check_test)
diff --git a/cmake/modules/CodeCoverageGCOV.cmake b/cmake/modules/CodeCoverageGCOV.cmake
new file mode 100644
index 0000000..bf670e0
--- /dev/null
+++ b/cmake/modules/CodeCoverageGCOV.cmake
@@ -0,0 +1,45 @@
+# CodeCoverageGCOV.cmake
+#
+# Adds options ENABLE_CODE_COVERAGE, which builds the project with
+# code coverage support
+#
+# It sets variables:
+# CODE_COVERAGE_DEFINES - to be used with target_compile_definitions() and similar
+# CODE_COVERAGE_CFLAGS - to be used with target_compile_options() and similar for C code
+# CODE_COVERAGE_CXXFLAGS - to be used with target_compile_options() and similar for C++ code
+# CODE_COVERAGE_LDFLAGS - to be used with target_link_libraries() and similar
+#
+# These variables should be added as the last in the options, because they change compilation
+
+include(CheckLibraryExists)
+include(PrintableOptions)
+
+add_printable_option(ENABLE_CODE_COVERAGE "Enable build with GCOV code coverage" OFF)
+
+if(ENABLE_CODE_COVERAGE)
+       if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
+               CHECK_LIBRARY_EXISTS("gcov" "gcov_exit" "" HAVE_GCOV_LIBRARY)
+               if(HAVE_GCOV_LIBRARY)
+                       set(CODE_COVERAGE_CFLAGS "-O0 -g -fprofile-arcs -ftest-coverage")
+                       set(CODE_COVERAGE_LDFLAGS "-lgcov")
+
+                       add_definitions(-DNDEBUG)
+                       set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CODE_COVERAGE_CFLAGS}")
+                       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CODE_COVERAGE_CFLAGS}")
+                       set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CODE_COVERAGE_LDFLAGS}")
+                       set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${CODE_COVERAGE_LDFLAGS}")
+                       set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CODE_COVERAGE_LDFLAGS}")
+                       set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} ${CODE_COVERAGE_LDFLAGS}")
+               else(HAVE_GCOV_LIBRARY)
+                       message(FATAL_ERROR "Cannot fing gcov library, use -DENABLE_CODE_COVERAGE=OFF disable 
it")
+               endif(HAVE_GCOV_LIBRARY)
+
+       else("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
+               message(FATAL_ERROR "Code coverage requires gcc compiler, use -DENABLE_CODE_COVERAGE=OFF 
disable it")
+       endif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
+else(ENABLE_CODE_COVERAGE)
+       set(CODE_COVERAGE_DEFINES "")
+       set(CODE_COVERAGE_CFLAGS "")
+       set(CODE_COVERAGE_CXXFLAGS "")
+       set(CODE_COVERAGE_LDFLAGS "")
+endif(ENABLE_CODE_COVERAGE)
diff --git a/cmake/modules/DistTargets.cmake b/cmake/modules/DistTargets.cmake
new file mode 100644
index 0000000..029f782
--- /dev/null
+++ b/cmake/modules/DistTargets.cmake
@@ -0,0 +1,86 @@
+# DistTarget.cmake
+#
+# Defines custom targets related to distributing source code.
+# It requires to have populated 'PROJECT_NAME' and 'PROJECT_VERSION' variables,
+# possibly through the project() command. It also uses 'PROJECT_DISTCONFIGURE_PARAMS'
+# variable when configuring the unpacked distribution.
+#
+# Added targets:
+# dist - only creates a tarball
+# disttest - creates a tarball and 'make && make install' it to a temporary prefix
+#    to verify that the code can be built and installed; it also verifies
+#    that the first line of the NEWS file contains the same version as
+#    the tarball and that it claims today's date.
+# distcheck - similar to 'disttest', only runs also 'make check' before installing
+
+# Filenames for tarball
+set(ARCHIVE_BASE_NAME ${PROJECT_NAME}-${PROJECT_VERSION})
+set(ARCHIVE_FULL_NAME ${ARCHIVE_BASE_NAME}.tar.xz)
+
+add_custom_target(dist
+       COMMAND ${CMAKE_COMMAND} -E echo "Creating '${ARCHIVE_FULL_NAME}'..."
+       COMMAND git archive --prefix=${ARCHIVE_BASE_NAME}/ HEAD | xz -z > 
${CMAKE_BINARY_DIR}/${ARCHIVE_FULL_NAME}
+       COMMAND ${CMAKE_COMMAND} -E echo "Distribution tarball '${ARCHIVE_FULL_NAME}' created at 
${CMAKE_BINARY_DIR}"
+       WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+)
+
+set(disttest_extract_dir "${CMAKE_BINARY_DIR}/${ARCHIVE_BASE_NAME}")
+set(disttest_build_dir "${disttest_extract_dir}/_build")
+set(disttest_install_dir "${disttest_extract_dir}/_install")
+
+add_custom_command(OUTPUT ${disttest_build_dir}/Makefile
+       # remove any left-over directory
+       COMMAND ${CMAKE_COMMAND} -E remove_directory ${disttest_extract_dir}
+
+       # extract the tarball
+       COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR} tar -xf ${ARCHIVE_FULL_NAME}
+
+       # verify the NEWS file contains what it should contain
+       COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}
+               bash ${CMAKE_SOURCE_DIR}/cmake/verify-news-file.sh "${disttest_extract_dir}/NEWS" 
"${PROJECT_VERSION}"
+
+       # create a _build sub-directory
+       COMMAND ${CMAKE_COMMAND} -E make_directory "${disttest_build_dir}"
+
+       # configure the project with PROJECT_DISTCHECK_PARAMS
+       COMMAND ${CMAKE_COMMAND} -E chdir "${disttest_build_dir}"
+               ${CMAKE_COMMAND} -G "Unix Makefiles"
+                       ${PROJECT_DISTCONFIGURE_PARAMS}
+                       -DCMAKE_BUILD_TYPE=Release
+                       -DCMAKE_INSTALL_PREFIX="${disttest_install_dir}"
+                       ..
+
+       # 'make' the project
+       COMMAND ${CMAKE_COMMAND} -E chdir ${disttest_build_dir} make -j
+
+       DEPENDS dist
+)
+
+add_custom_target(distcheck
+       # 'make check' the project
+       COMMAND ${CMAKE_COMMAND} -E chdir ${disttest_build_dir} make -j check
+
+       # 'make install' the project
+       COMMAND ${CMAKE_COMMAND} -E chdir ${disttest_build_dir} make -j install
+
+       # if we get this far, then everything worked, thus clean up
+       COMMAND ${CMAKE_COMMAND} -E remove_directory ${disttest_extract_dir}
+
+       # and show the good news
+       COMMAND ${CMAKE_COMMAND} -E echo "distcheck of '${ARCHIVE_FULL_NAME}' succeeded"
+
+       DEPENDS ${disttest_build_dir}/Makefile
+)
+
+add_custom_target(disttest
+       # 'make install' the project
+       COMMAND ${CMAKE_COMMAND} -E chdir ${disttest_build_dir} make -j install
+
+       # if we get this far, then everything worked, thus clean up
+       COMMAND ${CMAKE_COMMAND} -E remove_directory ${disttest_extract_dir}
+
+       # and show the good news
+       COMMAND ${CMAKE_COMMAND} -E echo "disttest of '${ARCHIVE_FULL_NAME}' succeeded"
+
+       DEPENDS ${disttest_build_dir}/Makefile
+)
diff --git a/cmake/modules/FindIntltool.cmake b/cmake/modules/FindIntltool.cmake
new file mode 100644
index 0000000..f6f27fe
--- /dev/null
+++ b/cmake/modules/FindIntltool.cmake
@@ -0,0 +1,209 @@
+# FindIntltool.cmake
+#
+# Searches for intltool and gettext. It aborts, if anything cannot be found.
+# Requires GETTEXT_PO_DIR to be set to full path of the po/ directory.
+#
+# Output is:
+#   INTLTOOL_UPDATE  - an intltool-update executable path, as found
+#   INTLTOOL_EXTRACT  - an intltool-extract executable path, as found
+#   INTLTOOL_MERGE  - an intltool-merge executable path, as found
+#
+# and anything from the FindGettext module.
+#
+# The below provided macros require GETTEXT_PACKAGE to be set.
+#
+# intltool_add_check_potfiles_target()
+#    Adds a check-potfiles target, which verifies that all files with translations
+#    are added in the POTFILES.in file inside GETTEXT_PO_DIR. This macro can be called
+#    only inside GETTEXT_PO_DIR.
+#
+# intltool_add_pot_file_target()
+#    Creates a new target pot-file, which generates ${GETTEXT_PACKAGE}.pot file into
+#    the CMAKE_CURERNT_BINARY_DIR. This target is not part of ALL.
+#    This can be called only inside GETTEXT_PO_DIR.
+#
+# intltool_process_po_files()
+#    Processes all files in the GETTEXT_PO_DIR and generates .gmo files for them
+#    in CMAKE_CURRENT_BINARY_DIR. These are added into a new target gmo-files.
+#    It also installs them into proper location under LOCALE_INSTALL_DIR.
+#    This can be called only inside GETTEXT_PO_DIR.
+#
+# intltool_setup_po_dir()
+#    Shortcut to setup intltool's po/ directory by adding all custom targets
+#    and such. this can be called only inside GETTEXT_PO_DIR.
+#
+# intltool_merge(_in_filename _out_filename ...args)
+#    Adds rule to call intltool-merge. The args are optional arguments.
+#    This can be called in any folder, only the GETTEXT_PO_DIR should
+#    be properly set, otherwise the call will fail.
+#
+# add_appdata_file(_infilename _outfilename)
+#    A shortcut to call intltool-merge() for an appdata file and install it
+#    to ${SHARE_INSTALL_DIR}/appdata
+
+include(FindGettext)
+
+if(NOT GETTEXT_FOUND)
+       message(FATAL_ERROR "gettext not found, please install at least 0.18.3 version")
+endif(NOT GETTEXT_FOUND)
+
+if(NOT GETTEXT_FOUND)
+       message(FATAL_ERROR "gettext not found, please install at least 0.18.3 version")
+endif(NOT GETTEXT_FOUND)
+
+if(GETTEXT_VERSION_STRING VERSION_LESS "0.18.3")
+       message(FATAL_ERROR "gettext version 0.18.3+ required, but version '${GETTEXT_VERSION_STRING}' found 
instead. Please update your gettext")
+endif(GETTEXT_VERSION_STRING VERSION_LESS "0.18.3")
+
+find_program(XGETTEXT xgettext)
+if(NOT XGETTEXT)
+       message(FATAL_ERROR "xgettext executable not found. Please install or update your gettext to at least 
0.18.3 version")
+endif(NOT XGETTEXT)
+
+find_program(INTLTOOL_UPDATE intltool-update)
+if(NOT INTLTOOL_UPDATE)
+       message(FATAL_ERROR "intltool-update not found. Please install it (usually part of an 'intltool' 
package)")
+endif(NOT INTLTOOL_UPDATE)
+
+find_program(INTLTOOL_EXTRACT intltool-extract)
+if(NOT INTLTOOL_EXTRACT)
+       message(FATAL_ERROR "intltool-extract not found. Please install it (usually part of an 'intltool' 
package)")
+endif(NOT INTLTOOL_EXTRACT)
+
+find_program(INTLTOOL_MERGE intltool-merge)
+if(NOT INTLTOOL_MERGE)
+       message(FATAL_ERROR "intltool-merge not found. Please install it (usually part of an 'intltool' 
package)")
+endif(NOT INTLTOOL_MERGE)
+
+macro(intltool_add_check_potfiles_target)
+       if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL GETTEXT_PO_DIR)
+               message(FATAL_ERROR "intltool_add_pot_file_target() can be called only inside GETTEXT_PO_DIR 
('${GETTEXT_PO_DIR}'), but it is called inside '${CMAKE_CURRENT_SOURCE_DIR}' instead")
+       endif(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL GETTEXT_PO_DIR)
+
+       add_custom_target(check-potfiles
+               COMMAND ${INTLTOOL_UPDATE} -m
+               WORKING_DIRECTORY ${GETTEXT_PO_DIR}
+       )
+endmacro(intltool_add_check_potfiles_target)
+
+macro(intltool_add_pot_file_target)
+       if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL GETTEXT_PO_DIR)
+               message(FATAL_ERROR "intltool_add_pot_file_target() can be called only inside GETTEXT_PO_DIR 
('${GETTEXT_PO_DIR}'), but it is called inside '${CMAKE_CURRENT_SOURCE_DIR}' instead")
+       endif(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL GETTEXT_PO_DIR)
+
+       add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${GETTEXT_PACKAGE}.pot
+               COMMAND ${CMAKE_COMMAND} -E env INTLTOOL_EXTRACT="${INTLTOOL_EXTRACT}" XGETTEXT="${XGETTEXT}" 
srcdir=${CMAKE_CURRENT_SOURCE_DIR} ${INTLTOOL_UPDATE} --gettext-package ${GETTEXT_PACKAGE} --pot
+       )
+
+       add_custom_target(pot-file
+               DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${GETTEXT_PACKAGE}.pot
+       )
+endmacro(intltool_add_pot_file_target)
+
+macro(intltool_process_po_files)
+       if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL GETTEXT_PO_DIR)
+               message(FATAL_ERROR "intltool_process_po_files() can be called only inside GETTEXT_PO_DIR 
('${GETTEXT_PO_DIR}'), but it is called inside '${CMAKE_CURRENT_SOURCE_DIR}' instead")
+       endif(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL GETTEXT_PO_DIR)
+
+       file(GLOB po_files ${GETTEXT_PO_DIR}/*.po)
+
+       set(LINGUAS)
+       set(LINGUAS_GMO)
+
+       foreach(file IN LISTS po_files)
+               get_filename_component(lang ${file} NAME_WE)
+               list(APPEND LINGUAS ${lang})
+               list(APPEND LINGUAS_GMO ${lang}.gmo)
+
+               add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${lang}.gmo
+                       COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${CMAKE_CURRENT_BINARY_DIR}/${lang}.gmo 
${CMAKE_CURRENT_SOURCE_DIR}/${lang}.po
+                       DEPENDS ${lang}.po
+               )
+
+               install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${lang}.gmo
+                       DESTINATION ${LOCALE_INSTALL_DIR}/${lang}/LC_MESSAGES/
+                       RENAME ${GETTEXT_PACKAGE}.mo
+               )
+               if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${lang}.gmo.m)
+                       install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${lang}.gmo.m
+                               DESTINATION ${LOCALE_INSTALL_DIR}/${lang}/LC_MESSAGES/
+                               RENAME ${GETTEXT_PACKAGE}.mo.m
+                       )
+               endif(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${lang}.gmo.m)
+       endforeach(file)
+
+       add_custom_target(gmo-files ALL
+               DEPENDS ${LINGUAS_GMO}
+       )
+endmacro(intltool_process_po_files)
+
+macro(intltool_setup_po_dir)
+       if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL GETTEXT_PO_DIR)
+               message(FATAL_ERROR "intltool_setup_po_dir() can be called only inside GETTEXT_PO_DIR 
('${GETTEXT_PO_DIR}'), but it is called inside '${CMAKE_CURRENT_SOURCE_DIR}' instead")
+       endif(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL GETTEXT_PO_DIR)
+
+       intltool_add_check_potfiles_target()
+       intltool_add_pot_file_target()
+       intltool_process_po_files()
+endmacro(intltool_setup_po_dir)
+
+macro(intltool_merge _in_filename _out_filename)
+       set(_in ${_in_filename})
+       set(_out ${_out_filename})
+
+       get_filename_component(_path ${_in} DIRECTORY)
+       if(_path STREQUAL "")
+               set(_in ${CMAKE_CURRENT_SOURCE_DIR}/${_in})
+       endif(_path STREQUAL "")
+
+       get_filename_component(_path ${_out} DIRECTORY)
+       if(_path STREQUAL "")
+               set(_out ${CMAKE_CURRENT_BINARY_DIR}/${_out})
+       endif(_path STREQUAL "")
+
+       set(_has_no_translations OFF)
+       set(_args)
+       foreach(_arg ${ARGN})
+               list(APPEND _args "${_arg}")
+               if(_arg STREQUAL "--no-translations")
+                       set(_has_no_translations ON)
+               endif(_arg STREQUAL "--no-translations")
+       endforeach(_arg)
+
+       if(_has_no_translations)
+               add_custom_command(OUTPUT ${_out}
+                       COMMAND ${INTLTOOL_MERGE} ${_args} --quiet "${_in}" "${_out}"
+                       DEPENDS ${_in}
+               )
+       else(_has_no_translations)
+               add_custom_command(OUTPUT ${_out}
+                       COMMAND ${INTLTOOL_MERGE} ${_args} --quiet 
--cache="${CMAKE_BINARY_DIR}/po/.intltool-merge-cache" "${GETTEXT_PO_DIR}" "${_in}" "${_out}"
+                       DEPENDS ${_in}
+               )
+       endif(_has_no_translations)
+endmacro(intltool_merge)
+
+macro(add_appdata_file _infilename _outfilename)
+       if(NOT TARGET appdata-files)
+               add_custom_target(appdata-files ALL)
+       endif(NOT TARGET appdata-files)
+
+       set(_out ${_outfilename})
+       get_filename_component(_outtarget ${_out} NAME_WE)
+       get_filename_component(_path ${_out} DIRECTORY)
+       if(_path STREQUAL "")
+               set(_out ${CMAKE_CURRENT_BINARY_DIR}/${_out})
+       endif(_path STREQUAL "")
+
+       intltool_merge(${_infilename} ${_out} --xml-style --utf8)
+
+       add_custom_target(appdata-${_outtarget}
+               DEPENDS ${_out}
+       )
+
+       add_dependencies(appdata-files appdata-${_outtarget})
+
+       install(FILES ${_out}
+               DESTINATION ${SHARE_INSTALL_DIR}/appdata
+       )
+endmacro(add_appdata_file)
diff --git a/cmake/modules/FindLDAP.cmake b/cmake/modules/FindLDAP.cmake
new file mode 100644
index 0000000..73c0d31
--- /dev/null
+++ b/cmake/modules/FindLDAP.cmake
@@ -0,0 +1,133 @@
+# FindLDAP.cmake
+#
+# Searches for OpenLDAP/SunLDAP library
+#
+# Adds these options:
+#    -DWITH_OPENLDAP=ON/OFF/PATH - enable/disable OpenLDAP, eventually set prefix to find it
+#    -DWITH_SUNLDAP=OFF/ON/PATH - enable/disable SunLDAP, eventually set prefix to find it
+#    -DWITH_STATIC_LDAP=OFF/ON - enable/disable static LDAP linking
+#
+# The OpenLDAP has precedence over SunLDAP, if both are specified. The default is to use OpenLDAP.
+#
+# The output is:
+#    HAVE_LDAP - set to ON, if LDAP support is enabled and libraries found
+#    SUNLDAP - set to ON, when using SunLDAP implementation
+#    LDAP_CFLAGS - CFLAGS to use with target_compile_options() and similar commands
+#    LDAP_INCLDUE_DIRS - include directories to use with target_include_directories() and similar commands
+#    LDAP_LDFLAGS - LDFLAGS to use with target_link_libraries() and similar commands
+
+include(CheckCSourceCompiles)
+include(CheckLibraryExists)
+include(PrintableOptions)
+
+add_printable_variable_path(WITH_OPENLDAP "Enable LDAP support using OpenLDAP, default ON" "ON")
+add_printable_variable_path(WITH_SUNLDAP "Enable LDAP support using SunLDAP, default OFF" "OFF")
+add_printable_option(WITH_STATIC_LDAP "Link LDAP statically, default OFF" OFF)
+
+if((NOT WITH_OPENLDAP) AND (NOT WITH_SUNLDAP))
+       return()
+endif((NOT WITH_OPENLDAP) AND (NOT WITH_SUNLDAP))
+
+string(LENGTH "${CMAKE_BINARY_DIR}" bindirlen)
+string(SUBSTRING "${WITH_OPENLDAP}" 0 ${bindirlen} substr)
+string(TOUPPER "${WITH_OPENLDAP}" optupper)
+
+if(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+       set(WITH_OPENLDAP "/usr")
+endif(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+
+string(SUBSTRING "${WITH_SUNLDAP}" 0 ${bindirlen} substr)
+string(TOUPPER "${WITH_SUNLDAP}" optupper)
+
+if(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+       set(WITH_SUNLDAP "/usr")
+endif(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+
+unset(bindirlen)
+unset(substr)
+unset(optupper)
+
+set(HAVE_LDAP ON)
+set(SUNLDAP OFF)
+
+macro(add_ldap_lib_if_provides _lib _symbol)
+       CHECK_LIBRARY_EXISTS(${_lib} ${_symbol} "" lib${_lib}_provides_${_symbol})
+       if(lib${_lib}_provides_${_symbol})
+               set(LDAP_LIBS "${LDAP_LIBS} -l${_lib}")
+       endif(lib${_lib}_provides_${_symbol})
+endmacro(add_ldap_lib_if_provides)
+
+set(LDAP_PREFIX "")
+if(WITH_OPENLDAP)
+       set(LDAP_PREFIX "${WITH_OPENLDAP}")
+else(WITH_OPENLDAP)
+       set(LDAP_PREFIX "${WITH_SUNLDAP}")
+       set(SUNLDAP ON)
+endif(WITH_OPENLDAP)
+
+set(LDAP_CFLAGS "")
+set(LDAP_INCLUDE_DIRECTORIES "${LDAP_PREFIX}/include")
+set(LDAP_LIBS "-L${LDAP_PREFIX}/lib${LIB_SUFFIX}")
+
+set(CMAKE_REQUIRED_INCLUDES "${LDAP_INCLUDE_DIRECTORIES}")
+set(CMAKE_REQUIRED_LIBRARIES "${LDAP_LIBS}")
+
+if(WITH_OPENLDAP)
+       CHECK_C_SOURCE_COMPILES("#include \"ldap.h\"
+                               int main(void) {
+                                       #if !defined(LDAP_VENDOR_VERSION) || LDAP_VENDOR_VERSION < 20000
+                                       #error OpenLDAP version not at least 2.0
+                                       #endif
+                                       return 0; }" openldap_2_x)
+       if(NOT openldap_2_x)
+               message(FATAL_ERROR "At least 2.0 OpenLDAP version required")
+       endif(NOT openldap_2_x)
+else(WITH_OPENLDAP)
+       CHECK_C_SOURCE_COMPILES("#include \"ldap.h\"
+                               int main(void) {
+                                       #if !defined(LDAP_VENDOR_VERSION) || LDAP_VENDOR_VERSION < 500
+                                       #error SunLDAP version not at least 2.0
+                                       #endif
+                                       return 0; }" sunldap_2_x)
+       if(NOT sunldap_2_x)
+               message(FATAL_ERROR "At least 2.0 SunLDAP version required")
+       endif(NOT sunldap_2_x)
+endif(WITH_OPENLDAP)
+
+add_ldap_lib_if_provides(resolv res_query)
+add_ldap_lib_if_provides(resolv __res_query)
+add_ldap_lib_if_provides(socket bind)
+CHECK_LIBRARY_EXISTS(lber ber_get_tag "" liblber_provides_ber_get_tag)
+if(liblber_provides_ber_get_tag)
+       if(WITH_STATIC_LDAP)
+               set(LDAP_LIBS "${LDAP_LIBS} ${LDAP_PREFIX}/lib${LIB_SUFFIX}/liblber.a")
+#              # libldap might depend on OpenSSL... We need to pull
+#              # in the dependency libs explicitly here since we're
+#              # not using libtool for the configure test.
+#              if test -f ${LDAP_PREFIX}/lib${LIB_SUFFIX}/libldap.la; then
+#                      LDAP_LIBS="`. ${LDAP_PREFIX}/libPLIB_SUFFIX}/libldap.la; echo $dependency_libs` 
$LDAP_LIBS"
+#              fi
+       else(WITH_STATIC_LDAP)
+               set(LDAP_LIBS "${LDAP_LIBS} -llber")
+       endif(WITH_STATIC_LDAP)
+endif(liblber_provides_ber_get_tag)
+
+CHECK_LIBRARY_EXISTS(ldap ldap_open "" libldap_provides_ldap_open)
+if(libldap_provides_ldap_open)
+       if(WITH_STATIC_LDAP)
+               set(LDAP_LIBS "${LDAP_LIBS} ${LDAP_PREFIX}/lib${LIB_SUFFIX}/libldap.a")
+       else(WITH_STATIC_LDAP)
+               set(LDAP_LIBS "${LDAP_LIBS} -lldap")
+       endif(WITH_STATIC_LDAP)
+else(libldap_provides_ldap_open)
+       if(WITH_OPENLDAP)
+               message(FATAL_ERROR "Could not find OpenLDAP libraries")
+       else(WITH_OPENLDAP)
+               message(FATAL_ERROR "Could not find SunLDAP libraries")
+       endif(WITH_OPENLDAP)
+endif(libldap_provides_ldap_open)
+
+unset(CMAKE_REQUIRED_INCLUDES)
+unset(CMAKE_REQUIRED_LIBRARIES)
+
+add_definitions(-DLDAP_DEPRECATED)
diff --git a/cmake/modules/FindSMIME.cmake b/cmake/modules/FindSMIME.cmake
new file mode 100644
index 0000000..3f47a65
--- /dev/null
+++ b/cmake/modules/FindSMIME.cmake
@@ -0,0 +1,146 @@
+# FindSMIME.cmake
+#
+# Searches for Mozilla's NSS and NSPR libraries, unless -DENABLE_SMIME=OFF is used
+#
+# The output is:
+#    mozilla_nspr - if non-empty, then a pkg-config package name for nspr
+#    mozilla_nss - if non-empty, then a pkg-config package name for nss
+#    MANUAL_NSPR_INCLUDES - if non-empty, then contains manual nspr include directory, used for 
target_include_directories() and similar commands
+#    MANUAL_NSPR_LIBS - if non-empty, then contains manual nspr libraries, used for target_link_libraries() 
and similar commands
+#    MANUAL_NSS_INCLUDES - if non-empty, then contains manual nss include directory, used for 
target_include_directories() and similar commands
+#    MANUAL_NSS_LIBS - if non-empty, then contains manual nss libraries, used for target_link_libraries() 
and similar commands
+#    MOZILLA_NSS_LIB_DIR - a lib directory where Mozilla stores its libraries
+
+include(CheckIncludeFiles)
+include(CheckCSourceCompiles)
+include(PrintableOptions)
+include(PkgConfigEx)
+
+add_printable_option(ENABLE_SMIME "Enable SMIME support through Mozilla nss" ON)
+add_printable_variable_path(WITH_NSPR_INCLUDES "Prefix of Mozilla nspr4 includes" "")
+add_printable_variable_path(WITH_NSPR_LIBS "Prefix of Mozilla nspr4 libs" "")
+add_printable_variable_path(WITH_NSS_INCLUDES "Prefix of Mozilla nss3 includes" "")
+add_printable_variable_path(WITH_NSS_LIBS "Prefix of Mozilla nss3 libs" "")
+
+if(NOT ENABLE_SMIME)
+       return()
+endif(NOT ENABLE_SMIME)
+
+set(mozilla_nspr "")
+set(mozilla_nss "")
+set(MOZILLA_NSS_LIB_DIR "")
+
+# Use pkg-config when none is specified
+if((WITH_NSPR_INCLUDES STREQUAL "") AND (WITH_NSPR_LIBS STREQUAL "") AND (WITH_NSS_INCLUDES STREQUAL "") AND 
(WITH_NSS_INCLUDES STREQUAL ""))
+       foreach(pkg nspr mozilla-nspr firefox-nspr xulrunner-nspr seamonkey-nspr)
+               pkg_check_exists(_have_pkg ${pkg})
+               if(_have_pkg)
+                       set(mozilla_nspr ${pkg})
+                       break()
+               endif(_have_pkg)
+       endforeach(pkg)
+
+       foreach(pkg nss mozilla-nss firefox-nss xulrunner-nss seamonkey-nss)
+               pkg_check_exists(_have_pkg ${pkg})
+               if(_have_pkg)
+                       set(mozilla_nss ${pkg})
+                       break()
+               endif(_have_pkg)
+       endforeach(pkg)
+
+       if((NOT (mozilla_nspr STREQUAL "")) AND (NOT (mozilla_nss STREQUAL "")))
+               pkg_check_variable(_nss_libdir ${mozilla_nss} libdir)
+
+               set(MANUAL_NSPR_INCLUDES "")
+               set(MANUAL_NSPR_LIBS "")
+               set(MANUAL_NSS_INCLUDES "")
+               set(MANUAL_NSS_LIBS "")
+               set(MOZILLA_NSS_LIB_DIR "${_nss_libdir}")
+               return()
+       endif((NOT (mozilla_nspr STREQUAL "")) AND (NOT (mozilla_nss STREQUAL "")))
+endif()
+
+# Manual search, even when pkg-config failed
+
+# ******************
+# Check for NSPR 4
+# ******************
+
+if(NOT (WITH_NSPR_INCLUDES STREQUAL ""))
+       set(CMAKE_REQUIRED_INCLUDES ${WITH_NSPR_INCLUDES})
+endif(NOT (WITH_NSPR_INCLUDES STREQUAL ""))
+
+CHECK_INCLUDE_FILES(nspr.h prio.h _have_headers)
+
+unset(CMAKE_REQUIRED_INCLUDES)
+
+if(NOT _have_headers)
+       message(FATAL_ERROR "NSPR headers not found. Use -DWITH_NSPR_INCLUDES=/path/to/nspr to specify the 
include dir of NSPR.")
+endif(NOT _have_headers)
+
+set(MANUAL_NSPR_INCLUDES "${WITH_NSPR_INCLUDES}")
+
+set(nsprlibs "-lplc4 -lplds4 -lnspr4")
+
+set(CMAKE_REQUIRED_INCLUDES ${MANUAL_NSPR_INCLUDES})
+set(CMAKE_REQUIRED_LIBRARIES ${nsprlibs})
+CHECK_C_SOURCE_COMPILES("#include <prinit.h>
+                       int main(void) { PR_Initialized(); return 0; }" _nsprlibs_okay)
+unset(CMAKE_REQUIRED_FLAGS)
+unset(CMAKE_REQUIRED_LIBRARIES)
+
+if(NOT _nsprlibs_okay)
+       message(FATAL_ERROR "NSPR libs not found. Use -DWITH_NSPR_LIBS=/path/to/libs to specify the libdir of 
NSPR")
+endif(NOT _nsprlibs_okay)
+
+set(MANUAL_NSPR_LIBS "")
+
+if(NOT (WITH_NSPR_LIBS STREQUAL ""))
+       set(MANUAL_NSPR_LIBS "-L${WITH_NSPR_LIBS}")
+endif(NOT (WITH_NSPR_LIBS STREQUAL ""))
+
+set(MANUAL_NSPR_LIBS "${MANUAL_NSPR_LIBS} ${nsprlibs}")
+
+# *****************
+# Check for NSS 3
+# *****************
+
+if(NOT (WITH_NSS_INCLUDES STREQUAL ""))
+       set(CMAKE_REQUIRED_INCLUDES ${WITH_NSS_INCLUDES})
+endif(NOT (WITH_NSS_INCLUDES STREQUAL ""))
+
+CHECK_INCLUDE_FILES(nss.h ssl.h smime.h _have_headers)
+
+unset(CMAKE_REQUIRED_INCLUDES)
+
+if(NOT _have_headers)
+       message(FATAL_ERROR "NSS headers not found. Use -DWITH_NSS_INCLUDES=/path/to/nss to specify the 
include dir of NSS.")
+endif(NOT _have_headers)
+
+set(MANUAL_NSS_INCLUDES "${WITH_NSS_INCLUDES} ${MANUAL_NSPR_INCLUDES}")
+
+set(nsslibs "-lssl3 -lsmime3 -lnss3")
+
+set(CMAKE_REQUIRED_INCLUDES ${MANUAL_NSS_INCLUDES})
+set(CMAKE_REQUIRED_LIBRARIES ${nsslibs} ${nsprlibs})
+CHECK_C_SOURCE_COMPILES("#include <nss.h>
+                       int main(void) { NSS_Init(\"\"); return 0; }" _nsslibs_okay)
+unset(CMAKE_REQUIRED_FLAGS)
+unset(CMAKE_REQUIRED_LIBRARIES)
+
+if(NOT _nsslibs_okay)
+       message(FATAL_ERROR "NSS libs not found. Use -DWITH_NSS_LIBS=/path/to/libs to specify the libdir of 
NSS")
+endif(NOT _nsslibs_okay)
+
+set(MANUAL_NSS_LIBS "")
+
+if(NOT (WITH_NSS_LIBS STREQUAL ""))
+       set(MANUAL_NSS_LIBS "-L${WITH_NSS_LIBS}")
+       set(MOZILLA_NSS_LIB_DIR "${WITH_NSS_LIBS}")
+endif(NOT (WITH_NSS_LIBS STREQUAL ""))
+
+set(MANUAL_NSS_LIBS "${MANUAL_NSS_LIBS} ${nsslibs} ${MANUAL_NSPR_LIBS}")
+
+if(MOZILLA_NSS_LIB_DIR STREQUAL "")
+       set(MOZILLA_NSS_LIB_DIR "${LIB_INSTALL_DIR}")
+endif(MOZILLA_NSS_LIB_DIR STREQUAL "")
diff --git a/cmake/modules/GLibTools.cmake b/cmake/modules/GLibTools.cmake
new file mode 100644
index 0000000..b247238
--- /dev/null
+++ b/cmake/modules/GLibTools.cmake
@@ -0,0 +1,251 @@
+# GLibTools.cmake
+#
+# Provides functions to run glib tools.
+#
+# Functions:
+#
+# glib_mkenums(_output_filename_noext _enums_header _define_name)
+#    runs glib-mkenums to generate enumtypes .h and .c files from _enums_header.
+#    It searches for files in the current source directory and exports to the current
+#    binary directory.
+#
+#    An example call is:
+#        glib_mkenums(camel-enumtypes camel-enums.h CAMEL_ENUMTYPES_H)
+#        which uses camel-enums.h as the source of known enums and generates
+#        camel-enumtypes.h which will use the CAMEL_ENUMTYPES_H define
+#        and also generates camel-enumtypes.c with the needed code.
+#
+# gdbus_codegen(_xml _interface_prefix _c_namespace _files_prefix _list_gens)
+#    runs gdbus-codegen to generate GDBus code from _xml file description,
+#    using _interface_prefix, _c_namespace and _files_prefix as arguments.
+#    The _list_gens is a list variable are stored expected generated files.
+#
+#    An example call is:
+#        set(GENERATED_DBUS_LOCALE
+#               e-dbus-localed.c
+#              e-dbus-localed.h
+#        )
+#        gdbus_codegen(org.freedesktop.locale1.xml org.freedesktop. E_DBus e-dbus-localed 
GENERATED_DBUS_LOCALE)
+#
+# gdbus_codegen_custom(_xml _interface_prefix _c_namespace _files_prefix _list_gens _args)
+#    The same as gdbus_codegen() except allows to pass other arguments to the call,
+#    like for example --c-generate-object-manager
+#
+# add_gsettings_schemas(_target _schema0 ...)
+#    Adds one or more GSettings schemas. The extension is supposed to be .gschema.xml. The schema file 
generation
+#    is added as a dependency of _target.
+#
+# glib_compile_resources _sourcedir _outputprefix _cname _inxml ...deps)
+#    Calls glib-compile-resources as defined in _inxml and using _outputprefix and_cname as other arguments
+#    beside _sourcedir. The optional arguments are other dependencies.
+
+include(PkgConfigEx)
+include(UninstallTarget)
+
+find_program(GLIB_MKENUMS glib-mkenums)
+if(NOT GLIB_MKENUMS)
+       message(FATAL_ERROR "Cannot find glib-mkenums, which is required to build ${PROJECT_NAME}")
+endif(NOT GLIB_MKENUMS)
+
+function(glib_mkenums _output_filename_noext _enums_header _define_name)
+       set(HEADER_TMPL "
+/*** BEGIN file-header ***/
+#ifndef ${_define_name}
+#define ${_define_name}
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* Enumerations from \"@filename@\" */
+
+/*** END file-production ***/
+
+/*** BEGIN enumeration-production ***/
+#define @ENUMPREFIX@_TYPE_@ENUMSHORT@  (@enum_name@_get_type())
+GType @enum_name@_get_type     (void) G_GNUC_CONST;
+
+/*** END enumeration-production ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* ${_define_name} */
+/*** END file-tail ***/")
+
+       file(WRITE 
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/enumtypes-${_output_filename_noext}.h.tmpl" 
"${HEADER_TMPL}\n")
+
+       add_custom_command(
+               OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_output_filename_noext}.h
+               COMMAND ${GLIB_MKENUMS} --template 
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/enumtypes-${_output_filename_noext}.h.tmpl" 
"${CMAKE_CURRENT_SOURCE_DIR}/${_enums_header}" >${CMAKE_CURRENT_BINARY_DIR}/${_output_filename_noext}.h
+       )
+
+set(SOURCE_TMPL "
+/*** BEGIN file-header ***/
+#include \"${_output_filename_noext}.h\"
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from \"@filename@\" */
+#include \"@filename@\"
+
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType
+@enum_name@_get_type (void)
+{
+       static volatile gsize the_type__volatile = 0;
+
+       if (g_once_init_enter (&the_type__volatile)) {
+               static const G\@Type\@Value values[] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+                       { \@VALUENAME\@,
+                         \"@VALUENAME@\",
+                         \"@valuenick@\" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+                       { 0, NULL, NULL }
+               };
+               GType the_type = g_\@type\@_register_static (
+                       g_intern_static_string (\"@EnumName@\"),
+                       values);
+               g_once_init_leave (&the_type__volatile, the_type);
+       }
+       return the_type__volatile;
+}
+
+/*** END value-tail ***/")
+
+       file(WRITE 
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/enumtypes-${_output_filename_noext}.c.tmpl" 
"${SOURCE_TMPL}\n")
+
+       add_custom_command(
+               OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_output_filename_noext}.c
+               COMMAND ${GLIB_MKENUMS} --template 
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/enumtypes-${_output_filename_noext}.c.tmpl" 
"${CMAKE_CURRENT_SOURCE_DIR}/${_enums_header}" >${CMAKE_CURRENT_BINARY_DIR}/${_output_filename_noext}.c
+       )
+endfunction(glib_mkenums)
+
+
+find_program(GDBUS_CODEGEN gdbus-codegen)
+if(NOT GDBUS_CODEGEN)
+       message(FATAL_ERROR "Cannot find gdbus-codegen, which is required to build ${PROJECT_NAME}")
+endif(NOT GDBUS_CODEGEN)
+
+function(gdbus_codegen_custom _xml _interface_prefix _c_namespace _files_prefix _list_gens _args)
+       add_custom_command(
+               OUTPUT ${${_list_gens}}
+               COMMAND ${GDBUS_CODEGEN}
+               ARGS --interface-prefix ${_interface_prefix}
+                       --c-namespace ${_c_namespace}
+                       --generate-c-code ${_files_prefix}
+                       --generate-docbook ${_files_prefix}
+                       ${_args}
+                       ${CMAKE_CURRENT_SOURCE_DIR}/${_xml}
+               VERBATIM
+       )
+endfunction(gdbus_codegen_custom)
+
+function(gdbus_codegen _xml _interface_prefix _c_namespace _files_prefix _list_gens)
+       gdbus_codegen_custom(${_xml} ${_interface_prefix} ${_c_namespace} ${_files_prefix} ${_list_gens} "")
+endfunction(gdbus_codegen)
+
+add_printable_option(ENABLE_SCHEMAS_COMPILE "Enable GSettings regeneration of gschemas.compile on install" 
ON)
+
+if(CMAKE_CROSSCOMPILING)
+       find_program(GLIB_COMPILE_SCHEMAS glib-compile-schemas)
+else(CMAKE_CROSSCOMPILING)
+       pkg_check_variable(GLIB_COMPILE_SCHEMAS gio-2.0 glib_compile_schemas)
+endif(CMAKE_CROSSCOMPILING)
+
+if(NOT GLIB_COMPILE_SCHEMAS)
+       message(FATAL_ERROR "Cannot find glib-compile-schemas, which is required to build ${PROJECT_NAME}")
+endif(NOT GLIB_COMPILE_SCHEMAS)
+
+set(GSETTINGS_SCHEMAS_DIR "${SHARE_INSTALL_DIR}/glib-2.0/schemas/")
+
+macro(add_gsettings_schemas _target _schema0)
+       set(_install_code)
+
+       foreach(_schema ${_schema0} ${ARGN})
+               string(REPLACE ".xml" ".valid" _outputfile "${_schema}")
+               get_filename_component(_outputfile "${_outputfile}" NAME)
+
+               get_filename_component(_schema_fullname "${_schema}" DIRECTORY)
+               get_filename_component(_schema_filename "${_schema}" NAME)
+               if(_schema_fullname STREQUAL "")
+                       set(_schema_fullname ${CMAKE_CURRENT_SOURCE_DIR}/${_schema})
+               else(_schema_fullname STREQUAL "")
+                       set(_schema_fullname ${_schema})
+               endif(_schema_fullname STREQUAL "")
+
+               add_custom_command(
+                       OUTPUT ${_outputfile}
+                       COMMAND ${GLIB_COMPILE_SCHEMAS} --strict --dry-run --schema-file=${_schema_fullname}
+                       COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_schema_fullname}" 
"${CMAKE_CURRENT_BINARY_DIR}/${_outputfile}"
+                       DEPENDS ${_schema_fullname}
+                       VERBATIM
+               )
+               add_custom_target(gsettings-schemas-${_schema_filename} ALL DEPENDS ${_outputfile})
+               add_dependencies(${_target} gsettings-schemas-${_schema_filename})
+               if(ENABLE_SCHEMAS_COMPILE)
+                       # this is required to compile gsettings schemas like after 'make install,
+                       # because there is no better way in CMake to run a code/script after
+                       # the whole `make install`
+                       set(_install_code "${_install_code}
+                               COMMAND ${CMAKE_COMMAND} -E copy_if_different \"${_schema_fullname}\" 
\"${GSETTINGS_SCHEMAS_DIR}\""
+                       )
+               endif(ENABLE_SCHEMAS_COMPILE)
+
+               # Do both, to have 'uninstall' working properly
+               install(FILES ${_schema_fullname}
+                       DESTINATION ${GSETTINGS_SCHEMAS_DIR})
+       endforeach(_schema)
+
+       if(_install_code)
+               # Compile gsettings schemas and ensure that all of them are in the place.
+               install(CODE
+                       "execute_process(${_install_code}
+                               COMMAND ${CMAKE_COMMAND} -E chdir . \"${GLIB_COMPILE_SCHEMAS}\" 
\"${GSETTINGS_SCHEMAS_DIR}\"
+                       )")
+       endif(_install_code)
+endmacro(add_gsettings_schemas)
+
+# This is called too early, when the schemas are not installed yet during `make install`
+#
+# compile_gsettings_schemas()
+#    Optionally (based on ENABLE_SCHEMAS_COMPILE) recompiles schemas at the destination folder
+#    after install. It's necessary to call it as the last command in the toplevel CMakeLists.txt,
+#    thus the compile runs when all the schemas are installed.
+#
+if(ENABLE_SCHEMAS_COMPILE)
+       add_custom_command(TARGET uninstall POST_BUILD
+               COMMAND ${CMAKE_COMMAND} -E chdir . "${GLIB_COMPILE_SCHEMAS}" "${GSETTINGS_SCHEMAS_DIR}"
+               COMMENT "Recompile GSettings schemas in '${GSETTINGS_SCHEMAS_DIR}'"
+       )
+endif(ENABLE_SCHEMAS_COMPILE)
+
+find_program(GLIB_COMPILE_RESOURCES glib-compile-resources)
+if(NOT GLIB_COMPILE_RESOURCES)
+       message(FATAL_ERROR "Cannot find glib-compile-resources, which is required to build ${PROJECT_NAME}")
+endif(NOT GLIB_COMPILE_RESOURCES)
+
+macro(glib_compile_resources _sourcedir _outputprefix _cname _inxml)
+       add_custom_command(
+               OUTPUT ${_outputprefix}.h
+               COMMAND ${GLIB_COMPILE_RESOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/${_inxml} 
--target=${_outputprefix}.h --sourcedir=${_sourcedir} --c-name ${_cname} --generate-header
+               DEPENDS ${_inxml} ${ARGN}
+               VERBATIM
+       )
+       add_custom_command(
+               OUTPUT ${_outputprefix}.c
+               COMMAND ${GLIB_COMPILE_RESOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/${_inxml} 
--target=${_outputprefix}.c --sourcedir=${_sourcedir} --c-name ${_cname} --generate-source
+               DEPENDS ${_inxml} ${ARGN}
+               VERBATIM
+       )
+endmacro(glib_compile_resources)
diff --git a/cmake/modules/GObjectIntrospection.cmake b/cmake/modules/GObjectIntrospection.cmake
new file mode 100644
index 0000000..1ca8811
--- /dev/null
+++ b/cmake/modules/GObjectIntrospection.cmake
@@ -0,0 +1,233 @@
+# GObjectIntrospection.cmake
+#
+# Adds an option -DENABLE_INTROSPECTION=OFF and helper commands which work only
+# when the introspection is enabled.
+#
+# Most of the script is copied and tuned from libical, which states:
+#    Copyright (C) 2010, Pino Toscano, <pino at kde.org>
+#
+#    Redistribution and use is allowed according to the terms of the BSD license.
+#    For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+include(PrintableOptions)
+include(PkgConfigEx)
+
+add_printable_option(ENABLE_INTROSPECTION "Enable GObject introspection" OFF)
+
+if(ENABLE_INTROSPECTION)
+       pkg_check_modules_for_option(ENABLE_INTROSPECTION "GObject introspection" GOBJECT_INTROSPECTION 
gobject-introspection-1.0)
+
+       pkg_check_variable(G_IR_SCANNER gobject-introspection-1.0 g_ir_scanner)
+       pkg_check_variable(G_IR_COMPILER gobject-introspection-1.0 g_ir_compiler)
+
+       if(NOT G_IR_SCANNER)
+               message(FATAL_ERROR "g-ir-scanner not provided by gobject-introspection-1.0, you can disable 
GObject introspection by -DENABLE_INTROSPECTION=OFF")
+       endif(NOT G_IR_SCANNER)
+       if(NOT G_IR_COMPILER)
+               message(FATAL_ERROR "g-ir-compiler not provided by gobject-introspection-1.0, you can disable 
GObject introspection by -DENABLE_INTROSPECTION=OFF")
+       endif(NOT G_IR_COMPILER)
+endif(ENABLE_INTROSPECTION)
+
+macro(_gir_list_prefix _outvar _listvar _prefix)
+       set(${_outvar})
+       foreach(_item IN LISTS ${_listvar})
+               list(APPEND ${_outvar} ${_prefix}${_item})
+       endforeach()
+endmacro(_gir_list_prefix)
+
+macro(_gir_list_prefix_libs _outvar _listvar _prefix)
+       set(${_outvar})
+       foreach(_item IN LISTS ${_listvar})
+               list(APPEND ${_outvar} ${_prefix}${_item}-${API_VERSION})
+               #get_target_property(_output_name ${_item} OUTPUT_NAME)
+               #if(_output_name)
+               #       list(APPEND ${_outvar} ${_prefix}${_output_name})
+               #else(_output_name)
+               #       list(APPEND ${_outvar} ${_prefix}${_item})
+               #endif(_output_name)
+       endforeach()
+endmacro(_gir_list_prefix_libs)
+
+macro(gir_construct_names _prefix _version _out_girname _out_varsprefix)
+       set(${_out_girname} "${_prefix}-${_version}.gir")
+       set(_varsprefix ${${_out_girname}})
+
+       string(REPLACE "-" "_" _varsprefix "${_varsprefix}")
+       string(REPLACE "." "_" _varsprefix "${_varsprefix}")
+
+       set(${_out_varsprefix} ${_varsprefix})
+endmacro(gir_construct_names)
+
+macro(gir_girfilename_to_target _outvar _girfilename)
+       set(${_outvar})
+       foreach(_gir_name "${_girfilename}" ${ARGN})
+               string(REPLACE "-" "_" _gir_name "${_gir_name}")
+               string(REPLACE "." "_" _gir_name "${_gir_name}")
+               list(APPEND ${_outvar} gir-girs-${_gir_name})
+       endforeach(_gir_name)
+endmacro(gir_girfilename_to_target)
+
+# the macro does something only if ENABLE_INTROSPECTION is ON
+# optionally ${_gir_name}_SKIP_TYPELIB can be set to ON to not build .typelib file, only the .gir file
+macro(gir_add_introspection gir)
+       if(ENABLE_INTROSPECTION)
+               set(_gir_girs)
+               set(_gir_typelibs)
+
+               set(_gir_name "${gir}")
+
+               ## Transform the gir filename to something which can reference through a variable
+               ## without automake/make complaining, eg Gtk-2.0.gir -> Gtk_2_0_gir
+               string(REPLACE "-" "_" _gir_name "${_gir_name}")
+               string(REPLACE "." "_" _gir_name "${_gir_name}")
+
+               # Namespace and Version is either fetched from the gir filename
+               # or the _NAMESPACE/_VERSION variable combo
+               set(_gir_namespace "${${_gir_name}_NAMESPACE}")
+               if (_gir_namespace STREQUAL "")
+                       string(REGEX REPLACE "([^-]+)-.*" "\\1" _gir_namespace "${gir}")
+               endif ()
+               set(_gir_version "${${_gir_name}_VERSION}")
+               if (_gir_version STREQUAL "")
+                       string(REGEX REPLACE ".*-([^-]+).gir" "\\1" _gir_version "${gir}")
+               endif ()
+
+               # _PROGRAM is an optional variable which needs its own --program argument
+               set(_gir_program "${${_gir_name}_PROGRAM}")
+               if (NOT _gir_program STREQUAL "")
+                       set(_gir_program "--program=${_gir_program}")
+               endif ()
+
+               # Variables which provides a list of things
+               _gir_list_prefix_libs(_gir_libraries ${_gir_name}_LIBS "--library=")
+               _gir_list_prefix(_gir_packages ${_gir_name}_PACKAGES "--pkg=")
+               _gir_list_prefix(_gir_includes ${_gir_name}_INCLUDES "--include=")
+
+               # Reuse the LIBTOOL variable from by automake if it's set
+               set(_gir_libtool "--no-libtool")
+
+               add_custom_command(
+                       COMMAND ${G_IR_SCANNER}
+                               ${INTROSPECTION_SCANNER_ARGS}
+                               --namespace=${_gir_namespace}
+                               --nsversion=${_gir_version}
+                               ${_gir_libtool}
+                               ${_gir_program}
+                               ${_gir_libraries}
+                               ${_gir_packages}
+                               ${_gir_includes}
+                               ${${_gir_name}_SCANNERFLAGS}
+                               ${${_gir_name}_CFLAGS}
+                               ${${_gir_name}_FILES}
+                               --output ${CMAKE_CURRENT_BINARY_DIR}/${gir}
+                               --accept-unprefixed
+                       DEPENDS ${${_gir_name}_FILES}
+                               ${${_gir_name}_LIBS}
+                               ${${_gir_name}_DEPS}
+                       OUTPUT ${gir}
+                       WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+                       VERBATIM
+               )
+               list(APPEND _gir_girs ${CMAKE_CURRENT_BINARY_DIR}/${gir})
+               install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${gir} DESTINATION ${SHARE_INSTALL_DIR}/gir-1.0)
+               add_custom_target(gir-girs-${_gir_name} ALL DEPENDS ${_gir_girs})
+
+               if(NOT DEFINED ${_gir_name}_SKIP_TYPELIB OR NOT ${${_gir_name}_SKIP_TYPELIB})
+                       string(REPLACE ".gir" ".typelib" _typelib "${gir}")
+                       add_custom_command(
+                               COMMAND ${G_IR_COMPILER}
+                                       ${INTROSPECTION_COMPILER_ARGS}
+                                       --includedir=.
+                                       ${CMAKE_CURRENT_BINARY_DIR}/${gir}
+                                       -o ${CMAKE_CURRENT_BINARY_DIR}/${_typelib}
+                               DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${gir}
+                               OUTPUT ${_typelib}
+                               WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+                       )
+                       list(APPEND _gir_typelibs ${CMAKE_CURRENT_BINARY_DIR}/${_typelib})
+                       install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_typelib} DESTINATION 
${LIB_INSTALL_DIR}/girepository-1.0)
+                       add_custom_target(gir-typelibs-${_gir_name} ALL DEPENDS ${_gir_typelibs})
+               endif(NOT DEFINED ${_gir_name}_SKIP_TYPELIB OR NOT ${${_gir_name}_SKIP_TYPELIB})
+       endif(ENABLE_INTROSPECTION)
+endmacro(gir_add_introspection)
+
+macro(_gir_deps_to_cmake_targets _outvar _inlist)
+       set(${_outvar})
+       foreach(_item IN LISTS ${_inlist})
+               get_filename_component(_filename "${_item}" NAME)
+               string(REPLACE "-" "_" _filename "${_filename}")
+               string(REPLACE "." "_" _filename "${_filename}")
+               list(APPEND ${_outvar} gir-girs-${_filename})
+       endforeach()
+endmacro(_gir_deps_to_cmake_targets)
+
+macro(_gir_deps_to_includedir _outvar _inlist)
+       set(${_outvar})
+       foreach(_item IN LISTS ${_inlist})
+               get_filename_component(_directory "${_item}" DIRECTORY)
+               list(APPEND ${_outvar} "--includedir=${_directory}")
+       endforeach()
+endmacro(_gir_deps_to_includedir)
+
+macro(gir_add_introspection_simple gir_library pkg_export_prefix gir_library_version c_include 
gir_identifies_prefixes_var gir_includes_var extra_cflags_var gir_extra_libdirs_var gir_libs_var gir_deps_var 
gir_sources_var)
+       gir_construct_names(${gir_library} ${gir_library_version} gir_name gir_vars_prefix)
+
+       unset(INTROSPECTION_SCANNER_FLAGS)
+       unset(INTROSPECTION_SCANNER_ARGS)
+       unset(INTROSPECTION_COMPILER_ARGS)
+
+       set(${gir_vars_prefix} ${gir_library})
+       set(${gir_vars_prefix}_SCANNERFLAGS "--warn-all")
+       set(${gir_vars_prefix}_VERSION "${gir_library_version}")
+       set(${gir_vars_prefix}_LIBRARY "${gir_vars_prefix}")
+       set(${gir_vars_prefix}_INCLUDES ${${gir_includes_var}})
+       set(${gir_vars_prefix}_CFLAGS
+               -I${CMAKE_CURRENT_BINARY_DIR}
+               -I${CMAKE_BINARY_DIR}
+               -I${CMAKE_CURRENT_SOURCE_DIR}
+               -I${CMAKE_SOURCE_DIR}
+               ${${extra_cflags_var}}
+       )
+       set(${gir_vars_prefix}_LIBS ${${gir_libs_var}})
+       set(${gir_vars_prefix}_FILES ${${gir_sources_var}})
+
+       _gir_deps_to_includedir(INTROSPECTION_COMPILER_ARGS ${gir_deps_var})
+       _gir_deps_to_cmake_targets(${gir_vars_prefix}_DEPS ${gir_deps_var})
+
+       _gir_list_prefix(_gir_identifies_prefixes ${gir_identifies_prefixes_var} "--identifier-prefix=")
+       _gir_list_prefix(_gir_extra_libdirs ${gir_extra_libdirs_var} "--library-path=")
+       _gir_list_prefix(_gir_deps ${gir_deps_var} "--include-uninstalled=")
+
+       set(INTROSPECTION_SCANNER_ARGS
+               --add-include-path=${CMAKE_BINARY_DIR}
+               --add-include-path=${CMAKE_SOURCE_DIR}
+               --add-include-path=${CMAKE_CURRENT_BINARY_DIR}
+               --add-include-path=${CMAKE_CURRENT_SOURCE_DIR}
+               --library-path=${LIB_INSTALL_DIR}
+               --library-path=${CMAKE_BINARY_DIR}
+               --library-path=${CMAKE_CURRENT_BINARY_DIR}
+               ${_gir_extra_libdirs}
+               ${_gir_identifies_prefixes}
+               ${_gir_deps}
+               --pkg-export ${pkg_export_prefix}-${gir_library_version}
+               --c-include=${c_include}
+               --cflags-begin
+               ${${gir_vars_prefix}_CFLAGS}
+               --cflags-end
+               --verbose
+       )
+
+       gir_add_introspection(${gir_name})
+
+endmacro(gir_add_introspection_simple)
+
+macro(gir_filter_out_sources _inout_listvar _contains_str)
+       set(_tmp)
+       foreach(_item IN LISTS ${_inout_listvar})
+               string(FIND "${_item}" "${_contains_str}" _contains)
+               if(_contains EQUAL -1)
+                       list(APPEND _tmp ${_prefix}${_item})
+               endif(_contains EQUAL -1)
+       endforeach()
+       set(${_inout_listvar} ${_tmp})
+endmacro(gir_filter_out_sources)
diff --git a/cmake/modules/GtkDoc.cmake b/cmake/modules/GtkDoc.cmake
new file mode 100644
index 0000000..4aa286a
--- /dev/null
+++ b/cmake/modules/GtkDoc.cmake
@@ -0,0 +1,150 @@
+# GtkDoc.cmake
+#
+# Macros to support develper documentation build from sources with gtk-doc.
+#
+# add_gtkdoc(_module _namespace _deprecated_guards _srcdirsvar _depsvar _ignoreheadersvar)
+#    Adds rules to build developer documentation using gtk-doc for some part.
+#    Arguments:
+#       _module - the module name, like 'camel'; it expects ${_part}-docs.sgml.in in the 
CMAKE_CURRENT_SOURCE_DIR
+#       _namespace - namespace for symbols
+#       _deprecated_guards - define name, which guards deprecated symbols
+#       _srcdirsvar - variable with dirs where the source files are located
+#       _depsvar - a variable with dependencies (targets)
+#       _ignoreheadersvar - a variable with a set of header files to ignore
+#
+# It also adds custom target gtkdoc-rebuild-${_module}-sgml to rebuild the sgml.in
+# file based on the current sources.
+
+include(PrintableOptions)
+
+add_printable_option(ENABLE_GTK_DOC "Use gtk-doc to build documentation" OFF)
+
+if(NOT ENABLE_GTK_DOC)
+       return()
+endif(NOT ENABLE_GTK_DOC)
+
+find_program(GTKDOC_SCAN gtkdoc-scan)
+find_program(GTKDOC_MKDB gtkdoc-mkdb)
+find_program(GTKDOC_MKHTML gtkdoc-mkhtml)
+find_program(GTKDOC_FIXXREF gtkdoc-fixxref)
+
+if(NOT (GTKDOC_SCAN AND GTKDOC_MKDB AND GTKDOC_MKHTML AND GTKDOC_FIXXREF))
+       message(FATAL_ERROR "Cannot find all gtk-doc binaries, install them or use -DENABLE_GTK_DOC=OFF 
instead")
+       return()
+endif()
+
+if(NOT TARGET gtkdocs)
+       add_custom_target(gtkdocs ALL)
+endif(NOT TARGET gtkdocs)
+
+if(NOT TARGET gtkdoc-rebuild-sgmls)
+       add_custom_target(gtkdoc-rebuild-sgmls)
+endif(NOT TARGET gtkdoc-rebuild-sgmls)
+
+macro(add_gtkdoc _module _namespace _deprecated_guards _srcdirsvar _depsvar _ignoreheadersvar)
+       configure_file(
+               ${CMAKE_CURRENT_SOURCE_DIR}/${_module}-docs.sgml.in
+               ${CMAKE_CURRENT_BINARY_DIR}/${_module}-docs.sgml
+               @ONLY
+       )
+
+       set(OUTPUT_DOCDIR ${SHARE_INSTALL_DIR}/gtk-doc/html/${_module})
+
+       set(_ignore_headers)
+       foreach(_header ${${_ignoreheadersvar}})
+               set(_ignore_headers "${_ignore_headers} ${_header}")
+       endforeach(_header)
+
+       set(_filedeps)
+       set(_srcdirs)
+       foreach(_srcdir ${${_srcdirsvar}})
+               set(_srcdirs ${_srcdirs} --source-dir="${_srcdir}")
+               file(GLOB _files ${_srcdir}/*.h* ${_srcdir}/*.c*)
+               list(APPEND _filedeps ${_files})
+       endforeach(_srcdir)
+
+       set(_mkhtml_prefix "")
+       if(APPLE)
+               set(_mkhtml_prefix "${CMAKE_COMMAND} -E env XML_CATALOG_FILES=\"/usr/local/etc/xml/catalog\"")
+       endif(APPLE)
+
+       add_custom_command(OUTPUT html/index.html
+               COMMAND ${GTKDOC_SCAN}
+                       --module=${_module}
+                       --deprecated-guards="${_deprecated_guards}"
+                       --ignore-headers="${_ignore_headers}"
+                       --rebuild-sections
+                       --rebuild-types
+                       ${_srcdirs}
+
+               COMMAND ${GTKDOC_MKDB}
+                       --module=${_module}
+                       --name-space=${_namespace}
+                       --main-sgml-file="${CMAKE_CURRENT_BINARY_DIR}/${_module}-docs.sgml"
+                       --sgml-mode
+                       --output-format=xml
+                       ${_srcdirs}
+
+               COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/html"
+
+               COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_CURRENT_BINARY_DIR}/html" ${_mkhtml_prefix} 
${GTKDOC_MKHTML} --path=.. ${_module} ../${_module}-docs.sgml
+
+               COMMAND ${GTKDOC_FIXXREF}
+                       --module=${_module}
+                       --module-dir=.
+                       --extra-dir=..
+                       --html-dir="${OUTPUT_DOCDIR}"
+
+               WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+               DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_module}-docs.sgml"
+                       ${_filedeps}
+               COMMENT "Generating ${_module} documentation"
+       )
+
+       add_custom_target(gtkdoc-${_module}
+               DEPENDS html/index.html
+       )
+
+       if(${_depsvar})
+               add_dependencies(gtkdoc-${_module} ${${_depsvar}})
+       endif(${_depsvar})
+
+       add_dependencies(gtkdocs gtkdoc-${_module})
+
+       install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/
+               DESTINATION ${OUTPUT_DOCDIR}
+       )
+
+       # ***************************************
+       # sgml.in file rebuild, unconditional
+       # ***************************************
+       add_custom_target(gtkdoc-rebuild-${_module}-sgml
+               COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_CURRENT_BINARY_DIR}/tmp"
+               COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/tmp"
+
+               COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_CURRENT_BINARY_DIR}/tmp"
+                       ${GTKDOC_SCAN}
+                       --module=${_module}
+                       --deprecated-guards="${_deprecated_guards}"
+                       --ignore-headers="${_ignore_headers}"
+                       --rebuild-sections
+                       --rebuild-types
+                       ${_srcdirs}
+
+               COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_CURRENT_BINARY_DIR}/tmp"
+                       ${GTKDOC_MKDB}
+                       --module=${_module}
+                       --name-space=${_namespace}
+                       --main-sgml-file="${CMAKE_CURRENT_BINARY_DIR}/tmp/${_module}-docs.sgml"
+                       --sgml-mode
+                       --output-format=xml
+                       ${_srcdirs}
+
+               COMMAND ${CMAKE_COMMAND} -E rename ${CMAKE_CURRENT_BINARY_DIR}/tmp/${_module}-docs.sgml 
${CMAKE_CURRENT_SOURCE_DIR}/${_module}-docs.sgml.in
+
+               COMMAND ${CMAKE_COMMAND} -E echo "File '${CMAKE_CURRENT_SOURCE_DIR}/${_module}-docs.sgml.in' 
overwritten, make sure you replace generated strings with proper content before committing."
+       )
+
+       add_dependencies(gtkdoc-rebuild-sgmls gtkdoc-rebuild-${_module}-sgml)
+
+endmacro(add_gtkdoc)
diff --git a/cmake/modules/InstalledTests.cmake b/cmake/modules/InstalledTests.cmake
new file mode 100644
index 0000000..ed1faa8
--- /dev/null
+++ b/cmake/modules/InstalledTests.cmake
@@ -0,0 +1,45 @@
+# InstalledTests.cmake
+#
+# Adds option ENABLE_INSTALLED_TESTS and helper macros to manage
+# installed test. There are also set variables:
+# INSTALLED_TESTS_EXEC_DIR - where to store installed tests and eventually its data
+# INSTALLED_TESTS_META_DIR - where to store .test meta files for installed tests
+#
+# install_test_if_enabled(_test_target _type _environ)
+#    Adds rules to install a test whose target is _test_target (the one
+#    used for add_executable()), while the target name should match
+#    the executable name. The _type and _environ are used for populating
+#    the .test meta file.
+
+include(PrintableOptions)
+
+add_printable_option(ENABLE_INSTALLED_TESTS "Enable installed tests" OFF)
+
+set(INSTALLED_TESTS_EXEC_DIR ${privlibexecdir}/installed-tests)
+set(INSTALLED_TESTS_META_DIR ${SHARE_INSTALL_DIR}/installed-tests/${PROJECT_NAME})
+
+macro(install_test_if_enabled _test_target _type _environ)
+       if(ENABLE_INSTALLED_TESTS)
+               set(TEST_TYPE ${_type})
+               set(TEST_ENVIRONMENT)
+               if(NOT ${_environ} STREQUAL "")
+                       set(TEST_ENVIRONMENT "env ${_environ} ")
+               endif(NOT ${_environ} STREQUAL "")
+
+               set(teststring "[Test]
+Type=${TEST_TYPE}
+Exec=${TEST_ENVIRONMENT}${INSTALLED_TESTS_EXEC_DIR}/${_test_target}
+"
+)
+
+               file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${_test_target}.test "${teststring}")
+
+               install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_test_target}.test
+                       DESTINATION ${INSTALLED_TESTS_META_DIR}
+               )
+
+               install(TARGETS ${_test_target}
+                       DESTINATION ${INSTALLED_TESTS_EXEC_DIR}
+               )
+       endif(ENABLE_INSTALLED_TESTS)
+endmacro(install_test_if_enabled)
diff --git a/cmake/modules/PkgConfigEx.cmake b/cmake/modules/PkgConfigEx.cmake
new file mode 100644
index 0000000..866fe7c
--- /dev/null
+++ b/cmake/modules/PkgConfigEx.cmake
@@ -0,0 +1,90 @@
+# PkgConfigEx.cmake
+#
+# Extends CMake's PkgConfig module with commands:
+#
+# pkg_check_modules_for_option(_option_name _option_description _prefix _module0)
+#
+#    which calls `pkg_check_modules(_prefix _module0)` and if <_prefix>_FOUND is False,
+#    then prints an error with a hint to disaable the _option_name if needed.
+#
+# pkg_check_exists(_output_name _pkg)
+#
+#    calls pkg-config --exists for _pkg and stores the result to _output_name.
+#
+# pkg_check_at_least_version(_output_name _pkg _version)
+#
+#    calls pkg-config --at-least-version=_version for _pkg and stores the result to _output_name.
+#
+# pkg_check_exact_version(_output_name _pkg _version)
+#
+#    calls pkg-config --exact-version=_version for _pkg and stores the result to _output_name.
+#
+# pkg_check_variable(_output_name _pkg _name)
+#
+#    gets a variable named _name from package _pkg and stores the result into _output_name
+
+find_package(PkgConfig REQUIRED)
+
+macro(pkg_check_modules_for_option _option_name _option_description _prefix _module0)
+       pkg_check_modules(${_prefix} ${_module0} ${ARGN})
+
+       if(NOT ${_prefix}_FOUND)
+               message(FATAL_ERROR "Necessary libraries not found or not enough version. If you want to 
disable ${_option_description}, please use -D${_option_name}=OFF argument to cmake command.")
+       endif(NOT ${_prefix}_FOUND)
+endmacro()
+
+macro(pkg_check_exists _output_name _pkg)
+       execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --exists ${_pkg}
+                       RESULT_VARIABLE ${_output_name})
+
+       # Negate the result, because 0 means 'found'
+       if(${_output_name})
+               set(${_output_name} OFF)
+       else(${_output_name})
+               set(${_output_name} ON)
+       endif(${_output_name})
+endmacro()
+
+macro(pkg_check_at_least_version _output_name _pkg _version)
+       execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --atleast-version=${_version} ${_pkg}
+                       RESULT_VARIABLE ${_output_name})
+
+       # Negate the result, because 0 means 'found'
+       if(${_output_name})
+               set(${_output_name} OFF)
+       else(${_output_name})
+               set(${_output_name} ON)
+       endif(${_output_name})
+endmacro()
+
+macro(pkg_check_exact_version _output_name _pkg _version)
+       execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --exact-version=${_version} ${_pkg}
+                       RESULT_VARIABLE ${_output_name})
+
+       # Negate the result, because 0 means 'found'
+       if(${_output_name})
+               set(${_output_name} OFF)
+       else(${_output_name})
+               set(${_output_name} ON)
+       endif(${_output_name})
+endmacro()
+
+function(pkg_check_variable _output_name _pkg _name)
+    execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=${_name} ${_pkg}
+                    OUTPUT_VARIABLE _pkg_result
+                    OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+    set("${_output_name}" "${_pkg_result}" CACHE STRING "pkg-config variable ${_name} of ${_pkg}")
+endfunction()
+
+macro(add_pkgconfig_file _input _output)
+       configure_file(
+               ${CMAKE_CURRENT_SOURCE_DIR}/${_input}
+               ${CMAKE_CURRENT_BINARY_DIR}/${_output}
+               @ONLY
+       )
+
+       install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_output}
+               DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
+       )
+endmacro()
diff --git a/cmake/modules/PrintableOptions.cmake b/cmake/modules/PrintableOptions.cmake
new file mode 100644
index 0000000..23ce356
--- /dev/null
+++ b/cmake/modules/PrintableOptions.cmake
@@ -0,0 +1,74 @@
+# PrintableOptions.cmake
+#
+# Provides functions to manage printable otpions,
+# which can be printed at the end of the configuration
+#
+# add_printable_variable_bare(_name)
+#    adds variable named _name to the list of prinable options
+#
+# add_printable_option(_name _description _default_value)
+#    the same as option() commnd, only also notes this option for later printing
+#
+# add_printable_variable(_name _description _default_value)
+#    sets a new cached STRING variable and adds it to the list of printable options
+#
+# add_printable_variable_path(_name _description _default_value)
+#    sets a new cached PATH variable and adds it to the list of printable options
+#
+# print_build_options()
+#    prints all the build options previously added with the above functions
+
+macro(add_printable_variable_bare _name)
+       if(_name STREQUAL "")
+               message(FATAL_ERROR "variable name cannot be empty")
+       endif(_name STREQUAL "")
+       list(APPEND _printable_options ${_name})
+endmacro()
+
+macro(add_printable_option _name _description _default_value)
+       if(_name STREQUAL "")
+               message(FATAL_ERROR "option name cannot be empty")
+       endif(_name STREQUAL "")
+       option(${_name} ${_description} ${_default_value})
+       add_printable_variable_bare(${_name})
+endmacro()
+
+macro(add_printable_variable _name _description _default_value)
+       if(_name STREQUAL "")
+               message(FATAL_ERROR "variable name cannot be empty")
+       endif(_name STREQUAL "")
+       set(${_name} ${_default_value} CACHE STRING ${_description})
+       add_printable_variable_bare(${_name})
+endmacro()
+
+macro(add_printable_variable_path _name _description _default_value)
+       if(_name STREQUAL "")
+               message(FATAL_ERROR "path variable name cannot be empty")
+       endif(_name STREQUAL "")
+       set(${_name} ${_default_value} CACHE PATH ${_description})
+       add_printable_variable_bare(${_name})
+endmacro()
+
+function(print_build_options)
+       message(STATUS "Configure options:")
+
+       set(max_len 0)
+       foreach(opt IN LISTS _printable_options)
+               string(LENGTH "${opt}" len)
+               if(max_len LESS len)
+                       set(max_len ${len})
+               endif(max_len LESS len)
+       endforeach()
+       math(EXPR max_len "${max_len} + 2")
+
+       foreach(opt IN LISTS _printable_options)
+               string(LENGTH "${opt}" len)
+               set(str "   ${opt} ")
+               foreach (IGNORE RANGE ${len} ${max_len})
+                       set(str "${str}.")
+               endforeach ()
+               set(str "${str} ${${opt}}")
+
+               message(STATUS ${str})
+       endforeach()
+endfunction()
diff --git a/cmake/modules/SetupBuildFlags.cmake b/cmake/modules/SetupBuildFlags.cmake
new file mode 100644
index 0000000..a7d2aa4
--- /dev/null
+++ b/cmake/modules/SetupBuildFlags.cmake
@@ -0,0 +1,80 @@
+# SetupBuildFlags.cmake
+#
+# Setups compiler/linker flags, skipping those which are not supported.
+
+include(CheckCCompilerFlag)
+include(CheckCXXCompilerFlag)
+
+macro(setup_build_flags _maintainer_mode)
+       list(APPEND proposed_flags
+               -Werror-implicit-function-declaration
+               -Wformat
+               -Wformat-security
+               -Winit-self
+               -Wmissing-declarations
+               -Wmissing-noreturn
+               -Wpointer-arith
+               -Wredundant-decls
+               -Wundef
+               -Wwrite-strings
+               -no-undefined
+               -fno-strict-aliasing
+       )
+
+       if(_maintainer_mode)
+               list(APPEND proposed_flags
+                       -Wall
+                       -Wextra
+                       -Wdeprecated-declarations
+                       -Wmissing-include-dirs
+               )
+       else(_maintainer_mode)
+               list(APPEND proposed_flags
+                       -Wno-deprecated-declarations
+                       -Wno-missing-include-dir)
+       endif(_maintainer_mode)
+
+       list(APPEND proposed_c_flags
+               ${proposed_flags}
+               -Wdeclaration-after-statement
+               -Wno-missing-field-initializers
+               -Wno-sign-compare
+               -Wno-unused-parameter
+               -Wnested-externs
+       )
+
+       if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
+               list(APPEND proposed_c_flags
+                       -Wno-parentheses-equality
+                       -Wno-format-nonliteral
+               )
+       endif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
+
+       list(APPEND proposed_cxx_flags
+               ${proposed_flags}
+               -Wabi
+               -Wnoexcept
+       )
+
+       foreach(flag IN LISTS proposed_c_flags)
+               check_c_compiler_flag(${flag} c_flag_${flag}_supported)
+               if(c_flag_${flag}_supported)
+                       set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
+               endif(c_flag_${flag}_supported)
+               unset(c_flag_${flag}_supported)
+       endforeach()
+
+       foreach(flag IN LISTS proposed_cxx_flags)
+               check_cxx_compiler_flag(${flag} cxx_flag_${flag}_supported)
+               if(cxx_flag_${flag}_supported)
+                       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
+               endif(cxx_flag_${flag}_supported)
+               unset(cxx_flag_${flag}_supported)
+       endforeach()
+
+       if(("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU"))
+               set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined")
+               set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined")
+               set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
+       endif(("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU"))
+endmacro()
diff --git a/cmake/modules/UninstallTarget.cmake b/cmake/modules/UninstallTarget.cmake
new file mode 100644
index 0000000..7ccfcf3
--- /dev/null
+++ b/cmake/modules/UninstallTarget.cmake
@@ -0,0 +1,13 @@
+# UninstallTarget.cmake
+#
+# Defines a custom target named 'uninstall'
+
+if(NOT TARGET uninstall)
+       configure_file(
+               "${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
+               "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
+               IMMEDIATE @ONLY)
+
+       add_custom_target(uninstall
+               COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake)
+endif(NOT TARGET uninstall)
diff --git a/cmake/verify-news-file.sh b/cmake/verify-news-file.sh
new file mode 100755
index 0000000..3ac8099
--- /dev/null
+++ b/cmake/verify-news-file.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+# Verifies that the NEWS file's first line contains correct version and date.
+# Requires arguments:
+#   $1 ... the NEWS file name, preferably with full path
+#   $2 ... expected version string, like "1.2.3"
+#
+# The date is expected in a form of YYYY-MM-DD of the current local time.
+# The NEWS line is in form of "PROJECTNAME VERSION DATE".
+
+FILENAME=$1
+EXPVERSION=$2
+
+if [ ! -f "$FILENAME" ]; then
+       echo "File '$FILENAME' does not exist" 1>&2
+       exit 1
+fi
+
+if [ -z "$EXPVERSION" ]; then
+       echo "Expected version argument not given or empty, use format '1.2.3'" 1>&2
+       exit 1
+fi
+
+NEWSLINE=`head --lines=1 "$FILENAME"`
+EXPDATE=`date +%Y-%m-%d`
+
+NEWSVERSION="${NEWSLINE#* }"
+NEWSDATE="${NEWSVERSION#* }"
+NEWSVERSION="${NEWSVERSION% *}"
+
+if [ "$NEWSVERSION" != "$EXPVERSION" ]; then
+       echo "Read NEWS version '$NEWSVERSION' doesn't match expected version '$EXPVERSION'" 1>&2
+       exit 1
+fi
+
+if [ "$NEWSDATE" != "$EXPDATE" ]; then
+       echo "Read NEWS date '$NEWSDATE' doesn't match expected version '$EXPDATE'" 1>&2
+       exit 1
+fi
diff --git a/composer/e-composer-actions.c b/composer/e-composer-actions.c
index fa92322..bafbc72 100644
--- a/composer/e-composer-actions.c
+++ b/composer/e-composer-actions.c
@@ -691,7 +691,7 @@ e_composer_actions_init (EMsgComposer *composer)
                e_html_editor_get_action (editor, "picture-gallery"), "sensitive",
                G_BINDING_SYNC_CREATE);
 
-#if defined (HAVE_NSS)
+#if defined (ENABLE_SMIME)
        visible = TRUE;
 #else
        visible = FALSE;
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index a2a9b89..6bc7efc 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -826,7 +826,7 @@ composer_build_message_pgp (AsyncContext *context,
        return TRUE;
 }
 
-#ifdef HAVE_SSL
+#ifdef ENABLE_SMIME
 static gboolean
 composer_build_message_smime (AsyncContext *context,
                               GCancellable *cancellable,
@@ -1029,12 +1029,12 @@ composer_build_message_thread (GSimpleAsyncResult *simple,
                return;
        }
 
-#if defined (HAVE_NSS)
+#if defined (ENABLE_SMIME)
        if (!composer_build_message_smime (context, cancellable, &error)) {
                g_simple_async_result_take_error (simple, error);
                return;
        }
-#endif /* HAVE_NSS */
+#endif /* ENABLE_SMIME */
 }
 
 static void
@@ -5069,7 +5069,7 @@ e_msg_composer_get_message (EMsgComposer *composer,
        if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
                flags |= COMPOSER_FLAG_PGP_ENCRYPT;
 
-#ifdef HAVE_NSS
+#ifdef ENABLE_SMIME
        action = ACTION (SMIME_SIGN);
        if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
                flags |= COMPOSER_FLAG_SMIME_SIGN;
@@ -5205,7 +5205,7 @@ e_msg_composer_get_message_draft (EMsgComposer *composer,
        if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
                flags |= COMPOSER_FLAG_PGP_ENCRYPT;
 
-#ifdef HAVE_NSS
+#ifdef ENABLE_SMIME
        action = ACTION (SMIME_SIGN);
        if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
                flags |= COMPOSER_FLAG_SMIME_SIGN;
diff --git a/config.h.in b/config.h.in
new file mode 100644
index 0000000..2d474f8
--- /dev/null
+++ b/config.h.in
@@ -0,0 +1,127 @@
+/* config.h generated by CMake */
+
+/* Name of the package */
+#define PACKAGE "@PROJECT_NAME@"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "@PROJECT_BUGREPORT@"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL "@PROJECT_URL@"
+
+/* Version number of the project */
+#define VERSION "@PROJECT_VERSION@"
+
+/* Version substring, for packagers */
+#define VERSION_SUBSTRING "@VERSION_SUBSTRING@"
+
+/* Define if you want a comment appended to the version number */
+#define VERSION_COMMENT "@VERSION_COMMENT@"
+
+/* Define to the latest stable version if this version is unstable */
+#cmakedefine STABLE_VERSION "@STABLE_VERSION@"
+
+/* Base version (Major.Minor) */
+#define BASE_VERSION "@BASE_VERSION@"
+
+/* Package name for gettext */
+#define GETTEXT_PACKAGE "@GETTEXT_PACKAGE@"
+
+/* Command to kill processes by name */
+#cmakedefine KILL_PROCESS_COMMAND "@KILL_PROCESS_COMMAND@"
+
+/* Define to 1 if you have the `nl_langinfo' function. */
+#cmakedefine HAVE_NL_LANGINFO 1
+
+/* Have nl_langinfo (_NL_MEASUREMENT_MEASUREMENT) */
+#cmakedefine HAVE__NL_MEASUREMENT_MEASUREMENT 1
+
+/* gnome-desktop */
+#cmakedefine HAVE_GNOME_DESKTOP 1
+
+/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
+#cmakedefine HAVE_SYS_WAIT_H 1
+
+/* Define if using Canberra and Canberra-GTK for sound */
+#cmakedefine HAVE_CANBERRA 1
+
+/* Define if gnome-autoar is enabled */
+#cmakedefine HAVE_AUTOAR 1
+
+/* Define if struct tm has a tm_gmtoff member */
+#cmakedefine HAVE_TM_GMTOFF 1
+
+/* Define if libc defines a timezone variable */
+#cmakedefine HAVE_TIMEZONE 1
+
+/* Define if libc defines an altzone variable */
+#cmakedefine HAVE_ALTZONE 1
+
+/* Define to 1 if you have the `mkdtemp' function. */
+#cmakedefine HAVE_MKDTEMP 1
+
+/* Define if you have the iso-codes package */
+#cmakedefine HAVE_ISO_CODES 1
+
+/* ISO codes prefix */
+#define ISO_CODES_PREFIX "@ISO_CODES_PREFIX@"
+
+/* defined if you have X11/XF86keysym.h */
+#cmakedefine HAVE_XFREE 1
+
+/* Define if using libcryptui */
+#cmakedefine HAVE_LIBCRYPTUI 1
+
+/* Define if TNEF attachments parser should be built */
+#cmakedefine HAVE_TNEF 1
+
+/* Define if TNEF include header is <ytnef.h> */
+#cmakedefine HAVE_YTNEF_H 1
+
+/* Define if TNEF include header is <libytnef/ytnef.h> */
+#cmakedefine HAVE_LIBYTNEF_YTNEF_H 1
+
+/* Bogofilter spam filtering program */
+#define BOGOFILTER_COMMAND "@BOGOFILTER_COMMAND@"
+
+/* SpamAssassin spam filtering program */
+#define SPAMASSASSIN_COMMAND "@SPAMASSASSIN_COMMAND@"
+
+/* SpamAssassin spam training program */
+#define SA_LEARN_COMMAND "@SA_LEARN_COMMAND@"
+
+/* Define if you have libnotify */
+#cmakedefine HAVE_LIBNOTIFY 1
+
+/* libical provides ical_set_unknown_token_handling_setting function */
+#cmakedefine HAVE_ICAL_UNKNOWN_TOKEN_HANDLING 1
+
+/* libical provides icaltzutil_set_exact_vtimezones_support function */
+#cmakedefine HAVE_ICALTZUTIL_SET_EXACT_VTIMEZONES_SUPPORT 1
+
+/* When defined spell checking is enabled */
+#cmakedefine HAVE_GTKSPELL 1
+
+/* Source code highlighting utility */
+#cmakedefine HIGHLIGHT_COMMAND "@HIGHLIGHT_COMMAND@"
+
+/* When defined Contacts preview will contain maps */
+#cmakedefine ENABLE_CONTACT_MAPS 1
+
+/* Define to 1 if you have the `gnu_get_libc_version' function. */
+#cmakedefine HAVE_GNU_GET_LIBC_VERSION 1
+
+/* Define if SMIME should be enabled */
+#cmakedefine ENABLE_SMIME 1
+
+/* Define if you have LDAP support */
+#cmakedefine HAVE_LDAP 1
+
+/* Define if you use SunLDAP */
+/#cmakedefine SUNLDAP 1
+
+/* Define to the full path of mozilla nss library */
+#define MOZILLA_NSS_LIB_DIR "@MOZILLA_NSS_LIB_DIR@"
+
+/* When defined contacts preview will contain maps */
+#cmakedefine ENABLE_CONTACT_MAPS 1
diff --git a/e-util/e-spell-text-view.c b/e-util/e-spell-text-view.c
index e6f4412..d2caa20 100644
--- a/e-util/e-spell-text-view.c
+++ b/e-util/e-spell-text-view.c
@@ -23,7 +23,7 @@
 
 #include <gtk/gtk.h>
 
-#ifdef WITH_GTKSPELL
+#ifdef HAVE_GTKSPELL
 #include <gtkspell/gtkspell.h>
 #endif
 
@@ -43,11 +43,11 @@
 gboolean
 e_spell_text_view_is_supported (void)
 {
-#ifdef WITH_GTKSPELL
+#ifdef HAVE_GTKSPELL
        return TRUE;
-#else /* WITH_GTKSPELL */
+#else /* HAVE_GTKSPELL */
        return FALSE;
-#endif /* WITH_GTKSPELL */
+#endif /* HAVE_GTKSPELL */
 }
 
 /**
@@ -64,7 +64,7 @@ e_spell_text_view_is_supported (void)
 gboolean
 e_spell_text_view_attach (GtkTextView *text_view)
 {
-#ifdef WITH_GTKSPELL
+#ifdef HAVE_GTKSPELL
        GtkSpellChecker *spell;
        GSettings *settings;
        gchar **strv;
@@ -90,9 +90,9 @@ e_spell_text_view_attach (GtkTextView *text_view)
        g_strfreev (strv);
 
        return success;
-#else /* WITH_GTKSPELL */
+#else /* HAVE_GTKSPELL */
        return FALSE;
-#endif /* WITH_GTKSPELL */
+#endif /* HAVE_GTKSPELL */
 }
 
 /**
@@ -108,11 +108,11 @@ e_spell_text_view_attach (GtkTextView *text_view)
 void
 e_spell_text_view_recheck_all (GtkTextView *text_view)
 {
-#ifdef WITH_GTKSPELL
+#ifdef HAVE_GTKSPELL
        GtkSpellChecker *spell;
 
        spell = gtk_spell_checker_get_from_text_view (text_view);
        if (spell)
                gtk_spell_checker_recheck_all (spell);
-#endif /* WITH_GTKSPELL */
+#endif /* HAVE_GTKSPELL */
 }
diff --git a/em-format/e-mail-part-secure-button.c b/em-format/e-mail-part-secure-button.c
index 2455303..51ff633 100644
--- a/em-format/e-mail-part-secure-button.c
+++ b/em-format/e-mail-part-secure-button.c
@@ -21,7 +21,7 @@
 
 #include <e-util/e-util.h>
 
-#if defined (HAVE_NSS) && defined (ENABLE_SMIME)
+#if defined (ENABLE_SMIME)
 #include "certificate-manager.h"
 #include "e-cert-db.h"
 #endif
@@ -34,7 +34,7 @@ const gchar *e_mail_formatter_secure_button_get_encrypt_description (CamelCipher
 const gchar *e_mail_formatter_secure_button_get_sign_description (CamelCipherValiditySign status);
 
 
-#if defined (HAVE_NSS) && defined (ENABLE_SMIME)
+#if defined (ENABLE_SMIME)
 static void
 viewcert_clicked (GtkWidget *button,
                   GtkWidget *grid)
@@ -107,14 +107,14 @@ add_cert_table (GtkWidget *grid,
 
                if (l) {
                        GtkWidget *w;
-#if defined (HAVE_NSS) && defined (ENABLE_SMIME)
+#if defined (ENABLE_SMIME)
                        ECert *ec = NULL;
 #endif
                        w = gtk_label_new (l);
                        gtk_misc_set_alignment ((GtkMisc *) w, 0.0, 0.5);
                        g_free (la);
                        gtk_table_attach (table, w, 0, 1, n, n + 1, GTK_FILL, GTK_FILL, 3, 3);
-#if defined (HAVE_NSS) && defined (ENABLE_SMIME)
+#if defined (ENABLE_SMIME)
                        w = gtk_button_new_with_mnemonic (_("_View Certificate"));
                        gtk_table_attach (table, w, 1, 2, n, n + 1, 0, 0, 3, 3);
                        g_object_set_data ((GObject *) w, "e-cert-info", info);
diff --git a/evolution-calendar.pc.in b/evolution-calendar.pc.in
index 81f1179..b2bd382 100644
--- a/evolution-calendar.pc.in
+++ b/evolution-calendar.pc.in
@@ -1,17 +1,12 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@LIB_INSTALL_DIR@
 
 privlibdir=@privsolibdir@
 privincludedir=@privincludedir@
 
-# The requirements list is kind of guesswork at
-# the moment.  Add more requirements as needed.
-
 Name: Evolution Calendar
 Description: Calendar utilities for Evolution
-Version: @VERSION@
-Requires: evolution-shell-3.0
+Version: @PROJECT_VERSION@
+Requires: evolution-shell-@INTERFACE_VERSION@
 Libs: -L${privlibdir} -levolution-calendar
 Cflags: -I${privincludedir}
diff --git a/evolution-mail.pc.in b/evolution-mail.pc.in
index 79b13d2..26d5dad 100644
--- a/evolution-mail.pc.in
+++ b/evolution-mail.pc.in
@@ -1,17 +1,12 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@LIB_INSTALL_DIR@
 
 privlibdir=@privsolibdir@
 privincludedir=@privincludedir@
 
-# The requirements list is kind of guesswork at
-# the moment.  Add more requirements as needed.
-
 Name: Evolution Mail
 Description: Mail utilities for Evolution
-Version: @VERSION@
-Requires: evolution-shell-3.0 camel-1.2 libemail-engine
+Version: @PROJECT_VERSION@
+Requires: evolution-shell-@INTERFACE_VERSION@ camel-1.2 libemail-engine
 Libs: -L${privlibdir} -levolution-mail -levolution-mail-composer -levolution-mail-formatter
 Cflags: -I${privincludedir}
diff --git a/evolution-shell.pc.in b/evolution-shell.pc.in
index fbc25d6..c3debfe 100644
--- a/evolution-shell.pc.in
+++ b/evolution-shell.pc.in
@@ -1,15 +1,10 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-libexecdir=@libexecdir@
-includedir=@includedir@
-datarootdir=@datarootdir@
-datadir=@datadir@
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@LIB_INSTALL_DIR@
 
 privlibdir=@privsolibdir@
 privlibexecdir=@privlibexecdir@
 privincludedir=@privincludedir@
-errordir=@privdatadir@/errors
+errordir=@errordir@
 moduledir=@moduledir@
 imagesdir=@imagesdir@
 
@@ -17,8 +12,8 @@ execversion=@BASE_VERSION@
 
 Name: evolution-shell
 Description: libraries needed for Evolution shell components
-Version: @VERSION@
+Version: @PROJECT_VERSION@
 Requires: gtk+-3.0 libebackend-1.2 libedataserver-1.2 libedataserverui-1.2 webkit2gtk-4.0
-Requires.private: @GNOME_DESKTOP_DEPENDENCY@
+@shell_private_requirements@
 Libs: -L${privlibdir} -levolution-shell -levolution-util -Wl,-R${privlibdir}
 Cflags: -I${privincludedir}
diff --git a/iconv-detect.c b/iconv-detect.c
index ab0a341..bc7d872 100644
--- a/iconv-detect.c
+++ b/iconv-detect.c
@@ -1,26 +1,25 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
- * This program is free software; you can redistribute it and/or modify it
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * This library is free software: you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published by
  * the Free Software Foundation.
  *
- * This program is distributed in the hope that it will be useful, but
+ * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
  * for more details.
  *
  * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- *
- *
- * Authors:
- *             Jeffrey Stedfast <fejj ximian com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ * along with this library. If not, see <http://www.gnu.org/licenses/>.
  *
+ * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <iconv.h>
 
 enum {
@@ -88,8 +87,37 @@ static CharInfo iso10646_tests[] = {
 
 static int num_iso10646_tests = sizeof (iso10646_tests) / sizeof (CharInfo);
 
+static int
+test_iconv (void)
+{
+       char *jp = "\x1B\x24\x42\x46\x7C\x4B\x5C\x38\x6C";
+       char *utf8 = "\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E";
+       char *transbuf = malloc (10), *trans = transbuf;
+       iconv_t cd;
+       size_t jp_len = strlen (jp), utf8_len = 10;
+       size_t utf8_real_len = strlen (utf8);
+
+       cd = iconv_open ("UTF-8", "ISO-2022-JP");
+       if (cd == (iconv_t) -1)
+               return 0;
+
+       if (iconv (cd, &jp, &jp_len, &trans, &utf8_len) == -1 || jp_len != 0) {
+               iconv_close (cd);
+               return 0;
+       }
+       if (memcmp (utf8, transbuf, utf8_real_len) != 0) {
+               iconv_close (cd);
+               return 0;
+       }
+
+       iconv_close (cd);
+
+       return 1;
+}
 
-int main (int argc, char **argv)
+int
+main (int argc,
+      char **argv)
 {
        unsigned int iso8859, iso2022, iso10646;
        CharInfo *info;
@@ -97,9 +125,12 @@ int main (int argc, char **argv)
        FILE *fp;
        int i;
 
+       if (!test_iconv ())
+               return 1;
+
        fp = fopen ("iconv-detect.h", "w");
        if (fp == NULL)
-               exit (255);
+               return 255;
 
        fprintf (fp, "/* This is an auto-generated header, DO NOT EDIT! */\n\n");
 
@@ -120,9 +151,6 @@ int main (int argc, char **argv)
        if (iso8859 == ISO_UNSUPPORTED) {
                fprintf (stderr, "System doesn't support any ISO-8859-1 formats\n");
                fprintf (fp, "#define ICONV_ISO_D_FORMAT \"%s\"\n", info[0].format);
-#ifdef CONFIGURE_IN
-               exit (1);
-#endif
        } else {
                fprintf (fp, "#define ICONV_ISO_D_FORMAT \"%s\"\n", info[i].format);
        }
@@ -144,9 +172,6 @@ int main (int argc, char **argv)
        if (iso2022 == ISO_UNSUPPORTED) {
                fprintf (stderr, "System doesn't support any ISO-2022 formats\n");
                fprintf (fp, "#define ICONV_ISO_S_FORMAT \"%s\"\n", info[0].format);
-#ifdef CONFIGURE_IN
-               exit (3);
-#endif
        } else {
                fprintf (fp, "#define ICONV_ISO_S_FORMAT \"%s\"\n", info[i].format);
        }
@@ -172,14 +197,11 @@ int main (int argc, char **argv)
        if (iso10646 == ISO_UNSUPPORTED) {
                fprintf (stderr, "System doesn't support any ISO-10646-1 formats\n");
                fprintf (fp, "#define ICONV_10646 \"%s\"\n", info[0].charset);
-#ifdef CONFIGURE_IN
-               exit (2);
-#endif
        } else {
                fprintf (fp, "#define ICONV_10646 \"%s\"\n", info[i].charset);
        }
 
        fclose (fp);
 
-       exit (0);
+       return 0;
 }
diff --git a/libemail-engine/e-mail-folder-utils.c b/libemail-engine/e-mail-folder-utils.c
index 0bb12bf..6a7e69b 100644
--- a/libemail-engine/e-mail-folder-utils.c
+++ b/libemail-engine/e-mail-folder-utils.c
@@ -31,7 +31,7 @@
 #include "e-mail-utils.h"
 
 /* X-Mailer header value */
-#define X_MAILER ("Evolution " VERSION SUB_VERSION " " VERSION_COMMENT)
+#define X_MAILER ("Evolution " VERSION VERSION_SUBSTRING " " VERSION_COMMENT)
 
 typedef struct _AsyncContext AsyncContext;
 
diff --git a/libemail-engine/e-mail-session-utils.c b/libemail-engine/e-mail-session-utils.c
index eb9f426..3f84376 100644
--- a/libemail-engine/e-mail-session-utils.c
+++ b/libemail-engine/e-mail-session-utils.c
@@ -29,7 +29,7 @@
 #include <libemail-engine/mail-tools.h>
 
 /* X-Mailer header value */
-#define X_MAILER ("Evolution " VERSION SUB_VERSION " " VERSION_COMMENT)
+#define X_MAILER ("Evolution " VERSION VERSION_SUBSTRING " " VERSION_COMMENT)
 
 /* FIXME: Temporary - remove this after we move filter/ to eds */
 #define E_FILTER_SOURCE_OUTGOING "outgoing"
diff --git a/libemail-engine/mail-ops.c b/libemail-engine/mail-ops.c
index 5661415..f1dc8f3 100644
--- a/libemail-engine/mail-ops.c
+++ b/libemail-engine/mail-ops.c
@@ -49,7 +49,7 @@
 #define d(x)
 
 /* XXX Make this a preprocessor definition. */
-const gchar *x_mailer = "Evolution " VERSION SUB_VERSION " " VERSION_COMMENT;
+const gchar *x_mailer = "Evolution " VERSION VERSION_SUBSTRING " " VERSION_COMMENT;
 
 /* used for both just filtering a folder + uid's, and for filtering a whole folder */
 /* used both for fetching mail, and for filtering mail */
diff --git a/mail/e-mail-config-security-page.c b/mail/e-mail-config-security-page.c
index 441159f..0a6f52f 100644
--- a/mail/e-mail-config-security-page.c
+++ b/mail/e-mail-config-security-page.c
@@ -23,9 +23,9 @@
 #include <e-util/e-util.h>
 #include <libebackend/libebackend.h>
 
-#if defined (HAVE_NSS)
+#if defined (ENABLE_SMIME)
 #include <smime/gui/e-cert-selector.h>
-#endif /* HAVE_NSS */
+#endif /* ENABLE_SMIME */
 
 #ifdef HAVE_LIBCRYPTUI
 #define LIBCRYPTUI_API_SUBJECT_TO_CHANGE
@@ -298,9 +298,9 @@ mail_config_security_page_constructed (GObject *object)
        const gchar *text;
        gchar *markup;
 
-#if defined (HAVE_NSS)
+#if defined (ENABLE_SMIME)
        ESourceSMIME *smime_ext;
-#endif /* HAVE_NSS */
+#endif /* ENABLE_SMIME */
 
        page = E_MAIL_CONFIG_SECURITY_PAGE (object);
 
@@ -315,10 +315,10 @@ mail_config_security_page_constructed (GObject *object)
        extension_name = E_SOURCE_EXTENSION_OPENPGP;
        openpgp_ext = e_source_get_extension (source, extension_name);
 
-#if defined (HAVE_NSS)
+#if defined (ENABLE_SMIME)
        extension_name = E_SOURCE_EXTENSION_SMIME;
        smime_ext = e_source_get_extension (source, extension_name);
-#endif /* HAVE_NSS */
+#endif /* ENABLE_SMIME */
 
        gtk_orientable_set_orientation (
                GTK_ORIENTABLE (page), GTK_ORIENTATION_VERTICAL);
@@ -511,7 +511,7 @@ mail_config_security_page_constructed (GObject *object)
                G_BINDING_SYNC_CREATE |
                G_BINDING_BIDIRECTIONAL);
 
-#if defined (HAVE_NSS)
+#if defined (ENABLE_SMIME)
 
        /*** Security MIME (S/MIME) ***/
 
@@ -720,7 +720,7 @@ mail_config_security_page_constructed (GObject *object)
                NULL,
                NULL, (GDestroyNotify) NULL);
 
-#endif /* HAVE_NSS */
+#endif /* ENABLE_SMIME */
 
        g_object_unref (size_group);
 
diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c
index 06c9c5d..de3de46 100644
--- a/modules/addressbook/e-book-shell-view-actions.c
+++ b/modules/addressbook/e-book-shell-view-actions.c
@@ -320,7 +320,7 @@ action_address_book_refresh_cb (GtkAction *action,
        g_object_unref (client);
 }
 
-#ifdef WITH_CONTACT_MAPS
+#ifdef ENABLE_CONTACT_MAPS
 static void
 contact_editor_contact_modified_cb (EABEditor *editor,
                                     const GError *error,
@@ -417,7 +417,7 @@ static void
 action_address_book_map_cb (GtkAction *action,
                             EBookShellView *book_shell_view)
 {
-#ifdef WITH_CONTACT_MAPS
+#ifdef ENABLE_CONTACT_MAPS
        EShell *shell;
        EShellView *shell_view;
        EShellBackend *shell_backend;
@@ -1394,7 +1394,7 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view)
        e_web_view_set_print_proxy (web_view, ACTION (CONTACT_PRINT));
        e_web_view_set_save_as_proxy (web_view, ACTION (CONTACT_SAVE_AS));
 
-#ifndef WITH_CONTACT_MAPS
+#ifndef ENABLE_CONTACT_MAPS
        gtk_action_set_visible (ACTION (CONTACT_PREVIEW_SHOW_MAPS), FALSE);
        gtk_action_set_visible (ACTION (ADDRESS_BOOK_MAP), FALSE);
        gtk_action_set_visible (ACTION (ADDRESS_BOOK_POPUP_MAP), FALSE);
diff --git a/modules/mdn/evolution-mdn.c b/modules/mdn/evolution-mdn.c
index 96744d5..1577fd5 100644
--- a/modules/mdn/evolution-mdn.c
+++ b/modules/mdn/evolution-mdn.c
@@ -325,7 +325,7 @@ mdn_notify_sender (ESource *identity_source,
 
        ua = g_strdup_printf (
                "%s; %s", hostname, "Evolution "
-               VERSION SUB_VERSION " " VERSION_COMMENT);
+               VERSION VERSION_SUBSTRING " " VERSION_COMMENT);
        recipient = g_strdup_printf ("rfc822; %s", self_address);
        disposition = mdn_get_disposition (action_mode, sending_mode);
 
diff --git a/shell/killev.c b/shell/killev.c
index 8e0e77a..6513f1e 100644
--- a/shell/killev.c
+++ b/shell/killev.c
@@ -161,17 +161,17 @@ main (gint argc,
        g_object_unref (monitor);
 
 kill:
-#ifdef KILL_PROCESS_CMD
-       if (system (KILL_PROCESS_CMD " -QUIT evolution 2> /dev/null") == -1)
-               g_warning ("%s: Failed to execute: '%s'", G_STRFUNC, KILL_PROCESS_CMD);
-       if (system (KILL_PROCESS_CMD " -TERM evolution-alarm-notify 2> /dev/null") == -1)
-               g_warning ("%s: Failed to execute: '%s'", G_STRFUNC, KILL_PROCESS_CMD);
-       if (system (KILL_PROCESS_CMD " -QUIT evolution-source-registry 2> /dev/null") == -1)
-               g_warning ("%s: Failed to execute: '%s'", G_STRFUNC, KILL_PROCESS_CMD);
-       if (system (KILL_PROCESS_CMD " -QUIT evolution-addressbook-factory 2> /dev/null") == -1)
-               g_warning ("%s: Failed to execute: '%s'", G_STRFUNC, KILL_PROCESS_CMD);
-       if (system (KILL_PROCESS_CMD " -QUIT evolution-calendar-factory 2> /dev/null") == -1)
-               g_warning ("%s: Failed to execute: '%s'", G_STRFUNC, KILL_PROCESS_CMD);
+#ifdef KILL_PROCESS_COMMAND
+       if (system (KILL_PROCESS_COMMAND " -QUIT evolution 2> /dev/null") == -1)
+               g_warning ("%s: Failed to execute: '%s'", G_STRFUNC, KILL_PROCESS_COMMAND);
+       if (system (KILL_PROCESS_COMMAND " -TERM evolution-alarm-notify 2> /dev/null") == -1)
+               g_warning ("%s: Failed to execute: '%s'", G_STRFUNC, KILL_PROCESS_COMMAND);
+       if (system (KILL_PROCESS_COMMAND " -QUIT evolution-source-registry 2> /dev/null") == -1)
+               g_warning ("%s: Failed to execute: '%s'", G_STRFUNC, KILL_PROCESS_COMMAND);
+       if (system (KILL_PROCESS_COMMAND " -QUIT evolution-addressbook-factory 2> /dev/null") == -1)
+               g_warning ("%s: Failed to execute: '%s'", G_STRFUNC, KILL_PROCESS_COMMAND);
+       if (system (KILL_PROCESS_COMMAND " -QUIT evolution-calendar-factory 2> /dev/null") == -1)
+               g_warning ("%s: Failed to execute: '%s'", G_STRFUNC, KILL_PROCESS_COMMAND);
 #else
        g_printerr ("No \"kill\" command available.\n");
 #endif
diff --git a/shell/main.c b/shell/main.c
index f472b2c..a297fd3 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -29,7 +29,7 @@
 #include <glib-unix.h>
 #endif
 
-#ifdef WITH_CONTACT_MAPS
+#ifdef ENABLE_CONTACT_MAPS
 #include <clutter-gtk/clutter-gtk.h>
 #endif
 
@@ -459,7 +459,7 @@ main (gint argc,
        tzset ();
 
        /* The contact maps feature uses clutter-gtk. */
-#ifdef WITH_CONTACT_MAPS
+#ifdef ENABLE_CONTACT_MAPS
        /* XXX This function is declared in gtk-clutter-util.h with an
         *     unnecessary G_GNUC_WARN_UNUSED_RESULT attribute.  But we
         *     don't need the returned error code because we're checking
@@ -473,7 +473,7 @@ main (gint argc,
                &argc, &argv,
                _("- The Evolution PIM and Email Client"),
                entries, (gchar *) GETTEXT_PACKAGE, &error);
-#endif /* WITH_CONTACT_MAPS */
+#endif /* ENABLE_CONTACT_MAPS */
 
        if (error != NULL) {
                g_printerr ("%s\n", error->message);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]