[evolution-ews/wip/cmake] Convert from autotools to CMake



commit 8c2d070ddf2478b18e2dddf5d56993b7573e437e
Author: Milan Crha <mcrha redhat com>
Date:   Tue Oct 4 23:17:59 2016 +0200

    Convert from autotools to CMake

 .gitignore                                         |    1 +
 CMakeLists.txt                                     |  199 +++++++++++
 cmake/cmake_uninstall.cmake.in                     |   21 ++
 cmake/modules/CheckTarget.cmake                    |   21 ++
 cmake/modules/CodeCoverageGCOV.cmake               |   45 +++
 cmake/modules/DistTargets.cmake                    |   86 +++++
 cmake/modules/EvolutionMacros.cmake                |   63 ++++
 cmake/modules/FindIntltool.cmake                   |  209 ++++++++++++
 cmake/modules/GLibTools.cmake                      |  277 ++++++++++++++++
 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 +++
 config.h.in                                        |   22 ++
 enumtypes.c.template                               |   37 --
 enumtypes.h.template                               |   24 --
 po/CMakeLists.txt                                  |    1 +
 src/CMakeLists.txt                                 |   65 ++++
 src/addressbook/CMakeLists.txt                     |  151 +++++++++
 src/addressbook/e-book-backend-ews.c               |    7 +-
 src/calendar/CMakeLists.txt                        |   66 ++++
 src/calendar/e-cal-backend-ews.c                   |    3 +-
 src/camel/CMakeLists.txt                           |  145 ++++++++
 src/camel/camel-ews-folder.c                       |    3 +-
 src/camel/camel-ews-transport.c                    |    3 +-
 src/camel/camel-ews-utils.c                        |    4 +-
 src/collection/CMakeLists.txt                      |   23 ++
 src/configuration/CMakeLists.txt                   |   70 ++++
 src/server/CMakeLists.txt                          |   83 +++++
 .../e-ews-camel-common.c}                          |    8 +-
 .../e-ews-camel-common.h}                          |    1 -
 src/server/e-ews-connection.h                      |    3 -
 src/{utils => server}/e-ews-query-to-restriction.c |    4 +-
 src/{utils => server}/e-ews-query-to-restriction.h |    0
 src/utils/Makefile.am                              |   39 ---
 src/utils/e-sqlite3-vfs.c                          |  350 --------------------
 src/utils/e-sqlite3-vfs.h                          |   26 --
 tests/CMakeLists.txt                               |   52 +++
 39 files changed, 1910 insertions(+), 498 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..2f83016
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,199 @@
+# Evolution-EWS 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-ews";)
+
+# Required for FindIntltool module
+set(GETTEXT_PACKAGE ${PROJECT_NAME})
+set(GETTEXT_PO_DIR ${CMAKE_SOURCE_DIR}/po)
+
+# Required for 'disttest' and 'ditcheck' of DistTarget module
+set(PROJECT_DISTCONFIGURE_PARAMS
+       -DENABLE_TESTS=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(evo_minimum_version ${PROJECT_VERSION})
+set(mspack_minimum_version 0.4)
+
+# 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(CheckCSourceCompiles)
+
+# 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")
+
+# ******************************
+# Dependencies
+# ******************************
+
+include(CodeCoverageGCOV)
+include(CheckTarget)
+include(DistTargets)
+include(EvolutionMacros)
+include(GLibTools)
+include(PkgConfigEx)
+include(SetupBuildFlags)
+include(UninstallTarget)
+
+include(FindIntltool)
+
+add_printable_option(ENABLE_MAINTAINER_MODE "Enable maintainer mode" OFF)
+
+if(ENABLE_MAINTAINER_MODE)
+       set(BUILD_TESTING ON)
+endif(ENABLE_MAINTAINER_MODE)
+
+# Setup compiler/linker flags
+setup_build_flags(${ENABLE_MAINTAINER_MODE})
+
+if(${ENABLE_MAINTAINER_MODE})
+       add_definitions(-DEDS_DISABLE_DEPRECATED=1)
+endif(${ENABLE_MAINTAINER_MODE})
+
+set(MATH_LDFLAGS -lm)
+
+pkg_check_modules(CAMEL camel-1.2>=${eds_minimum_version})
+pkg_check_modules(EVOLUTION_DATA_SERVER evolution-data-server-1.2>=${eds_minimum_version})
+pkg_check_modules(LIBEBACKEND libebackend-1.2>=${eds_minimum_version})
+pkg_check_modules(LIBEBOOK libebook-1.2>=${eds_minimum_version})
+pkg_check_modules(LIBECAL libecal-1.2>=${eds_minimum_version})
+pkg_check_modules(LIBEDATABOOK libedata-book-1.2>=${eds_minimum_version})
+pkg_check_modules(LIBEDATACAL libedata-cal-1.2>=${eds_minimum_version})
+pkg_check_modules(LIBEDATASERVER libedataserver-1.2>=${eds_minimum_version})
+
+pkg_check_modules(EVOLUTION_SHELL evolution-shell-3.0>=${evo_minimum_version})
+pkg_check_modules(EVOLUTION_MAIL evolution-mail-3.0>=${evo_minimum_version})
+pkg_check_modules(EVOLUTION_CALENDAR evolution-calendar-3.0>=${evo_minimum_version})
+
+pkg_check_modules(GNOME_PLATFORM
+       glib-2.0>=${glib_minimum_version}
+       gtk+-3.0>=${gdk_minimum_version}
+)
+
+pkg_check_modules(LIBICAL libical)
+pkg_check_modules(SOUP libsoup-2.4>=${soup_minimum_version})
+
+# ******************************
+# libmspack with OAB support
+# ******************************
+
+add_printable_option(WITH_MSPACK "Use libmspack for OAB decompress" ON)
+
+if(WITH_MSPACK)
+       pkg_check_modules_for_option(WITH_MSPACK "libmspack for OAB decompress" MSPACK 
libmspack>=${mspack_minimum_version})
+endif(WITH_MSPACK)
+
+# ******************************
+# SOUP_MESSAGE_IDEMPOTENT flag
+# ******************************
+
+set(CMAKE_REQUIRED_INCLUDES ${SOUP_INCLUDE_DIRS})
+set(CMAKE_REQUIRED_LIBRARIES ${SOUP_LDFLAGS})
+
+CHECK_C_SOURCE_COMPILES("#include <libsoup/soup.h>
+                       int main(void) { SoupMessageFlags flag; flag = SOUP_MESSAGE_IDEMPOTENT; return 0; }" 
HAVE_SOUP_MESSAGE_IDEMPOTENT_FLAG)
+
+unset(CMAKE_REQUIRED_INCLUDES)
+unset(CMAKE_REQUIRED_LIBRARIES)
+
+# ******************************
+# uhttpmock for tests
+# ******************************
+
+add_printable_option(ENABLE_TESTS "Enable low level tests for EwsConnection" OFF)
+
+if(ENABLE_TESTS)
+       pkg_check_modules_for_option(ENABLE_TESTS "low level tests" UHTTPMOCK libuhttpmock-0.0)
+endif(ENABLE_TESTS)
+
+# ******************************
+# Special directories
+# ******************************
+
+set(privlibdir "${LIB_INSTALL_DIR}/${PROJECT_NAME}")
+
+pkg_check_variable(errordir evolution-shell-3.0 errordir)
+pkg_check_variable(camel_providerdir camel-1.2 camel_providerdir)
+pkg_check_variable(ebook_backenddir libedata-book-1.2 backenddir)
+pkg_check_variable(ecal_backenddir libedata-cal-1.2 backenddir)
+pkg_check_variable(eds_moduledir libebackend-1.2 moduledir)
+pkg_check_variable(evo_moduledir evolution-shell-3.0 moduledir)
+pkg_check_variable(ewsdatadir evolution-data-server-1.2 privdatadir)
+
+set(ewsdatadir "${ewsdatadir}/ews")
+
+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)
+
+# 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()
+
+add_appdata_file(evolution-ews.metainfo.xml.in evolution-ews.metainfo.xml)
+
+add_subdirectory(po)
+add_subdirectory(src)
+
+if(ENABLE_TESTS)
+       add_subdirectory(tests)
+endif(ENABLE_TESTS)
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/EvolutionMacros.cmake b/cmake/modules/EvolutionMacros.cmake
new file mode 100644
index 0000000..0491e13
--- /dev/null
+++ b/cmake/modules/EvolutionMacros.cmake
@@ -0,0 +1,63 @@
+# EvolutionMacros.cmake
+#
+# Utility macros for evolution-related files
+#
+# add_error_files(_part _file0)
+#    Adds build and install rules to create .error files from .error.xml
+#    files in the current source directory. The _file0 is expected to be
+#    without the .xml extension. The macro can receive one or more error
+#    files. There is created a custom "${_part}-error-files" target.
+#
+# add_eplug_file(_part _eplug_filename)
+#    Adds build and install rules to create .eplug files from .eplug.xml
+#    files in the current source directory. The _eplug_filename is expected
+#    to be without the .xml extension. The macro can receive exactly one
+#    eplug file. There is created a custom "${_part}-eplug-file" target.
+
+include(FindIntltool)
+
+macro(add_custom_xml_files _part _destination _targetsuffix _ext _mergeparam _file0)
+       set(filedeps)
+
+       foreach(file ${_file0} ${ARGN})
+               intltool_merge(${file}${_ext} ${file} --xml-style --utf8 ${_mergeparam})
+
+               get_filename_component(_path ${file} DIRECTORY)
+               if(_path STREQUAL "")
+                       set(builtfile ${CMAKE_CURRENT_BINARY_DIR}/${file})
+               else(_path STREQUAL "")
+                       set(builtfile ${file})
+               endif(_path STREQUAL "")
+
+               install(FILES ${builtfile}
+                       DESTINATION ${_destination}
+               )
+
+               list(APPEND filedeps ${builtfile})
+       endforeach(file)
+
+       add_custom_target(${_part}-${_targetsuffix}-files ALL
+               DEPENDS ${filedeps}
+       )
+endmacro(add_custom_xml_files)
+
+macro(add_error_files _part _file0)
+       add_custom_xml_files(${_part} ${errordir} error .xml --no-translations ${_file0} ${ARGN})
+endmacro(add_error_files)
+
+macro(add_eplug_file _part _eplug_filename)
+       set(PLUGINDIR "${plugindir}")
+       set(SOEXT "${CMAKE_SHARED_MODULE_SUFFIX}")
+       set(LOCALEDIR "${LOCALE_INSTALL_DIR}")
+
+       configure_file(${_eplug_filename}.xml
+               ${CMAKE_CURRENT_BINARY_DIR}/${_eplug_filename}.in
+               @ONLY
+       )
+
+       unset(PLUGINDIR)
+       unset(SOEXT)
+       unset(LOCALEDIR)
+
+       add_custom_xml_files(${_part} ${plugindir} plugin .in --no-translations 
${CMAKE_CURRENT_BINARY_DIR}/${_eplug_filename})
+endmacro(add_eplug_file)
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/GLibTools.cmake b/cmake/modules/GLibTools.cmake
new file mode 100644
index 0000000..ba05824
--- /dev/null
+++ b/cmake/modules/GLibTools.cmake
@@ -0,0 +1,277 @@
+# 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.
+#
+# glib_genmarshal(_output_filename_noext _prefix _marshallist_filename)
+#    runs glib-genmarshal to process ${_marshallist_filename} to ${_output_filename_noext}.c
+#    and ${_output_filename_noext}.h files in the current binary directory, using
+#    the ${_prefix} as the function prefix.
+#
+# 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(GLIB_GENMARSHAL glib-genmarshal)
+if(NOT GLIB_GENMARSHAL)
+       message(FATAL_ERROR "Cannot find glib-genmarshal, which is required to build ${PROJECT_NAME}")
+endif(NOT GLIB_GENMARSHAL)
+
+function(glib_genmarshal _output_filename_noext _prefix _marshallist_filename)
+       add_custom_command(
+               OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_output_filename_noext}.h
+               COMMAND ${GLIB_GENMARSHAL} --header --prefix=${_prefix} 
"${CMAKE_CURRENT_SOURCE_DIR}/${_marshallist_filename}" 
${CMAKE_CURRENT_BINARY_DIR}/${_output_filename_noext}.h.tmp
+               COMMAND ${CMAKE_COMMAND} -E rename 
${CMAKE_CURRENT_BINARY_DIR}/${_output_filename_noext}.h.tmp 
${CMAKE_CURRENT_BINARY_DIR}/${_output_filename_noext}.h
+               DEPENDS ${_marshallist_filename}
+       )
+
+       add_custom_command(
+               OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_output_filename_noext}.c
+               COMMAND ${CMAKE_COMMAND} -E echo " #include \\\"${_output_filename_noext}.h\\\"" 
${CMAKE_CURRENT_BINARY_DIR}/${_output_filename_noext}.c.tmp
+               COMMAND ${GLIB_GENMARSHAL} --body --prefix=${_prefix} 
"${CMAKE_CURRENT_SOURCE_DIR}/${_marshallist_filename}" 
${CMAKE_CURRENT_BINARY_DIR}/${_output_filename_noext}.c.tmp
+               COMMAND ${CMAKE_COMMAND} -E rename 
${CMAKE_CURRENT_BINARY_DIR}/${_output_filename_noext}.c.tmp 
${CMAKE_CURRENT_BINARY_DIR}/${_output_filename_noext}.c
+               DEPENDS ${_marshallist_filename}
+       )
+endfunction(glib_genmarshal)
+
+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/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/config.h.in b/config.h.in
new file mode 100644
index 0000000..926fad6
--- /dev/null
+++ b/config.h.in
@@ -0,0 +1,22 @@
+/* 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@"
+
+/* Version number of the project */
+#define VERSION "@PROJECT_VERSION@"
+
+/* Package name for gettext */
+#define GETTEXT_PACKAGE "@GETTEXT_PACKAGE@"
+
+/* Define to add support for low level tests */
+#cmakedefine ENABLE_TESTS 1
+
+/* libsoup provides SOUP_MESSAGE_IDEMPOTENT flag */
+#cmakedefine HAVE_SOUP_MESSAGE_IDEMPOTENT_FLAG 1
+
+/* libmspack has OAB support */
+#cmakedefine WITH_MSPACK 1
diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt
new file mode 100644
index 0000000..9e81642
--- /dev/null
+++ b/po/CMakeLists.txt
@@ -0,0 +1 @@
+intltool_setup_po_dir()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..7501bc8
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,65 @@
+macro(add_simple_module _name _renameto _sourcesvar _depsvar _defsvar _cflagsvar _incdirsvar _ldflagsvar 
_destination)
+       set(DEPENDENCIES
+               evolution-ews
+       )
+
+       set(SOURCES
+               ${${_sourcesvar}}
+       )
+
+       add_library(${_name} MODULE
+               ${SOURCES}
+       )
+
+       set_target_properties(${_name} PROPERTIES
+               PREFIX ""
+               OUTPUT_NAME "${_renameto}"
+       )
+
+       add_dependencies(${_name}
+               ${DEPENDENCIES}
+               ${${_depsvar}}
+       )
+
+       target_compile_definitions(${_name} PRIVATE
+               -DG_LOG_DOMAIN=\"${_name}\"
+               -DEXCHANGE_EWS_LOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+               ${${_defsvar}}
+       )
+
+       target_compile_options(${_name} PUBLIC
+               ${LIBEBACKEND_CFLAGS}
+               ${LIBEDATASERVER_CFLAGS}
+               ${SOUP_CFLAGS}
+               ${${_cflagsvar}}
+       )
+
+       target_include_directories(${_name} PUBLIC
+               ${CMAKE_BINARY_DIR}
+               ${CMAKE_SOURCE_DIR}
+               ${LIBEBACKEND_INCLUDE_DIRS}
+               ${LIBEDATASERVER_INCLUDE_DIRS}
+               ${SOUP_INCLUDE_DIRS}
+               ${${_incdirsvar}}
+       )
+
+       target_link_libraries(${_name}
+               ${DEPENDENCIES}
+               ${${_depsvar}}
+               ${LIBEBACKEND_LDFLAGS}
+               ${LIBEDATASERVER_LDFLAGS}
+               ${SOUP_LDFLAGS}
+               ${${_ldflagsvar}}
+       )
+
+       install(TARGETS ${_name}
+               DESTINATION ${_destination}
+       )
+endmacro(add_simple_module)
+
+add_subdirectory(addressbook)
+add_subdirectory(calendar)
+add_subdirectory(camel)
+add_subdirectory(collection)
+add_subdirectory(configuration)
+add_subdirectory(server)
diff --git a/src/addressbook/CMakeLists.txt b/src/addressbook/CMakeLists.txt
new file mode 100644
index 0000000..9852fb3
--- /dev/null
+++ b/src/addressbook/CMakeLists.txt
@@ -0,0 +1,151 @@
+set(DEPENDENCIES
+       evolution-ews
+)
+
+set(SOURCES
+       ews-oab-props.h
+       ews-oab-decoder.c
+       ews-oab-decoder.h
+       ews-oab-decompress.h
+       e-book-backend-ews.c
+       e-book-backend-ews.h
+       e-book-backend-ews-factory.c
+)
+
+if(WITH_MSPACK)
+       list(APPEND SOURCES
+               ews-oab-decompress.c
+       )
+else(WITH_MSPACK)
+       list(APPEND SOURCES
+               mspack/lzx.h
+               mspack/lzxd.c
+               mspack/readbits.h
+               mspack/readhuff.h
+               mspack/oab-decompress.c
+       )
+endif(WITH_MSPACK)
+
+add_library(ebookbackendews MODULE
+       ${SOURCES}
+)
+
+add_dependencies(ebookbackendews
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(ebookbackendews PRIVATE
+       -DG_LOG_DOMAIN=\"ebookbackendews\"
+       -DBACKENDDIR=\"${ebook_backenddir}\"
+       -DEXCHANGE_EWS_LOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+)
+
+target_compile_options(ebookbackendews PUBLIC
+       ${LIBEBACKEND_CFLAGS}
+       ${LIBEBOOK_CFLAGS}
+       ${LIBEDATABOOK_CFLAGS}
+       ${LIBEDATASERVER_CFLAGS}
+       ${MSPACK_CFLAGS}
+       ${SOUP_CFLAGS}
+)
+
+target_include_directories(ebookbackendews PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_BINARY_DIR}/src
+       ${CMAKE_SOURCE_DIR}/src
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${CMAKE_CURRENT_SOURCE_DIR}
+       ${LIBEBACKEND_INCLUDE_DIRS}
+       ${LIBEBOOK_INCLUDE_DIRS}
+       ${LIBEDATABOOK_INCLUDE_DIRS}
+       ${LIBEDATASERVER_INCLUDE_DIRS}
+       ${MSPACK_INCLUDE_DIRS}
+       ${SOUP_INCLUDE_DIRS}
+)
+
+target_link_libraries(ebookbackendews
+       ${DEPENDENCIES}
+       ${LIBEBACKEND_LDFLAGS}
+       ${LIBEBOOK_LDFLAGS}
+       ${LIBEDATABOOK_LDFLAGS}
+       ${LIBEDATASERVER_LDFLAGS}
+       ${MATH_LDFLAGS}
+       ${MSPACK_LDFLAGS}
+       ${SOUP_LDFLAGS}
+)
+
+install(TARGETS ebookbackendews
+       DESTINATION ${ebook_backenddir}
+)
+
+# ******************************
+# Internal test programs
+# ******************************
+
+if(WITH_MSPACK)
+       add_executable(gal-lzx-decompress-test
+               ews-oab-decompress.c
+               ews-oab-decompress.h
+               gal-lzx-decompress-test.c
+       )
+
+       target_compile_definitions(gal-lzx-decompress-test PRIVATE
+               -DG_LOG_DOMAIN=\"gal-lzx-decompress-test\"
+       )
+
+       target_compile_options(gal-lzx-decompress-test PUBLIC
+               ${GNOME_PLATFORM_CFLAGS}
+               ${MSPACK_CFLAGS}
+       )
+
+       target_include_directories(gal-lzx-decompress-test PUBLIC
+               ${CMAKE_BINARY_DIR}
+               ${CMAKE_CURRENT_BINARY_DIR}
+               ${CMAKE_CURRENT_SOURCE_DIR}
+               ${GNOME_PLATFORM_INCLUDE_DIRS}
+               ${MSPACK_INCLUDE_DIRS}
+       )
+
+       target_link_libraries(gal-lzx-decompress-test
+               ${GNOME_PLATFORM_LDFLAGS}
+               ${MSPACK_LDFLAGS}
+       )
+
+       # **************************************************************
+
+       add_executable(oab-decode-test
+               ews-oab-decoder.c
+               ews-oab-decoder.h
+               oab-decode-test.c
+       )
+
+       target_compile_definitions(oab-decode-test PRIVATE
+               -DG_LOG_DOMAIN=\"oab-decode-test\"
+       )
+
+       target_compile_options(oab-decode-test PUBLIC
+               ${GNOME_PLATFORM_CFLAGS}
+               ${LIBEBOOK_CFLAGS}
+               ${LIBEDATABOOK_CFLAGS}
+               ${MSPACK_CFLAGS}
+       )
+
+       target_include_directories(oab-decode-test PUBLIC
+               ${CMAKE_BINARY_DIR}
+               ${CMAKE_CURRENT_BINARY_DIR}
+               ${CMAKE_CURRENT_SOURCE_DIR}
+               ${GNOME_PLATFORM_INCLUDE_DIRS}
+               ${LIBEBOOK_INCLUDE_DIRS}
+               ${LIBEDATABOOK_INCLUDE_DIRS}
+               ${MSPACK_INCLUDE_DIRS}
+       )
+
+       target_link_libraries(oab-decode-test
+               ${GNOME_PLATFORM_LDFLAGS}
+               ${LIBEBOOK_LDFLAGS}
+               ${LIBEDATABOOK_LDFLAGS}
+               ${MSPACK_LDFLAGS}
+               ${MATH_LDFLAGS}
+       )
+endif(WITH_MSPACK)
diff --git a/src/addressbook/e-book-backend-ews.c b/src/addressbook/e-book-backend-ews.c
index ba4505e..4be2b8e 100644
--- a/src/addressbook/e-book-backend-ews.c
+++ b/src/addressbook/e-book-backend-ews.c
@@ -45,10 +45,9 @@
 #include "server/e-ews-connection.h"
 #include "server/e-ews-connection-utils.h"
 #include "server/e-ews-item.h"
+#include "server/e-ews-query-to-restriction.h"
 #include "server/e-source-ews-folder.h"
 
-#include "utils/e-ews-query-to-restriction.h"
-
 #include "e-book-backend-ews.h"
 #include "ews-oab-decoder.h"
 #include "ews-oab-decompress.h"
@@ -2382,7 +2381,7 @@ static gchar *
 ews_download_gal (EBookBackendEws *cbews, EwsOALDetails *full, GSList *deltas, guint32 seq,
                  GCancellable *cancellable, GError **error)
 {
-#ifdef USE_MSPACK
+#ifdef WITH_MSPACK
        EBookBackendEwsPrivate *priv = cbews->priv;
        GSList *p;
        gchar *thisoab = NULL;
@@ -2443,7 +2442,7 @@ ews_download_gal (EBookBackendEws *cbews, EwsOALDetails *full, GSList *deltas, g
                g_free (thisoab);
        }
  full:
-#endif
+#endif /* WITH_MSPACK */
        d (printf ("Ewsgal: Downloading full gal \n"));
        return ews_download_full_gal (cbews, full, cancellable, error);
 }
diff --git a/src/calendar/CMakeLists.txt b/src/calendar/CMakeLists.txt
new file mode 100644
index 0000000..fff441f
--- /dev/null
+++ b/src/calendar/CMakeLists.txt
@@ -0,0 +1,66 @@
+install(FILES windowsZones.xml
+       DESTINATION ${ewsdatadir}
+)
+
+set(DEPENDENCIES
+       evolution-ews
+)
+
+set(SOURCES
+       e-cal-backend-ews.c
+       e-cal-backend-ews.h
+       e-cal-backend-ews-factory.c
+       e-cal-backend-ews-utils.c
+       e-cal-backend-ews-utils.h
+)
+
+add_library(ecalbackendews MODULE
+       ${SOURCES}
+)
+
+add_dependencies(ecalbackendews
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(ecalbackendews PRIVATE
+       -DG_LOG_DOMAIN=\"ecalbackendews\"
+       -DEXCHANGE_EWS_DATADIR=\"${ewsdatadir}\"
+       -DEXCHANGE_EWS_LOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+)
+
+target_compile_options(ecalbackendews PUBLIC
+       ${CAMEL_CFLAGS}
+       ${EVOLUTION_CALENDAR_CFLAGS}
+       ${LIBEBACKEND_CFLAGS}
+       ${LIBECAL_CFLAGS}
+       ${LIBEDATACAL_CFLAGS}
+       ${SOUP_CFLAGS}
+)
+
+target_include_directories(ecalbackendews PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_BINARY_DIR}/src
+       ${CMAKE_SOURCE_DIR}/src
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${CAMEL_INCLUDE_DIRS}
+       ${EVOLUTION_CALENDAR_INCLUDE_DIRS}
+       ${LIBEBACKEND_INCLUDE_DIRS}
+       ${LIBECAL_INCLUDE_DIRS}
+       ${LIBEDATACAL_INCLUDE_DIRS}
+       ${SOUP_INCLUDE_DIRS}
+)
+
+target_link_libraries(ecalbackendews
+       ${DEPENDENCIES}
+       ${CAMEL_LDFLAGS}
+       ${EVOLUTION_CALENDAR_LDFLAGS}
+       ${LIBEBACKEND_LDFLAGS}
+       ${LIBECAL_LDFLAGS}
+       ${LIBEDATACAL_LDFLAGS}
+       ${SOUP_LDFLAGS}
+)
+
+install(TARGETS ecalbackendews
+       DESTINATION ${ecal_backenddir}
+)
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index ded9c57..84fe34a 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -44,8 +44,7 @@
 
 #include "server/e-source-ews-folder.h"
 #include "server/e-ews-connection-utils.h"
-
-#include "utils/ews-camel-common.h"
+#include "server/e-ews-camel-common.h"
 
 #include "e-cal-backend-ews.h"
 #include "e-cal-backend-ews-utils.h"
diff --git a/src/camel/CMakeLists.txt b/src/camel/CMakeLists.txt
new file mode 100644
index 0000000..9280522
--- /dev/null
+++ b/src/camel/CMakeLists.txt
@@ -0,0 +1,145 @@
+install(FILES libcamelews.urls
+       DESTINATION ${camel_providerdir}
+)
+
+# *************************************************
+# Installed private library which can be linked to
+# *************************************************
+
+glib_mkenums(camel-ews-enumtypes camel-ews-enums.h CAMEL_EWS_ENUMTYPES_H)
+
+set(DEPENDENCIES
+       evolution-ews
+)
+
+set(SOURCES
+       camel-ews-enums.h
+       camel-ews-folder.c
+       camel-ews-folder.h
+       camel-ews-private.h
+       camel-ews-store-summary.c
+       camel-ews-store-summary.h
+       camel-ews-store.c
+       camel-ews-store.h
+       camel-ews-summary.c
+       camel-ews-summary.h
+       camel-ews-utils.c
+       camel-ews-utils.h
+       camel-ews-transport.c
+       camel-ews-transport.h
+       ${CMAKE_CURRENT_BINARY_DIR}/camel-ews-enumtypes.c
+       ${CMAKE_CURRENT_BINARY_DIR}/camel-ews-enumtypes.h
+)
+
+add_library(camelews-priv SHARED
+       ${SOURCES}
+)
+
+add_dependencies(camelews-priv
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(camelews-priv PRIVATE
+       -DG_LOG_DOMAIN=\"camel-ews-provider\"
+       -DEXCHANGE_EWS_LOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+)
+
+target_compile_options(camelews-priv PUBLIC
+       ${CAMEL_CFLAGS}
+       ${EVOLUTION_SHELL_CFLAGS}
+       ${EVOLUTION_MAIL_CFLAGS}
+       ${LIBEDATASERVER_CFLAGS}
+       ${LIBECAL_CFLAGS}
+       ${SOUP_CFLAGS}
+)
+
+target_include_directories(camelews-priv PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_BINARY_DIR}/src
+       ${CMAKE_SOURCE_DIR}/src
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${CAMEL_INCLUDE_DIRS}
+       ${EVOLUTION_SHELL_INCLUDE_DIRS}
+       ${EVOLUTION_MAIL_INCLUDE_DIRS}
+       ${LIBEDATASERVER_INCLUDE_DIRS}
+       ${LIBECAL_INCLUDE_DIRS}
+       ${SOUP_INCLUDE_DIRS}
+)
+
+target_link_libraries(camelews-priv
+       ${DEPENDENCIES}
+       ${CAMEL_LDFLAGS}
+       ${EVOLUTION_SHELL_LDFLAGS}
+       ${EVOLUTION_MAIL_LDFLAGS}
+       ${LIBEDATASERVER_LDFLAGS}
+       ${LIBECAL_LDFLAGS}
+       ${SOUP_LDFLAGS}
+)
+
+install(TARGETS camelews-priv
+       DESTINATION ${privsolibdir}
+)
+
+# *************************************************
+# Provider module
+# *************************************************
+
+set(DEPENDENCIES
+       camelews-priv
+       evolution-ews
+)
+
+set(SOURCES
+       camel-ews-provider.c
+)
+
+add_library(camelews MODULE
+       ${SOURCES}
+)
+
+add_dependencies(camelews
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(camelews PRIVATE
+       -DG_LOG_DOMAIN=\"camel-ews-provider\"
+       -DEXCHANGE_EWS_LOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+)
+
+target_compile_options(camelews PUBLIC
+       ${CAMEL_CFLAGS}
+       ${EVOLUTION_SHELL_CFLAGS}
+       ${EVOLUTION_MAIL_CFLAGS}
+       ${LIBEDATASERVER_CFLAGS}
+       ${LIBECAL_CFLAGS}
+       ${SOUP_CFLAGS}
+)
+
+target_include_directories(camelews PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_BINARY_DIR}/src
+       ${CMAKE_SOURCE_DIR}/src
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${CAMEL_INCLUDE_DIRS}
+       ${EVOLUTION_SHELL_INCLUDE_DIRS}
+       ${EVOLUTION_MAIL_INCLUDE_DIRS}
+       ${LIBEDATASERVER_INCLUDE_DIRS}
+       ${LIBECAL_INCLUDE_DIRS}
+       ${SOUP_INCLUDE_DIRS}
+)
+
+target_link_libraries(camelews
+       ${DEPENDENCIES}
+       ${CAMEL_LDFLAGS}
+       ${EVOLUTION_SHELL_LDFLAGS}
+       ${EVOLUTION_MAIL_LDFLAGS}
+       ${LIBEDATASERVER_LDFLAGS}
+       ${LIBECAL_LDFLAGS}
+       ${SOUP_LDFLAGS}
+)
+
+install(TARGETS camelews
+       DESTINATION ${camel_providerdir}
+)
diff --git a/src/camel/camel-ews-folder.c b/src/camel/camel-ews-folder.c
index 9900030..431fceb 100644
--- a/src/camel/camel-ews-folder.c
+++ b/src/camel/camel-ews-folder.c
@@ -45,12 +45,11 @@ which needs to be better organized via functions */
 #include <libical/icalparser.h>
 
 #include "server/camel-ews-settings.h"
+#include "server/e-ews-camel-common.h"
 #include "server/e-ews-connection.h"
 #include "server/e-ews-item-change.h"
 #include "server/e-ews-message.h"
 
-#include "utils/ews-camel-common.h"
-
 #include "camel-ews-folder.h"
 #include "camel-ews-private.h"
 #include "camel-ews-store.h"
diff --git a/src/camel/camel-ews-transport.c b/src/camel/camel-ews-transport.c
index 7688cf4..dc10007 100644
--- a/src/camel/camel-ews-transport.c
+++ b/src/camel/camel-ews-transport.c
@@ -33,8 +33,7 @@
 #include <libemail-engine/libemail-engine.h>
 
 #include "server/camel-ews-settings.h"
-
-#include "utils/ews-camel-common.h"
+#include "server/e-ews-camel-common.h"
 
 #include "camel-ews-store.h"
 #include "camel-ews-transport.h"
diff --git a/src/camel/camel-ews-utils.c b/src/camel/camel-ews-utils.c
index 27b7389..b0e7e77 100644
--- a/src/camel/camel-ews-utils.c
+++ b/src/camel/camel-ews-utils.c
@@ -31,9 +31,9 @@
 #include <glib/gstdio.h>
 
 #include "server/camel-ews-settings.h"
-#include "server/e-ews-message.h"
+#include "server/e-ews-camel-common.h"
 #include "server/e-ews-item-change.h"
-#include "utils/ews-camel-common.h"
+#include "server/e-ews-message.h"
 
 #include "camel-ews-utils.h"
 
diff --git a/src/collection/CMakeLists.txt b/src/collection/CMakeLists.txt
new file mode 100644
index 0000000..83f38fa
--- /dev/null
+++ b/src/collection/CMakeLists.txt
@@ -0,0 +1,23 @@
+set(extra_deps)
+set(sources
+       module-ews-backend.c
+       e-ews-backend.c
+       e-ews-backend.h
+       e-ews-backend-factory.c
+       e-ews-backend-factory.h
+)
+set(extra_defines)
+set(extra_cflags)
+set(extra_incdirs)
+set(extra_ldflags)
+
+add_simple_module(module-collection-ews-backend
+       module-ews-backend
+       sources
+       extra_deps
+       extra_defines
+       extra_cflags
+       extra_incdirs
+       extra_ldflags
+       "${eds_moduledir}"
+)
diff --git a/src/configuration/CMakeLists.txt b/src/configuration/CMakeLists.txt
new file mode 100644
index 0000000..690ede1
--- /dev/null
+++ b/src/configuration/CMakeLists.txt
@@ -0,0 +1,70 @@
+add_error_files(configuration module-ews-configuration.error)
+
+set(extra_deps
+       camelews-priv
+)
+set(sources
+       module-ews-configuration.c
+       e-cal-config-ews.c
+       e-cal-config-ews.h
+       e-book-config-ews.c
+       e-book-config-ews.h
+       e-mail-config-ews-autodiscover.c
+       e-mail-config-ews-autodiscover.h
+       e-mail-config-ews-backend.c
+       e-mail-config-ews-backend.h
+       e-mail-config-ews-gal.c
+       e-mail-config-ews-gal.h
+       e-mail-config-ews-notebook.c
+       e-mail-config-ews-notebook.h
+       e-mail-config-ews-oal-combo-box.c
+       e-mail-config-ews-oal-combo-box.h
+       e-mail-config-ews-delegates-page.c
+       e-mail-config-ews-delegates-page.h
+       e-mail-config-ews-folder-sizes-page.c
+       e-mail-config-ews-folder-sizes-page.h
+       e-mail-config-ews-ooo-page.c
+       e-mail-config-ews-ooo-page.h
+       e-ews-config-ui-extension.c
+       e-ews-config-ui-extension.h
+       e-ews-config-utils.c
+       e-ews-config-utils.h
+       e-ews-edit-folder-permissions.c
+       e-ews-edit-folder-permissions.h
+       e-ews-search-user.c
+       e-ews-search-user.h
+       e-ews-subscribe-foreign-folder.c
+       e-ews-subscribe-foreign-folder.h
+       e-ews-ooo-notificator.c
+       e-ews-ooo-notificator.h
+)
+set(extra_defines)
+set(extra_cflags
+       ${EVOLUTION_MAIL_CFLAGS}
+       ${EVOLUTION_SHELL_CFLAGS}
+       ${LIBECAL_CFLAGS}
+       ${LIBEBOOK_CFLAGS}
+)
+set(extra_incdirs
+       ${EVOLUTION_MAIL_INCLUDE_DIRS}
+       ${EVOLUTION_SHELL_INCLUDE_DIRS}
+       ${LIBECAL_INCLUDE_DIRS}
+       ${LIBEBOOK_INCLUDE_DIRS}
+)
+set(extra_ldflags
+       ${EVOLUTION_MAIL_LDFLAGS}
+       ${EVOLUTION_SHELL_LDFLAGS}
+       ${LIBECAL_LDFLAGS}
+       ${LIBEBOOK_LDFLAGS}
+)
+
+add_simple_module(module-configuration-ews-backend
+       module-ews-backend
+       sources
+       extra_deps
+       extra_defines
+       extra_cflags
+       extra_incdirs
+       extra_ldflags
+       "${evo_moduledir}"
+)
diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt
new file mode 100644
index 0000000..6875659
--- /dev/null
+++ b/src/server/CMakeLists.txt
@@ -0,0 +1,83 @@
+glib_mkenums(e-ews-enumtypes e-ews-enums.h E_EWS_ENUMTYPES_H)
+
+set(SOURCES
+       camel-ews-settings.c
+       camel-ews-settings.h
+       e-ews-camel-common.c
+       e-ews-camel-common.h
+       e-ews-connection.c
+       e-ews-connection.h
+       e-ews-connection-utils.c
+       e-ews-connection-utils.h
+       e-ews-debug.c
+       e-ews-debug.h
+       e-ews-folder.c
+       e-ews-folder.h
+       e-ews-item.c
+       e-ews-item.h
+       e-ews-item-change.c
+       e-ews-item-change.h
+       e-ews-message.c
+       e-ews-message.h
+       e-ews-notification.c
+       e-ews-notification.h
+       e-ews-oof-settings.c
+       e-ews-query-to-restriction.c
+       e-ews-query-to-restriction.h
+       e-soup-auth-negotiate.c
+       e-soup-auth-negotiate.h
+       e-soap-message.c
+       e-soap-message.h
+       e-soap-response.c
+       e-soap-response.h
+       e-source-ews-folder.c
+       e-source-ews-folder.h
+       ews-errors.c
+       ews-errors.h
+       ${CMAKE_CURRENT_BINARY_DIR}/e-ews-enumtypes.c
+       ${CMAKE_CURRENT_BINARY_DIR}/e-ews-enumtypes.h
+)
+
+add_library(evolution-ews SHARED
+       ${SOURCES}
+)
+
+target_compile_definitions(evolution-ews PRIVATE
+       -DG_LOG_DOMAIN=\"evolution-ews\"
+)
+
+target_compile_options(evolution-ews PUBLIC
+       ${CAMEL_CFLAGS}
+       ${LIBECAL_CFLAGS}
+       ${LIBEDATACAL_CFLAGS}
+       ${LIBEDATASERVER_CFLAGS}
+       ${LIBICAL_CFLAGS}
+       ${SOUP_CFLAGS}
+)
+
+target_include_directories(evolution-ews PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_BINARY_DIR}/src
+       ${CMAKE_SOURCE_DIR}/src
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${CAMEL_INCLUDE_DIRS}
+       ${LIBECAL_INCLUDE_DIRS}
+       ${LIBEDATACAL_INCLUDE_DIRS}
+       ${LIBEDATASERVER_INCLUDE_DIRS}
+       ${LIBICAL_INCLUDE_DIRS}
+       ${SOUP_INCLUDE_DIRS}
+)
+
+target_link_libraries(evolution-ews
+       ${CAMEL_LDFLAGS}
+       ${LIBECAL_LDFLAGS}
+       ${LIBEDATACAL_LDFLAGS}
+       ${LIBEDATASERVER_LDFLAGS}
+       ${LIBICAL_LDFLAGS}
+       ${SOUP_LDFLAGS}
+)
+
+install(TARGETS evolution-ews
+       DESTINATION ${privsolibdir}
+)
diff --git a/src/utils/ews-camel-common.c b/src/server/e-ews-camel-common.c
similarity index 99%
rename from src/utils/ews-camel-common.c
rename to src/server/e-ews-camel-common.c
index eecce7f..6c63737 100644
--- a/src/utils/ews-camel-common.c
+++ b/src/server/e-ews-camel-common.c
@@ -25,11 +25,11 @@
 #include <glib/gi18n-lib.h>
 #include <glib/gstdio.h>
 
-#include "ews-camel-common.h"
-
 #include "server/e-ews-message.h"
 #include "server/e-ews-item-change.h"
 
+#include "e-ews-camel-common.h"
+
 struct _create_mime_msg_data {
        EEwsConnection *cnc;
        CamelMimeMessage *message;
@@ -124,7 +124,7 @@ create_mime_message_cb (ESoapMessage *msg,
 
        if (create_data->info)
                message_camel_flags = camel_message_info_get_flags (create_data->info);
-               
+
        e_soap_message_start_element (msg, "Message", NULL, NULL);
        e_soap_message_start_element (msg, "MimeContent", NULL, NULL);
 
@@ -286,7 +286,7 @@ create_mime_message_cb (ESoapMessage *msg,
                recip_to = g_hash_table_new (camel_strcase_hash, camel_strcase_equal);
                recip_cc = g_hash_table_new (camel_strcase_hash, camel_strcase_equal);
                recip_bcc = g_hash_table_new (camel_strcase_hash, camel_strcase_equal);
-       
+
                filter_recipients (create_data->message, create_data->recipients, recip_to, recip_cc, 
recip_bcc);
 
                write_recipients (msg, "ToRecipients", recip_to);
diff --git a/src/utils/ews-camel-common.h b/src/server/e-ews-camel-common.h
similarity index 99%
rename from src/utils/ews-camel-common.h
rename to src/server/e-ews-camel-common.h
index 2f9a37d..a4dc1e0 100644
--- a/src/utils/ews-camel-common.h
+++ b/src/server/e-ews-camel-common.h
@@ -43,4 +43,3 @@ camel_ews_utils_create_mime_message (EEwsConnection *cnc,
 G_END_DECLS
 
 #endif /* EWS_CAMEL_COMMON_H */
-
diff --git a/src/server/e-ews-connection.h b/src/server/e-ews-connection.h
index f46bb54..c8e35b6 100644
--- a/src/server/e-ews-connection.h
+++ b/src/server/e-ews-connection.h
@@ -385,9 +385,6 @@ void                e_ews_notification_event_free   (EEwsNotificationEvent *event);
 void           ews_oal_free                    (EwsOAL *oal);
 void           ews_oal_details_free            (EwsOALDetails *details);
 
-void           e_ews_connection_utils_unref_in_thread
-                                               (gpointer object);
-
 GType          e_ews_connection_get_type       (void);
 EEwsConnection *e_ews_connection_new           (const gchar *uri,
                                                 CamelEwsSettings *settings);
diff --git a/src/utils/e-ews-query-to-restriction.c b/src/server/e-ews-query-to-restriction.c
similarity index 100%
rename from src/utils/e-ews-query-to-restriction.c
rename to src/server/e-ews-query-to-restriction.c
index 4b353b5..bd682b4 100644
--- a/src/utils/e-ews-query-to-restriction.c
+++ b/src/server/e-ews-query-to-restriction.c
@@ -29,10 +29,10 @@
 #include <camel/camel.h>
 #include <libedata-cal/libedata-cal.h>
 
-#include "e-ews-query-to-restriction.h"
-
 #include "server/e-ews-message.h"
 
+#include "e-ews-query-to-restriction.h"
+
 #define d(x) x
 
 #define WRITE_CONTAINS_MESSAGE(msg, mode, compare, uri, val) \
diff --git a/src/utils/e-ews-query-to-restriction.h b/src/server/e-ews-query-to-restriction.h
similarity index 100%
rename from src/utils/e-ews-query-to-restriction.h
rename to src/server/e-ews-query-to-restriction.h
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644
index 0000000..119a0a3
--- /dev/null
+++ b/tests/CMakeLists.txt
@@ -0,0 +1,52 @@
+macro(add_ews_test _name)
+       set(DEPENDENCIES
+               evolution-ews
+       )
+
+       set(SOURCES
+               ews-test-common.c
+               ews-test-common.h
+       )
+
+       add_executable(${_name}
+               ${SOURCES}
+               ${ARGN}
+       )
+
+       add_dependencies(${_name}
+               ${DEPENDENCIES}
+       )
+
+       target_compile_definitions(${_name} PRIVATE
+               -DG_LOG_DOMAIN=\"${_name}\"
+               -DTEST_FILE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"
+               -DCALENDAR_MODULE_DIR=\"${CMAKE_SOURCE_DIR}/src/calendar/\"
+       )
+
+       target_compile_options(${_name} PUBLIC
+               ${LIBECAL_CFLAGS}
+               ${LIBEDATASERVER_CFLAGS}
+               ${UHTTPMOCK_CFLAGS}
+       )
+
+       target_include_directories(${_name} PUBLIC
+               ${CMAKE_BINARY_DIR}
+               ${CMAKE_SOURCE_DIR}
+               ${CMAKE_BINARY_DIR}/src
+               ${CMAKE_SOURCE_DIR}/src
+               ${LIBECAL_INCLUDE_DIRS}
+               ${LIBEDATASERVER_INCLUDE_DIRS}
+               ${UHTTPMOCK_INCLUDE_DIRS}
+       )
+
+       target_link_libraries(${_name}
+               ${DEPENDENCIES}
+               ${LIBECAL_LDFLAGS}
+               ${LIBEDATASERVER_LDFLAGS}
+               ${UHTTPMOCK_LDFLAGS}
+       )
+
+endmacro(add_ews_test)
+
+add_ews_test(ews-test-camel ews-test-camel.c)
+add_ews_test(ews-test-timezones ews-test-timezones.c)


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