[evolution-data-server] Convert from autotools to CMake



commit 2f505851c3a5e0e4aa1dfd0a71e67035810cb8fb
Author: Milan Crha <mcrha redhat com>
Date:   Mon Oct 10 15:16:25 2016 +0200

    Convert from autotools to CMake

 .gitignore                                         |    3 +
 CMakeLists.txt                                     |  926 +++++++++
 Makefile.am                                        |  143 --
 addressbook/CMakeLists.txt                         |    5 +
 addressbook/Makefile.am                            |    3 -
 addressbook/backends/CMakeLists.txt                |   11 +
 addressbook/backends/Makefile.am                   |   15 -
 addressbook/backends/file/CMakeLists.txt           |   57 +
 addressbook/backends/file/Makefile.am              |   48 -
 .../backends/file/e-book-backend-file-factory.c    |    2 +-
 .../file/e-book-backend-file-migrate-bdb.c         |    2 +-
 addressbook/backends/file/e-book-backend-file.c    |    2 +-
 addressbook/backends/google/CMakeLists.txt         |  100 +
 addressbook/backends/google/Makefile.am            |   88 -
 .../google/e-book-backend-google-factory.c         |    2 +-
 .../backends/google/e-book-backend-google.c        |    3 +-
 addressbook/backends/google/e-book-google-utils.c  |    3 +-
 addressbook/backends/google/tests/CMakeLists.txt   |   38 +
 addressbook/backends/google/tests/Makefile.am      |   34 -
 addressbook/backends/ldap/CMakeLists.txt           |   50 +
 addressbook/backends/ldap/Makefile.am              |   46 -
 .../backends/ldap/e-book-backend-ldap-factory.c    |    4 +-
 addressbook/backends/ldap/e-book-backend-ldap.c    |    4 +-
 addressbook/backends/webdav/CMakeLists.txt         |   43 +
 addressbook/backends/webdav/Makefile.am            |   40 -
 .../webdav/e-book-backend-webdav-factory.c         |    2 +-
 .../backends/webdav/e-book-backend-webdav.c        |    2 +-
 addressbook/libebook-contacts/CMakeLists.txt       |  164 ++
 addressbook/libebook-contacts/Makefile.am          |  174 --
 .../libebook-contacts/e-book-contacts-types.c      |    4 +-
 addressbook/libebook-contacts/e-book-query.c       |    6 +-
 addressbook/libebook-contacts/e-contact.c          |    4 +-
 .../libebook-contacts/e-phone-number-private.cpp   |    4 +-
 addressbook/libebook-contacts/e-phone-number.c     |    4 +-
 .../libebook-contacts/libebook-contacts.pc.in      |   19 +-
 addressbook/libebook/CMakeLists.txt                |  130 ++
 addressbook/libebook/Makefile.am                   |  163 --
 addressbook/libebook/e-book-client-cursor.c        |    4 +-
 addressbook/libebook/e-book-client-view.c          |    4 +-
 addressbook/libebook/e-book-client.c               |    4 +-
 addressbook/libebook/e-book.c                      |    3 +-
 addressbook/libebook/e-destination.c               |    3 +-
 addressbook/libebook/libebook.pc.in                |   19 +-
 addressbook/libedata-book/CMakeLists.txt           |  196 ++
 addressbook/libedata-book/Makefile.am              |  153 --
 addressbook/libedata-book/e-book-backend-cache.c   |    4 +-
 .../libedata-book/e-book-backend-db-cache.c        |    3 +-
 addressbook/libedata-book/e-book-backend-factory.c |    3 +-
 .../libedata-book/e-book-backend-sqlitedb-test.c   |    3 +-
 addressbook/libedata-book/e-book-backend-summary.c |    4 +-
 addressbook/libedata-book/e-book-backend.c         |    2 +-
 .../libedata-book/e-data-book-cursor-sqlite.c      |    4 +-
 addressbook/libedata-book/e-data-book-cursor.c     |    4 +-
 addressbook/libedata-book/e-data-book-direct.c     |    4 +-
 addressbook/libedata-book/e-data-book-factory.c    |    3 +-
 addressbook/libedata-book/e-data-book-view.c       |    4 +-
 addressbook/libedata-book/e-data-book.c            |    4 +-
 .../libedata-book/e-subprocess-book-factory.c      |    4 +-
 .../evolution-addressbook-factory-subprocess.c     |    4 +-
 addressbook/libedata-book/libedata-book.pc.in      |   19 +-
 addressbook/libegdbus/CMakeLists.txt               |   36 +
 addressbook/libegdbus/Makefile.am                  |   29 -
 art/CMakeLists.txt                                 |   24 +
 art/Makefile.am                                    |   24 -
 autogen.sh                                         |   43 -
 calendar/CMakeLists.txt                            |    4 +
 calendar/Makefile.am                               |    3 -
 calendar/backends/CMakeLists.txt                   |   12 +
 calendar/backends/Makefile.am                      |   15 -
 calendar/backends/caldav/CMakeLists.txt            |   46 +
 calendar/backends/caldav/Makefile.am               |   38 -
 .../backends/caldav/e-cal-backend-caldav-factory.c |    2 +-
 calendar/backends/caldav/e-cal-backend-caldav.c    |    3 +-
 calendar/backends/contacts/CMakeLists.txt          |   50 +
 calendar/backends/contacts/Makefile.am             |   43 -
 .../contacts/e-cal-backend-contacts-factory.c      |    2 +-
 .../backends/contacts/e-cal-backend-contacts.c     |    4 +-
 calendar/backends/file/CMakeLists.txt              |   79 +
 calendar/backends/file/Makefile.am                 |   68 -
 calendar/backends/file/e-cal-backend-file-events.c |    4 +-
 .../backends/file/e-cal-backend-file-factory.c     |    2 +-
 calendar/backends/file/e-cal-backend-file-todos.c  |    4 +-
 calendar/backends/file/e-cal-backend-file.c        |    4 +-
 calendar/backends/gtasks/CMakeLists.txt            |   51 +
 calendar/backends/gtasks/Makefile.am               |   42 -
 .../backends/gtasks/e-cal-backend-gtasks-factory.c |    2 +-
 calendar/backends/gtasks/e-cal-backend-gtasks.c    |    4 +-
 calendar/backends/http/CMakeLists.txt              |   46 +
 calendar/backends/http/Makefile.am                 |   39 -
 .../backends/http/e-cal-backend-http-factory.c     |    2 +-
 calendar/backends/http/e-cal-backend-http.c        |    3 +-
 calendar/backends/weather/CMakeLists.txt           |   51 +
 calendar/backends/weather/Makefile.am              |   47 -
 .../weather/e-cal-backend-weather-factory.c        |    2 +-
 calendar/backends/weather/e-cal-backend-weather.c  |    3 +-
 calendar/libecal/CMakeLists.txt                    |   93 +
 calendar/libecal/Makefile.am                       |  111 --
 calendar/libecal/e-cal-check-timezones.c           |    4 +-
 calendar/libecal/e-cal-client-view.c               |    4 +-
 calendar/libecal/e-cal-client.c                    |    4 +-
 calendar/libecal/e-cal-component.c                 |    3 +-
 calendar/libecal/e-cal-recur.c                     |    4 +-
 calendar/libecal/e-cal-util.c                      |    3 +-
 calendar/libecal/e-cal-view.c                      |    4 +-
 calendar/libecal/e-cal.c                           |    4 +-
 calendar/libecal/libecal.pc.in                     |   17 +-
 calendar/libedata-cal/CMakeLists.txt               |  136 ++
 calendar/libedata-cal/Makefile.am                  |  124 --
 calendar/libedata-cal/e-cal-backend-cache.c        |    4 +-
 calendar/libedata-cal/e-cal-backend-factory.c      |    3 +-
 calendar/libedata-cal/e-cal-backend-intervaltree.c |    4 +-
 calendar/libedata-cal/e-cal-backend-sexp.c         |    4 +-
 calendar/libedata-cal/e-cal-backend-store.c        |    4 +-
 calendar/libedata-cal/e-cal-backend-sync.c         |    4 +-
 calendar/libedata-cal/e-cal-backend-util.c         |    4 +-
 calendar/libedata-cal/e-cal-backend.c              |    2 +-
 calendar/libedata-cal/e-data-cal-factory.c         |    3 +-
 calendar/libedata-cal/e-data-cal-view.c            |    4 +-
 calendar/libedata-cal/e-data-cal.c                 |    4 +-
 calendar/libedata-cal/e-subprocess-cal-factory.c   |    4 +-
 .../evolution-calendar-factory-subprocess.c        |    3 +-
 calendar/libedata-cal/libedata-cal.pc.in           |   19 +-
 calendar/libegdbus/CMakeLists.txt                  |   36 +
 calendar/libegdbus/Makefile.am                     |   28 -
 camel/CMakeLists.txt                               |  459 +++++
 camel/Makefile.am                                  |  473 -----
 camel/camel-block-file.c                           |    4 +-
 camel/camel-certdb.c                               |    4 +-
 camel/camel-charset-map.c                          |    4 +-
 camel/camel-cipher-context.c                       |    4 +-
 camel/camel-data-cache.c                           |    4 +-
 camel/camel-data-wrapper.c                         |    4 +-
 camel/camel-db.c                                   |    8 +-
 camel/camel-debug.c                                |    4 +-
 camel/camel-file-utils.c                           |    4 +-
 camel/camel-filter-driver.c                        |    4 +-
 camel/camel-filter-search.c                        |    4 +-
 camel/camel-folder-search.c                        |    4 +-
 camel/camel-folder-summary.c                       |    4 +-
 camel/camel-folder-thread.c                        |    4 +-
 camel/camel-folder.c                               |    4 +-
 camel/camel-gpg-context.c                          |    4 +-
 camel/camel-gpg-photo-saver.c                      |    4 +-
 camel/camel-iconv.c                                |    4 +-
 camel/camel-index-control.c                        |    4 +-
 camel/camel-index.c                                |    4 +-
 camel/camel-junk-filter.c                          |    4 +-
 camel/camel-lock-client.c                          |    4 +-
 camel/camel-lock.c                                 |   24 +-
 camel/camel-medium.c                               |    4 +-
 camel/camel-mime-filter-bestenc.c                  |    4 +-
 camel/camel-mime-filter-canon.c                    |    4 +-
 camel/camel-mime-filter-charset.c                  |    4 +-
 camel/camel-mime-filter-enriched.c                 |    4 +-
 camel/camel-mime-filter-from.c                     |    4 +-
 camel/camel-mime-filter-gzip.c                     |    4 +-
 camel/camel-mime-filter-linewrap.c                 |    4 +-
 camel/camel-mime-filter-pgp.c                      |    4 +-
 camel/camel-mime-filter-progress.c                 |    4 +-
 camel/camel-mime-filter-tohtml.c                   |    4 +-
 camel/camel-mime-filter-windows.c                  |    4 +-
 camel/camel-mime-filter-yenc.c                     |    4 +-
 camel/camel-mime-message.c                         |    4 +-
 camel/camel-mime-part-utils.c                      |    4 +-
 camel/camel-mime-part.c                            |    4 +-
 camel/camel-mime-utils.c                           |    4 +-
 camel/camel-movemail.c                             |   14 +-
 camel/camel-msgport.c                              |    4 +-
 camel/camel-multipart-encrypted.c                  |    4 +-
 camel/camel-multipart-signed.c                     |    4 +-
 camel/camel-multipart.c                            |    4 +-
 camel/camel-net-utils.c                            |    4 +-
 camel/camel-network-service.c                      |    4 +-
 camel/camel-object.c                               |    4 +-
 camel/camel-offline-folder.c                       |    4 +-
 camel/camel-offline-store.c                        |    4 +-
 camel/camel-operation.c                            |    2 +-
 camel/camel-partition-table.c                      |    4 +-
 camel/camel-provider.c                             |    4 +-
 camel/camel-sasl-anonymous.c                       |    4 +-
 camel/camel-sasl-cram-md5.c                        |    4 +-
 camel/camel-sasl-digest-md5.c                      |    4 +-
 camel/camel-sasl-gssapi.c                          |    4 +-
 camel/camel-sasl-login.c                           |    4 +-
 camel/camel-sasl-ntlm.c                            |    4 +-
 camel/camel-sasl-plain.c                           |    4 +-
 camel/camel-sasl-popb4smtp.c                       |    4 +-
 camel/camel-sasl.c                                 |    4 +-
 camel/camel-search-private.c                       |    4 +-
 camel/camel-search-sql-sexp.c                      |    4 +-
 camel/camel-service.c                              |    4 +-
 camel/camel-session.c                              |    4 +-
 camel/camel-sexp.c                                 |    3 +-
 camel/camel-smime-context.c                        |    4 +-
 camel/camel-store-summary.c                        |    4 +-
 camel/camel-store.c                                |    4 +-
 camel/camel-stream-buffer.c                        |    4 +-
 camel/camel-stream-filter.c                        |    4 +-
 camel/camel-stream-fs.c                            |    4 +-
 camel/camel-stream-mem.c                           |    4 +-
 camel/camel-stream-null.c                          |    4 +-
 camel/camel-stream-process.c                       |    4 +-
 camel/camel-stream.c                               |    5 +-
 camel/camel-string-utils.c                         |    4 +-
 camel/camel-subscribable.c                         |    5 +-
 camel/camel-text-index.c                           |    4 +-
 camel/camel-transport.c                            |    4 +-
 camel/camel-trie.c                                 |    4 +-
 camel/camel-uid-cache.c                            |    4 +-
 camel/camel-url-scanner.c                          |    4 +-
 camel/camel-url.c                                  |    4 +-
 camel/camel-utf8.c                                 |    4 +-
 camel/camel-vee-data-cache.c                       |    4 +-
 camel/camel-vee-folder.c                           |    4 +-
 camel/camel-vee-store.c                            |    4 +-
 camel/camel-vee-summary.c                          |    4 +-
 camel/camel-vtrash-folder.c                        |    4 +-
 camel/camel-win32.h                                |    4 +-
 camel/camel.c                                      |    4 +-
 camel/camel.pc.in                                  |   11 +-
 camel/providers/CMakeLists.txt                     |    9 +
 camel/providers/Makefile.am                        |    8 -
 camel/providers/imapx/CMakeLists.txt               |   92 +
 camel/providers/imapx/Makefile.am                  |   98 -
 camel/providers/imapx/camel-imapx-command.c        |    5 +-
 camel/providers/imapx/camel-imapx-conn-manager.c   |    4 +-
 camel/providers/imapx/camel-imapx-folder.c         |    4 +-
 camel/providers/imapx/camel-imapx-input-stream.c   |    5 +-
 camel/providers/imapx/camel-imapx-job.c            |    5 +-
 camel/providers/imapx/camel-imapx-provider.c       |    4 +-
 camel/providers/imapx/camel-imapx-search.c         |    4 +-
 camel/providers/imapx/camel-imapx-server.c         |    4 +-
 camel/providers/imapx/camel-imapx-store-summary.c  |    4 +-
 camel/providers/imapx/camel-imapx-store.c          |    4 +-
 camel/providers/imapx/camel-imapx-summary.c        |    4 +-
 camel/providers/imapx/camel-imapx-utils.c          |    4 +-
 camel/providers/imapx/test-imapx.c                 |   60 -
 camel/providers/local/CMakeLists.txt               |   83 +
 camel/providers/local/Makefile.am                  |   77 -
 camel/providers/local/camel-local-folder.c         |    4 +-
 camel/providers/local/camel-local-private.c        |    4 +-
 camel/providers/local/camel-local-private.h        |    4 +-
 camel/providers/local/camel-local-provider.c       |    4 +-
 camel/providers/local/camel-local-store.c          |    4 +-
 camel/providers/local/camel-local-summary.c        |    4 +-
 camel/providers/local/camel-maildir-folder.c       |    4 +-
 camel/providers/local/camel-maildir-store.c        |    4 +-
 camel/providers/local/camel-maildir-summary.c      |    4 +-
 camel/providers/local/camel-mbox-folder.c          |    4 +-
 camel/providers/local/camel-mbox-store.c           |    4 +-
 camel/providers/local/camel-mbox-summary.c         |    4 +-
 camel/providers/local/camel-mh-folder.c            |    4 +-
 camel/providers/local/camel-mh-store.c             |    4 +-
 camel/providers/local/camel-mh-summary.c           |    4 +-
 camel/providers/local/camel-spool-folder.c         |    4 +-
 camel/providers/local/camel-spool-store.c          |    4 +-
 camel/providers/local/camel-spool-summary.c        |    4 +-
 camel/providers/nntp/CMakeLists.txt                |   56 +
 camel/providers/nntp/Makefile.am                   |   46 -
 camel/providers/nntp/camel-nntp-folder.c           |    4 +-
 camel/providers/nntp/camel-nntp-private.h          |    4 +-
 camel/providers/nntp/camel-nntp-provider.c         |    4 +-
 camel/providers/nntp/camel-nntp-store-summary.c    |    4 +-
 camel/providers/nntp/camel-nntp-store.c            |    4 +-
 camel/providers/nntp/camel-nntp-stream.c           |    4 +-
 camel/providers/nntp/camel-nntp-summary.c          |    4 +-
 camel/providers/nntp/test-newsrc.c                 |   26 -
 camel/providers/pop3/CMakeLists.txt                |   52 +
 camel/providers/pop3/Makefile.am                   |   43 -
 camel/providers/pop3/camel-pop3-engine.c           |    4 +-
 camel/providers/pop3/camel-pop3-folder.c           |    4 +-
 camel/providers/pop3/camel-pop3-provider.c         |    4 +-
 camel/providers/pop3/camel-pop3-store.c            |    4 +-
 camel/providers/pop3/camel-pop3-stream.c           |    4 +-
 camel/providers/sendmail/CMakeLists.txt            |   48 +
 camel/providers/sendmail/Makefile.am               |   36 -
 camel/providers/sendmail/camel-sendmail-provider.c |    4 +-
 .../providers/sendmail/camel-sendmail-transport.c  |    4 +-
 camel/providers/smtp/CMakeLists.txt                |   46 +
 camel/providers/smtp/Makefile.am                   |   34 -
 camel/providers/smtp/camel-smtp-provider.c         |    4 +-
 camel/providers/smtp/camel-smtp-transport.c        |    4 +-
 camel/tests/CMakeLists.txt                         |   52 +
 camel/tests/Makefile.am                            |   17 -
 camel/tests/folder/CMakeLists.txt                  |   15 +
 camel/tests/folder/Makefile.am                     |   59 -
 camel/tests/lib/CMakeLists.txt                     |   70 +
 camel/tests/lib/Makefile.am                        |   48 -
 camel/tests/lib/camel-test.h                       |    2 +-
 camel/tests/lib/session.c                          |    4 +-
 camel/tests/message/CMakeLists.txt                 |    7 +
 camel/tests/message/Makefile.am                    |   32 -
 camel/tests/mime-filter/CMakeLists.txt             |    8 +
 camel/tests/mime-filter/Makefile.am                |   46 -
 camel/tests/misc/CMakeLists.txt                    |   11 +
 camel/tests/misc/Makefile.am                       |   45 -
 camel/tests/misc/rfc2047.c                         |    4 +-
 camel/tests/misc/split.c                           |    3 +-
 camel/tests/misc/test1.c                           |    2 +-
 camel/tests/misc/test2.c                           |    2 +-
 camel/tests/misc/url-scan.c                        |    4 +-
 camel/tests/misc/url.c                             |    2 +-
 camel/tests/misc/utf7.c                            |    2 +-
 camel/tests/smime/CMakeLists.txt                   |    7 +
 camel/tests/smime/Makefile.am                      |   34 -
 camel/tests/smime/pgp-mime.c                       |    4 +-
 camel/tests/smime/pgp.c                            |    4 +-
 camel/tests/smime/pkcs7.c                          |    2 +-
 cmake/cmake_uninstall.cmake.in                     |   21 +
 cmake/modules/CheckTarget.cmake                    |   21 +
 cmake/modules/CodeCoverageGCOV.cmake               |   45 +
 cmake/modules/DistTargets.cmake                    |   87 +
 cmake/modules/FindIntltool.cmake                   |  209 ++
 cmake/modules/FindKRB5.cmake                       |  109 ++
 cmake/modules/FindLDAP.cmake                       |  133 ++
 cmake/modules/FindPhonenumber.cmake                |   77 +
 cmake/modules/FindSMIME.cmake                      |  146 ++
 cmake/modules/GLibTools.cmake                      |  277 +++
 cmake/modules/GObjectIntrospection.cmake           |  227 +++
 cmake/modules/GtkDoc.cmake                         |  150 ++
 cmake/modules/InstalledTests.cmake                 |   88 +
 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                          |   56 +
 config.h.in                                        |  192 ++
 configure.ac                                       | 1985 --------------------
 data/CMakeLists.txt                                |   27 +
 data/Makefile.am                                   |   33 -
 docs/CMakeLists.txt                                |    1 +
 docs/Makefile.am                                   |    3 -
 docs/reference/CMakeLists.txt                      |    6 +
 docs/reference/Makefile.am                         |   15 -
 docs/reference/camel/CMakeLists.txt                |   34 +
 docs/reference/camel/Makefile.am                   |   88 -
 .../camel/{camel-docs.sgml => camel-docs.sgml.in}  |    8 +-
 docs/reference/camel/tree_index.sgml               |   66 -
 docs/reference/eds/Makefile.am                     |  169 --
 docs/reference/eds/version.xml.in                  |    1 -
 .../reference/evolution-data-server/CMakeLists.txt |   44 +
 .../evolution-data-server-cursor-example.sgml.in}  |   10 +-
 .../evolution-data-server-docs.sgml.in}            |    7 +-
 .../image-sources/cursor-alphabetic-indexes.odg    |  Bin 17856 -> 17856 bytes
 .../image-sources/cursor-positions-filtered.odg    |  Bin 19396 -> 19396 bytes
 .../image-sources/cursor-positions-step.odg        |  Bin 22688 -> 22688 bytes
 .../image-sources/cursor-positions.odg             |  Bin 17473 -> 17473 bytes
 .../images/cursor-alphabetic-indexes.png           |  Bin 115122 -> 115122 bytes
 .../images/cursor-positions-filtered.png           |  Bin 145568 -> 145568 bytes
 .../images/cursor-positions-step.png               |  Bin 325691 -> 325691 bytes
 .../images/cursor-positions.png                    |  Bin 131869 -> 131869 bytes
 docs/reference/private/CMakeLists.txt              |   13 +
 docs/reference/private/Makefile.am                 |   61 -
 .../private/libedbus-private-docs.sgml.in          |   28 +-
 enumtypes.c.template                               |   37 -
 enumtypes.h.template                               |   24 -
 evolution-data-server.pc.in                        |   15 +-
 examples/CMakeLists.txt                            |    1 +
 examples/Makefile.am                               |    3 -
 examples/cursor/CMakeLists.txt                     |   60 +
 examples/cursor/Makefile.am                        |   72 -
 git.mk                                             |  224 ---
 iconv-detect.c                                     |   63 +-
 libebackend/CMakeLists.txt                         |  136 ++
 libebackend/Makefile.am                            |  149 --
 libebackend/e-backend-factory.c                    |    6 +-
 libebackend/e-backend.c                            |    3 +-
 libebackend/e-cache-reaper.c                       |    2 +
 libebackend/e-collection-backend.c                 |    5 +-
 libebackend/e-data-factory.c                       |    5 +-
 libebackend/e-db3-utils.c                          |    2 +-
 libebackend/e-dbhash.c                             |    2 +-
 libebackend/e-dbus-server.c                        |    6 +-
 libebackend/e-file-cache.c                         |    3 +-
 libebackend/e-offline-listener.c                   |    4 +-
 libebackend/e-offline-listener.h                   |    4 -
 .../e-server-side-source-credentials-provider.c    |    4 +-
 libebackend/e-server-side-source.c                 |    7 +-
 libebackend/e-source-registry-server.c             |    9 +-
 libebackend/e-sqlite3-vfs.c                        |    3 +-
 libebackend/e-subprocess-factory.c                 |    4 +-
 libebackend/e-user-prompter-server-extension.c     |    4 +-
 libebackend/e-user-prompter-server.c               |    4 +-
 libebackend/e-user-prompter.c                      |    4 +-
 libebackend/libebackend.pc.in                      |   15 +-
 libedataserver/CMakeLists.txt                      |  295 +++
 libedataserver/Makefile.am                         |  298 ---
 libedataserver/e-alphabet-index-private.cpp        |    4 +-
 libedataserver/e-cancellable-locks.c               |    4 +-
 libedataserver/e-categories.c                      |    4 +-
 libedataserver/e-client.c                          |    4 +-
 libedataserver/e-collator.c                        |    4 +-
 libedataserver/e-credentials.c                     |    4 +-
 libedataserver/e-data-server-util.c                |    8 +-
 libedataserver/e-debug-log.c                       |    3 +-
 libedataserver/e-extensible.c                      |    4 +-
 libedataserver/e-extension.c                       |    4 +-
 libedataserver/e-free-form-exp.c                   |    4 +-
 libedataserver/e-iterator.c                        |    2 +-
 libedataserver/e-list-iterator.c                   |    2 +-
 libedataserver/e-list.c                            |    2 +-
 libedataserver/e-module.c                          |    4 +-
 libedataserver/e-network-monitor.c                 |    4 +-
 libedataserver/e-proxy.c                           |    4 +-
 libedataserver/e-secret-store.c                    |    4 +-
 libedataserver/e-sexp.c                            |    4 +-
 libedataserver/e-soup-auth-bearer.c                |    4 +-
 libedataserver/e-soup-ssl-trust.c                  |    4 +-
 libedataserver/e-source-collection.c               |    7 +-
 libedataserver/e-source-contacts.c                 |    4 +-
 .../e-source-credentials-provider-impl-google.c    |    4 +-
 .../e-source-credentials-provider-impl-password.c  |    4 +-
 .../e-source-credentials-provider-impl.c           |    4 +-
 libedataserver/e-source-credentials-provider.c     |    4 +-
 libedataserver/e-source-ldap.c                     |    4 +-
 libedataserver/e-source-local.c                    |    4 +-
 libedataserver/e-source-mail-composition.c         |    4 +-
 libedataserver/e-source-mail-signature.c           |    5 +-
 libedataserver/e-source-proxy.c                    |    5 +-
 libedataserver/e-source-registry.c                 |   23 +-
 libedataserver/e-source-weather.c                  |    4 +-
 libedataserver/e-source-webdav.c                   |    4 +-
 libedataserver/e-source.c                          |    7 +-
 libedataserver/e-time-utils.c                      |    7 +-
 libedataserver/e-transliterator-private.cpp        |    4 +-
 libedataserver/e-url.c                             |    3 +-
 libedataserver/e-webdav-discover.c                 |    4 +-
 libedataserver/e-xml-hash-utils.c                  |    2 +-
 libedataserver/e-xml-utils.c                       |    2 +-
 libedataserver/eds-version.h.in                    |    6 +-
 libedataserver/libedataserver-private.h            |    8 -
 libedataserver/libedataserver.pc.in                |   13 +-
 libedataserverui/CMakeLists.txt                    |   96 +
 libedataserverui/Makefile.am                       |   85 -
 libedataserverui/e-cell-renderer-color.c           |    4 +-
 .../e-credentials-prompter-impl-google.c           |    4 +-
 .../e-credentials-prompter-impl-password.c         |    4 +-
 libedataserverui/e-credentials-prompter-impl.c     |    4 +-
 libedataserverui/e-credentials-prompter.c          |    4 +-
 libedataserverui/e-trust-prompt.c                  |    4 +-
 libedataserverui/e-webdav-discover-widget.c        |    4 +-
 libedataserverui/libedataserverui.pc.in            |   14 +-
 m4/as-compiler-flag.m4                             |   61 -
 m4/eds-installed-tests.m4                          |  111 --
 m4/evo_check_langinfo.m4                           |   25 -
 m4/evo_krb5_support.m4                             |  136 --
 m4/evo_ldap_check.m4                               |   92 -
 m4/evo_phonenumber.m4                              |  134 --
 m4/evo_purify_support.m4                           |   23 -
 m4/evo_sunldap_check.m4                            |   94 -
 m4/introspection.m4                                |   94 -
 modules/CMakeLists.txt                             |   84 +
 modules/Makefile.am                                |   31 -
 modules/cache-reaper/CMakeLists.txt                |   17 +
 modules/cache-reaper/Makefile.am                   |   28 -
 modules/cache-reaper/module-cache-reaper.c         |    4 +-
 modules/gnome-online-accounts/CMakeLists.txt       |   38 +
 modules/gnome-online-accounts/Makefile.am          |   71 -
 modules/gnome-online-accounts/e-goa-client.c       |    4 +-
 .../gnome-online-accounts/e-goa-password-based.c   |    4 +-
 modules/gnome-online-accounts/goaewsclient.c       |    3 +-
 .../gnome-online-accounts/module-credentials-goa.c |    4 +-
 .../module-gnome-online-accounts.c                 |    3 +-
 modules/google-backend/CMakeLists.txt              |   17 +
 modules/google-backend/Makefile.am                 |   31 -
 modules/google-backend/module-google-backend.c     |    5 +-
 modules/outlook-backend/CMakeLists.txt             |   17 +
 modules/outlook-backend/Makefile.am                |   29 -
 modules/outlook-backend/module-outlook-backend.c   |    3 +-
 modules/owncloud-backend/CMakeLists.txt            |   17 +
 modules/owncloud-backend/Makefile.am               |   29 -
 modules/owncloud-backend/module-owncloud-backend.c |    4 +-
 modules/secret-monitor/CMakeLists.txt              |   17 +
 modules/secret-monitor/Makefile.am                 |   30 -
 modules/secret-monitor/module-secret-monitor.c     |    2 +
 modules/trust-prompt/CMakeLists.txt                |   41 +
 modules/trust-prompt/Makefile.am                   |   39 -
 modules/trust-prompt/module-trust-prompt.c         |    4 +-
 modules/trust-prompt/trust-prompt-gtk.c            |    4 +-
 modules/ubuntu-online-accounts/CMakeLists.txt      |  158 ++
 modules/ubuntu-online-accounts/Makefile.am         |  130 --
 .../e-signon-session-password.c                    |    5 +-
 .../module-credentials-uoa.c                       |    4 +-
 .../module-ubuntu-online-accounts.c                |    3 +-
 modules/ubuntu-online-accounts/uoa-utils.c         |    5 +-
 modules/yahoo-backend/CMakeLists.txt               |   17 +
 modules/yahoo-backend/Makefile.am                  |   29 -
 modules/yahoo-backend/module-yahoo-backend.c       |    3 +-
 po/CMakeLists.txt                                  |    1 +
 po/LINGUAS                                         |   89 -
 po/POTFILES.skip                                   |    1 +
 private/CMakeLists.txt                             |  189 ++
 private/Makefile.am                                |  255 ---
 services/CMakeLists.txt                            |    7 +
 services/Makefile.am                               |   14 -
 .../evolution-addressbook-factory/CMakeLists.txt   |   75 +
 services/evolution-addressbook-factory/Makefile.am |   65 -
 .../evolution-addressbook-factory.c                |    3 +-
 .../evolution-addressbook-factory.service.in       |    2 +-
 ...ome.evolution.dataserver.AddressBook.service.in |    4 +-
 services/evolution-calendar-factory/CMakeLists.txt |   74 +
 services/evolution-calendar-factory/Makefile.am    |   63 -
 .../evolution-calendar-factory.c                   |    3 +-
 .../evolution-calendar-factory.service.in          |    2 +-
 ....gnome.evolution.dataserver.Calendar.service.in |    4 +-
 services/evolution-source-registry/CMakeLists.txt  |  151 ++
 services/evolution-source-registry/Makefile.am     |  137 --
 .../evolution-scan-gconf-tree-xml.c                |    3 +-
 .../evolution-source-registry-migrate-proxies.c    |    3 +-
 .../evolution-source-registry.c                    |    3 +-
 .../evolution-source-registry.service.in           |    2 +-
 ...g.gnome.evolution.dataserver.Sources.service.in |    4 +-
 services/evolution-user-prompter/CMakeLists.txt    |   77 +
 services/evolution-user-prompter/Makefile.am       |   54 -
 .../evolution-user-prompter.c                      |    3 +-
 .../evolution-user-prompter.service.in             |    2 +-
 ...me.evolution.dataserver.UserPrompter.service.in |    4 +-
 services/evolution-user-prompter/prompt-user-gtk.c |    4 +-
 tests/CMakeLists.txt                               |   61 +
 tests/Makefile.am                                  |   14 -
 tests/book-migration/CMakeLists.txt                |   96 +
 tests/book-migration/Makefile.am                   |  104 -
 tests/book-migration/db/CMakeLists.txt             |   27 +
 tests/book-migration/db/Makefile.am                |   39 -
 tests/book-migration/test-migration.c              |    2 +-
 tests/libebook-contacts/CMakeLists.txt             |   41 +
 tests/libebook-contacts/Makefile.am                |   57 -
 tests/libebook-contacts/test-phone-number.c        |    4 +-
 tests/libebook/CMakeLists.txt                      |  114 ++
 tests/libebook/Makefile.am                         |  147 --
 tests/libebook/client/CMakeLists.txt               |  143 ++
 tests/libebook/client/Makefile.am                  |  177 --
 .../client/test-book-client-cursor-operations.c    |    2 +-
 .../client/test-book-client-custom-summary.c       |    2 +-
 .../libebook/client/test-book-client-e164-param.c  |    3 +-
 tests/libebook/vcard/CMakeLists.txt                |   39 +
 tests/libebook/vcard/Makefile.am                   |   31 -
 tests/libecal/CMakeLists.txt                       |  125 ++
 tests/libecal/Makefile.am                          |  122 --
 tests/libecal/client/CMakeLists.txt                |   50 +
 tests/libecal/client/Makefile.am                   |   84 -
 tests/libedata-book/CMakeLists.txt                 |  129 ++
 tests/libedata-book/Makefile.am                    |  111 --
 tests/libedata-book/data-test-utils.c              |    4 +-
 tests/libedata-cal/CMakeLists.txt                  |   40 +
 tests/libedata-cal/Makefile.am                     |   45 -
 tests/libedataserver/CMakeLists.txt                |   62 +
 tests/libedataserver/Makefile.am                   |   72 -
 tests/test-server-utils/CMakeLists.txt             |  108 ++
 tests/test-server-utils/Makefile.am                |   84 -
 tests/test-server-utils/e-test-server-utils.c      |    4 +-
 tests/test-server-utils/services/CMakeLists.txt    |   11 +
 tests/test-server-utils/services/Makefile.am       |    7 -
 ...ome.evolution.dataserver.AddressBook.service.in |    2 +-
 ....gnome.evolution.dataserver.Calendar.service.in |    2 +-
 ...g.gnome.evolution.dataserver.Sources.service.in |    2 +-
 tools/CMakeLists.txt                               |    1 +
 tools/Makefile.am                                  |    5 -
 tools/addressbook-export/CMakeLists.txt            |   59 +
 tools/addressbook-export/Makefile.am               |   41 -
 tools/addressbook-export/addressbook-export.c      |    4 +-
 vala/CMakeLists.txt                                |  141 ++
 vala/Makefile.am                                   |  100 -
 563 files changed, 9049 insertions(+), 10188 deletions(-)
---
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e449d05
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+build
+_build
+.build
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..d77e640
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,926 @@
+# Evolution-Data-Server build script
+
+cmake_minimum_required(VERSION 3.0)
+cmake_policy(VERSION 3.0)
+
+project(evolution-data-server
+       VERSION 3.23.1
+       LANGUAGES C CXX)
+set(PROJECT_BUGREPORT "http://bugzilla.gnome.org/enter_bug.cgi?product=Evolution-Data-Server";)
+
+# 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)
+
+# This number is meaningless, but we're now stuck with it in our
+# library names for backward compatibility.
+set(API_VERSION 1.2)
+
+# 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_GOA=ON
+       -DENABLE_UOA=ON
+       -DENABLE_EXAMPLES=ON
+       -DENABLE_INTROSPECTION=ON
+       -DENABLE_VALA_BINDINGS=ON
+       -DENABLE_INSTALLED_TESTS=ON
+       -DENABLE_GTK_DOC=ON
+       -DWITH_PRIVATE_DOCS=ON
+)
+
+# ******************************
+# D-Bus versioning
+# ******************************
+set(ADDRESS_BOOK_DBUS_SERVICE_NAME     "org.gnome.evolution.dataserver.AddressBook9")
+set(CALENDAR_DBUS_SERVICE_NAME         "org.gnome.evolution.dataserver.Calendar7")
+set(SOURCES_DBUS_SERVICE_NAME          "org.gnome.evolution.dataserver.Sources5")
+set(USER_PROMPTER_DBUS_SERVICE_NAME    "org.gnome.evolution.dataserver.UserPrompter0")
+
+# ******************************
+# Library versioning
+# ******************************
+set(LIBCAMEL_CURRENT 59)
+set(LIBCAMEL_REVISION 0)
+set(LIBCAMEL_AGE 0)
+
+set(LIBEBACKEND_CURRENT 10)
+set(LIBEBACKEND_REVISION 0)
+set(LIBEBACKEND_AGE 0)
+
+set(LIBEDATASERVER_CURRENT 22)
+set(LIBEDATASERVER_REVISION 0)
+set(LIBEDATASERVER_AGE 0)
+
+set(LIBEDATASERVERUI_CURRENT 1)
+set(LIBEDATASERVERUI_REVISION 0)
+set(LIBEDATASERVERUI_AGE 0)
+
+set(LIBEBOOK_CURRENT 19)
+set(LIBEBOOK_REVISION 1)
+set(LIBEBOOK_AGE 3)
+
+set(LIBEBOOK_CONTACTS_CURRENT 2)
+set(LIBEBOOK_CONTACTS_REVISION 0)
+set(LIBEBOOK_CONTACTS_AGE 0)
+
+set(LIBEDATABOOK_CURRENT 25)
+set(LIBEDATABOOK_REVISION 0)
+set(LIBEDATABOOK_AGE 0)
+
+set(LIBECAL_CURRENT 19)
+set(LIBECAL_REVISION 0)
+set(LIBECAL_AGE 0)
+
+set(LIBEDATACAL_CURRENT 28)
+set(LIBEDATACAL_REVISION 0)
+set(LIBEDATACAL_AGE 0)
+
+# 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(gcr_minimum_version 3.4)
+set(libgdata_minimum_version 0.15.1)
+set(libical_minimum_version 0.43)
+set(libsecret_minimum_version 0.5)
+set(libxml_minimum_version 2.0.0)
+set(sqlite_minimum_version 3.7.17)
+
+# Optional Packages
+set(goa_minimum_version 3.8)
+set(gweather_minimum_version 3.10)
+set(libaccounts_glib_minimum_version 1.4)
+set(libsignon_glib_minimum_version 1.8)
+set(json_glib_minimum_version 1.0.4)
+set(webkit2gtk_minimum_version 2.11.91)
+
+# 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(imagesdir "${SHARE_INSTALL_DIR}/pixmaps/${PROJECT_NAME}")
+set(moduledir "${privlibdir}/registry-modules")
+set(credentialmoduledir "${privlibdir}/credential-modules")
+set(ebook_backenddir "${privlibdir}/addressbook-backends")
+set(ecal_backenddir "${privlibdir}/calendar-backends")
+set(ro_sourcesdir "${privdatadir}/ro-sources")
+set(rw_sourcesdir "${privdatadir}/rw-sources")
+set(camel_providerdir "${privlibdir}/camel-providers")
+
+# *******************
+# D-BUS service stuff
+# *******************
+set(servicelibexecdir "${LIBEXEC_INSTALL_DIR}")
+if(WIN32 AND (NOT ("$ENV{WIN32_SERVICELIBEXECDIR}" STREQUAL "")))
+       #
+       # D-Bus requires Windows full path, not Unix-like, like the one provided by MSYS
+       #
+       AC_SUBST(WIN32_SERVICELIBEXECDIR)
+       set(servicelibexecdir "$ENV{WIN32_SERVICELIBEXECDIR}")
+endif(WIN32 AND (NOT ("$ENV{WIN32_SERVICELIBEXECDIR}" STREQUAL "")))
+
+add_printable_variable_path(WITH_DBUS_SERVICE_DIR "Set directory for D-Bus service files" 
"${SHARE_INSTALL_DIR}/dbus-1/services")
+
+# It is correct for this to be in ${CMAKE_INSTALL_PREFIX}/lib, even on systems where that
+# does not match ${LIB_INSTALL_DIR}. This is what systemd uses on such platforms.
+
+add_printable_variable_path(WITH_SYSTEMDUSERUNITDIR "Set directory for systemd user units, or 'no' to 
disable" "${CMAKE_INSTALL_PREFIX}/lib/systemd/user")
+
+string(LENGTH "${CMAKE_BINARY_DIR}" bindirlen)
+string(SUBSTRING "${WITH_SYSTEMDUSERUNITDIR}" 0 ${bindirlen} substr)
+string(TOUPPER "${WITH_SYSTEMDUSERUNITDIR}" optupper)
+
+if(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+       set(WITH_SYSTEMD_USER_UNITS ON)
+       set(WITH_SYSTEMDUSERUNITDIR "${CMAKE_INSTALL_PREFIX}/lib/systemd/user")
+elseif(NOT WITH_SYSTEMDUSERUNITDIR)
+       set(WITH_SYSTEMD_USER_UNITS OFF)
+else()
+       set(WITH_SYSTEMD_USER_UNITS ON)
+endif()
+
+unset(bindirlen)
+unset(substr)
+unset(optupper)
+
+# ******************************
+# Dependencies
+# ******************************
+
+include(CodeCoverageGCOV)
+include(CheckTarget)
+include(DistTargets)
+include(GLibTools)
+include(GObjectIntrospection)
+include(GtkDoc)
+include(InstalledTests)
+include(PkgConfigEx)
+include(SetupBuildFlags)
+include(UninstallTarget)
+
+include(FindIntltool)
+include(FindKRB5)
+include(FindLDAP)
+include(FindPhonenumber)
+include(FindSMIME)
+
+add_printable_option(ENABLE_MAINTAINER_MODE "Enable maintainer mode" OFF)
+add_printable_option(WITH_PRIVATE_DOCS "Build documentation for private libraries (requires 
-DENABLE-GTK-DOC=ON" OFF)
+
+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(com_err.h HAVE_COM_ERR_H)
+CHECK_INCLUDE_FILE(et/com_err.h HAVE_ET_COM_ERR_H)
+CHECK_INCLUDE_FILE(sys/wait.h HAVE_SYS_WAIT_H)
+CHECK_INCLUDE_FILE(wspiapi.h HAVE_WSPIAPI_H)
+CHECK_INCLUDE_FILE(zlib.h HAVE_ZLIB_H)
+CHECK_FUNCTION_EXISTS(fsync HAVE_FSYNC)
+CHECK_FUNCTION_EXISTS(strptime HAVE_STRPTIME)
+CHECK_FUNCTION_EXISTS(nl_langinfo HAVE_NL_LANGINFO)
+
+# ******************************
+# required executables
+# ******************************
+
+find_program(GPERF gperf)
+if(NOT GPERF)
+       message(FATAL_ERROR "You need gperf to build ${PROJECT_NAME}")
+endif(NOT GPERF)
+
+find_program(PERL perl)
+if(NOT PERL)
+       message(FATAL_ERROR "You need perl to build ${PROJECT_NAME}")
+endif(NOT PERL)
+
+find_program(PYTHON python)
+if(NOT PYTHON)
+       message(FATAL_ERROR "You need python to build ${PROJECT_NAME}")
+endif(NOT PYTHON)
+
+# ******************************
+# db_load checking, it's optional
+# ******************************
+
+find_program(DB_LOAD db_load)
+if(DB_LOAD)
+       set(HAVE_DB_LOAD ON)
+else(DB_LOAD)
+       set(HAVE_DB_LOAD OFF)
+       message(WARNING "db_load not found, some unit tests will not be run")
+endif(DB_LOAD)
+
+# ******************************
+# deflateInit is a #define, use deflateEnd instead
+# ******************************
+
+CHECK_LIBRARY_EXISTS(z deflateEnd "" deflateEnd_exists)
+
+if(NOT HAVE_ZLIB_H)
+       message(FATAL_ERROR "zlib.h not found")
+endif(NOT HAVE_ZLIB_H)
+if(NOT deflateEnd_exists)
+       message(FATAL_ERROR "zlib doesn't provide deflateEnd")
+endif(NOT deflateEnd_exists)
+
+pkg_check_modules(GNOME_PLATFORM
+       gio-2.0>=${glib_minimum_version}
+       gmodule-2.0>=${glib_minimum_version}
+       libxml-2.0>=${libxml_minimum_version}
+       libsoup-2.4>=${soup_minimum_version}
+)
+
+if(WIN32)
+       pkg_check_modules(GIO_UNIX gio-windows-2.0)
+else(WIN32)
+       pkg_check_modules(GIO_UNIX gio-unix-2.0)
+endif(WIN32)
+
+# *******************
+# Check for ICU
+# *******************
+#
+# ICU started shipping pkg-config files but it's not present
+# on many systems, if we don't find the pkg-config
+# file then let's fallback on a manual check
+pkg_check_modules(ICU icu-i18n)
+
+if(NOT ICU_FOUND)
+       CHECK_INCLUDE_FILE(unicode/ucol.h HAVE_UNICODE_UCOL_H)
+       if(NOT HAVE_UNICODE_UCOL_H)
+               message(FATAL_ERROR "ICU unicode/ucol.h not found; icu-i18n is required")
+       endif(HAVE_UNICODE_UCOL_H)
+
+       set(CMAKE_REQUIRED_LIBRARIES "-licui18n -licuuc -licudata")
+       CHECK_C_SOURCE_COMPILES("#include <unicode/ucol.h>
+                               int main(void) { ucol_open (\"\", NULL); return 0; }" HAVE_UCOL_OPEN)
+       unset(CMAKE_REQUIRED_LIBRARIES)
+
+       if(HAVE_UCOL_OPEN)
+               set(ICU_CFLAGS -D_REENTRANT)
+               set(ICU_LIBS "-licui18n -licuuc -licudata")
+       else(HAVE_UCOL_OPEN)
+               message(FATAL_ERROR "Failed to find icu-i18n, install its development files or build them 
first")
+       endif(HAVE_UCOL_OPEN)
+endif(NOT ICU_FOUND)
+
+# *************************
+# Check for GTK+
+# *************************
+
+add_printable_option(ENABLE_GTK "Enable gtk+ support" ON)
+
+if(ENABLE_GTK)
+       pkg_check_modules_for_option(ENABLE_GTK "GTK+ support" GTK gtk+-3.0>=${gdk_minimum_version})
+       pkg_check_modules_for_option(ENABLE_GTK "GTK+ support" GCR gcr-3>=${gcr_minimum_version})
+
+       set(HAVE_GTK 1)
+endif(ENABLE_GTK)
+
+# ***************************************************
+# Check for WebKitGTK+ and json-glib for google auth
+# ***************************************************
+
+add_printable_option(ENABLE_GOOGLE_AUTH "Enable built-in Google authentication" ON)
+
+if(ENABLE_GOOGLE_AUTH)
+       pkg_check_modules_for_option(ENABLE_GOOGLE_AUTH "Google authentication support" GOOGLE_AUTH
+               webkit2gtk-4.0>=${webkit2gtk_minimum_version}
+               json-glib-1.0>=${json_glib_minimum_version}
+       )
+
+       add_printable_variable(WITH_GOOGLE_CLIENT_ID "Google OAuth 2.0 client id" "")
+       add_printable_variable(WITH_GOOGLE_CLIENT_SECRET "Google OAuth 2.0 client secret" "")
+
+       if(WITH_GOOGLE_CLIENT_ID STREQUAL "")
+               set(WITH_GOOGLE_CLIENT_ID 
"590402290962-2i0b7rqma8b9nmtfrcp7fa06g6cf7g74.apps.googleusercontent.com")
+       endif(WITH_GOOGLE_CLIENT_ID STREQUAL "")
+
+       if(WITH_GOOGLE_CLIENT_SECRET STREQUAL "")
+               set(WITH_GOOGLE_CLIENT_SECRET "mtfUe5W8Aal9DcgVipOY1T9G")
+       endif(WITH_GOOGLE_CLIENT_SECRET STREQUAL "")
+endif(ENABLE_GOOGLE_AUTH)
+
+# ******************************************
+# Check whether to build examples/demos
+# ******************************************
+
+add_printable_option(ENABLE_EXAMPLES "Enable the build of examples" ON)
+
+if(ENABLE_EXAMPLES)
+       pkg_check_modules_for_option(ENABLE_EXAMPLES "build the example program(s)" EXAMPLES
+               gtk+-3.0>=3.10
+               glib-2.0>=2.38
+       )
+
+       set(BUILD_EXAMPLES 1)
+endif(ENABLE_EXAMPLES)
+
+# *******************************
+# Check for GNOME Online Accounts
+# *******************************
+
+add_printable_option(ENABLE_GOA "Enable GNOME Online Accounts support" ON)
+
+if(ENABLE_GOA)
+       pkg_check_modules_for_option(ENABLE_GOA "GNOME Online Accounts support" GOA 
goa-1.0>=${goa_minimum_version})
+
+       set(HAVE_GOA 1)
+endif(ENABLE_GOA)
+
+# ********************************
+# Check for Ubuntu Online Accounts
+# ********************************
+
+add_printable_option(ENABLE_UOA "Enable Ubuntu Online Accounts support" ON)
+
+if(ENABLE_UOA)
+       pkg_check_modules_for_option(ENABLE_UOA "Ubuntu Online Accounts support" LIBACCOUNTS_GLIB 
libaccounts-glib>=${libaccounts_glib_minimum_version})
+       pkg_check_modules_for_option(ENABLE_UOA "Ubuntu Online Accounts support" LIBSIGNON_GLIB 
libsignon-glib>=${libsignon_glib_minimum_version})
+       pkg_check_modules_for_option(ENABLE_UOA "Ubuntu Online Accounts support" JSON_GLIB json-glib-1.0)
+       pkg_check_modules_for_option(ENABLE_UOA "Ubuntu Online Accounts support" REST rest-0.7)
+
+       set(HAVE_UOA 1)
+endif(ENABLE_UOA)
+
+# **********************************************
+# Check if backend per process should be enabled
+# **********************************************
+
+add_printable_option(ENABLE_BACKEND_PER_PROCESS "Enable backend per process support" ON)
+
+# ***********************************
+# Check for libsecret and gcr-base
+# ***********************************
+
+if(NOT WIN32)
+       pkg_check_modules(LIBSECRET REQUIRED libsecret-unstable>=${libsecret_minimum_version})
+       pkg_check_modules(GCR_BASE REQUIRED gcr-base-3>=${gcr_minimum_version})
+endif(NOT WIN32)
+
+# ******************************
+# libdb checking
+# ******************************
+add_printable_variable(WITH_LIBDB "Prefix where libdb is installed" "")
+
+if(NOT ("${WITH_LIBDB}" STREQUAL "NO"))
+       if(NOT (("${WITH_LIBDB}" STREQUAL "") OR ("${WITH_LIBDB}" STREQUAL "YES")))
+               set(LIBDB_CFLAGS "-I${WITH_LIBDB}/include")
+               set(LIBDB_LIBS "-L${WITH_LIBDB}/lib -ldb")
+       else(NOT (("${WITH_LIBDB}" STREQUAL "") OR ("${WITH_LIBDB}" STREQUAL "YES")))
+               if(("$ENV{DB_CFLAGS}" STREQUAL "") AND ("$ENV{DB_LIBS}" STREQUAL ""))
+                       set(LIBDB_CFLAGS "")
+                       set(LIBDB_LIBS "-ldb")
+               else(("$ENV{DB_CFLAGS}" STREQUAL "") AND ("$ENV{DB_LIBS}" STREQUAL ""))
+                       set(LIBDB_CFLAGS $ENV{DB_CFLAGS})
+                       set(LIBDB_LIBS $ENV{DB_LIBS})
+               endif(("$ENV{DB_CFLAGS}" STREQUAL "") AND ("$ENV{DB_LIBS}" STREQUAL ""))
+       endif(NOT (("${WITH_LIBDB}" STREQUAL "") OR ("${WITH_LIBDB}" STREQUAL "YES")))
+
+       set(CMAKE_REQUIRED_FLAGS ${LIBDB_CFLAGS})
+       set(CMAKE_REQUIRED_LIBRARIES ${LIBDB_LIBS})
+       CHECK_C_SOURCE_COMPILES("#include <db.h>
+                               int main(void) { db_create(NULL, NULL, 0); return 0; }" HAVE_LIBDB)
+       unset(CMAKE_REQUIRED_FLAGS)
+       unset(CMAKE_REQUIRED_LIBRARIES)
+endif(NOT ("${WITH_LIBDB}" STREQUAL "NO"))
+
+# ******************************
+# 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)
+
+# ******************************
+# Backtraces for debugging
+# ******************************
+
+add_printable_option(ENABLE_BACKTRACES "Enable backtraces for camel_pointer_tracker" OFF)
+
+if(ENABLE_BACKTRACES)
+       CHECK_C_SOURCE_COMPILES("#include <execinfo.h>
+                               int main(void) { void *bt[1]; backtrace_symbols (bt, backtrace(bt, 1)); 
return 0; }" _have_bsf)
+
+       if(_have_bsf)
+               set(CMAKE_REQUIRED_LIBRARIES -ldw)
+               CHECK_C_SOURCE_COMPILES("#include <elfutils/libdwfl.h>
+                                       int main(void) {
+                                               Dwfl *dwfl;
+                                               Dwfl_Module *module;
+                                               Dwarf_Addr module_low_addr;
+                                               Dwfl_Line *line;
+
+                                               dwfl_standard_find_debuginfo;
+                                               dwfl_linux_proc_find_elf;
+                                               dwfl_begin (NULL);
+                                               dwfl_linux_proc_report (NULL, 1);
+                                               dwfl_report_end (NULL, NULL, NULL);
+                                               dwfl_end (NULL);
+                                               dwfl_module_addrname (NULL, NULL);
+                                               dwfl_module_getsrc (NULL, NULL);
+                                               dwfl_lineinfo (NULL, NULL, NULL, NULL, NULL, NULL);
+                                               DWARF_CB_ABORT; DWARF_CB_OK;
+                                               dwfl_getmodules (NULL, NULL, NULL, 0);
+                                               return 0; }" _have_elfdwlf)
+               unset(CMAKE_REQUIRED_LIBRARIES)
+
+               if(_have_elfdwlf)
+                       set(HAVE_ELFUTILS_LIBDWFL ON)
+                       set(LIBDWFL_LIBS "-ldw")
+               endif(_have_elfdwlf)
+       endif(_have_bsf)
+endif(ENABLE_BACKTRACES)
+
+# ******************************
+# Check for nl_langinfo features
+# ******************************
+
+CHECK_C_SOURCE_COMPILES("#include <langinfo.h>
+                       int main(void) { char *detail = nl_langinfo (CODESET); return 0; }" HAVE_CODESET)
+
+CHECK_C_SOURCE_COMPILES("#include <langinfo.h>
+                       int main(void) { char *detail = nl_langinfo (_NL_ADDRESS_COUNTRY_AB2); return 0; }" 
HAVE__NL_ADDRESS_COUNTRY_AB2)
+
+# *******************************************************
+# Check to see if strftime supports the use of %l and %k
+# *******************************************************
+
+CHECK_C_SOURCE_RUNS("
+       #include <stdlib.h>
+       #include <string.h>
+       #include <time.h>
+       int main(int argc, char **argv) {
+       char buf[10];
+       time_t rawtime;
+       struct tm *timeinfo;
+
+       time(&rawtime);
+       timeinfo=localtime(&rawtime);
+       buf[0] = 0;
+       strftime(buf, 10, \"%lx%k\", timeinfo);
+
+       if (!buf[0] || buf[0] == 'x' || strstr(buf, \"l\") || strstr(buf, \"k\"))
+               return 1;
+       return 0;
+       }" HAVE_LKSTRFTIME)
+
+# ******************************
+# system mail stuff
+# ******************************
+
+find_program(SENDMAIL_PATH sendmail /usr/sbin /usr/lib)
+find_path(SYSTEM_MAIL_DIR /var/mail /var/spool/mail)
+
+# ******************************
+# 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))
+
+# ******************************
+# gethostbyaddr_r prototype
+# ******************************
+
+CHECK_C_SOURCE_COMPILES("#include <sys/types.h>
+                       #include <sys/socket.h>
+                       #include <netinet/in.h>
+                       #include <netdb.h>
+                       #define BUFSIZE (sizeof(struct hostent)+10)
+
+                       int main(void) {
+                               struct hostent hent;
+                               char buffer[BUFSIZE];
+                               int bufsize=BUFSIZE;
+                               int h_errno;
+                               (void)gethostbyaddr_r (\"www.ximian.com\", 14, AF_INET, &hent, buffer, 
bufsize, &h_errno);
+                               return 0;
+                       }" GETHOSTBYADDR_R_SEVEN_ARGS)
+
+# ******************************
+# gethostbyname_r prototype
+# ******************************
+
+CHECK_C_SOURCE_COMPILES("#include <sys/types.h>
+                       #include <sys/socket.h>
+                       #include <netinet/in.h>
+                       #include <netdb.h>
+                       #define BUFSIZE (sizeof(struct hostent)+10)
+
+                       int main(void) {
+                               struct hostent hent;
+                               char buffer[BUFSIZE];
+                               int bufsize=BUFSIZE;
+                               int h_errno;
+                               (void)gethostbyname_r (\"www.ximian.com\", &hent, buffer, bufsize, &h_errno);
+                               return 0;
+                       }" GETHOSTBYNAME_R_FIVE_ARGS)
+
+# ******************************
+# IPv6 support and getaddrinfo calls
+# ******************************
+
+add_printable_option(ENABLE_IPV6 "Enable IPv6 support" ON)
+
+CHECK_C_SOURCE_COMPILES("#include <sys/types.h>
+                       #include <sys/socket.h>
+                       #include <netinet/in.h>
+                       #include <netdb.h>
+                       #include <stddef.h>
+
+                       int main(void) {
+                               #ifndef NI_MAXHOST
+                               #define NI_MAXHOST      1025
+                               #endif
+
+                               #ifndef NI_MAXSERV
+                               #define NI_MAXSERV      32
+                               #endif
+
+                               struct addrinfo hints, *res;
+                               struct sockaddr_in6 sin6;
+                               int af = AF_INET6;
+                               char host[NI_MAXHOST];
+                               char serv[NI_MAXSERV];
+
+                               getaddrinfo (\"www.ximian.com\", NULL, &hints, &res);
+                               freeaddrinfo (res);
+                               getnameinfo((struct sockaddr *)&sin6, sizeof(sin6), host, sizeof(host), serv, 
sizeof(serv), 0);
+                               return 0;
+                       }" have_addrinfo)
+
+if(NOT have_addrinfo)
+       set(NEED_ADDRINFO ON)
+       if(ENABLE_IPV6)
+               message(FATAL_ERROR "System doesn't support necessary interfaces for IPv6 support. Use 
-DENABLE_IPV6=OFF to disable IPv6 support.")
+       endif(ENABLE_IPV6)
+else(NOT have_addrinfo)
+       if(ENABLE_IPV6)
+               CHECK_C_SOURCE_COMPILES("#include <sys/types.h>
+                                       #include <sys/socket.h>
+                                       #include <netinet/in.h>
+                                       #include <netdb.h>
+
+                                       int main(void) {
+                                               struct addrinfo hints;
+                                               hints.ai_flags = AI_ADDRCONFIG;
+                                               return 0;
+                                       }" HAVE_AI_ADDRCONFIG)
+       endif(ENABLE_IPV6)
+endif(NOT have_addrinfo)
+
+# **********************************
+# Weather calendar backend support
+# **********************************
+
+add_printable_option(ENABLE_WEATHER "Build the weather calendar backend" ON)
+
+if(ENABLE_WEATHER)
+       pkg_check_modules_for_option(ENABLE_WEATHER "weather calendar backend" LIBGWEATHER 
gweather-3.0>=${gweather_minimum_version})
+endif(ENABLE_WEATHER)
+
+# ******************************
+# File locking
+# ******************************
+
+add_printable_option(ENABLE_DOT_LOCKING "Enable support for locking mail files with dot locking" ON)
+
+if(WIN32 AND ENABLE_DOT_LOCKING)
+       message(WARNING "Auto-disabling dot locking for mail files for this platform")
+       set(ENABLE_DOT_LOCKING OFF)
+       set(USE_DOT_LOCKING OFF)
+else(WIN32 AND ENABLE_DOT_LOCKING)
+       set(USE_DOT_LOCKING ENABLE_DOT_LOCKING)
+endif(WIN32 AND ENABLE_DOT_LOCKING)
+
+add_printable_variable(ENABLE_FILE_LOCKING "Enable support for locking mail files with file locking (one of 
fcntl/flock/no)" "fcntl")
+
+if(NOT WIN32)
+       if (${ENABLE_FILE_LOCKING} STREQUAL "fcntl")
+               set(USE_FCNTL_LOCKING ON)
+       elseif(${ENABLE_FILE_LOCKING} STREQUAL "flock")
+               set(USE_FLOCK_LOCKING ON)
+       endif()
+endif(NOT WIN32)
+
+# ******************************
+# sendmail operation
+# ******************************
+
+set(defval OFF)
+if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+       set(defval ON)
+endif(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+
+add_printable_option(ENABLE_BROKEN_SPOOL "Use SunOS/Solaris sendmail which has a broken spool format" 
${defval})
+
+unset(defval)
+
+# ******************************
+# sqlite3 flags
+# ******************************
+pkg_check_modules(SQLITE3 sqlite3>=${sqlite_minimum_version})
+
+# ******************************
+# Google flags
+# ******************************
+
+add_printable_option(ENABLE_GOOGLE "Enable Google support" ON)
+if(ENABLE_GOOGLE)
+       pkg_check_modules_for_option(ENABLE_GOOGLE "Google" LIBGDATA libgdata>=${libgdata_minimum_version})
+       set(HAVE_LIBGDATA ON)
+endif(ENABLE_GOOGLE)
+
+# ******************************
+# Checks for large file support
+# ******************************
+
+add_printable_option(ENABLE_LARGEFILE "Enable support for large files" ON)
+
+if(ENABLE_LARGEFILE)
+       CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
+
+       if(HAVE_UNISTD_H)
+               set(CMAKE_REQUIRED_FLAGS "-DHAVE_UNISTD_H")
+       endif(HAVE_UNISTD_H)
+
+       CHECK_C_SOURCE_COMPILES("#ifdef HAVE_UNISTD_H
+                       #include <unistd.h>
+                       #endif
+                       int main(void) {
+                               off64_t x1;
+                               return 0;
+                       }" have_off64_t_bare)
+       if(NOT have_off64_t_bare)
+               CHECK_C_SOURCE_COMPILES("#define _LARGEFILE64_SOURCE
+                               #ifdef HAVE_UNISTD_H
+                               #include <unistd.h>
+                               #endif
+                               int main(void) {
+                                       off64_t x1;
+                                       return 0;
+                               }" have_off64_t_with_largefile64_source)
+       endif(NOT have_off64_t_bare)
+
+       CHECK_C_SOURCE_COMPILES("#include <sys/types.h>
+                       #include <sys/stat.h>
+                       #include <fcntl.h>
+                       int main(void) {
+                               int fd = open (\"__o_largefile\", O_CREAT | O_RDWR | O_LARGEFILE, 0644);
+                               return 0;
+                       }" have_o_largefile_bare)
+       if(NOT have_o_largefile_bare)
+               CHECK_C_SOURCE_COMPILES("#define _LARGEFILE64_SOURCE
+                               #include <sys/types.h>
+                               #include <sys/stat.h>
+                               #include <fcntl.h>
+                               int main(void) {
+                                       int fd = open (\"__o_largefile\", O_CREAT | O_RDWR | O_LARGEFILE, 
0644);
+                                       return 0;
+                               }" have_o_largefile_with_largefile64_source)
+       endif(NOT have_o_largefile_bare)
+
+       set(HAVE_O_LARGEFILE ON)
+       if(have_o_largefile_with_largefile64_source)
+               add_definitions(-D_LARGEFILE64_SOURCE=1)
+       elseif(NOT have_o_largefile_bare)
+               set(HAVE_O_LARGEFILE OFF)
+       endif()
+       unset(CMAKE_REQUIRED_FLAGS)
+else(ENABLE_LARGEFILE)
+       set(HAVE_O_LARGEFILE OFF)
+endif(ENABLE_LARGEFILE)
+
+# ******************************
+# libical tweaks, part I
+# ******************************
+
+pkg_check_at_least_version(HAVE_LIBICAL_2_0 libical 2.0)
+
+# *****
+# libical.pc from libical-0.43 has a bug in its CFlags.
+# It wants apps to include <libical/ical*.h> but it's CFlags make it difficult
+# to differentiate between <libical/ical.h> and <ical.h>
+# We have fixed all our instances to use <libical/ical.h>.
+# Work-around the buggy CFlags for the 0.43 version.
+# *****
+pkg_check_exact_version(libical_is_0_43 libical 0.43)
+if(libical_is_0_43)
+       pkg_check_variable(LIBICAL_EXTRA_CFLAGS libical includedir)
+endif(libical_is_0_43)
+
+# ******************************
+# subparts flags
+# ******************************
+
+pkg_check_modules(SOUP libsoup-2.4)
+pkg_check_modules(DATA_SERVER gio-2.0 gmodule-2.0 libsecret-1 libxml-2.0 libsoup-2.4 ${mozilla_nspr} 
${mozilla_nss})
+set(E_DATA_SERVER_INCLUDES ${E_DATA_SERVER_INCLUDES} ${MANUAL_NSPR_INCLUDES} ${MANUAL_NSS_INCLUDES})
+set(E_DATA_SERVER_LDFLAGS ${E_DATA_SERVER_LDFLAGS} ${MANUAL_NSPR_LIBS} ${MANUAL_NSS_LIBS})
+
+pkg_check_modules(BACKEND gio-2.0 gmodule-2.0 libsecret-1 libsoup-2.4 libxml-2.0)
+pkg_check_modules(ADDRESSBOOK gio-2.0 libxml-2.0 libsoup-2.4 libsecret-1)
+pkg_check_modules(CALENDAR gio-2.0 libical>=${libical_minimum_version} libsoup-2.4 libxml-2.0 libsecret-1)
+set(CALENDAR_CFLAGS "${CALENDAR_CFLAGS} ${LIBICAL_EXTRA_CFLAGS}")
+
+pkg_check_modules(CAMEL gio-2.0 gmodule-2.0 ${mozilla_nss} ${mozilla_nspr} 
sqlite3>=${sqlite_minimum_version})
+set(CAMEL_CFLAGS "${CAMEL_CFLAGS} ${KRB5_CFLAGS} ${MANUAL_NSS_CFLAGS} ${MANUAL_NSPR_CFLAGS} ${ICU_CFLAGS}")
+set(CAMEL_LDFLAGS "${CAMEL_LDFLAGS} -lz ${KRB5_LDFLAGS} ${MANUAL_NSS_LIBS} ${MANUAL_NSPR_LIBS} 
${ICU_LDFLAGS}")
+
+string(STRIP "${CAMEL_CFLAGS}" CAMEL_CFLAGS)
+string(STRIP "${CAMEL_LDFLAGS}" CAMEL_LDFLAGS)
+
+# ******************************
+# libical tweaks, part II (re-using CALENDAR_CFLAGS/CALENDAR_LDFLAGS)
+# ******************************
+
+set(CMAKE_REQUIRED_FLAGS "${CALENDAR_CFLAGS}")
+set(CMAKE_REQUIRED_LIBRARIES "${CALENDAR_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)
+
+# ******************************
+# Vala binding
+# ******************************
+
+add_printable_option(ENABLE_VALA_BINDINGS "Build the experimental Vala bindings" OFF)
+
+if(ENABLE_VALA_BINDINGS)
+       if(NOT ENABLE_INTROSPECTION)
+               message(FATAL_ERROR "Vala bindings require introspection generation to be enabled, use 
-DENABLE_INTROSPECTION=ON to enable it, or disable Vala bindings with -DENABLE_VALA_BINDINGS=OFF")
+       endif(NOT ENABLE_INTROSPECTION)
+
+       find_program(VALAC valac)
+       if(NOT VALAC)
+               message(FATAL_ERROR "The valac not found. Install it or disable Vala bindings with 
-DENABLE_VALA_BINDINGS=OFF")
+       endif(NOT VALAC)
+
+       find_program(VAPIGEN vapigen)
+       if(NOT VAPIGEN)
+               message(FATAL_ERROR "The vapigen not found. Install it or disable Vala bindings with 
-DENABLE_VALA_BINDINGS=OFF")
+       endif(NOT VAPIGEN)
+
+endif(ENABLE_VALA_BINDINGS)
+
+# Generate the ${PROJECT_NAME}-config.h file
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/config.h.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.h)
+
+print_build_options()
+
+add_pkgconfig_file(evolution-data-server.pc.in evolution-data-server-${API_VERSION}.pc)
+
+add_subdirectory(art)
+add_subdirectory(addressbook)
+add_subdirectory(calendar)
+add_subdirectory(camel)
+add_subdirectory(data)
+add_subdirectory(libebackend)
+add_subdirectory(libedataserver)
+add_subdirectory(modules)
+add_subdirectory(private)
+add_subdirectory(po)
+add_subdirectory(services)
+add_subdirectory(tests)
+add_subdirectory(tools)
+
+if(HAVE_GTK)
+       add_subdirectory(libedataserverui)
+endif(HAVE_GTK)
+
+if(ENABLE_GTK_DOC)
+       add_subdirectory(docs)
+endif(ENABLE_GTK_DOC)
+
+if(ENABLE_EXAMPLES)
+       add_subdirectory(examples)
+endif(ENABLE_EXAMPLES)
+
+if(ENABLE_VALA_BINDINGS)
+       add_subdirectory(vala)
+endif(ENABLE_VALA_BINDINGS)
diff --git a/addressbook/CMakeLists.txt b/addressbook/CMakeLists.txt
new file mode 100644
index 0000000..b1c7066
--- /dev/null
+++ b/addressbook/CMakeLists.txt
@@ -0,0 +1,5 @@
+add_subdirectory(backends)
+add_subdirectory(libebook)
+add_subdirectory(libebook-contacts)
+add_subdirectory(libedata-book)
+add_subdirectory(libegdbus)
diff --git a/addressbook/backends/CMakeLists.txt b/addressbook/backends/CMakeLists.txt
new file mode 100644
index 0000000..2d1693d
--- /dev/null
+++ b/addressbook/backends/CMakeLists.txt
@@ -0,0 +1,11 @@
+add_subdirectory(file)
+
+if(ENABLE_GOOGLE)
+       add_subdirectory(google)
+endif(ENABLE_GOOGLE)
+
+if(HAVE_LDAP)
+       add_subdirectory(ldap)
+endif(HAVE_LDAP)
+
+add_subdirectory(webdav)
diff --git a/addressbook/backends/file/CMakeLists.txt b/addressbook/backends/file/CMakeLists.txt
new file mode 100644
index 0000000..bed2a0b
--- /dev/null
+++ b/addressbook/backends/file/CMakeLists.txt
@@ -0,0 +1,57 @@
+set(DEPENDENCIES
+       ebackend
+       ebook
+       ebook-contacts
+       edataserver
+       edata-book
+)
+
+set(SOURCES
+       e-book-backend-file.c
+       e-book-backend-file.h
+       e-book-backend-file-factory.c
+)
+
+if(HAVE_LIBDB)
+       list(APPEND SOURCES
+               e-book-backend-file-migrate-bdb.c
+               e-book-backend-file-migrate-bdb.h
+       )
+endif(HAVE_LIBDB)
+
+add_library(ebookbackendfile MODULE
+       ${SOURCES}
+)
+
+add_dependencies(ebookbackendfile
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(ebookbackendfile PRIVATE
+       -DG_LOG_DOMAIN=\"e-book-backend-file\"
+       -DBACKENDDIR=\"${ebook_backenddir}\"
+)
+
+target_compile_options(ebookbackendfile PUBLIC
+       ${ADDRESSBOOK_CFLAGS}
+       ${LIBDB_CFLAGS}
+)
+
+target_include_directories(ebookbackendfile PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_BINARY_DIR}/addressbook
+       ${CMAKE_SOURCE_DIR}/addressbook
+       ${ADDRESSBOOK_INCLUDE_DIRS}
+       ${LIBDB_INCLUDE_DIRS}
+)
+
+target_link_libraries(ebookbackendfile
+       ${DEPENDENCIES}
+       ${ADDRESSBOOK_LDFLAGS}
+       ${LIBDB_LIBS}
+)
+
+install(TARGETS ebookbackendfile
+       DESTINATION ${ebook_backenddir}
+)
diff --git a/addressbook/backends/file/e-book-backend-file-factory.c 
b/addressbook/backends/file/e-book-backend-file-factory.c
index 7ab6a7c..8317544 100644
--- a/addressbook/backends/file/e-book-backend-file-factory.c
+++ b/addressbook/backends/file/e-book-backend-file-factory.c
@@ -19,7 +19,7 @@
  * Authors: Chris Toshok <toshok ximian com>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include "e-book-backend-file.h"
 
diff --git a/addressbook/backends/file/e-book-backend-file-migrate-bdb.c 
b/addressbook/backends/file/e-book-backend-file-migrate-bdb.c
index a33e91e..38b7a13 100644
--- a/addressbook/backends/file/e-book-backend-file-migrate-bdb.c
+++ b/addressbook/backends/file/e-book-backend-file-migrate-bdb.c
@@ -21,7 +21,7 @@
  * Based on work by Nat Friedman, Chris Toshok and Hans Petter Jansson.
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/addressbook/backends/file/e-book-backend-file.c b/addressbook/backends/file/e-book-backend-file.c
index 28eaf63..3bc0e05 100644
--- a/addressbook/backends/file/e-book-backend-file.c
+++ b/addressbook/backends/file/e-book-backend-file.c
@@ -23,7 +23,7 @@
  *          Tristan Van Berkom <tristanvb openismus com>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/addressbook/backends/google/CMakeLists.txt b/addressbook/backends/google/CMakeLists.txt
new file mode 100644
index 0000000..21ac8b9
--- /dev/null
+++ b/addressbook/backends/google/CMakeLists.txt
@@ -0,0 +1,100 @@
+set(DEPENDENCIES
+       ebackend
+       ebook
+       ebook-contacts
+       edataserver
+       edata-book
+)
+
+add_library(ebookbackendgoogle MODULE
+       e-book-backend-google-factory.c
+       e-book-backend-google.c
+       e-book-backend-google.h
+       e-book-google-utils.c
+       e-book-google-utils.h
+       e-gdata-oauth2-authorizer.c
+       e-gdata-oauth2-authorizer.h
+)
+
+add_dependencies(ebookbackendgoogle
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(ebookbackendgoogle PRIVATE
+       -DG_LOG_DOMAIN=\"e-book-backend-google\"
+       -DBACKENDDIR=\"${ebook_backenddir}\"
+)
+
+target_compile_options(ebookbackendgoogle PUBLIC
+       ${ADDRESSBOOK_CFLAGS}
+       ${LIBGDATA_CFLAGS}
+)
+
+target_include_directories(ebookbackendgoogle PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_BINARY_DIR}/addressbook
+       ${CMAKE_SOURCE_DIR}/addressbook
+       ${ADDRESSBOOK_INCLUDE_DIRS}
+       ${LIBGDATA_INCLUDE_DIRS}
+)
+
+target_link_libraries(ebookbackendgoogle
+       ${DEPENDENCIES}
+       ${ADDRESSBOOK_LDFLAGS}
+       ${LIBGDATA_LDFLAGS}
+)
+
+install(TARGETS ebookbackendgoogle
+       DESTINATION ${ebook_backenddir}
+)
+
+# Private utility library.
+# This is split out to allow it to be unit tested.
+
+set(SOURCES
+       e-book-google-utils.c
+       e-book-google-utils.h
+)
+
+add_library(ebook-google-utils STATIC
+       ${SOURCES}
+)
+
+add_dependencies(ebook-google-utils
+       ebackend
+       ebook
+       ebook-contacts
+       edataserver
+       edata-book
+)
+
+target_compile_definitions(ebook-google-utils PRIVATE
+       -DG_LOG_DOMAIN=\"e-book-google-utils\"
+)
+
+target_compile_options(ebook-google-utils PUBLIC
+       ${ADDRESSBOOK_CFLAGS}
+       ${LIBGDATA_CFLAGS}
+)
+
+target_include_directories(ebook-google-utils PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_BINARY_DIR}/addressbook
+       ${CMAKE_SOURCE_DIR}/addressbook
+       ${ADDRESSBOOK_INCLUDE_DIRS}
+       ${LIBGDATA_INCLUDE_DIRS}
+)
+
+target_link_libraries(ebook-google-utils
+       ebackend
+       ebook
+       ebook-contacts
+       edataserver
+       edata-book
+       ${ADDRESSBOOK_LDFLAGS}
+       ${LIBGDATA_LDFLAGS}
+)
+
+add_subdirectory(tests)
diff --git a/addressbook/backends/google/e-book-backend-google-factory.c 
b/addressbook/backends/google/e-book-backend-google-factory.c
index a0ea5d3..68b4d51 100644
--- a/addressbook/backends/google/e-book-backend-google-factory.c
+++ b/addressbook/backends/google/e-book-backend-google-factory.c
@@ -17,7 +17,7 @@
  * Authors: Joergen Scheibengruber <joergen.scheibengruber AT googlemail.com>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include "e-book-backend-google.h"
 
diff --git a/addressbook/backends/google/e-book-backend-google.c 
b/addressbook/backends/google/e-book-backend-google.c
index fc30395..1284c0e 100644
--- a/addressbook/backends/google/e-book-backend-google.c
+++ b/addressbook/backends/google/e-book-backend-google.c
@@ -19,7 +19,8 @@
  *          Philip Withnall <philip tecnocode co uk>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <string.h>
 #include <errno.h>
 
diff --git a/addressbook/backends/google/e-book-google-utils.c 
b/addressbook/backends/google/e-book-google-utils.c
index 6544b02..ceb75b0 100644
--- a/addressbook/backends/google/e-book-google-utils.c
+++ b/addressbook/backends/google/e-book-google-utils.c
@@ -19,7 +19,8 @@
  *          Philip Withnall <philip tecnocode co uk>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <string.h>
 #include <errno.h>
 
diff --git a/addressbook/backends/google/tests/CMakeLists.txt 
b/addressbook/backends/google/tests/CMakeLists.txt
new file mode 100644
index 0000000..f4edf6f
--- /dev/null
+++ b/addressbook/backends/google/tests/CMakeLists.txt
@@ -0,0 +1,38 @@
+set(DEPENDENCIES
+       ebook-google-utils
+)
+
+add_executable(ebookbackendgoogle-phonenumber
+       EXCLUDE_FROM_ALL
+       phone-numbers.c
+)
+
+add_dependencies(ebookbackendgoogle-phonenumber
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(ebookbackendgoogle-phonenumber PRIVATE
+       -DG_LOG_DOMAIN=\"ebookbackendgoogle-phonenumber\"
+)
+
+target_compile_options(ebookbackendgoogle-phonenumber PUBLIC
+       ${ADDRESSBOOK_CFLAGS}
+       ${LIBGDATA_CFLAGS}
+)
+
+target_include_directories(ebookbackendgoogle-phonenumber PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/addressbook/backends/google
+       ${CMAKE_CURRENT_SOURCE_DIR}
+       ${ADDRESSBOOK_INCLUDE_DIRS}
+       ${LIBGDATA_INCLUDE_DIRS}
+)
+
+target_link_libraries(ebookbackendgoogle-phonenumber
+       ${DEPENDENCIES}
+       ${ADDRESSBOOK_LDFLAGS}
+       ${LIBGDATA_LDFLAGS}
+)
+
+add_check_test(ebookbackendgoogle-phonenumber)
diff --git a/addressbook/backends/ldap/CMakeLists.txt b/addressbook/backends/ldap/CMakeLists.txt
new file mode 100644
index 0000000..73aef66
--- /dev/null
+++ b/addressbook/backends/ldap/CMakeLists.txt
@@ -0,0 +1,50 @@
+set(DEPENDENCIES
+       ebackend
+       ebook
+       ebook-contacts
+       edataserver
+       edata-book
+)
+
+add_library(ebookbackendldap MODULE
+       e-book-backend-ldap.c
+       e-book-backend-ldap.h
+       e-book-backend-ldap-factory.c
+)
+
+add_dependencies(ebookbackendldap
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(ebookbackendldap PRIVATE
+       -DG_LOG_DOMAIN=\"e-book-backend-ldap\"
+       -DBACKENDDIR=\"${ebook_backenddir}\"
+)
+
+target_compile_options(ebookbackendldap PUBLIC
+       ${ADDRESSBOOK_CFLAGS}
+       ${LDAP_CFLAGS}
+)
+
+target_include_directories(ebookbackendldap PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_BINARY_DIR}/addressbook
+       ${CMAKE_SOURCE_DIR}/addressbook
+       ${ADDRESSBOOK_INCLUDE_DIRS}
+       ${LDAP_INCLUDE_DIRS}
+)
+
+target_link_libraries(ebookbackendldap
+       ${DEPENDENCIES}
+       ${ADDRESSBOOK_LDFLAGS}
+       ${LDAP_LIBS}
+)
+
+install(TARGETS ebookbackendldap
+       DESTINATION ${ebook_backenddir}
+)
+
+install(FILES evolutionperson.schema
+       DESTINATION ${privdatadir}
+)
diff --git a/addressbook/backends/ldap/e-book-backend-ldap-factory.c 
b/addressbook/backends/ldap/e-book-backend-ldap-factory.c
index 2d069a1..f8d36c0 100644
--- a/addressbook/backends/ldap/e-book-backend-ldap-factory.c
+++ b/addressbook/backends/ldap/e-book-backend-ldap-factory.c
@@ -19,9 +19,7 @@
  * Authors: Chris Toshok <toshok ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-book-backend-ldap.h"
 
diff --git a/addressbook/backends/ldap/e-book-backend-ldap.c b/addressbook/backends/ldap/e-book-backend-ldap.c
index 93d5f8a..2940c42 100644
--- a/addressbook/backends/ldap/e-book-backend-ldap.c
+++ b/addressbook/backends/ldap/e-book-backend-ldap.c
@@ -22,9 +22,7 @@
 
 #define DEBUG
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdlib.h>
 #include <fcntl.h>
diff --git a/addressbook/backends/webdav/CMakeLists.txt b/addressbook/backends/webdav/CMakeLists.txt
new file mode 100644
index 0000000..ad5a104
--- /dev/null
+++ b/addressbook/backends/webdav/CMakeLists.txt
@@ -0,0 +1,43 @@
+set(DEPENDENCIES
+       ebackend
+       ebook
+       ebook-contacts
+       edataserver
+       edata-book
+)
+
+add_library(ebookbackendwebdav MODULE
+       e-book-backend-webdav.c
+       e-book-backend-webdav.h
+       e-book-backend-webdav-factory.c
+)
+
+add_dependencies(ebookbackendwebdav
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(ebookbackendwebdav PRIVATE
+       -DG_LOG_DOMAIN=\"e-book-backend-webdav\"
+       -DBACKENDDIR=\"${ebook_backenddir}\"
+)
+
+target_compile_options(ebookbackendwebdav PUBLIC
+       ${ADDRESSBOOK_CFLAGS}
+)
+
+target_include_directories(ebookbackendwebdav PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_BINARY_DIR}/addressbook
+       ${CMAKE_SOURCE_DIR}/addressbook
+       ${ADDRESSBOOK_INCLUDE_DIRS}
+)
+
+target_link_libraries(ebookbackendwebdav
+       ${DEPENDENCIES}
+       ${ADDRESSBOOK_LDFLAGS}
+)
+
+install(TARGETS ebookbackendwebdav
+       DESTINATION ${ebook_backenddir}
+)
diff --git a/addressbook/backends/webdav/e-book-backend-webdav-factory.c 
b/addressbook/backends/webdav/e-book-backend-webdav-factory.c
index 5137626..1887ef0 100644
--- a/addressbook/backends/webdav/e-book-backend-webdav-factory.c
+++ b/addressbook/backends/webdav/e-book-backend-webdav-factory.c
@@ -17,7 +17,7 @@
  * Authors: Matthias Braun <matze braunis de>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include "e-book-backend-webdav.h"
 
diff --git a/addressbook/backends/webdav/e-book-backend-webdav.c 
b/addressbook/backends/webdav/e-book-backend-webdav.c
index 70138a0..97b6750 100644
--- a/addressbook/backends/webdav/e-book-backend-webdav.c
+++ b/addressbook/backends/webdav/e-book-backend-webdav.c
@@ -23,7 +23,7 @@
  *   ETags are saved in the WEBDAV_CONTACT_ETAG field so we know which cached contacts
  *   are outdated.
  */
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/addressbook/libebook-contacts/CMakeLists.txt b/addressbook/libebook-contacts/CMakeLists.txt
new file mode 100644
index 0000000..aabedc9
--- /dev/null
+++ b/addressbook/libebook-contacts/CMakeLists.txt
@@ -0,0 +1,164 @@
+glib_mkenums(e-book-contacts-enumtypes e-book-contacts-types.h E_BOOK_CONTACTS_ENUMTYPES_H)
+
+add_pkgconfig_file(libebook-contacts.pc.in libebook-contacts-${API_VERSION}.pc)
+
+add_custom_command(
+       OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/e-name-western-tables.h
+       COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/gen-western-table.py 
<${CMAKE_CURRENT_SOURCE_DIR}/e-name-western-tables.h.in >${CMAKE_CURRENT_BINARY_DIR}/e-name-western-tables.h
+       DEPENDS gen-western-table.py e-name-western-tables.h.in
+)
+
+set(DEPENDENCIES
+       camel
+       edataserver
+)
+
+set(SOURCES
+       e-address-western.c
+       e-book-contacts-types.c
+       e-book-query.c
+       e-contact.c
+       e-name-western.c
+       e-phone-number.c
+       e-phone-number-private.h
+       e-source-backend-summary-setup.c
+       e-vcard.c
+       ${CMAKE_CURRENT_BINARY_DIR}/e-book-contacts-enumtypes.c
+       ${CMAKE_CURRENT_BINARY_DIR}/e-name-western-tables.h
+)
+
+set(HEADERS
+       libebook-contacts.h
+       e-address-western.h
+       e-book-contacts-types.h
+       e-book-query.h
+       e-contact.h
+       e-name-western.h
+       e-phone-number.h
+       e-source-backend-summary-setup.h
+       e-vcard.h
+       ${CMAKE_CURRENT_BINARY_DIR}/e-book-contacts-enumtypes.h
+)
+
+if(ENABLE_PHONENUMBER)
+       # We put the C++ code into a separate static library, so that we can use
+       # the C linker for libebook-contacts. This avoids that libebook-contacts
+       # depends on the C++ Standard Library, even if phone number support is
+       # disabled.
+
+       add_library(ephonenumber-private STATIC
+               e-alphabet-index-private.cpp
+               e-transliterator-private.cpp
+       )
+
+       target_compile_definitions(ephonenumber-private PRIVATE
+               -DG_LOG_DOMAIN=\"e-phone-number\"
+               -DLIBEBOOK_CONTACTS_COMPILATION
+       )
+
+       target_compile_options(ephonenumber-private PUBLIC
+               ${PHONENUMBER_CXXFLAGS}
+       )
+
+       target_include_directories(ephonenumber-private PUBLIC
+               ${CMAKE_BINARY_DIR}
+               ${CMAKE_CURRENT_BINARY_DIR}
+               ${PHONENUMBER_INCLUDE_DIRS}
+       )
+
+       target_link_libraries(ephonenumber-private
+               ${PHONENUMBER_LDFLAGS}
+       )
+
+       list(APPEND DEPENDENCIES
+               ephonenumber-private
+       )
+endif(ENABLE_PHONENUMBER)
+
+add_library(ebook-contacts SHARED
+       ${SOURCES}
+       ${HEADERS}
+)
+
+add_dependencies(ebook-contacts
+       ${DEPENDENCIES}
+)
+
+set_target_properties(ebook-contacts PROPERTIES
+       VERSION "${LIBEBOOK_CONTACTS_CURRENT}.${LIBEBOOK_CONTACTS_REVISION}.${LIBEBOOK_CONTACTS_AGE}"
+       SOVERSION ${LIBEBOOK_CONTACTS_CURRENT}
+       OUTPUT_NAME ebook-contacts-${API_VERSION}
+)
+
+target_compile_definitions(ebook-contacts PRIVATE
+       -DG_LOG_DOMAIN=\"libebook-contacts\"
+       -DLOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+       -DLIBEBOOK_CONTACTS_COMPILATION
+)
+
+target_compile_options(ebook-contacts PUBLIC
+       ${ADDRESSBOOK_CFLAGS}
+)
+
+target_include_directories(ebook-contacts PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/addressbook
+       ${CMAKE_BINARY_DIR}/addressbook/libegdbus
+       ${CMAKE_BINARY_DIR}/private
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/private
+       ${CMAKE_SOURCE_DIR}/addressbook
+       ${CMAKE_SOURCE_DIR}/addressbook/libegdbus
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${ADDRESSBOOK_INCLUDE_DIRS}
+)
+
+target_link_libraries(ebook-contacts
+       ${DEPENDENCIES}
+       ${ADDRESSBOOK_LDFLAGS}
+)
+
+install(TARGETS ebook-contacts
+       DESTINATION ${LIB_INSTALL_DIR}
+)
+
+install(FILES ${HEADERS}
+       DESTINATION ${privincludedir}/libebook-contacts
+)
+
+set(gir_sources ${SOURCES} ${HEADERS})
+set(gir_identifies_prefixes E)
+set(gir_includes GObject-2.0 GLib-2.0 Gio-2.0 libxml2-2.0)
+set(gir_cflags
+       ${CAMEL_CFLAGS} ${DATA_SERVER_CFLAGS}
+       -DLIBEBOOK_CONTACTS_COMPILATION
+       -I${CMAKE_BINARY_DIR}/addressbook
+       -I${CMAKE_BINARY_DIR}/addressbook/libebook-contacts
+       -I${CMAKE_SOURCE_DIR}/addressbook
+       -I${CMAKE_SOURCE_DIR}/addressbook/libebook-contacts
+)
+set(gir_libdirs
+       ${CMAKE_BINARY_DIR}/private
+       ${CMAKE_BINARY_DIR}/libedataserver
+)
+set(gir_libs
+       ebook-contacts
+       edataserver
+)
+set(gir_deps
+       ${CMAKE_BINARY_DIR}/libedataserver/EDataServer-${API_VERSION}.gir
+)
+
+gir_add_introspection_simple(
+       EBookContacts
+       libebook-contacts
+       ${API_VERSION}
+       "libebook-contacts/libebook-contacts.h"
+       gir_identifies_prefixes
+       gir_includes
+       gir_cflags
+       gir_libdirs
+       gir_libs
+       gir_deps
+       gir_sources
+)
diff --git a/addressbook/libebook-contacts/e-book-contacts-types.c 
b/addressbook/libebook-contacts/e-book-contacts-types.c
index bf04dcf..7d1bfee 100644
--- a/addressbook/libebook-contacts/e-book-contacts-types.c
+++ b/addressbook/libebook-contacts/e-book-contacts-types.c
@@ -12,9 +12,7 @@
  * along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n-lib.h>
 
diff --git a/addressbook/libebook-contacts/e-book-query.c b/addressbook/libebook-contacts/e-book-query.c
index 3604bae..214ac8e 100644
--- a/addressbook/libebook-contacts/e-book-query.c
+++ b/addressbook/libebook-contacts/e-book-query.c
@@ -31,9 +31,7 @@
  * #EBookClientView and #EBookClientCursor interfaces.
  **/
 
-#include "e-book-query.h"
-
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include <locale.h>
 #include <stdarg.h>
@@ -41,6 +39,8 @@
 
 #include <libedataserver/libedataserver.h>
 
+#include "e-book-query.h"
+
 #ifdef G_OS_WIN32
 #ifndef LC_MESSAGES
 #define LC_MESSAGES LC_CTYPE
diff --git a/addressbook/libebook-contacts/e-contact.c b/addressbook/libebook-contacts/e-contact.c
index 5ac55e9..dea9dce 100644
--- a/addressbook/libebook-contacts/e-contact.c
+++ b/addressbook/libebook-contacts/e-contact.c
@@ -30,9 +30,7 @@
  * vCards in the form of an #EContact for your convenience.
  **/
 
-#if HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <ctype.h>
diff --git a/addressbook/libebook-contacts/e-phone-number-private.cpp 
b/addressbook/libebook-contacts/e-phone-number-private.cpp
index b539bc4..4c5aebb 100644
--- a/addressbook/libebook-contacts/e-phone-number-private.cpp
+++ b/addressbook/libebook-contacts/e-phone-number-private.cpp
@@ -17,9 +17,7 @@
  * Authors: Mathias Hasselmann <mathias openismus com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #ifndef ENABLE_PHONENUMBER
 #error Phone number support must be enabled for this file
diff --git a/addressbook/libebook-contacts/e-phone-number.c b/addressbook/libebook-contacts/e-phone-number.c
index 180c39a..88d6807 100644
--- a/addressbook/libebook-contacts/e-phone-number.c
+++ b/addressbook/libebook-contacts/e-phone-number.c
@@ -17,9 +17,7 @@
  * Authors: Mathias Hasselmann <mathias openismus com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-phone-number.h"
 
diff --git a/addressbook/libebook-contacts/libebook-contacts.pc.in 
b/addressbook/libebook-contacts/libebook-contacts.pc.in
index d1396fb..30c4955 100644
--- a/addressbook/libebook-contacts/libebook-contacts.pc.in
+++ b/addressbook/libebook-contacts/libebook-contacts.pc.in
@@ -1,16 +1,15 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-datarootdir=@datarootdir@
-datadir=@datadir@
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+includedir=@INCLUDE_INSTALL_DIR@
+datarootdir=@SHARE_INSTALL_DIR@
+datadir=@SHARE_INSTALL_DIR@
 
 privincludedir=@privincludedir@
 
 Name: libebook-contacts
 Description: Client library for evolution contacts and vcard structures
-Version: @VERSION@
-Requires: libedataserver-1.2
-Requires.private: camel-1.2
-Libs: -L${libdir} -lebook-contacts-1.2
+Version: @PROJECT_VERSION@
+Requires: libedataserver-@API_VERSION@
+Requires.private: camel-@API_VERSION@
+Libs: -L${libdir} -lebook-contacts-@API_VERSION@
 Cflags: -I${privincludedir}
diff --git a/addressbook/libebook/CMakeLists.txt b/addressbook/libebook/CMakeLists.txt
new file mode 100644
index 0000000..06da3ec
--- /dev/null
+++ b/addressbook/libebook/CMakeLists.txt
@@ -0,0 +1,130 @@
+glib_mkenums(e-book-enumtypes e-book-types.h E_BOOK_ENUMTYPES_H)
+
+add_pkgconfig_file(libebook.pc.in libebook-${API_VERSION}.pc)
+
+set(DEPENDENCIES
+       camel
+       ebackend
+       ebook-contacts
+       edbus-private
+       edataserver
+       edata-book
+       egdbus-book
+)
+
+set(SOURCES
+       e-book.c
+       e-book-client.c
+       e-book-client-cursor.c
+       e-book-client-view.c
+       e-book-view-private.h
+       e-book-view.c
+       e-destination.c
+       e-error.h
+       ${CMAKE_CURRENT_BINARY_DIR}/e-book-enumtypes.c
+)
+
+set(HEADERS
+       libebook.h
+       e-book.h
+       e-book-client.h
+       e-book-client-cursor.h
+       e-book-client-view.h
+       e-book-view.h
+       e-book-types.h
+       e-destination.h
+       ${CMAKE_CURRENT_BINARY_DIR}/e-book-enumtypes.h
+)
+
+add_library(ebook SHARED
+       ${SOURCES}
+       ${HEADERS}
+)
+
+add_dependencies(ebook
+       ${DEPENDENCIES}
+)
+
+set_target_properties(ebook PROPERTIES
+       VERSION "${LIBEBOOK_CURRENT}.${LIBEBOOK_REVISION}.${LIBEBOOK_AGE}"
+       SOVERSION ${LIBEBOOK_CURRENT}
+       OUTPUT_NAME ebook-${API_VERSION}
+)
+
+target_compile_definitions(ebook PRIVATE
+       -DG_LOG_DOMAIN=\"libebook\"
+       -DLOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+       -DLIBEBOOK_COMPILATION
+)
+
+target_compile_options(ebook PUBLIC
+       ${ADDRESSBOOK_CFLAGS}
+)
+
+target_include_directories(ebook PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/addressbook
+       ${CMAKE_BINARY_DIR}/addressbook/libegdbus
+       ${CMAKE_BINARY_DIR}/private
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/private
+       ${CMAKE_SOURCE_DIR}/addressbook
+       ${CMAKE_SOURCE_DIR}/addressbook/libegdbus
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${ADDRESSBOOK_INCLUDE_DIRS}
+)
+
+target_link_libraries(ebook
+       ${DEPENDENCIES}
+       ${ADDRESSBOOK_LDFLAGS}
+)
+
+install(TARGETS ebook
+       DESTINATION ${LIB_INSTALL_DIR}
+)
+
+install(FILES ${HEADERS}
+       DESTINATION ${privincludedir}/libebook
+)
+
+set(gir_sources ${SOURCES} ${HEADERS})
+set(gir_identifies_prefixes E)
+set(gir_includes GObject-2.0 GLib-2.0 Gio-2.0 libxml2-2.0)
+set(gir_cflags
+       ${CAMEL_CFLAGS} ${DATA_SERVER_CFLAGS}
+       -DLIBEBOOK_COMPILATION
+       -I${CMAKE_BINARY_DIR}/addressbook
+       -I${CMAKE_BINARY_DIR}/addressbook/libebook
+       -I${CMAKE_SOURCE_DIR}/addressbook
+       -I${CMAKE_SOURCE_DIR}/addressbook/libebook
+)
+set(gir_libdirs
+       ${CMAKE_BINARY_DIR}/private
+       ${CMAKE_BINARY_DIR}/libedataserver
+       ${CMAKE_BINARY_DIR}/addressbook/libebook-contacts
+       ${CMAKE_BINARY_DIR}/addressbook/libedata-book
+)
+set(gir_libs
+       ebook
+       ebook-contacts
+       edata-book
+       edataserver
+)
+set(gir_deps
+       ${CMAKE_BINARY_DIR}/libedataserver/EDataServer-${API_VERSION}.gir
+       ${CMAKE_BINARY_DIR}/addressbook/libebook-contacts/EBookContacts-${API_VERSION}.gir
+)
+
+gir_add_introspection_simple(
+       EBook
+       libebook
+       ${API_VERSION}
+       "libebook/libebook.h"
+       gir_identifies_prefixes
+       gir_includes
+       gir_cflags
+       gir_libdirs
+       gir_libs
+       gir_deps
+       gir_sources
+)
diff --git a/addressbook/libebook/e-book-client-cursor.c b/addressbook/libebook/e-book-client-cursor.c
index 30a1f2a..7a8b240 100644
--- a/addressbook/libebook/e-book-client-cursor.c
+++ b/addressbook/libebook/e-book-client-cursor.c
@@ -453,9 +453,7 @@
  * </refsect2>
  *
  */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n-lib.h>
 
diff --git a/addressbook/libebook/e-book-client-view.c b/addressbook/libebook/e-book-client-view.c
index be4df5c..01b9049 100644
--- a/addressbook/libebook/e-book-client-view.c
+++ b/addressbook/libebook/e-book-client-view.c
@@ -29,9 +29,7 @@
  * to create an #EBookClientView.
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n-lib.h>
 
diff --git a/addressbook/libebook/e-book-client.c b/addressbook/libebook/e-book-client.c
index a037605..3fc2091 100644
--- a/addressbook/libebook/e-book-client.c
+++ b/addressbook/libebook/e-book-client.c
@@ -27,9 +27,7 @@
  * the addressbook.
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <locale.h>
 #include <glib/gi18n-lib.h>
diff --git a/addressbook/libebook/e-book.c b/addressbook/libebook/e-book.c
index 1412b63..087ef47 100644
--- a/addressbook/libebook/e-book.c
+++ b/addressbook/libebook/e-book.c
@@ -33,7 +33,8 @@
  * Deprecated: 3.2: Use #EBookClient instead.
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <unistd.h>
 #include <string.h>
 #include <glib/gi18n-lib.h>
diff --git a/addressbook/libebook/e-destination.c b/addressbook/libebook/e-destination.c
index 85d1163..599e4bc 100644
--- a/addressbook/libebook/e-destination.c
+++ b/addressbook/libebook/e-destination.c
@@ -29,7 +29,8 @@
  * _get_*() functions.
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include "e-destination.h"
 
 #include <stdlib.h>
diff --git a/addressbook/libebook/libebook.pc.in b/addressbook/libebook/libebook.pc.in
index 293cdc0..c5b2ed2 100644
--- a/addressbook/libebook/libebook.pc.in
+++ b/addressbook/libebook/libebook.pc.in
@@ -1,16 +1,15 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-datarootdir=@datarootdir@
-datadir=@datadir@
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+includedir=@INCLUDE_INSTALL_DIR@
+datarootdir=@SHARE_INSTALL_DIR@
+datadir=@SHARE_INSTALL_DIR@
 
 privincludedir=@privincludedir@
 
 Name: libebook
 Description: Client library for evolution address books
-Version: @VERSION@
-Requires: libedataserver-1.2 libebook-contacts-1.2 libedata-book-1.2
-Requires.private: camel-1.2
-Libs: -L${libdir} -lebook-1.2
+Version: @PROJECT_VERSION@
+Requires: libedataserver-@API_VERSION@ libebook-contacts-@API_VERSION@ libedata-book-@API_VERSION@
+Requires.private: camel-@API_VERSION@
+Libs: -L${libdir} -lebook-@API_VERSION@
 Cflags: -I${privincludedir}
diff --git a/addressbook/libedata-book/CMakeLists.txt b/addressbook/libedata-book/CMakeLists.txt
new file mode 100644
index 0000000..44bc75f
--- /dev/null
+++ b/addressbook/libedata-book/CMakeLists.txt
@@ -0,0 +1,196 @@
+add_pkgconfig_file(libedata-book.pc.in libedata-book-${API_VERSION}.pc)
+
+set(DEPENDENCIES
+       camel
+       ebackend
+       ebook-contacts
+       edbus-private
+       edataserver
+       egdbus-book
+)
+
+set(SOURCES
+       e-book-backend-factory.c
+       e-book-backend-sexp.c
+       e-book-backend-summary.c
+       e-book-backend-cache.c
+       e-book-backend-sqlitedb.c
+       e-book-backend.c
+       e-book-sqlite.c
+       e-data-book.c
+       e-data-book-cursor.c
+       e-data-book-cursor-sqlite.c
+       e-data-book-direct.c
+       e-data-book-factory.c
+       e-data-book-view.c
+       e-subprocess-book-factory.c
+       ximian-vcard.h
+)
+
+set(HEADERS
+       libedata-book.h
+       e-book-backend-factory.h
+       e-book-backend-sexp.h
+       e-book-backend-summary.h
+       e-book-backend.h
+       e-data-book-factory.h
+       e-data-book-view.h
+       e-data-book.h
+       e-data-book-cursor.h
+       e-data-book-cursor-sqlite.h
+       e-data-book-direct.h
+       e-book-backend-cache.h
+       e-book-backend-sqlitedb.h
+       e-book-sqlite.h
+       e-subprocess-book-factory.h
+)
+
+if(WITH_LIBDB)
+       list(APPEND SOURCES
+               e-book-backend-db-cache.c
+       )
+
+       list(APPEND HEADERS
+               e-book-backend-db-cache.h
+       )
+endif(WITH_LIBDB)
+
+add_library(edata-book SHARED
+       ${SOURCES}
+       ${HEADERS}
+)
+
+add_dependencies(edata-book
+       ${DEPENDENCIES}
+)
+
+set_target_properties(edata-book PROPERTIES
+       VERSION "${LIBEDATABOOK_CURRENT}.${LIBEDATABOOK_REVISION}.${LIBEDATABOOK_AGE}"
+       SOVERSION ${LIBEDATABOOK_CURRENT}
+       OUTPUT_NAME edata-book-${API_VERSION}
+)
+
+target_compile_definitions(edata-book PRIVATE
+       -DG_LOG_DOMAIN=\"libedata-book\"
+       -DBACKENDDIR=\"${ebook_backenddir}\"
+       -DSUBPROCESS_BOOK_BACKEND_PATH=\"${LIBEXEC_INSTALL_DIR}/evolution-addressbook-factory-subprocess\"
+       -DLIBEDATA_BOOK_COMPILATION
+)
+
+target_compile_options(edata-book PUBLIC
+       ${ADDRESSBOOK_CFLAGS}
+       ${LIBDB_CFLAGS}
+       ${SQLITE3_CFLAGS}
+)
+
+target_include_directories(edata-book PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/addressbook
+       ${CMAKE_BINARY_DIR}/addressbook/libegdbus
+       ${CMAKE_BINARY_DIR}/private
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/private
+       ${CMAKE_SOURCE_DIR}/addressbook
+       ${CMAKE_SOURCE_DIR}/addressbook/libegdbus
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${ADDRESSBOOK_INCLUDE_DIRS}
+       ${LIBDB_INCLUDE_DIRS}
+       ${SQLITE3_INCLUDE_DIRS}
+)
+
+target_link_libraries(edata-book
+       ${DEPENDENCIES}
+       ${ADDRESSBOOK_LDFLAGS}
+       ${LIBDB_LIBS}
+       ${SQLITE3_LDFLAGS}
+)
+
+install(TARGETS edata-book
+       DESTINATION ${LIB_INSTALL_DIR}
+)
+
+install(FILES ${HEADERS}
+       DESTINATION ${privincludedir}/libedata-book
+)
+
+add_executable(e-book-backend-sqlitedb-test EXCLUDE_FROM_ALL e-book-backend-sqlitedb-test.c)
+
+target_compile_definitions(e-book-backend-sqlitedb-test PRIVATE
+       -DG_LOG_DOMAIN=\"libedata-book\"
+       -DBACKENDDIR=\"${ebook_backenddir}\"
+       -DSUBPROCESS_BOOK_BACKEND_PATH=\"${LIBEXEC_INSTALL_DIR}/evolution-addressbook-factory-subprocess\"
+       -DLIBEDATA_BOOK_COMPILATION
+)
+
+target_compile_options(e-book-backend-sqlitedb-test PUBLIC
+       ${ADDRESSBOOK_CFLAGS}
+       ${LIBDB_CFLAGS}
+       ${SQLITE3_CFLAGS}
+)
+
+target_include_directories(e-book-backend-sqlitedb-test PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/addressbook
+       ${CMAKE_BINARY_DIR}/addressbook/libegdbus
+       ${CMAKE_BINARY_DIR}/private
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/private
+       ${CMAKE_SOURCE_DIR}/addressbook
+       ${CMAKE_SOURCE_DIR}/addressbook/libegdbus
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${ADDRESSBOOK_INCLUDE_DIRS}
+       ${LIBDB_INCLUDE_DIRS}
+       ${SQLITE3_INCLUDE_DIRS}
+)
+
+target_link_libraries(e-book-backend-sqlitedb-test
+       edata-book
+       ${DEPENDENCIES}
+       ${ADDRESSBOOK_LDFLAGS}
+       ${LIBDB_LIBS}
+       ${SQLITE3_LDFLAGS}
+)
+
+set(DEPENDENCIES
+       ebackend
+       edataserver
+       edata-book
+       edbus-private
+)
+
+add_executable(evolution-addressbook-factory-subprocess
+       evolution-addressbook-factory-subprocess.c)
+
+target_compile_definitions(evolution-addressbook-factory-subprocess PRIVATE
+       -DG_LOG_DOMAIN=\"evolution-addressbook-factory-subprocess\"
+       -DLOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+)
+
+target_compile_options(evolution-addressbook-factory-subprocess PUBLIC
+       ${ADDRESSBOOK_CFLAGS}
+       ${GTK_CFLAGS}
+)
+
+target_include_directories(evolution-addressbook-factory-subprocess PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/addressbook
+       ${CMAKE_BINARY_DIR}/addressbook/libegdbus
+       ${CMAKE_BINARY_DIR}/private
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/private
+       ${CMAKE_SOURCE_DIR}/addressbook
+       ${CMAKE_SOURCE_DIR}/addressbook/libegdbus
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${ADDRESSBOOK_INCLUDE_DIRS}
+       ${GTK_INCLUDE_DIRS}
+)
+
+target_link_libraries(evolution-addressbook-factory-subprocess
+       ${DEPENDENCIES}
+       ${ADDRESSBOOK_LDFLAGS}
+       ${GTK_LDFLAGS}
+)
+
+install(TARGETS evolution-addressbook-factory-subprocess
+       DESTINATION ${LIBEXEC_INSTALL_DIR}
+)
diff --git a/addressbook/libedata-book/e-book-backend-cache.c 
b/addressbook/libedata-book/e-book-backend-cache.c
index f29de05..08cd623 100644
--- a/addressbook/libedata-book/e-book-backend-cache.c
+++ b/addressbook/libedata-book/e-book-backend-cache.c
@@ -25,9 +25,7 @@
  *
  * The #EBookBackendCache is deprecated, use #EBookSqlite instead.
  */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/addressbook/libedata-book/e-book-backend-db-cache.c 
b/addressbook/libedata-book/e-book-backend-db-cache.c
index 0081d0b..943d9bc 100644
--- a/addressbook/libedata-book/e-book-backend-db-cache.c
+++ b/addressbook/libedata-book/e-book-backend-db-cache.c
@@ -26,7 +26,8 @@
  * This API is deprecated, use #EBookSqlite instead.
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <stdlib.h>
 #include <string.h>
 
diff --git a/addressbook/libedata-book/e-book-backend-factory.c 
b/addressbook/libedata-book/e-book-backend-factory.c
index 49a682b..27f9843 100644
--- a/addressbook/libedata-book/e-book-backend-factory.c
+++ b/addressbook/libedata-book/e-book-backend-factory.c
@@ -26,7 +26,8 @@
  * backend types.
  **/
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <string.h>
 
 #include "e-book-backend.h"
diff --git a/addressbook/libedata-book/e-book-backend-sqlitedb-test.c 
b/addressbook/libedata-book/e-book-backend-sqlitedb-test.c
index 8eb6062..2a957e9 100644
--- a/addressbook/libedata-book/e-book-backend-sqlitedb-test.c
+++ b/addressbook/libedata-book/e-book-backend-sqlitedb-test.c
@@ -18,7 +18,8 @@
  * Authors: Chenthill Palanisamy <pchenthill novell com>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <libebook-contacts/libebook-contacts.h>
 #include "e-book-backend-sqlitedb.h"
 
diff --git a/addressbook/libedata-book/e-book-backend-summary.c 
b/addressbook/libedata-book/e-book-backend-summary.c
index 2275548..df69281 100644
--- a/addressbook/libedata-book/e-book-backend-summary.c
+++ b/addressbook/libedata-book/e-book-backend-summary.c
@@ -24,9 +24,7 @@
  *
  * The #EBookBackendSummary is deprecated, use #EBookSqlite instead.
  */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 #include <sys/types.h>
diff --git a/addressbook/libedata-book/e-book-backend.c b/addressbook/libedata-book/e-book-backend.c
index dce04ce..9efac67 100644
--- a/addressbook/libedata-book/e-book-backend.c
+++ b/addressbook/libedata-book/e-book-backend.c
@@ -29,7 +29,7 @@
  * addressbook backends must implement methods on this class.
  **/
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n-lib.h>
 
diff --git a/addressbook/libedata-book/e-data-book-cursor-sqlite.c 
b/addressbook/libedata-book/e-data-book-cursor-sqlite.c
index 0fbd2ec..084f907 100644
--- a/addressbook/libedata-book/e-data-book-cursor-sqlite.c
+++ b/addressbook/libedata-book/e-data-book-cursor-sqlite.c
@@ -26,9 +26,7 @@
  * stores contacts using #EBookSqlite.
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n.h>
 
diff --git a/addressbook/libedata-book/e-data-book-cursor.c b/addressbook/libedata-book/e-data-book-cursor.c
index fc01872..7c8fb5b 100644
--- a/addressbook/libedata-book/e-data-book-cursor.c
+++ b/addressbook/libedata-book/e-data-book-cursor.c
@@ -212,9 +212,7 @@
  * </refsect2>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n.h>
 
diff --git a/addressbook/libedata-book/e-data-book-direct.c b/addressbook/libedata-book/e-data-book-direct.c
index 9df6fb1..776fb4f 100644
--- a/addressbook/libedata-book/e-data-book-direct.c
+++ b/addressbook/libedata-book/e-data-book-direct.c
@@ -31,9 +31,7 @@
  * will be created and #EBookBackendClass.configure_direct() will be
  * called on the corresponding client side instance.
  **/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/addressbook/libedata-book/e-data-book-factory.c b/addressbook/libedata-book/e-data-book-factory.c
index 7b247de..ba18068 100644
--- a/addressbook/libedata-book/e-data-book-factory.c
+++ b/addressbook/libedata-book/e-data-book-factory.c
@@ -28,7 +28,8 @@
  * the #EDataBook layer for server side addressbooks to communicate
  * with client side #EBookClient objects.
  **/
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <locale.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/addressbook/libedata-book/e-data-book-view.c b/addressbook/libedata-book/e-data-book-view.c
index d9b8f8d..3f70c4b 100644
--- a/addressbook/libedata-book/e-data-book-view.c
+++ b/addressbook/libedata-book/e-data-book-view.c
@@ -31,9 +31,7 @@
  * which will be delivered to the #EBookClientView
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/addressbook/libedata-book/e-data-book.c b/addressbook/libedata-book/e-data-book.c
index 9c17cb7..58f2ed9 100644
--- a/addressbook/libedata-book/e-data-book.c
+++ b/addressbook/libedata-book/e-data-book.c
@@ -24,9 +24,7 @@
  * an #EBookBackend to satisfy client requests.
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <locale.h>
 #include <unistd.h>
diff --git a/addressbook/libedata-book/e-subprocess-book-factory.c 
b/addressbook/libedata-book/e-subprocess-book-factory.c
index ae4beea..406285f 100644
--- a/addressbook/libedata-book/e-subprocess-book-factory.c
+++ b/addressbook/libedata-book/e-subprocess-book-factory.c
@@ -23,9 +23,7 @@
  * the communication between #EDataBookFactory and #EBackend
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <locale.h>
 #include <stdlib.h>
diff --git a/addressbook/libedata-book/evolution-addressbook-factory-subprocess.c 
b/addressbook/libedata-book/evolution-addressbook-factory-subprocess.c
index e0eaf44..00a6b85 100644
--- a/addressbook/libedata-book/evolution-addressbook-factory-subprocess.c
+++ b/addressbook/libedata-book/evolution-addressbook-factory-subprocess.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <locale.h>
 #include <stdlib.h>
diff --git a/addressbook/libedata-book/libedata-book.pc.in b/addressbook/libedata-book/libedata-book.pc.in
index b1f871b..606edcf 100644
--- a/addressbook/libedata-book/libedata-book.pc.in
+++ b/addressbook/libedata-book/libedata-book.pc.in
@@ -1,10 +1,9 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-libexecdir=@libexecdir@
-includedir=@includedir@
-datarootdir=@datarootdir@
-datadir=@datadir@
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+libexecdir=@LIBEXEC_INSTALL_DIR@
+includedir=@INCLUDE_INSTALL_DIR@
+datarootdir=@SHARE_INSTALL_DIR@
+datadir=@SHARE_INSTALL_DIR@
 
 privlibdir=@privlibdir@
 privincludedir=@privincludedir@
@@ -13,7 +12,7 @@ backenddir=@ebook_backenddir@
 
 Name: libedatabook
 Description: Backend library for evolution address books
-Version: @VERSION@
-Requires: libebackend-1.2 libebook-contacts-1.2
-Libs: -L${libdir} -ledata-book-1.2
+Version: @PROJECT_VERSION@
+Requires: libebackend-@API_VERSION@ libebook-contacts-@API_VERSION@
+Libs: -L${libdir} -ledata-book-@API_VERSION@
 Cflags: -I${privincludedir}
diff --git a/addressbook/libegdbus/CMakeLists.txt b/addressbook/libegdbus/CMakeLists.txt
new file mode 100644
index 0000000..4144d3d
--- /dev/null
+++ b/addressbook/libegdbus/CMakeLists.txt
@@ -0,0 +1,36 @@
+set(SOURCES
+       e-gdbus-book-view.h
+       e-gdbus-book-view.c
+)
+
+set(DEPENDENCIES
+       edataserver
+)
+
+add_library(egdbus-book STATIC
+       ${SOURCES}
+)
+
+add_dependencies(egdbus-book
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(egdbus-book PRIVATE
+       -DG_LOG_DOMAIN=\"egdbus-book\"
+)
+
+target_compile_options(egdbus-book PUBLIC
+       ${DATA_SERVER_CFLAGS}
+)
+
+target_include_directories(egdbus-book PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${DATA_SERVER_INCLUDE_DIRS}
+)
+
+target_link_libraries(egdbus-book
+       ${DEPENDENCIES}
+       ${DATA_SERVER_LDFLAGS}
+)
diff --git a/art/CMakeLists.txt b/art/CMakeLists.txt
new file mode 100644
index 0000000..d74da56
--- /dev/null
+++ b/art/CMakeLists.txt
@@ -0,0 +1,24 @@
+set(IMAGES
+       category_birthday_16.png
+       category_business_16.png
+       category_favorites_16.png
+       category_gifts_16.png
+       category_goals_16.png
+       category_holiday_16.png
+       category_holiday-cards_16.png
+       category_hot-contacts_16.png
+       category_ideas_16.png
+       category_international_16.png
+       category_key-customer_16.png
+       category_miscellaneous_16.png
+       category_personal_16.png
+       category_phonecalls_16.png
+       category_status_16.png
+       category_strategies_16.png
+       category_suppliers_16.png
+       category_time-and-expenses_16.png
+)
+
+install(FILES ${IMAGES}
+       DESTINATION ${imagesdir}
+)
diff --git a/calendar/CMakeLists.txt b/calendar/CMakeLists.txt
new file mode 100644
index 0000000..b555f9e
--- /dev/null
+++ b/calendar/CMakeLists.txt
@@ -0,0 +1,4 @@
+add_subdirectory(backends)
+add_subdirectory(libecal)
+add_subdirectory(libedata-cal)
+add_subdirectory(libegdbus)
diff --git a/calendar/backends/CMakeLists.txt b/calendar/backends/CMakeLists.txt
new file mode 100644
index 0000000..56b8c38
--- /dev/null
+++ b/calendar/backends/CMakeLists.txt
@@ -0,0 +1,12 @@
+add_subdirectory(caldav)
+add_subdirectory(contacts)
+add_subdirectory(file)
+add_subdirectory(http)
+
+if(HAVE_LIBGDATA)
+       add_subdirectory(gtasks)
+endif(HAVE_LIBGDATA)
+
+if(ENABLE_WEATHER)
+       add_subdirectory(weather)
+endif(ENABLE_WEATHER)
diff --git a/calendar/backends/caldav/CMakeLists.txt b/calendar/backends/caldav/CMakeLists.txt
new file mode 100644
index 0000000..d44609d
--- /dev/null
+++ b/calendar/backends/caldav/CMakeLists.txt
@@ -0,0 +1,46 @@
+set(DEPENDENCIES
+       ebackend
+       ecal
+       edataserver
+       edata-cal
+)
+
+set(SOURCES
+       e-cal-backend-caldav-factory.c
+       e-cal-backend-caldav.c
+       e-cal-backend-caldav.h
+)
+
+add_library(ecalbackendcaldav MODULE
+       ${SOURCES}
+)
+
+add_dependencies(ecalbackendcaldav
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(ecalbackendcaldav PRIVATE
+       -DG_LOG_DOMAIN=\"e-cal-backend-caldav\"
+       -DBACKENDDIR=\"${ecal_backenddir}\"
+)
+
+target_compile_options(ecalbackendcaldav PUBLIC
+       ${CALENDAR_CFLAGS}
+)
+
+target_include_directories(ecalbackendcaldav PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_BINARY_DIR}/calendar
+       ${CMAKE_SOURCE_DIR}/calendar
+       ${CALENDAR_INCLUDE_DIRS}
+)
+
+target_link_libraries(ecalbackendcaldav
+       ${DEPENDENCIES}
+       ${CALENDAR_LDFLAGS}
+)
+
+install(TARGETS ecalbackendcaldav
+       DESTINATION ${ecal_backenddir}
+)
diff --git a/calendar/backends/caldav/e-cal-backend-caldav-factory.c 
b/calendar/backends/caldav/e-cal-backend-caldav-factory.c
index 6a54273..1b99c8d 100644
--- a/calendar/backends/caldav/e-cal-backend-caldav-factory.c
+++ b/calendar/backends/caldav/e-cal-backend-caldav-factory.c
@@ -18,7 +18,7 @@
  * Authors: Christian Kellner <gicmo gnome org>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include "e-cal-backend-caldav.h"
 
diff --git a/calendar/backends/caldav/e-cal-backend-caldav.c b/calendar/backends/caldav/e-cal-backend-caldav.c
index 0fe4cb2..f7b69db 100644
--- a/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -18,7 +18,8 @@
  * Authors: Christian Kellner <gicmo gnome org>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <string.h>
 #include <unistd.h>
 #include <glib/gstdio.h>
diff --git a/calendar/backends/contacts/CMakeLists.txt b/calendar/backends/contacts/CMakeLists.txt
new file mode 100644
index 0000000..8e70d2e
--- /dev/null
+++ b/calendar/backends/contacts/CMakeLists.txt
@@ -0,0 +1,50 @@
+set(DEPENDENCIES
+       ebackend
+       ebook
+       ebook-contacts
+       ecal
+       edataserver
+       edata-cal
+)
+
+set(SOURCES
+       e-cal-backend-contacts-factory.c
+       e-cal-backend-contacts.c
+       e-cal-backend-contacts.h
+)
+
+add_library(ecalbackendcontacts MODULE
+       ${SOURCES}
+)
+
+add_dependencies(ecalbackendcontacts
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(ecalbackendcontacts PRIVATE
+       -DG_LOG_DOMAIN=\"e-cal-backend-contacts\"
+       -DBACKENDDIR=\"${ecal_backenddir}\"
+)
+
+target_compile_options(ecalbackendcontacts PUBLIC
+       ${CALENDAR_CFLAGS}
+)
+
+target_include_directories(ecalbackendcontacts PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_BINARY_DIR}/addressbook
+       ${CMAKE_SOURCE_DIR}/addressbook
+       ${CMAKE_BINARY_DIR}/calendar
+       ${CMAKE_SOURCE_DIR}/calendar
+       ${CALENDAR_INCLUDE_DIRS}
+)
+
+target_link_libraries(ecalbackendcontacts
+       ${DEPENDENCIES}
+       ${CALENDAR_LDFLAGS}
+)
+
+install(TARGETS ecalbackendcontacts
+       DESTINATION ${ecal_backenddir}
+)
diff --git a/calendar/backends/contacts/e-cal-backend-contacts-factory.c 
b/calendar/backends/contacts/e-cal-backend-contacts-factory.c
index 10b1eed..d75aa97 100644
--- a/calendar/backends/contacts/e-cal-backend-contacts-factory.c
+++ b/calendar/backends/contacts/e-cal-backend-contacts-factory.c
@@ -17,7 +17,7 @@
  * Authors: Chris Toshok (toshok ximian com)
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include "e-cal-backend-contacts.h"
 
diff --git a/calendar/backends/contacts/e-cal-backend-contacts.c 
b/calendar/backends/contacts/e-cal-backend-contacts.c
index 3187b6e..d2b5708 100644
--- a/calendar/backends/contacts/e-cal-backend-contacts.c
+++ b/calendar/backends/contacts/e-cal-backend-contacts.c
@@ -21,9 +21,7 @@
  *          Gerg� �rdi <cactus cactus rulez org>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/calendar/backends/file/CMakeLists.txt b/calendar/backends/file/CMakeLists.txt
new file mode 100644
index 0000000..2434c49
--- /dev/null
+++ b/calendar/backends/file/CMakeLists.txt
@@ -0,0 +1,79 @@
+set(DEPENDENCIES
+       ebackend
+       ecal
+       edataserver
+       edata-cal
+)
+
+set(SOURCES
+       e-cal-backend-file-factory.c
+       e-cal-backend-file-events.c
+       e-cal-backend-file-events.h
+       e-cal-backend-file-journal.c
+       e-cal-backend-file-journal.h
+       e-cal-backend-file-todos.c
+       e-cal-backend-file-todos.h
+       e-cal-backend-file.c
+       e-cal-backend-file.h
+)
+
+add_library(ecalbackendfile MODULE
+       ${SOURCES}
+)
+
+add_dependencies(ecalbackendfile
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(ecalbackendfile PRIVATE
+       -DG_LOG_DOMAIN=\"e-cal-backend-file\"
+       -DBACKENDDIR=\"${ecal_backenddir}\"
+)
+
+target_compile_options(ecalbackendfile PUBLIC
+       ${CALENDAR_CFLAGS}
+)
+
+target_include_directories(ecalbackendfile PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_BINARY_DIR}/calendar
+       ${CMAKE_SOURCE_DIR}/calendar
+       ${CALENDAR_INCLUDE_DIRS}
+)
+
+target_link_libraries(ecalbackendfile
+       ${DEPENDENCIES}
+       ${CALENDAR_LDFLAGS}
+)
+
+install(TARGETS ecalbackendfile
+       DESTINATION ${ecal_backenddir}
+)
+
+add_executable(test-interval-searches
+       e-cal-backend-file.c
+)
+
+target_compile_definitions(test-interval-searches PRIVATE
+       -DG_LOG_DOMAIN=\"e-cal-backend-file\"
+       -DBACKENDDIR=\"${ecal_backenddir}\"
+       -DTEST_QUERY_RESULT=1
+)
+
+target_compile_options(test-interval-searches PUBLIC
+       ${CALENDAR_CFLAGS}
+)
+
+target_include_directories(test-interval-searches PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_BINARY_DIR}/calendar
+       ${CMAKE_SOURCE_DIR}/calendar
+       ${CALENDAR_INCLUDE_DIRS}
+)
+
+target_link_libraries(test-interval-searches
+       ${DEPENDENCIES}
+       ${CALENDAR_LDFLAGS}
+)
diff --git a/calendar/backends/file/e-cal-backend-file-events.c 
b/calendar/backends/file/e-cal-backend-file-events.c
index a29db7e..2687aa1 100644
--- a/calendar/backends/file/e-cal-backend-file-events.c
+++ b/calendar/backends/file/e-cal-backend-file-events.c
@@ -18,9 +18,7 @@
  *          Rodrigo Moya <rodrigo ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-cal-backend-file-events.h"
 
diff --git a/calendar/backends/file/e-cal-backend-file-factory.c 
b/calendar/backends/file/e-cal-backend-file-factory.c
index 04f5a60..ddf0eb0 100644
--- a/calendar/backends/file/e-cal-backend-file-factory.c
+++ b/calendar/backends/file/e-cal-backend-file-factory.c
@@ -17,7 +17,7 @@
  * Authors: Chris Toshok (toshok ximian com)
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include "e-cal-backend-file-events.h"
 #include "e-cal-backend-file-journal.h"
diff --git a/calendar/backends/file/e-cal-backend-file-todos.c 
b/calendar/backends/file/e-cal-backend-file-todos.c
index 4eaaa3c..86b5285 100644
--- a/calendar/backends/file/e-cal-backend-file-todos.c
+++ b/calendar/backends/file/e-cal-backend-file-todos.c
@@ -18,9 +18,7 @@
  *          Rodrigo Moya <rodrigo ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-cal-backend-file-todos.h"
 
diff --git a/calendar/backends/file/e-cal-backend-file.c b/calendar/backends/file/e-cal-backend-file.c
index ec9d4f6..ee0fb89 100644
--- a/calendar/backends/file/e-cal-backend-file.c
+++ b/calendar/backends/file/e-cal-backend-file.c
@@ -20,9 +20,7 @@
  *          Jan Brittenson <bson gnu ai mit edu>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 #include <unistd.h>
diff --git a/calendar/backends/gtasks/CMakeLists.txt b/calendar/backends/gtasks/CMakeLists.txt
new file mode 100644
index 0000000..10c0aa6
--- /dev/null
+++ b/calendar/backends/gtasks/CMakeLists.txt
@@ -0,0 +1,51 @@
+set(DEPENDENCIES
+       ebackend
+       ecal
+       edataserver
+       edata-cal
+)
+
+set(SOURCES
+       e-cal-backend-gtasks-factory.c
+       e-cal-backend-gtasks.c
+       e-cal-backend-gtasks.h
+       e-gdata-oauth2-authorizer.c
+       e-gdata-oauth2-authorizer.h
+)
+
+add_library(ecalbackendgtasks MODULE
+       ${SOURCES}
+)
+
+add_dependencies(ecalbackendgtasks
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(ecalbackendgtasks PRIVATE
+       -DG_LOG_DOMAIN=\"e-cal-backend-gtasks\"
+       -DBACKENDDIR=\"${ecal_backenddir}\"
+)
+
+target_compile_options(ecalbackendgtasks PUBLIC
+       ${CALENDAR_CFLAGS}
+       ${LIBGDATA_CFLAGS}
+)
+
+target_include_directories(ecalbackendgtasks PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_BINARY_DIR}/calendar
+       ${CMAKE_SOURCE_DIR}/calendar
+       ${CALENDAR_INCLUDE_DIRS}
+       ${LIBGDATA_INCLUDE_DIRS}
+)
+
+target_link_libraries(ecalbackendgtasks
+       ${DEPENDENCIES}
+       ${CALENDAR_LDFLAGS}
+       ${LIBGDATA_LDFLAGS}
+)
+
+install(TARGETS ecalbackendgtasks
+       DESTINATION ${ecal_backenddir}
+)
diff --git a/calendar/backends/gtasks/e-cal-backend-gtasks-factory.c 
b/calendar/backends/gtasks/e-cal-backend-gtasks-factory.c
index 323844f..f7f5ed0 100644
--- a/calendar/backends/gtasks/e-cal-backend-gtasks-factory.c
+++ b/calendar/backends/gtasks/e-cal-backend-gtasks-factory.c
@@ -16,7 +16,7 @@
  * Authors: Milan Crha <mcrha redhat com>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include "e-cal-backend-gtasks.h"
 
diff --git a/calendar/backends/gtasks/e-cal-backend-gtasks.c b/calendar/backends/gtasks/e-cal-backend-gtasks.c
index b73542a..2a3f35f 100644
--- a/calendar/backends/gtasks/e-cal-backend-gtasks.c
+++ b/calendar/backends/gtasks/e-cal-backend-gtasks.c
@@ -16,9 +16,7 @@
  * Authors: Milan Crha <mcrha redhat com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n-lib.h>
 #include <gdata/gdata.h>
diff --git a/calendar/backends/http/CMakeLists.txt b/calendar/backends/http/CMakeLists.txt
new file mode 100644
index 0000000..cb6e9c8
--- /dev/null
+++ b/calendar/backends/http/CMakeLists.txt
@@ -0,0 +1,46 @@
+set(DEPENDENCIES
+       ebackend
+       ecal
+       edataserver
+       edata-cal
+)
+
+set(SOURCES
+       e-cal-backend-http-factory.c
+       e-cal-backend-http.c
+       e-cal-backend-http.h
+)
+
+add_library(ecalbackendhttp MODULE
+       ${SOURCES}
+)
+
+add_dependencies(ecalbackendhttp
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(ecalbackendhttp PRIVATE
+       -DG_LOG_DOMAIN=\"e-cal-backend-http\"
+       -DBACKENDDIR=\"${ecal_backenddir}\"
+)
+
+target_compile_options(ecalbackendhttp PUBLIC
+       ${CALENDAR_CFLAGS}
+)
+
+target_include_directories(ecalbackendhttp PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_BINARY_DIR}/calendar
+       ${CMAKE_SOURCE_DIR}/calendar
+       ${CALENDAR_INCLUDE_DIRS}
+)
+
+target_link_libraries(ecalbackendhttp
+       ${DEPENDENCIES}
+       ${CALENDAR_LDFLAGS}
+)
+
+install(TARGETS ecalbackendhttp
+       DESTINATION ${ecal_backenddir}
+)
diff --git a/calendar/backends/http/e-cal-backend-http-factory.c 
b/calendar/backends/http/e-cal-backend-http-factory.c
index 611d250..fb77c42 100644
--- a/calendar/backends/http/e-cal-backend-http-factory.c
+++ b/calendar/backends/http/e-cal-backend-http-factory.c
@@ -17,7 +17,7 @@
  * Authors: Chris Toshok (toshok ximian com)
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include "e-cal-backend-http.h"
 
diff --git a/calendar/backends/http/e-cal-backend-http.c b/calendar/backends/http/e-cal-backend-http.c
index 0500bf5..1cb7f13 100644
--- a/calendar/backends/http/e-cal-backend-http.c
+++ b/calendar/backends/http/e-cal-backend-http.c
@@ -18,7 +18,8 @@
  * Authors: Hans Petter Jansson <hpj ximian com>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <string.h>
 #include <unistd.h>
 #include <glib/gi18n-lib.h>
diff --git a/calendar/backends/weather/CMakeLists.txt b/calendar/backends/weather/CMakeLists.txt
new file mode 100644
index 0000000..774114f
--- /dev/null
+++ b/calendar/backends/weather/CMakeLists.txt
@@ -0,0 +1,51 @@
+set(DEPENDENCIES
+       ebackend
+       ecal
+       edataserver
+       edata-cal
+)
+
+set(SOURCES
+       e-cal-backend-weather-factory.c
+       e-cal-backend-weather.c
+       e-cal-backend-weather.h
+       e-weather-source.c
+       e-weather-source.h
+)
+
+add_library(ecalbackendweather MODULE
+       ${SOURCES}
+)
+
+add_dependencies(ecalbackendweather
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(ecalbackendweather PRIVATE
+       -DG_LOG_DOMAIN=\"e-cal-backend-weather\"
+       -DBACKENDDIR=\"${ecal_backenddir}\"
+)
+
+target_compile_options(ecalbackendweather PUBLIC
+       ${CALENDAR_CFLAGS}
+       ${LIBGWEATHER_CFLAGS}
+)
+
+target_include_directories(ecalbackendweather PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_BINARY_DIR}/calendar
+       ${CMAKE_SOURCE_DIR}/calendar
+       ${CALENDAR_INCLUDE_DIRS}
+       ${LIBGWEATHER__INCLUDE_DIRS}
+)
+
+target_link_libraries(ecalbackendweather
+       ${DEPENDENCIES}
+       ${CALENDAR_LDFLAGS}
+       ${LIBGWEATHER_LDFLAGS}
+)
+
+install(TARGETS ecalbackendweather
+       DESTINATION ${ecal_backenddir}
+)
diff --git a/calendar/backends/weather/e-cal-backend-weather-factory.c 
b/calendar/backends/weather/e-cal-backend-weather-factory.c
index 543426d..d3c8d63 100644
--- a/calendar/backends/weather/e-cal-backend-weather-factory.c
+++ b/calendar/backends/weather/e-cal-backend-weather-factory.c
@@ -17,7 +17,7 @@
  * Authors: David Trowbridge <trowbrds cs colorado edu>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include "e-cal-backend-weather.h"
 
diff --git a/calendar/backends/weather/e-cal-backend-weather.c 
b/calendar/backends/weather/e-cal-backend-weather.c
index d33cfa0..3902293 100644
--- a/calendar/backends/weather/e-cal-backend-weather.c
+++ b/calendar/backends/weather/e-cal-backend-weather.c
@@ -17,7 +17,8 @@
  * Authors: David Trowbridge <trowbrds cs colorado edu>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <glib/gi18n-lib.h>
 #include <string.h>
 
diff --git a/calendar/libecal/CMakeLists.txt b/calendar/libecal/CMakeLists.txt
new file mode 100644
index 0000000..0f4e559
--- /dev/null
+++ b/calendar/libecal/CMakeLists.txt
@@ -0,0 +1,93 @@
+glib_mkenums(e-cal-enumtypes e-cal-types.h E_CAL_ENUMTYPES_H)
+
+add_pkgconfig_file(libecal.pc.in libecal-${API_VERSION}.pc)
+
+set(DEPENDENCIES
+       edbus-private
+       edataserver
+       egdbus-cal
+)
+
+set(SOURCES
+       e-cal.c
+       e-cal-client.c
+       e-cal-client-view.c
+       e-cal-component.c
+       e-cal-recur.c
+       e-cal-time-util.c
+       e-cal-check-timezones.c
+       e-cal-system-timezone.c
+       e-cal-util.c
+       e-cal-view.c
+       e-cal-view-private.h
+       e-timezone-cache.c
+       ${CMAKE_CURRENT_BINARY_DIR}/e-cal-enumtypes.c
+)
+
+set(HEADERS
+       libecal.h
+       e-cal.h
+       e-cal-client.h
+       e-cal-client-view.h
+       e-cal-component.h
+       e-cal-recur.h
+       e-cal-time-util.h
+        e-cal-check-timezones.h
+       e-cal-system-timezone.h
+       e-cal-types.h
+       e-cal-util.h
+       e-cal-view.h
+       e-timezone-cache.h
+       ${CMAKE_CURRENT_BINARY_DIR}/e-cal-enumtypes.h
+)
+
+add_library(ecal SHARED
+       ${SOURCES}
+       ${HEADERS}
+)
+
+add_dependencies(ecal
+       ${DEPENDENCIES}
+)
+
+set_target_properties(ecal PROPERTIES
+       VERSION "${LIBECAL_CURRENT}.${LIBECAL_REVISION}.${LIBECAL_AGE}"
+       SOVERSION ${LIBECAL_CURRENT}
+       OUTPUT_NAME ecal-${API_VERSION}
+)
+
+target_compile_definitions(ecal PRIVATE
+       -DG_LOG_DOMAIN=\"libecal\"
+       -DLOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+       -DLIBECAL_COMPILATION
+)
+
+target_compile_options(ecal PUBLIC
+       ${CALENDAR_CFLAGS}
+)
+
+target_include_directories(ecal PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/calendar
+       ${CMAKE_BINARY_DIR}/calendar/libegdbus
+       ${CMAKE_BINARY_DIR}/private
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/private
+       ${CMAKE_SOURCE_DIR}/calendar
+       ${CMAKE_SOURCE_DIR}/calendar/libegdbus
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${CALENDAR_INCLUDE_DIRS}
+)
+
+target_link_libraries(ecal
+       ${DEPENDENCIES}
+       ${CALENDAR_LDFLAGS}
+)
+
+install(TARGETS ecal
+       DESTINATION ${LIB_INSTALL_DIR}
+)
+
+install(FILES ${HEADERS}
+       DESTINATION ${privincludedir}/libecal
+)
diff --git a/calendar/libecal/e-cal-check-timezones.c b/calendar/libecal/e-cal-check-timezones.c
index 32d067a..32b1818 100644
--- a/calendar/libecal/e-cal-check-timezones.c
+++ b/calendar/libecal/e-cal-check-timezones.c
@@ -16,9 +16,7 @@
  * Authors: Patrick Ohly <patrick ohly gmx de>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <libical/ical.h>
 
diff --git a/calendar/libecal/e-cal-client-view.c b/calendar/libecal/e-cal-client-view.c
index 63b7282..8dcf3da 100644
--- a/calendar/libecal/e-cal-client-view.c
+++ b/calendar/libecal/e-cal-client-view.c
@@ -30,9 +30,7 @@
  * to create an #ECalClientView.
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n-lib.h>
 
diff --git a/calendar/libecal/e-cal-client.c b/calendar/libecal/e-cal-client.c
index bab0090..fe2fca3 100644
--- a/calendar/libecal/e-cal-client.c
+++ b/calendar/libecal/e-cal-client.c
@@ -26,9 +26,7 @@
  * the calendar.
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n-lib.h>
 #include <gio/gio.h>
diff --git a/calendar/libecal/e-cal-component.c b/calendar/libecal/e-cal-component.c
index 4b19e0a..8eadd65 100644
--- a/calendar/libecal/e-cal-component.c
+++ b/calendar/libecal/e-cal-component.c
@@ -26,7 +26,8 @@
  * or other component in a given calendar.
  **/
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
diff --git a/calendar/libecal/e-cal-recur.c b/calendar/libecal/e-cal-recur.c
index cd61d4a..0b0d3d9 100644
--- a/calendar/libecal/e-cal-recur.c
+++ b/calendar/libecal/e-cal-recur.c
@@ -19,9 +19,7 @@
  * Authors: Damon Chaplin <damon ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdlib.h>
 #include <string.h>
diff --git a/calendar/libecal/e-cal-util.c b/calendar/libecal/e-cal-util.c
index fdbe6a3..d65dd4e 100644
--- a/calendar/libecal/e-cal-util.c
+++ b/calendar/libecal/e-cal-util.c
@@ -17,7 +17,8 @@
  * Authors: Federico Mena-Quintero <federico ximian com>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <stdlib.h>
 #include <string.h>
 #include <glib/gstdio.h>
diff --git a/calendar/libecal/e-cal-view.c b/calendar/libecal/e-cal-view.c
index 072a0fa..5cd7253 100644
--- a/calendar/libecal/e-cal-view.c
+++ b/calendar/libecal/e-cal-view.c
@@ -20,9 +20,7 @@
  *          Ross Burton <ross linux intel com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 #include "e-cal.h"
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index fe39615..2b75086 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -31,9 +31,7 @@
  * Deprecated: 3.2: Use #ECalClient instead.
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <unistd.h>
 #include <string.h>
diff --git a/calendar/libecal/libecal.pc.in b/calendar/libecal/libecal.pc.in
index 22428b6..9adfa04 100644
--- a/calendar/libecal/libecal.pc.in
+++ b/calendar/libecal/libecal.pc.in
@@ -1,15 +1,14 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-datarootdir=@datarootdir@
-datadir=@datadir@
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+includedir=@INCLUDE_INSTALL_DIR@
+datarootdir=@SHARE_INSTALL_DIR@
+datadir=@SHARE_INSTALL_DIR@
 
 privincludedir=@privincludedir@
 
 Name: libecal
 Description: Client library for evolution calendars
-Version: @VERSION@
-Requires: libical >= @LIBICAL_REQUIRED@ libedataserver-1.2
-Libs: -L${libdir} -lecal-1.2
+Version: @PROJECT_VERSION@
+Requires: libical libedataserver-@API_VERSION@
+Libs: -L${libdir} -lecal-@API_VERSION@
 Cflags: -I${privincludedir} @LIBICAL_EXTRA_CFLAGS@
diff --git a/calendar/libedata-cal/CMakeLists.txt b/calendar/libedata-cal/CMakeLists.txt
new file mode 100644
index 0000000..271b1d8
--- /dev/null
+++ b/calendar/libedata-cal/CMakeLists.txt
@@ -0,0 +1,136 @@
+add_pkgconfig_file(libedata-cal.pc.in libedata-cal-${API_VERSION}.pc)
+
+set(DEPENDENCIES
+       ebackend
+       ecal
+       edbus-private
+       edataserver
+       egdbus-cal
+)
+
+set(SOURCES
+       e-cal-backend.c
+       e-cal-backend-cache.c
+       e-cal-backend-factory.c
+       e-cal-backend-intervaltree.c
+       e-cal-backend-sexp.c
+       e-cal-backend-sync.c
+       e-cal-backend-util.c
+       e-cal-backend-store.c
+       e-data-cal.c
+       e-data-cal-factory.c
+       e-data-cal-view.c
+       e-subprocess-cal-factory.c
+)
+
+set(HEADERS
+       libedata-cal.h
+       e-cal-backend.h
+       e-cal-backend-cache.h
+       e-cal-backend-factory.h
+       e-cal-backend-intervaltree.h
+       e-cal-backend-sync.h
+       e-cal-backend-util.h
+       e-cal-backend-sexp.h
+       e-data-cal.h
+       e-data-cal-factory.h
+       e-cal-backend-store.h
+       e-data-cal-view.h
+       e-subprocess-cal-factory.h
+)
+
+add_library(edata-cal SHARED
+       ${SOURCES}
+       ${HEADERS}
+)
+
+add_dependencies(edata-cal
+       ${DEPENDENCIES}
+)
+
+set_target_properties(edata-cal PROPERTIES
+       VERSION "${LIBEDATACAL_CURRENT}.${LIBEDATACAL_REVISION}.${LIBEDATACAL_AGE}"
+       SOVERSION ${LIBEDATACAL_CURRENT}
+       OUTPUT_NAME edata-cal-${API_VERSION}
+)
+
+target_compile_definitions(edata-cal PRIVATE
+       -DG_LOG_DOMAIN=\"libedata-cal\"
+       -DBACKENDDIR=\"${ecal_backenddir}\"
+       -DSUBPROCESS_CAL_BACKEND_PATH=\"${LIBEXEC_INSTALL_DIR}/evolution-calendar-factory-subprocess\"
+       -DLIBEDATA_CAL_COMPILATION
+)
+
+target_compile_options(edata-cal PUBLIC
+       ${CALENDAR_CFLAGS}
+)
+
+target_include_directories(edata-cal PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/calendar
+       ${CMAKE_BINARY_DIR}/calendar/libegdbus
+       ${CMAKE_BINARY_DIR}/private
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/private
+       ${CMAKE_SOURCE_DIR}/calendar
+       ${CMAKE_SOURCE_DIR}/calendar/libegdbus
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${CALENDAR_INCLUDE_DIRS}
+)
+
+target_link_libraries(edata-cal
+       ${DEPENDENCIES}
+       ${CALENDAR_LDFLAGS}
+)
+
+install(TARGETS edata-cal
+       DESTINATION ${LIB_INSTALL_DIR}
+)
+
+install(FILES ${HEADERS}
+       DESTINATION ${privincludedir}/libedata-cal
+)
+
+set(DEPENDENCIES
+       ebackend
+       edataserver
+       edata-cal
+       edbus-private
+)
+
+add_executable(evolution-calendar-factory-subprocess
+       evolution-calendar-factory-subprocess.c)
+
+target_compile_definitions(evolution-calendar-factory-subprocess PRIVATE
+       -DG_LOG_DOMAIN=\"evolution-calendar-factory-subprocess\"
+       -DLOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+)
+
+target_compile_options(evolution-calendar-factory-subprocess PUBLIC
+       ${CALENDAR_CFLAGS}
+       ${GTK_CFLAGS}
+)
+
+target_include_directories(evolution-calendar-factory-subprocess PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/calendar
+       ${CMAKE_BINARY_DIR}/calendar/libegdbus
+       ${CMAKE_BINARY_DIR}/private
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/private
+       ${CMAKE_SOURCE_DIR}/calendar
+       ${CMAKE_SOURCE_DIR}/calendar/libegdbus
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${CALENDAR_INCLUDE_DIRS}
+       ${GTK_INCLUDE_DIRS}
+)
+
+target_link_libraries(evolution-calendar-factory-subprocess
+       ${DEPENDENCIES}
+       ${CALENDAR_LDFLAGS}
+       ${GTK_LDFLAGS}
+)
+
+install(TARGETS evolution-calendar-factory-subprocess
+       DESTINATION ${LIBEXEC_INSTALL_DIR}
+)
diff --git a/calendar/libedata-cal/e-cal-backend-cache.c b/calendar/libedata-cal/e-cal-backend-cache.c
index 2071abd..a75f8c4 100644
--- a/calendar/libedata-cal/e-cal-backend-cache.c
+++ b/calendar/libedata-cal/e-cal-backend-cache.c
@@ -26,9 +26,7 @@
  * This class can be used by backends to store calendar components.
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 #include <glib/gstdio.h>
diff --git a/calendar/libedata-cal/e-cal-backend-factory.c b/calendar/libedata-cal/e-cal-backend-factory.c
index 63dcb0c..2c73cdf 100644
--- a/calendar/libedata-cal/e-cal-backend-factory.c
+++ b/calendar/libedata-cal/e-cal-backend-factory.c
@@ -26,7 +26,8 @@
  * backend types.
  **/
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <string.h>
 
 #include "e-cal-backend.h"
diff --git a/calendar/libedata-cal/e-cal-backend-intervaltree.c 
b/calendar/libedata-cal/e-cal-backend-intervaltree.c
index 17b4f92..b94cea0 100644
--- a/calendar/libedata-cal/e-cal-backend-intervaltree.c
+++ b/calendar/libedata-cal/e-cal-backend-intervaltree.c
@@ -29,9 +29,7 @@
  * the start of the interval.
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <string.h>
diff --git a/calendar/libedata-cal/e-cal-backend-sexp.c b/calendar/libedata-cal/e-cal-backend-sexp.c
index af59070..6786d54 100644
--- a/calendar/libedata-cal/e-cal-backend-sexp.c
+++ b/calendar/libedata-cal/e-cal-backend-sexp.c
@@ -24,9 +24,7 @@
  * and is used by various backends to implement component filtering and searching.
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 #include <glib/gi18n-lib.h>
diff --git a/calendar/libedata-cal/e-cal-backend-store.c b/calendar/libedata-cal/e-cal-backend-store.c
index acde6d7..422492c 100644
--- a/calendar/libedata-cal/e-cal-backend-store.c
+++ b/calendar/libedata-cal/e-cal-backend-store.c
@@ -26,7 +26,7 @@
  * This class can be used by backends to store calendar components.
  **/
 
-#include "e-cal-backend-store.h"
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 #include <glib/gstdio.h>
@@ -35,6 +35,8 @@
 
 #include "e-cal-backend-intervaltree.h"
 
+#include "e-cal-backend-store.h"
+
 #define E_CAL_BACKEND_STORE_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
        ((obj), E_TYPE_CAL_BACKEND_STORE, ECalBackendStorePrivate))
diff --git a/calendar/libedata-cal/e-cal-backend-sync.c b/calendar/libedata-cal/e-cal-backend-sync.c
index 76d0e09..0449933 100644
--- a/calendar/libedata-cal/e-cal-backend-sync.c
+++ b/calendar/libedata-cal/e-cal-backend-sync.c
@@ -26,9 +26,7 @@
  * abstract backend for easier implementation of calendar backends.
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n-lib.h>
 #include <libedataserver/libedataserver.h>
diff --git a/calendar/libedata-cal/e-cal-backend-util.c b/calendar/libedata-cal/e-cal-backend-util.c
index d2af07e..691f517 100644
--- a/calendar/libedata-cal/e-cal-backend-util.c
+++ b/calendar/libedata-cal/e-cal-backend-util.c
@@ -18,9 +18,7 @@
  * Authors: Rodrigo Moya <rodrigo ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 #include <glib/gi18n-lib.h>
diff --git a/calendar/libedata-cal/e-cal-backend.c b/calendar/libedata-cal/e-cal-backend.c
index 62c92c0..18115e8 100644
--- a/calendar/libedata-cal/e-cal-backend.c
+++ b/calendar/libedata-cal/e-cal-backend.c
@@ -24,7 +24,7 @@
  * calendar backends must implement methods on this class.
  **/
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n-lib.h>
 
diff --git a/calendar/libedata-cal/e-data-cal-factory.c b/calendar/libedata-cal/e-data-cal-factory.c
index 21d5153..810b310 100644
--- a/calendar/libedata-cal/e-data-cal-factory.c
+++ b/calendar/libedata-cal/e-data-cal-factory.c
@@ -31,7 +31,8 @@
  * with client side #ECalClient objects.
  **/
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <locale.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/calendar/libedata-cal/e-data-cal-view.c b/calendar/libedata-cal/e-data-cal-view.c
index 442a9d8..56a0c1a 100644
--- a/calendar/libedata-cal/e-data-cal-view.c
+++ b/calendar/libedata-cal/e-data-cal-view.c
@@ -32,9 +32,7 @@
  * which will be delivered to the #ECalClientView
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/calendar/libedata-cal/e-data-cal.c b/calendar/libedata-cal/e-data-cal.c
index 99f234d..5b6722d 100644
--- a/calendar/libedata-cal/e-data-cal.c
+++ b/calendar/libedata-cal/e-data-cal.c
@@ -24,9 +24,7 @@
  * an #ECalBackend to satisfy client requests.
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <libical/ical.h>
 #include <glib/gi18n-lib.h>
diff --git a/calendar/libedata-cal/e-subprocess-cal-factory.c 
b/calendar/libedata-cal/e-subprocess-cal-factory.c
index 8d94929..c4aa3f4 100644
--- a/calendar/libedata-cal/e-subprocess-cal-factory.c
+++ b/calendar/libedata-cal/e-subprocess-cal-factory.c
@@ -23,9 +23,7 @@
  * the communication between #EDataCalFactory and #EBackend
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <locale.h>
 #include <stdlib.h>
diff --git a/calendar/libedata-cal/evolution-calendar-factory-subprocess.c 
b/calendar/libedata-cal/evolution-calendar-factory-subprocess.c
index 877f6c1..f131f39 100644
--- a/calendar/libedata-cal/evolution-calendar-factory-subprocess.c
+++ b/calendar/libedata-cal/evolution-calendar-factory-subprocess.c
@@ -15,7 +15,8 @@
  *
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <locale.h>
 #include <stdlib.h>
 #include <glib/gi18n.h>
diff --git a/calendar/libedata-cal/libedata-cal.pc.in b/calendar/libedata-cal/libedata-cal.pc.in
index 1ffc5bd..bdbeda6 100644
--- a/calendar/libedata-cal/libedata-cal.pc.in
+++ b/calendar/libedata-cal/libedata-cal.pc.in
@@ -1,10 +1,9 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-libexecdir=@libexecdir@
-includedir=@includedir@
-datarootdir=@datarootdir@
-datadir=@datadir@
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+libexecdir=@LIBEXEC_INSTALL_DIR@
+includedir=@INCLUDE_INSTALL_DIR@
+datarootdir=@SHARE_INSTALL_DIR@
+datadir=@SHARE_INSTALL_DIR@
 
 privlibdir=@privlibdir@
 privincludedir=@privincludedir@
@@ -13,7 +12,7 @@ backenddir=@ecal_backenddir@
 
 Name: libedata-cal
 Description: Backend library for evolution calendars
-Version: @VERSION@
-Requires: libical >= @LIBICAL_REQUIRED@ libebackend-1.2 libecal-1.2
-Libs: -L${libdir} -ledata-cal-1.2
+Version: @PROJECT_VERSION@
+Requires: libical libebackend-@API_VERSION@ libecal-@API_VERSION@
+Libs: -L${libdir} -ledata-cal-@API_VERSION@
 Cflags: -I${privincludedir}
diff --git a/calendar/libegdbus/CMakeLists.txt b/calendar/libegdbus/CMakeLists.txt
new file mode 100644
index 0000000..f261565
--- /dev/null
+++ b/calendar/libegdbus/CMakeLists.txt
@@ -0,0 +1,36 @@
+set(SOURCES
+       e-gdbus-cal-view.h
+       e-gdbus-cal-view.c
+)
+
+set(DEPENDENCIES
+       edataserver
+)
+
+add_library(egdbus-cal STATIC
+       ${SOURCES}
+)
+
+add_dependencies(egdbus-cal
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(egdbus-cal PRIVATE
+       -DG_LOG_DOMAIN=\"egdbus-cal\"
+)
+
+target_compile_options(egdbus-cal PUBLIC
+       ${DATA_SERVER_CFLAGS}
+)
+
+target_include_directories(egdbus-cal PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${DATA_SERVER_INCLUDE_DIRS}
+)
+
+target_link_libraries(egdbus-cal
+       ${DEPENDENCIES}
+       ${DATA_SERVER_LDFLAGS}
+)
diff --git a/camel/CMakeLists.txt b/camel/CMakeLists.txt
new file mode 100644
index 0000000..40e236b
--- /dev/null
+++ b/camel/CMakeLists.txt
@@ -0,0 +1,459 @@
+glib_mkenums(camel-enumtypes camel-enums.h CAMEL_ENUMTYPES_H)
+
+add_custom_command(
+       OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/camel-mime-tables.c
+       COMMAND ${PERL} ${CMAKE_CURRENT_SOURCE_DIR}/gentables.pl 
${CMAKE_CURRENT_BINARY_DIR}/camel-mime-tables.c
+       DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gentables.pl
+)
+
+set(SOURCES
+       camel.c
+       camel-address.c
+       camel-async-closure.c
+       camel-block-file.c
+       camel-certdb.c
+       camel-charset-map.c
+       camel-cipher-context.c
+       camel-data-cache.c
+       camel-data-wrapper.c
+       camel-db.c
+       camel-debug.c
+       camel-file-utils.c
+       camel-filter-driver.c
+       camel-filter-input-stream.c
+       camel-filter-output-stream.c
+       camel-filter-search.c
+       camel-folder-search.c
+       camel-folder-summary.c
+       camel-folder-thread.c
+       camel-folder.c
+       camel-gpg-context.c
+       camel-html-parser.c
+       camel-iconv.c
+       camel-index.c
+       camel-internet-address.c
+       camel-junk-filter.c
+       camel-local-settings.c
+       camel-lock.c
+       camel-medium.c
+       camel-memchunk.c
+       camel-mempool.c
+       camel-mime-filter-basic.c
+       camel-mime-filter-bestenc.c
+       camel-mime-filter-canon.c
+       camel-mime-filter-charset.c
+       camel-mime-filter-crlf.c
+       camel-mime-filter-enriched.c
+       camel-mime-filter-from.c
+       camel-mime-filter-gzip.c
+       camel-mime-filter-html.c
+       camel-mime-filter-index.c
+       camel-mime-filter-linewrap.c
+       camel-mime-filter-pgp.c
+       camel-mime-filter-progress.c
+       camel-mime-filter-tohtml.c
+       camel-mime-filter-windows.c
+       camel-mime-filter-yenc.c
+       camel-mime-filter.c
+       camel-mime-message.c
+       camel-mime-parser.c
+       camel-mime-part-utils.c
+       camel-mime-part.c
+       camel-mime-utils.c
+       camel-msgport.c
+       camel-multipart-encrypted.c
+       camel-multipart-signed.c
+       camel-multipart.c
+       camel-net-utils.c
+       camel-network-service.c
+       camel-network-settings.c
+       camel-nntp-address.c
+       camel-null-output-stream.c
+       camel-object-bag.c
+       camel-object.c
+       camel-offline-folder.c
+       camel-offline-settings.c
+       camel-offline-store.c
+       camel-operation.c
+       camel-partition-table.c
+       camel-provider.c
+       camel-sasl-anonymous.c
+       camel-sasl-cram-md5.c
+       camel-sasl-digest-md5.c
+       camel-sasl-gssapi.c
+       camel-sasl-login.c
+       camel-sasl-ntlm.c
+       camel-sasl-plain.c
+       camel-sasl-popb4smtp.c
+       camel-sasl.c
+       camel-search-private.c
+       camel-search-sql-sexp.c
+       camel-service.c
+       camel-session.c
+       camel-settings.c
+       camel-sexp.c
+       camel-smime-context.c
+       camel-store-settings.c
+       camel-store-summary.c
+       camel-store.c
+       camel-stream-buffer.c
+       camel-stream-filter.c
+       camel-stream-fs.c
+       camel-stream-mem.c
+       camel-stream-null.c
+       camel-stream.c
+       camel-string-utils.c
+       camel-subscribable.c
+       camel-text-index.c
+       camel-transport.c
+       camel-trie.c
+       camel-uid-cache.c
+       camel-url-scanner.c
+       camel-url.c
+       camel-utf8.c
+       camel-vee-data-cache.c
+       camel-vee-folder.c
+       camel-vee-store.c
+       camel-vee-summary.c
+       camel-vtrash-folder.c
+       ${CMAKE_CURRENT_BINARY_DIR}/camel-enumtypes.c
+       ${CMAKE_CURRENT_BINARY_DIR}/camel-mime-tables.c
+)
+
+if(WIN32)
+       list(APPEND SOURCES
+               camel-win32.c
+       )
+else(WIN32)
+       list(APPEND SOURCES
+               camel-lock-client.c
+               camel-movemail.c
+               camel-stream-process.c
+       )
+endif(WIN32)
+
+set(HEADERS
+       camel.h
+       camel-address.h
+       camel-async-closure.h
+       camel-block-file.h
+       camel-certdb.h
+       camel-charset-map.h
+       camel-cipher-context.h
+       camel-data-cache.h
+       camel-data-wrapper.h
+       camel-db.h
+       camel-debug.h
+       camel-enums.h
+       camel-file-utils.h
+       camel-filter-driver.h
+       camel-filter-input-stream.h
+       camel-filter-output-stream.h
+       camel-filter-search.h
+       camel-folder-search.h
+       camel-folder-summary.h
+       camel-folder-thread.h
+       camel-folder.h
+       camel-gpg-context.h
+       camel-html-parser.h
+       camel-iconv.h
+       camel-index.h
+       camel-internet-address.h
+       camel-junk-filter.h
+       camel-local-settings.h
+       camel-lock-client.h
+       camel-lock-helper.h
+       camel-lock.h
+       camel-medium.h
+       camel-memchunk.h
+       camel-mempool.h
+       camel-mime-filter-basic.h
+       camel-mime-filter-bestenc.h
+       camel-mime-filter-canon.h
+       camel-mime-filter-charset.h
+       camel-mime-filter-crlf.h
+       camel-mime-filter-enriched.h
+       camel-mime-filter-from.h
+       camel-mime-filter-gzip.h
+       camel-mime-filter-html.h
+       camel-mime-filter-index.h
+       camel-mime-filter-linewrap.h
+       camel-mime-filter-pgp.h
+       camel-mime-filter-progress.h
+       camel-mime-filter-tohtml.h
+       camel-mime-filter-windows.h
+       camel-mime-filter-yenc.h
+       camel-mime-filter.h
+       camel-mime-message.h
+       camel-mime-parser.h
+       camel-mime-part-utils.h
+       camel-mime-part.h
+       camel-mime-utils.h
+       camel-movemail.h
+       camel-msgport.h
+       camel-multipart-encrypted.h
+       camel-multipart-signed.h
+       camel-multipart.h
+       camel-net-utils.h
+       camel-network-service.h
+       camel-network-settings.h
+       camel-nntp-address.h
+       camel-null-output-stream.h
+       camel-object-bag.h
+       camel-object.h
+       camel-offline-folder.h
+       camel-offline-settings.h
+       camel-offline-store.h
+       camel-operation.h
+       camel-partition-table.h
+       camel-provider.h
+       camel-sasl-anonymous.h
+       camel-sasl-cram-md5.h
+       camel-sasl-digest-md5.h
+       camel-sasl-gssapi.h
+       camel-sasl-login.h
+       camel-sasl-ntlm.h
+       camel-sasl-plain.h
+       camel-sasl-popb4smtp.h
+       camel-sasl.h
+       camel-search-private.h
+       camel-search-sql-sexp.h
+       camel-service.h
+       camel-session.h
+       camel-settings.h
+       camel-sexp.h
+       camel-smime-context.h
+       camel-store-settings.h
+       camel-store-summary.h
+       camel-store.h
+       camel-stream-buffer.h
+       camel-stream-filter.h
+       camel-stream-fs.h
+       camel-stream-mem.h
+       camel-stream-null.h
+       camel-stream-process.h
+       camel-stream.h
+       camel-string-utils.h
+       camel-subscribable.h
+       camel-text-index.h
+       camel-transport.h
+       camel-trie.h
+       camel-uid-cache.h
+       camel-url-scanner.h
+       camel-url.h
+       camel-utf8.h
+       camel-vee-data-cache.h
+       camel-vee-folder.h
+       camel-vee-store.h
+       camel-vee-summary.h
+       camel-vtrash-folder.h
+       ${CMAKE_CURRENT_BINARY_DIR}/camel-enumtypes.h
+)
+
+add_library(camel SHARED
+       ${SOURCES}
+       ${HEADERS}
+)
+
+set_target_properties(camel PROPERTIES
+       VERSION "${LIBCAMEL_CURRENT}.${LIBCAMEL_REVISION}.${LIBCAMEL_AGE}"
+       SOVERSION ${LIBCAMEL_CURRENT}
+       OUTPUT_NAME camel-${API_VERSION}
+)
+
+target_compile_definitions(camel PRIVATE
+       -DG_LOG_DOMAIN=\"camel\"
+       -DCAMEL_LIBEXECDIR=\"${LIBEXEC_INSTALL_DIR}\"
+       -DCAMEL_PROVIDERDIR=\"${camel_providerdir}\"
+       -DE_DATA_SERVER_PREFIX=\"${CMAKE_INSTALL_PREFIX}\"
+       -DLOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+       -DCAMEL_COMPILATION
+)
+
+target_compile_options(camel PUBLIC
+       ${CAMEL_CFLAGS}
+       ${SOCKET_CFLAGS}
+       ${ICONV_CFLAGS}
+       ${REGEX_CFLAGS}
+       ${LIBDWFL_CFLAGS}
+)
+
+target_include_directories(camel PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_CURRENT_SOURCE_DIR}
+       ${CAMEL_INCLUDE_DIRS}
+       ${SOCKET_INCLUDE_DIRS}
+       ${ICONV_INCLUDE_DIRS}
+       ${REGEX_INCLUDE_DIRS}
+)
+
+target_link_libraries(camel
+       ${CAMEL_LDFLAGS}
+       ${SOCKET_LDFLAGS}
+       ${ICONV_LDFLAGS}
+       ${REGEX_LDFLAGS}
+       ${LIBDWFL_LDFLAGS}
+)
+
+install(TARGETS camel
+       DESTINATION ${LIB_INSTALL_DIR}
+)
+
+install(FILES ${HEADERS}
+       DESTINATION ${privincludedir}/camel
+)
+
+add_pkgconfig_file(camel.pc.in camel-${API_VERSION}.pc)
+
+set(gir_sources ${SOURCES} ${HEADERS})
+set(gir_identifies_prefixes Camel camel)
+set(gir_includes GObject-2.0 Gio-2.0 libxml2-2.0)
+set(gir_cflags ${CAMEL_CFLAGS} -DCAMEL_COMPILATION)
+set(gir_libdirs)
+set(gir_libs camel)
+set(gir_deps)
+
+# Remove the below set() once the typelib will be buildable; the gi-r-compiler crashes with
+#    ERROR:girepository/girparser.c:343:state_switch: assertion failed: (ctx->state != newstate)
+gir_construct_names(Camel ${API_VERSION} camel_gir_name camel_gir_vars_prefix)
+set(${camel_gir_vars_prefix}_SKIP_TYPELIB ON)
+
+gir_add_introspection_simple(
+       Camel
+       camel
+       ${API_VERSION}
+       "camel/camel.h"
+       gir_identifies_prefixes
+       gir_includes
+       gir_cflags
+       gir_libdirs
+       gir_libs
+       gir_deps
+       gir_sources
+)
+
+if(NOT WIN32)
+       add_executable(camel-lock-helper
+               camel-lock.c
+               camel-lock.h
+               camel-lock-helper.c
+               camel-lock-helper.h
+       )
+
+       set_target_properties(camel-lock-helper PROPERTIES
+               OUTPUT_NAME camel-lock-helper-${API_VERSION}
+       )
+
+       target_compile_definitions(camel-lock-helper PRIVATE
+               -DG_LOG_DOMAIN=\"camel-lock-helper\"
+               -DCAMEL_LIBEXECDIR=\"${LIBEXEC_INSTALL_DIR}\"
+               -DCAMEL_PROVIDERDIR=\"${camel_providerdir}\"
+               -DE_DATA_SERVER_PREFIX=\"${CMAKE_INSTALL_PREFIX}\"
+               -DLOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+               -DCAMEL_COMPILATION
+       )
+
+       target_compile_options(camel-lock-helper PUBLIC
+               ${GNOME_PLATFORM_CFLAGS}
+       )
+
+       target_include_directories(camel-lock-helper PUBLIC
+               ${CMAKE_BINARY_DIR}
+               ${CMAKE_CURRENT_BINARY_DIR}
+               ${CMAKE_SOURCE_DIR}
+               ${CMAKE_CURRENT_SOURCE_DIR}
+               ${GNOME_PLATFORM_INCLUDE_DIRS}
+       )
+
+       target_link_libraries(camel-lock-helper
+               ${GNOME_PLATFORM_LDFLAGS}
+       )
+
+       install(TARGETS camel-lock-helper
+               DESTINATION ${LIBEXEC_INSTALL_DIR}
+       )
+endif(NOT WIN32)
+
+add_executable(camel-index-control
+       camel-index-control.c
+)
+
+add_dependencies(camel-index-control camel)
+
+set_target_properties(camel-index-control PROPERTIES
+       OUTPUT_NAME camel-index-control-${API_VERSION}
+)
+
+target_compile_definitions(camel-index-control PRIVATE
+       -DG_LOG_DOMAIN=\"camel-index-control-${API_VERSION}\"
+       -DCAMEL_LIBEXECDIR=\"${LIBEXEC_INSTALL_DIR}\"
+       -DCAMEL_PROVIDERDIR=\"${camel_providerdir}\"
+       -DE_DATA_SERVER_PREFIX=\"${CMAKE_INSTALL_PREFIX}\"
+       -DLOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+       -DCAMEL_COMPILATION
+)
+
+target_compile_options(camel-index-control PUBLIC
+       ${CAMEL_CFLAGS}
+       ${SOCKET_CFLAGS}
+       ${ICONV_CFLAGS}
+       ${REGEX_CFLAGS}
+       ${LIBDWFL_CFLAGS}
+)
+
+target_include_directories(camel-index-control PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_CURRENT_SOURCE_DIR}
+       ${CAMEL_INCLUDE_DIRS}
+       ${SOCKET_INCLUDE_DIRS}
+       ${ICONV_INCLUDE_DIRS}
+       ${REGEX_INCLUDE_DIRS}
+)
+
+target_link_libraries(camel-index-control
+       camel
+       ${CAMEL_LDFLAGS}
+       ${SOCKET_LDFLAGS}
+       ${ICONV_LDFLAGS}
+       ${REGEX_LDFLAGS}
+       ${LIBDWFL_LDFLAGS}
+)
+
+install(TARGETS camel-index-control
+       DESTINATION ${LIBEXEC_INSTALL_DIR}
+)
+
+add_executable(camel-gpg-photo-saver
+       camel-gpg-photo-saver.c
+)
+
+target_compile_definitions(camel-gpg-photo-saver PRIVATE
+       -DG_LOG_DOMAIN=\"camel-gpg-photo-saver\"
+)
+
+target_compile_options(camel-gpg-photo-saver PUBLIC
+       ${GNOME_PLATFORM_CFLAGS}
+)
+
+target_include_directories(camel-gpg-photo-saver PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_CURRENT_SOURCE_DIR}
+       ${GNOME_PLATFORM_INCLUDE_DIRS}
+)
+
+target_link_libraries(camel-gpg-photo-saver
+       ${GNOME_PLATFORM_LDFLAGS}
+)
+
+install(TARGETS camel-gpg-photo-saver
+       DESTINATION ${LIBEXEC_INSTALL_DIR}
+)
+
+add_subdirectory(providers)
+add_subdirectory(tests)
diff --git a/camel/camel-block-file.c b/camel/camel-block-file.c
index 71f4c4f..92ec24b 100644
--- a/camel/camel-block-file.c
+++ b/camel/camel-block-file.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <fcntl.h>
diff --git a/camel/camel-certdb.c b/camel/camel-certdb.c
index 0b77c05..31a301b 100644
--- a/camel/camel-certdb.c
+++ b/camel/camel-certdb.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <fcntl.h>
diff --git a/camel/camel-charset-map.c b/camel/camel-charset-map.c
index 59ab17e..38f4167 100644
--- a/camel/camel-charset-map.c
+++ b/camel/camel-charset-map.c
@@ -19,9 +19,7 @@
  *          Dan Winship <danw ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/camel/camel-cipher-context.c b/camel/camel-cipher-context.c
index c20a70a..80bcc6c 100644
--- a/camel/camel-cipher-context.c
+++ b/camel/camel-cipher-context.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/camel/camel-data-cache.c b/camel/camel-data-cache.c
index e7c15e0..13615a0 100644
--- a/camel/camel-data-cache.c
+++ b/camel/camel-data-cache.c
@@ -18,9 +18,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <sys/types.h>
 #include <ctype.h>
diff --git a/camel/camel-data-wrapper.c b/camel/camel-data-wrapper.c
index 2baca21..1da5026 100644
--- a/camel/camel-data-wrapper.c
+++ b/camel/camel-data-wrapper.c
@@ -17,9 +17,7 @@
  * Authors: Bertrand Guiheneuf <bertrand helixcode com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <glib/gi18n-lib.h>
diff --git a/camel/camel-db.c b/camel/camel-db.c
index e51f162..dffad32 100644
--- a/camel/camel-db.c
+++ b/camel/camel-db.c
@@ -18,10 +18,7 @@
  *          Srinivasa Ragavan <sragavan novell com>
  */
 
-#include "camel-db.h"
-#include "camel-string-utils.h"
-
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <ctype.h>
@@ -34,6 +31,9 @@
 
 #include "camel-debug.h"
 #include "camel-object.h"
+#include "camel-string-utils.h"
+
+#include "camel-db.h"
 
 /* how long to wait before invoking sync on the file */
 #define SYNC_TIMEOUT_SECONDS 5
diff --git a/camel/camel-debug.c b/camel/camel-debug.c
index ddce44e..a0677ab 100644
--- a/camel/camel-debug.c
+++ b/camel/camel-debug.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/camel/camel-file-utils.c b/camel/camel-file-utils.c
index 8206bf3..93f24ee 100644
--- a/camel/camel-file-utils.c
+++ b/camel/camel-file-utils.c
@@ -19,9 +19,7 @@
  *          Dan Winship <danw ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <fcntl.h>
diff --git a/camel/camel-filter-driver.c b/camel/camel-filter-driver.c
index 7a2bd1e..b0e73b4 100644
--- a/camel/camel-filter-driver.c
+++ b/camel/camel-filter-driver.c
@@ -18,9 +18,7 @@
  *          Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <fcntl.h>
diff --git a/camel/camel-filter-search.c b/camel/camel-filter-search.c
index 06173ad..68f0b63 100644
--- a/camel/camel-filter-search.c
+++ b/camel/camel-filter-search.c
@@ -18,9 +18,7 @@
  *         Michael Zucchi <NotZed Ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 /* POSIX requires <sys/types.h> be included before <regex.h> */
 #include <sys/types.h>
diff --git a/camel/camel-folder-search.c b/camel/camel-folder-search.c
index adbc95a..ffb4add 100644
--- a/camel/camel-folder-search.c
+++ b/camel/camel-folder-search.c
@@ -21,9 +21,7 @@
  * It implements enough to do basic searches on folders that can provide
  * an in-memory summary and a body index. */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 /* POSIX requires <sys/types.h> be included before <regex.h> */
 #include <sys/types.h>
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index eb46cfe..aec35e3 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <stdlib.h>
diff --git a/camel/camel-folder-thread.c b/camel/camel-folder-thread.c
index 642a197..277ccea 100644
--- a/camel/camel-folder-thread.c
+++ b/camel/camel-folder-thread.c
@@ -19,9 +19,7 @@
 
 /* TODO: This could probably be made a camel object, but it isn't really required */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <errno.h>
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index c9a3a71..2b08478 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -18,9 +18,7 @@
  * Authors: Bertrand Guiheneuf <bertrand helixcode com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c
index c7097dc..b539272 100644
--- a/camel/camel-gpg-context.c
+++ b/camel/camel-gpg-context.c
@@ -23,9 +23,7 @@
  * gpg:status  print gpg status-fd output to stdout
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/camel/camel-gpg-photo-saver.c b/camel/camel-gpg-photo-saver.c
index 7ee29f8..4746a73 100644
--- a/camel/camel-gpg-photo-saver.c
+++ b/camel/camel-gpg-photo-saver.c
@@ -15,9 +15,7 @@
  * along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib.h>
 #include <glib/gstdio.h>
diff --git a/camel/camel-iconv.c b/camel/camel-iconv.c
index d3ab956..ed5b2fe 100644
--- a/camel/camel-iconv.c
+++ b/camel/camel-iconv.c
@@ -19,9 +19,7 @@
  *          Jeffery Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/camel/camel-index-control.c b/camel/camel-index-control.c
index ad2b389..f09b3fe 100644
--- a/camel/camel-index-control.c
+++ b/camel/camel-index-control.c
@@ -14,9 +14,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <errno.h>
diff --git a/camel/camel-index.c b/camel/camel-index.c
index 82c37ae..8af9415 100644
--- a/camel/camel-index.c
+++ b/camel/camel-index.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <errno.h>
diff --git a/camel/camel-junk-filter.c b/camel/camel-junk-filter.c
index 8a058a9..54fa544 100644
--- a/camel/camel-junk-filter.c
+++ b/camel/camel-junk-filter.c
@@ -15,12 +15,12 @@
  *
  */
 
-#include "camel-junk-filter.h"
+#include "evolution-data-server-config.h"
 
-#include <config.h>
 #include <glib/gi18n-lib.h>
 
 #include "camel-operation.h"
+#include "camel-junk-filter.h"
 
 G_DEFINE_INTERFACE (CamelJunkFilter, camel_junk_filter, G_TYPE_OBJECT)
 
diff --git a/camel/camel-lock-client.c b/camel/camel-lock-client.c
index 012bec3..a08341e 100644
--- a/camel/camel-lock-client.c
+++ b/camel/camel-lock-client.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <fcntl.h>
diff --git a/camel/camel-lock.c b/camel/camel-lock.c
index 0307bc1..6bbda77 100644
--- a/camel/camel-lock.c
+++ b/camel/camel-lock.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <stdio.h>
@@ -29,18 +27,18 @@
 #include <time.h>
 #include <sys/stat.h>
 
-#ifdef USE_DOT
+#ifdef USE_DOT_LOCKING
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #endif
 
-#ifdef USE_FCNTL
+#ifdef USE_FCNTL_LOCKING
 #include <fcntl.h>
 #include <unistd.h>
 #endif
 
-#ifdef USE_FLOCK
+#ifdef USE_FLOCK_LOCKING
 #include <sys/file.h>
 #endif
 
@@ -76,7 +74,7 @@ gint
 camel_lock_dot (const gchar *path,
                 GError **error)
 {
-#ifdef USE_DOT
+#ifdef USE_DOT_LOCKING
        gchar *locktmp, *lock;
        gsize lock_len = 0;
        gsize locktmp_len = 0;
@@ -153,7 +151,7 @@ camel_lock_dot (const gchar *path,
                _("Timed out trying to get lock file on %s.  "
                "Try again later."), path);
        return -1;
-#else /* !USE_DOT */
+#else /* !USE_DOT_LOCKING */
        return 0;
 #endif
 }
@@ -167,7 +165,7 @@ camel_lock_dot (const gchar *path,
 void
 camel_unlock_dot (const gchar *path)
 {
-#ifdef USE_DOT
+#ifdef USE_DOT_LOCKING
        gchar *lock;
        gsize lock_len;
 
@@ -197,7 +195,7 @@ camel_lock_fcntl (gint fd,
                   CamelLockType type,
                   GError **error)
 {
-#ifdef USE_FCNTL
+#ifdef USE_FCNTL_LOCKING
        struct flock lock;
 
        d (printf ("fcntl locking %d\n", fd));
@@ -236,7 +234,7 @@ camel_lock_fcntl (gint fd,
 void
 camel_unlock_fcntl (gint fd)
 {
-#ifdef USE_FCNTL
+#ifdef USE_FCNTL_LOCKING
        struct flock lock;
 
        d (printf ("fcntl unlocking %d\n", fd));
@@ -265,7 +263,7 @@ camel_lock_flock (gint fd,
                   CamelLockType type,
                   GError **error)
 {
-#ifdef USE_FLOCK
+#ifdef USE_FLOCK_LOCKING
        gint op;
 
        d (printf ("flock locking %d\n", fd));
@@ -296,7 +294,7 @@ camel_lock_flock (gint fd,
 void
 camel_unlock_flock (gint fd)
 {
-#ifdef USE_FLOCK
+#ifdef USE_FLOCK_LOCKING
        d (printf ("flock unlocking %d\n", fd));
 
        CHECK_CALL (flock (fd, LOCK_UN));
diff --git a/camel/camel-medium.c b/camel/camel-medium.c
index b518383..dc0d5d0 100644
--- a/camel/camel-medium.c
+++ b/camel/camel-medium.c
@@ -19,9 +19,7 @@
  *         Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <stdio.h>
diff --git a/camel/camel-mime-filter-bestenc.c b/camel/camel-mime-filter-bestenc.c
index 6f91f04..1a377ed 100644
--- a/camel/camel-mime-filter-bestenc.c
+++ b/camel/camel-mime-filter-bestenc.c
@@ -16,9 +16,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <string.h>
diff --git a/camel/camel-mime-filter-canon.c b/camel/camel-mime-filter-canon.c
index 2f188f1..d5a6e84 100644
--- a/camel/camel-mime-filter-canon.c
+++ b/camel/camel-mime-filter-canon.c
@@ -20,9 +20,7 @@
 
 /* canonicalisation filter, used for secure mime incoming and outgoing */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <string.h>
diff --git a/camel/camel-mime-filter-charset.c b/camel/camel-mime-filter-charset.c
index 78133b1..c3b9d3d 100644
--- a/camel/camel-mime-filter-charset.c
+++ b/camel/camel-mime-filter-charset.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <string.h>
diff --git a/camel/camel-mime-filter-enriched.c b/camel/camel-mime-filter-enriched.c
index bb5dea0..d09b0f9 100644
--- a/camel/camel-mime-filter-enriched.c
+++ b/camel/camel-mime-filter-enriched.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/camel/camel-mime-filter-from.c b/camel/camel-mime-filter-from.c
index 6a02cfb..fa99700 100644
--- a/camel/camel-mime-filter-from.c
+++ b/camel/camel-mime-filter-from.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/camel/camel-mime-filter-gzip.c b/camel/camel-mime-filter-gzip.c
index 7685200..8e8c9e1 100644
--- a/camel/camel-mime-filter-gzip.c
+++ b/camel/camel-mime-filter-gzip.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <string.h>
diff --git a/camel/camel-mime-filter-linewrap.c b/camel/camel-mime-filter-linewrap.c
index 7c1e72e..790b9fb 100644
--- a/camel/camel-mime-filter-linewrap.c
+++ b/camel/camel-mime-filter-linewrap.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 
diff --git a/camel/camel-mime-filter-pgp.c b/camel/camel-mime-filter-pgp.c
index 521bb8e..ac29e26 100644
--- a/camel/camel-mime-filter-pgp.c
+++ b/camel/camel-mime-filter-pgp.c
@@ -21,9 +21,7 @@
 /* Strips PGP message headers from the input stream and also performs
  * pgp decoding as described in section 7.1 of RFC2440 */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <string.h>
diff --git a/camel/camel-mime-filter-progress.c b/camel/camel-mime-filter-progress.c
index a6056b1..08921f3 100644
--- a/camel/camel-mime-filter-progress.c
+++ b/camel/camel-mime-filter-progress.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <string.h>
diff --git a/camel/camel-mime-filter-tohtml.c b/camel/camel-mime-filter-tohtml.c
index 50c55ed..07024aa 100644
--- a/camel/camel-mime-filter-tohtml.c
+++ b/camel/camel-mime-filter-tohtml.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <string.h>
diff --git a/camel/camel-mime-filter-windows.c b/camel/camel-mime-filter-windows.c
index 884b3f8..d2358a1 100644
--- a/camel/camel-mime-filter-windows.c
+++ b/camel/camel-mime-filter-windows.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <stdio.h>
diff --git a/camel/camel-mime-filter-yenc.c b/camel/camel-mime-filter-yenc.c
index 0f18f0f..ba87c9e 100644
--- a/camel/camel-mime-filter-yenc.c
+++ b/camel/camel-mime-filter-yenc.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c
index c877a7a..d41b030 100644
--- a/camel/camel-mime-message.c
+++ b/camel/camel-mime-message.c
@@ -20,9 +20,7 @@
  *          Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <errno.h>
diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c
index 8959a25..9fe0f9e 100644
--- a/camel/camel-mime-part-utils.c
+++ b/camel/camel-mime-part-utils.c
@@ -20,9 +20,7 @@
  *          Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <errno.h>
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index 263a041..70b842b 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -20,9 +20,7 @@
  *          Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <errno.h>
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index c64f54f..7c33fb8 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -18,9 +18,7 @@
  *          Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/camel/camel-movemail.c b/camel/camel-movemail.c
index 9e4d067..4e00e2e 100644
--- a/camel/camel-movemail.c
+++ b/camel/camel-movemail.c
@@ -18,9 +18,7 @@
  * Authors: Dan Winship <danw ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <fcntl.h>
@@ -57,7 +55,7 @@ static void movemail_external (const gchar *source, const gchar *dest,
                               GError **error);
 #endif
 
-#ifdef HAVE_BROKEN_SPOOL
+#ifdef ENABLE_BROKEN_SPOOL
 static gint camel_movemail_copy_filter (gint fromfd, gint tofd, goffset start, gsize bytes, CamelMimeFilter 
*filter);
 static gint camel_movemail_solaris (gint oldsfd, gint dfd, GError **error);
 #else
@@ -147,7 +145,7 @@ camel_movemail (const gchar *source,
                return -1;
        }
 
-#ifdef HAVE_BROKEN_SPOOL
+#ifdef ENABLE_BROKEN_SPOOL
        res = camel_movemail_solaris (sfd, dfd, ex);
 #else
        res = camel_movemail_copy_file (sfd, dfd, error);
@@ -256,7 +254,7 @@ movemail_external (const gchar *source,
 }
 #endif
 
-#ifndef HAVE_BROKEN_SPOOL
+#ifndef ENABLE_BROKEN_SPOOL
 static gint
 camel_movemail_copy_file (gint sfd,
                           gint dfd,
@@ -358,7 +356,7 @@ camel_movemail_copy (gint fromfd,
 
 #define PRE_SIZE (32)
 
-#ifdef HAVE_BROKEN_SPOOL
+#ifdef ENABLE_BROKEN_SPOOL
 static gint
 camel_movemail_copy_filter (gint fromfd,
                             gint tofd,
@@ -574,5 +572,5 @@ fail:
 
        return -1;
 }
-#endif /* HAVE_BROKEN_SPOOL */
+#endif /* ENABLE_BROKEN_SPOOL */
 
diff --git a/camel/camel-msgport.c b/camel/camel-msgport.c
index 210315d..26a9cd0 100644
--- a/camel/camel-msgport.c
+++ b/camel/camel-msgport.c
@@ -16,9 +16,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <unistd.h>
diff --git a/camel/camel-multipart-encrypted.c b/camel/camel-multipart-encrypted.c
index 312dca9..5853b3e 100644
--- a/camel/camel-multipart-encrypted.c
+++ b/camel/camel-multipart-encrypted.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "camel-multipart-encrypted.h"
 
diff --git a/camel/camel-multipart-signed.c b/camel/camel-multipart-signed.c
index 0480c61..737131e 100644
--- a/camel/camel-multipart-signed.c
+++ b/camel/camel-multipart-signed.c
@@ -18,9 +18,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <stdio.h>
diff --git a/camel/camel-multipart.c b/camel/camel-multipart.c
index e33f31f..0836b5e 100644
--- a/camel/camel-multipart.c
+++ b/camel/camel-multipart.c
@@ -18,9 +18,7 @@
  * Authors: Bertrand Guiheneuf <bertrand helixcode com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <string.h> /* strlen() */
diff --git a/camel/camel-net-utils.c b/camel/camel-net-utils.c
index 91cfafd..cf56e82 100644
--- a/camel/camel-net-utils.c
+++ b/camel/camel-net-utils.c
@@ -19,9 +19,7 @@
  *         Chris Toshok <toshok ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <stdio.h>
diff --git a/camel/camel-network-service.c b/camel/camel-network-service.c
index df0ca64..5758c5b 100644
--- a/camel/camel-network-service.c
+++ b/camel/camel-network-service.c
@@ -14,9 +14,7 @@
  * along with this library. If not, see <http://www.gnu.org/licenses/>.
  *
  */
-#if HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "camel-network-service.h"
 
diff --git a/camel/camel-object.c b/camel/camel-object.c
index 1c3a545..ea7a0b8 100644
--- a/camel/camel-object.c
+++ b/camel/camel-object.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <stdio.h>
diff --git a/camel/camel-offline-folder.c b/camel/camel-offline-folder.c
index 9d3da37..217515d 100644
--- a/camel/camel-offline-folder.c
+++ b/camel/camel-offline-folder.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj novell com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n-lib.h>
 
diff --git a/camel/camel-offline-store.c b/camel/camel-offline-store.c
index 2865906..b49b786 100644
--- a/camel/camel-offline-store.c
+++ b/camel/camel-offline-store.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj novell com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n-lib.h>
 
diff --git a/camel/camel-operation.c b/camel/camel-operation.c
index 388f3b6..b160c90 100644
--- a/camel/camel-operation.c
+++ b/camel/camel-operation.c
@@ -15,7 +15,7 @@
  *
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <unistd.h>
diff --git a/camel/camel-partition-table.c b/camel/camel-partition-table.c
index 2a2b6fe..e51c16b 100644
--- a/camel/camel-partition-table.c
+++ b/camel/camel-partition-table.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <fcntl.h>
diff --git a/camel/camel-provider.c b/camel/camel-provider.c
index c469270..45d2611 100644
--- a/camel/camel-provider.c
+++ b/camel/camel-provider.c
@@ -22,9 +22,7 @@
 
 /* FIXME: Shouldn't we add a version number to providers ? */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <stdio.h>
diff --git a/camel/camel-sasl-anonymous.c b/camel/camel-sasl-anonymous.c
index 2ca3c16..62c1fe0 100644
--- a/camel/camel-sasl-anonymous.c
+++ b/camel/camel-sasl-anonymous.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/camel/camel-sasl-cram-md5.c b/camel/camel-sasl-cram-md5.c
index ae79478..3ca12b6 100644
--- a/camel/camel-sasl-cram-md5.c
+++ b/camel/camel-sasl-cram-md5.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <string.h>
diff --git a/camel/camel-sasl-digest-md5.c b/camel/camel-sasl-digest-md5.c
index b41d9da..0312ba0 100644
--- a/camel/camel-sasl-digest-md5.c
+++ b/camel/camel-sasl-digest-md5.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <stdio.h>
diff --git a/camel/camel-sasl-gssapi.c b/camel/camel-sasl-gssapi.c
index b1f919d..08d429d 100644
--- a/camel/camel-sasl-gssapi.c
+++ b/camel/camel-sasl-gssapi.c
@@ -19,9 +19,7 @@
 
 /* If building without Kerberos support, this class is an empty shell. */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 
diff --git a/camel/camel-sasl-login.c b/camel/camel-sasl-login.c
index 8716783..703805e 100644
--- a/camel/camel-sasl-login.c
+++ b/camel/camel-sasl-login.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/camel/camel-sasl-ntlm.c b/camel/camel-sasl-ntlm.c
index 6c6c18e..4ee5a7d 100644
--- a/camel/camel-sasl-ntlm.c
+++ b/camel/camel-sasl-ntlm.c
@@ -16,9 +16,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <string.h>
diff --git a/camel/camel-sasl-plain.c b/camel/camel-sasl-plain.c
index 7e2b4d2..09b4dd7 100644
--- a/camel/camel-sasl-plain.c
+++ b/camel/camel-sasl-plain.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/camel/camel-sasl-popb4smtp.c b/camel/camel-sasl-popb4smtp.c
index 5843a8f..26ef512 100644
--- a/camel/camel-sasl-popb4smtp.c
+++ b/camel/camel-sasl-popb4smtp.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 #include <time.h>
diff --git a/camel/camel-sasl.c b/camel/camel-sasl.c
index 9096f88..38a55ce 100644
--- a/camel/camel-sasl.c
+++ b/camel/camel-sasl.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/camel/camel-search-private.c b/camel/camel-search-private.c
index d68d86f..ced34e9 100644
--- a/camel/camel-search-private.c
+++ b/camel/camel-search-private.c
@@ -18,9 +18,7 @@
  *         Michael Zucchi <NotZed Ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 /* POSIX requires <sys/types.h> be included before <regex.h> */
 #include <sys/types.h>
diff --git a/camel/camel-search-sql-sexp.c b/camel/camel-search-sql-sexp.c
index 5d98e0e..2ecbf21 100644
--- a/camel/camel-search-sql-sexp.c
+++ b/camel/camel-search-sql-sexp.c
@@ -21,9 +21,7 @@
  * It implements enough to do basic searches on folders that can provide
  * an in-memory summary and a body index. */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <string.h>
diff --git a/camel/camel-service.c b/camel/camel-service.c
index ee669ff..cc4cac9 100644
--- a/camel/camel-service.c
+++ b/camel/camel-service.c
@@ -18,9 +18,7 @@
  * Authors: Bertrand Guiheneuf <bertrand helixcode com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <errno.h>
diff --git a/camel/camel-session.c b/camel/camel-session.c
index 10437dd..1c4fcc5 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -20,9 +20,7 @@
  *          Bertrand Guiheneuf <bertrand helixcode com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <stdio.h>
diff --git a/camel/camel-sexp.c b/camel/camel-sexp.c
index 140b6d7..41664c4 100644
--- a/camel/camel-sexp.c
+++ b/camel/camel-sexp.c
@@ -78,7 +78,8 @@
  *         Execute a sequence.  The last function return is the return type.
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
diff --git a/camel/camel-smime-context.c b/camel/camel-smime-context.c
index e75aecd..1e18a1d 100644
--- a/camel/camel-smime-context.c
+++ b/camel/camel-smime-context.c
@@ -23,9 +23,7 @@
  *          Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #ifdef ENABLE_SMIME
 
diff --git a/camel/camel-store-summary.c b/camel/camel-store-summary.c
index 94497f6..23527bc 100644
--- a/camel/camel-store-summary.c
+++ b/camel/camel-store-summary.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <errno.h>
diff --git a/camel/camel-store.c b/camel/camel-store.c
index 09f2163..4d4f112 100644
--- a/camel/camel-store.c
+++ b/camel/camel-store.c
@@ -19,9 +19,7 @@
  *          Dan Winship <danw ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <string.h>
diff --git a/camel/camel-stream-buffer.c b/camel/camel-stream-buffer.c
index 4ef6d49..7ad8c62 100644
--- a/camel/camel-stream-buffer.c
+++ b/camel/camel-stream-buffer.c
@@ -18,9 +18,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <fcntl.h>
diff --git a/camel/camel-stream-filter.c b/camel/camel-stream-filter.c
index 1430433..9ef6df5 100644
--- a/camel/camel-stream-filter.c
+++ b/camel/camel-stream-filter.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <stdio.h>
diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c
index 389db0a..78045df 100644
--- a/camel/camel-stream-fs.c
+++ b/camel/camel-stream-fs.c
@@ -19,9 +19,7 @@
  *         Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <string.h>
diff --git a/camel/camel-stream-mem.c b/camel/camel-stream-mem.c
index 0120834..e7c2e1d 100644
--- a/camel/camel-stream-mem.c
+++ b/camel/camel-stream-mem.c
@@ -19,9 +19,7 @@
  *         Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <fcntl.h>
diff --git a/camel/camel-stream-null.c b/camel/camel-stream-null.c
index 24283bd..db75989 100644
--- a/camel/camel-stream-null.c
+++ b/camel/camel-stream-null.c
@@ -18,9 +18,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n-lib.h>
 
diff --git a/camel/camel-stream-process.c b/camel/camel-stream-process.c
index fd3f7c7..c8ab3ac 100644
--- a/camel/camel-stream-process.c
+++ b/camel/camel-stream-process.c
@@ -19,9 +19,7 @@
  *          Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <fcntl.h>
diff --git a/camel/camel-stream.c b/camel/camel-stream.c
index 5973f48..3841819 100644
--- a/camel/camel-stream.c
+++ b/camel/camel-stream.c
@@ -18,13 +18,14 @@
  * Authors: Bertrand Guiheneuf <bertrand helixcode com>
  */
 
-#include "camel-stream.h"
+#include "evolution-data-server-config.h"
 
-#include <config.h>
 #include <glib/gi18n-lib.h>
 
 #include <camel/camel-debug.h>
 
+#include "camel-stream.h"
+
 #define CAMEL_STREAM_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
        ((obj), CAMEL_TYPE_STREAM, CamelStreamPrivate))
diff --git a/camel/camel-string-utils.c b/camel/camel-string-utils.c
index 1fcf510..f362c85 100644
--- a/camel/camel-string-utils.c
+++ b/camel/camel-string-utils.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/camel/camel-subscribable.c b/camel/camel-subscribable.c
index a33c3a8..3ec4f58 100644
--- a/camel/camel-subscribable.c
+++ b/camel/camel-subscribable.c
@@ -15,9 +15,8 @@
  *
  */
 
-#include "camel-subscribable.h"
+#include "evolution-data-server-config.h"
 
-#include <config.h>
 #include <glib/gi18n-lib.h>
 
 #include "camel-async-closure.h"
@@ -25,6 +24,8 @@
 #include "camel-session.h"
 #include "camel-vtrash-folder.h"
 
+#include "camel-subscribable.h"
+
 typedef struct _AsyncContext AsyncContext;
 typedef struct _SignalClosure SignalClosure;
 
diff --git a/camel/camel-text-index.c b/camel/camel-text-index.c
index dbf5f8f..7807753 100644
--- a/camel/camel-text-index.c
+++ b/camel/camel-text-index.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <errno.h>
diff --git a/camel/camel-transport.c b/camel/camel-transport.c
index ddde8ea..d83eef0 100644
--- a/camel/camel-transport.c
+++ b/camel/camel-transport.c
@@ -18,9 +18,7 @@
  * Authors: Dan Winship <danw ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "camel-address.h"
 #include "camel-async-closure.h"
diff --git a/camel/camel-trie.c b/camel/camel-trie.c
index bb414e5..4d9ea9f 100644
--- a/camel/camel-trie.c
+++ b/camel/camel-trie.c
@@ -16,9 +16,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <string.h>
diff --git a/camel/camel-uid-cache.c b/camel/camel-uid-cache.c
index 2033894..e6fbc28 100644
--- a/camel/camel-uid-cache.c
+++ b/camel/camel-uid-cache.c
@@ -18,9 +18,7 @@
  * Authors: Dan Winship <danw ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <fcntl.h>
diff --git a/camel/camel-url-scanner.c b/camel/camel-url-scanner.c
index 773c6db..c977e14 100644
--- a/camel/camel-url-scanner.c
+++ b/camel/camel-url-scanner.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <stdio.h>
diff --git a/camel/camel-url.c b/camel/camel-url.c
index 5cc477f..b51ed09 100644
--- a/camel/camel-url.c
+++ b/camel/camel-url.c
@@ -19,9 +19,7 @@
  *          Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <stdio.h>
diff --git a/camel/camel-utf8.c b/camel/camel-utf8.c
index 5c34c11..b2c7420 100644
--- a/camel/camel-utf8.c
+++ b/camel/camel-utf8.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 #include <sys/types.h>
diff --git a/camel/camel-vee-data-cache.c b/camel/camel-vee-data-cache.c
index ba439e0..b3567e8 100644
--- a/camel/camel-vee-data-cache.c
+++ b/camel/camel-vee-data-cache.c
@@ -16,9 +16,7 @@
  * Authors: Milan Crha <mcrha redhat com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "camel-string-utils.h"
 #include "camel-store.h"
diff --git a/camel/camel-vee-folder.c b/camel/camel-vee-folder.c
index 5566caa..a6355ad 100644
--- a/camel/camel-vee-folder.c
+++ b/camel/camel-vee-folder.c
@@ -18,9 +18,7 @@
  *          Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/camel/camel-vee-store.c b/camel/camel-vee-store.c
index 93697ba..393207c 100644
--- a/camel/camel-vee-store.c
+++ b/camel/camel-vee-store.c
@@ -16,9 +16,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/camel/camel-vee-summary.c b/camel/camel-vee-summary.c
index 1d64469..ddd527d 100644
--- a/camel/camel-vee-summary.c
+++ b/camel/camel-vee-summary.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <stdlib.h>
diff --git a/camel/camel-vtrash-folder.c b/camel/camel-vtrash-folder.c
index 7362009..b8eef41 100644
--- a/camel/camel-vtrash-folder.c
+++ b/camel/camel-vtrash-folder.c
@@ -18,9 +18,7 @@
  *         Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/camel/camel-win32.h b/camel/camel-win32.h
index 99b726b..d906054 100644
--- a/camel/camel-win32.h
+++ b/camel/camel-win32.h
@@ -24,9 +24,7 @@
 /* need a way to configure and save this data, if this header is to
    be installed.  For now, dont install it */
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib.h>
 
diff --git a/camel/camel.c b/camel/camel.c
index 0789426..9a4564c 100644
--- a/camel/camel.c
+++ b/camel/camel.c
@@ -18,9 +18,7 @@
  *          Bertrand Guiheneuf <bertrand helixcode com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <signal.h>
 
diff --git a/camel/camel.pc.in b/camel/camel.pc.in
index 8009590..55e1099 100644
--- a/camel/camel.pc.in
+++ b/camel/camel.pc.in
@@ -1,7 +1,6 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+includedir=@INCLUDE_INSTALL_DIR@
 
 privlibdir=@privlibdir@
 privincludedir=@privincludedir@
@@ -10,7 +9,7 @@ camel_providerdir=@camel_providerdir@
 
 Name: camel
 Description: the Evolution MIME message handling library
-Version: @VERSION@
+Version: @PROJECT_VERSION@
 Requires: gio-2.0 sqlite3 @mozilla_nss@ @mozilla_nspr@
-Libs: -L${libdir} -lcamel-1.2 @MANUAL_NSS_LIBS@
+Libs: -L${libdir} -lcamel-@API_VERSION@ @MANUAL_NSS_LIBS@
 Cflags: -I${privincludedir} @MANUAL_NSS_CFLAGS@
diff --git a/camel/providers/CMakeLists.txt b/camel/providers/CMakeLists.txt
new file mode 100644
index 0000000..c1e5859
--- /dev/null
+++ b/camel/providers/CMakeLists.txt
@@ -0,0 +1,9 @@
+add_subdirectory(imapx)
+add_subdirectory(local)
+add_subdirectory(nntp)
+add_subdirectory(pop3)
+add_subdirectory(smtp)
+
+if(NOT WIN32)
+       add_subdirectory(sendmail)
+endif(NOT WIN32)
\ No newline at end of file
diff --git a/camel/providers/imapx/CMakeLists.txt b/camel/providers/imapx/CMakeLists.txt
new file mode 100644
index 0000000..77c2dbc
--- /dev/null
+++ b/camel/providers/imapx/CMakeLists.txt
@@ -0,0 +1,92 @@
+set(SOURCES
+       camel-imapx-provider.c
+       camel-imapx-command.c
+       camel-imapx-command.h
+       camel-imapx-conn-manager.c
+       camel-imapx-conn-manager.h
+       camel-imapx-folder.c
+       camel-imapx-folder.h
+       camel-imapx-input-stream.c
+       camel-imapx-input-stream.h
+       camel-imapx-job.c
+       camel-imapx-job.h
+       camel-imapx-list-response.c
+       camel-imapx-list-response.h
+       camel-imapx-logger.c
+       camel-imapx-logger.h
+       camel-imapx-mailbox.c
+       camel-imapx-mailbox.h
+       camel-imapx-namespace.c
+       camel-imapx-namespace.h
+       camel-imapx-namespace-response.c
+       camel-imapx-namespace-response.h
+       camel-imapx-search.c
+       camel-imapx-search.h
+       camel-imapx-server.c
+       camel-imapx-server.h
+       camel-imapx-settings.c
+       camel-imapx-settings.h
+       camel-imapx-status-response.c
+       camel-imapx-status-response.h
+       camel-imapx-store.c
+       camel-imapx-store.h
+       camel-imapx-store-summary.c
+       camel-imapx-store-summary.h
+       camel-imapx-summary.c
+       camel-imapx-summary.h
+       camel-imapx-tokenise.h
+       camel-imapx-utils.c
+       camel-imapx-utils.h
+)
+
+set(DEPENDENCIES
+       camel
+)
+
+add_custom_command(
+       OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/camel-imapx-tokenise.h
+       COMMAND ${GPERF} -H imapx_hash -N imapx_tokenise_struct -L ANSI-C -o -t -k1,$$ 
${CMAKE_CURRENT_SOURCE_DIR}/camel-imapx-tokens.txt 
--output-file=${CMAKE_CURRENT_BINARY_DIR}/camel-imapx-tokenise.h
+       DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/camel-imapx-tokens.txt
+)
+
+add_library(camelimapx MODULE ${SOURCES})
+
+add_dependencies(camelimapx
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(camelimapx PRIVATE
+       -DG_LOG_DOMAIN=\"camel-imapx-provider\"
+)
+
+target_compile_options(camelimapx PUBLIC
+       ${CAMEL_CFLAGS}
+       ${GIO_UNIX_CFLAGS}
+       ${CALENDAR_CFLAGS}
+)
+
+target_include_directories(camelimapx PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/camel
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/camel
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${CAMEL_INCLUDE_DIRS}
+       ${GIO_UNIX_INCLUDE_DIRS}
+       ${CALENDAR_INCLUDE_DIRS}
+)
+
+target_link_libraries(camelimapx
+       ${DEPENDENCIES}
+       ${CAMEL_LDFLAGS}
+       ${GIO_UNIX_LDFLAGS}
+       ${CALENDAR_LDFLAGS}
+)
+
+install(TARGETS camelimapx
+       DESTINATION ${camel_providerdir}
+)
+
+install(FILES libcamelimapx.urls
+       DESTINATION ${camel_providerdir}
+)
diff --git a/camel/providers/imapx/camel-imapx-command.c b/camel/providers/imapx/camel-imapx-command.c
index e56dd6a..cf54416 100644
--- a/camel/providers/imapx/camel-imapx-command.c
+++ b/camel/providers/imapx/camel-imapx-command.c
@@ -15,9 +15,8 @@
  *
  */
 
-#include "camel-imapx-command.h"
+#include "evolution-data-server-config.h"
 
-#include <config.h>
 #include <string.h>
 #include <glib/gstdio.h>
 #include <glib/gi18n-lib.h>
@@ -26,6 +25,8 @@
 #include "camel-imapx-server.h"
 #include "camel-imapx-store.h"
 
+#include "camel-imapx-command.h"
+
 #define c(...) camel_imapx_debug(command, __VA_ARGS__)
 
 typedef struct _CamelIMAPXRealCommand CamelIMAPXRealCommand;
diff --git a/camel/providers/imapx/camel-imapx-conn-manager.c 
b/camel/providers/imapx/camel-imapx-conn-manager.c
index c8bda8b..983c69b 100644
--- a/camel/providers/imapx/camel-imapx-conn-manager.c
+++ b/camel/providers/imapx/camel-imapx-conn-manager.c
@@ -18,9 +18,7 @@
  * Authors: Chenthill Palanisamy <pchenthill novell com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib.h>
 #include <glib/gi18n-lib.h>
diff --git a/camel/providers/imapx/camel-imapx-folder.c b/camel/providers/imapx/camel-imapx-folder.c
index 1002a30..0d73287 100644
--- a/camel/providers/imapx/camel-imapx-folder.c
+++ b/camel/providers/imapx/camel-imapx-folder.c
@@ -18,9 +18,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <glib/gi18n-lib.h>
diff --git a/camel/providers/imapx/camel-imapx-input-stream.c 
b/camel/providers/imapx/camel-imapx-input-stream.c
index 8afb0a6..b71bd74 100644
--- a/camel/providers/imapx/camel-imapx-input-stream.c
+++ b/camel/providers/imapx/camel-imapx-input-stream.c
@@ -15,9 +15,8 @@
  *
  */
 
-#include "camel-imapx-input-stream.h"
+#include "evolution-data-server-config.h"
 
-#include <config.h>
 #include <string.h>
 #include <stdio.h>
 #include <ctype.h>
@@ -30,6 +29,8 @@
 #include "camel-imapx-server.h"
 #include "camel-imapx-utils.h"
 
+#include "camel-imapx-input-stream.h"
+
 #define CAMEL_IMAPX_INPUT_STREAM_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
        ((obj), CAMEL_TYPE_IMAPX_INPUT_STREAM, CamelIMAPXInputStreamPrivate))
diff --git a/camel/providers/imapx/camel-imapx-job.c b/camel/providers/imapx/camel-imapx-job.c
index 635ceaf..ed9c45a 100644
--- a/camel/providers/imapx/camel-imapx-job.c
+++ b/camel/providers/imapx/camel-imapx-job.c
@@ -14,9 +14,8 @@
  * along with this library. If not, see <http://www.gnu.org/licenses/>.
  *
  */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/camel/providers/imapx/camel-imapx-provider.c b/camel/providers/imapx/camel-imapx-provider.c
index bc9b94a..9036364 100644
--- a/camel/providers/imapx/camel-imapx-provider.c
+++ b/camel/providers/imapx/camel-imapx-provider.c
@@ -20,9 +20,7 @@
  *   Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 #include <camel/camel.h>
diff --git a/camel/providers/imapx/camel-imapx-search.c b/camel/providers/imapx/camel-imapx-search.c
index a14ba6e..b4e0a80 100644
--- a/camel/providers/imapx/camel-imapx-search.c
+++ b/camel/providers/imapx/camel-imapx-search.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "camel-imapx-search.h"
 
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index f2bd005..518dbe3 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -16,9 +16,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <fcntl.h>
diff --git a/camel/providers/imapx/camel-imapx-store-summary.c 
b/camel/providers/imapx/camel-imapx-store-summary.c
index ef58f6d..6b0158e 100644
--- a/camel/providers/imapx/camel-imapx-store-summary.c
+++ b/camel/providers/imapx/camel-imapx-store-summary.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <errno.h>
diff --git a/camel/providers/imapx/camel-imapx-store.c b/camel/providers/imapx/camel-imapx-store.c
index cca9c25..96bbb84 100644
--- a/camel/providers/imapx/camel-imapx-store.c
+++ b/camel/providers/imapx/camel-imapx-store.c
@@ -18,9 +18,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <sys/types.h>
 #ifdef _WIN32
diff --git a/camel/providers/imapx/camel-imapx-summary.c b/camel/providers/imapx/camel-imapx-summary.c
index dbaff72..6e3a2d2 100644
--- a/camel/providers/imapx/camel-imapx-summary.c
+++ b/camel/providers/imapx/camel-imapx-summary.c
@@ -18,9 +18,7 @@
  *          Dan Winship <danw ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <stdlib.h>
diff --git a/camel/providers/imapx/camel-imapx-utils.c b/camel/providers/imapx/camel-imapx-utils.c
index e94e123..c60666d 100644
--- a/camel/providers/imapx/camel-imapx-utils.c
+++ b/camel/providers/imapx/camel-imapx-utils.c
@@ -16,9 +16,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <errno.h>
diff --git a/camel/providers/local/CMakeLists.txt b/camel/providers/local/CMakeLists.txt
new file mode 100644
index 0000000..1077c90
--- /dev/null
+++ b/camel/providers/local/CMakeLists.txt
@@ -0,0 +1,83 @@
+set(SOURCES
+       camel-local-folder.c
+       camel-local-folder.h
+       camel-local-store.c
+       camel-local-store.h
+       camel-local-summary.c
+       camel-local-summary.h
+       camel-local-private.c
+       camel-local-private.h
+       camel-local-provider.c
+       camel-maildir-folder.c
+       camel-maildir-folder.h
+       camel-maildir-store.c
+       camel-maildir-store.h
+       camel-maildir-summary.c
+       camel-maildir-summary.h
+       camel-mbox-folder.c
+       camel-mbox-folder.h
+       camel-mbox-store.c
+       camel-mbox-store.h
+       camel-mbox-summary.c
+       camel-mbox-summary.h
+       camel-mh-folder.c
+       camel-mh-folder.h
+       camel-mh-settings.c
+       camel-mh-settings.h
+       camel-mh-store.c
+       camel-mh-store.h
+       camel-mh-summary.c
+       camel-mh-summary.h
+)
+
+set(DEPENDENCIES
+       camel
+)
+
+if(NOT WIN32)
+       list(APPEND SOURCES
+               camel-spool-folder.c
+               camel-spool-folder.h
+               camel-spool-settings.c
+               camel-spool-settings.h
+               camel-spool-store.c
+               camel-spool-store.h
+               camel-spool-summary.c
+               camel-spool-summary.h
+       )
+endif(NOT WIN32)
+
+add_library(camellocal MODULE ${SOURCES})
+
+add_dependencies(camellocal
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(camellocal PRIVATE
+       -DG_LOG_DOMAIN=\"camel-local-provider\"
+)
+
+target_compile_options(camellocal PUBLIC
+       ${CAMEL_CFLAGS}
+)
+
+target_include_directories(camellocal PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/camel
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/camel
+       ${CAMEL_INCLUDE_DIRS}
+)
+
+target_link_libraries(camellocal
+       ${DEPENDENCIES}
+       ${CAMEL_LDFLAGS}
+)
+
+install(TARGETS camellocal
+       DESTINATION ${camel_providerdir}
+)
+
+install(FILES libcamellocal.urls
+       DESTINATION ${camel_providerdir}
+)
diff --git a/camel/providers/local/camel-local-folder.c b/camel/providers/local/camel-local-folder.c
index 00987b1..47ba761 100644
--- a/camel/providers/local/camel-local-folder.c
+++ b/camel/providers/local/camel-local-folder.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <fcntl.h>
diff --git a/camel/providers/local/camel-local-private.c b/camel/providers/local/camel-local-private.c
index 75eae8d..f19c784 100644
--- a/camel/providers/local/camel-local-private.c
+++ b/camel/providers/local/camel-local-private.c
@@ -16,9 +16,7 @@
  * Authors: Srinivsa Ragavan <sragavan novell com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdlib.h>
 #include <string.h>
diff --git a/camel/providers/local/camel-local-private.h b/camel/providers/local/camel-local-private.h
index 1da21ce..71eebc8 100644
--- a/camel/providers/local/camel-local-private.h
+++ b/camel/providers/local/camel-local-private.h
@@ -23,9 +23,7 @@
 /* need a way to configure and save this data, if this header is to
  * be installed.  For now, dont install it */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib.h>
 
diff --git a/camel/providers/local/camel-local-provider.c b/camel/providers/local/camel-local-provider.c
index de41646..0613dd0 100644
--- a/camel/providers/local/camel-local-provider.c
+++ b/camel/providers/local/camel-local-provider.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <string.h>
diff --git a/camel/providers/local/camel-local-store.c b/camel/providers/local/camel-local-store.c
index 2362381..324a44e 100644
--- a/camel/providers/local/camel-local-store.c
+++ b/camel/providers/local/camel-local-store.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <stdio.h>
diff --git a/camel/providers/local/camel-local-summary.c b/camel/providers/local/camel-local-summary.c
index 11caeed..9fee506 100644
--- a/camel/providers/local/camel-local-summary.c
+++ b/camel/providers/local/camel-local-summary.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <errno.h>
diff --git a/camel/providers/local/camel-maildir-folder.c b/camel/providers/local/camel-maildir-folder.c
index 5ff9a13..7ec56fd 100644
--- a/camel/providers/local/camel-maildir-folder.c
+++ b/camel/providers/local/camel-maildir-folder.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <dirent.h>
 #include <errno.h>
diff --git a/camel/providers/local/camel-maildir-store.c b/camel/providers/local/camel-maildir-store.c
index 2c53329..be483b1 100644
--- a/camel/providers/local/camel-maildir-store.c
+++ b/camel/providers/local/camel-maildir-store.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <dirent.h>
 #include <errno.h>
diff --git a/camel/providers/local/camel-maildir-summary.c b/camel/providers/local/camel-maildir-summary.c
index ca5fb94..2c5a56b 100644
--- a/camel/providers/local/camel-maildir-summary.c
+++ b/camel/providers/local/camel-maildir-summary.c
@@ -16,9 +16,7 @@
  * Authors: Not Zed <notzed lostzed mmc com au>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <dirent.h>
diff --git a/camel/providers/local/camel-mbox-folder.c b/camel/providers/local/camel-mbox-folder.c
index 478ec31..56ca428 100644
--- a/camel/providers/local/camel-mbox-folder.c
+++ b/camel/providers/local/camel-mbox-folder.c
@@ -18,9 +18,7 @@
  *          Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <fcntl.h>
diff --git a/camel/providers/local/camel-mbox-store.c b/camel/providers/local/camel-mbox-store.c
index 87829cf..cff6ff1 100644
--- a/camel/providers/local/camel-mbox-store.c
+++ b/camel/providers/local/camel-mbox-store.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <fcntl.h>
diff --git a/camel/providers/local/camel-mbox-summary.c b/camel/providers/local/camel-mbox-summary.c
index b169a74..4e82fdc 100644
--- a/camel/providers/local/camel-mbox-summary.c
+++ b/camel/providers/local/camel-mbox-summary.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <errno.h>
diff --git a/camel/providers/local/camel-mh-folder.c b/camel/providers/local/camel-mh-folder.c
index 2a745e6..7eaafe9 100644
--- a/camel/providers/local/camel-mh-folder.c
+++ b/camel/providers/local/camel-mh-folder.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <dirent.h>
 #include <errno.h>
diff --git a/camel/providers/local/camel-mh-store.c b/camel/providers/local/camel-mh-store.c
index 3cae858..7f771ec 100644
--- a/camel/providers/local/camel-mh-store.c
+++ b/camel/providers/local/camel-mh-store.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <dirent.h>
 #include <errno.h>
diff --git a/camel/providers/local/camel-mh-summary.c b/camel/providers/local/camel-mh-summary.c
index 09372e5..b653192 100644
--- a/camel/providers/local/camel-mh-summary.c
+++ b/camel/providers/local/camel-mh-summary.c
@@ -16,9 +16,7 @@
  * Authors: Not Zed <notzed lostzed mmc com au>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <dirent.h>
diff --git a/camel/providers/local/camel-spool-folder.c b/camel/providers/local/camel-spool-folder.c
index 3ea2732..af8c064 100644
--- a/camel/providers/local/camel-spool-folder.c
+++ b/camel/providers/local/camel-spool-folder.c
@@ -16,9 +16,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <dirent.h>
 #include <errno.h>
diff --git a/camel/providers/local/camel-spool-store.c b/camel/providers/local/camel-spool-store.c
index 2a5849d..b97810d 100644
--- a/camel/providers/local/camel-spool-store.c
+++ b/camel/providers/local/camel-spool-store.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <dirent.h>
 #include <errno.h>
diff --git a/camel/providers/local/camel-spool-summary.c b/camel/providers/local/camel-spool-summary.c
index 1b6c835..44e3719 100644
--- a/camel/providers/local/camel-spool-summary.c
+++ b/camel/providers/local/camel-spool-summary.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <errno.h>
diff --git a/camel/providers/nntp/CMakeLists.txt b/camel/providers/nntp/CMakeLists.txt
new file mode 100644
index 0000000..8a05bff
--- /dev/null
+++ b/camel/providers/nntp/CMakeLists.txt
@@ -0,0 +1,56 @@
+set(SOURCES
+       camel-nntp-folder.c
+       camel-nntp-folder.h
+       camel-nntp-private.h
+       camel-nntp-provider.c
+       camel-nntp-resp-codes.h
+       camel-nntp-settings.c
+       camel-nntp-settings.h
+       camel-nntp-store-summary.c
+       camel-nntp-store-summary.h
+       camel-nntp-store.c
+       camel-nntp-store.h
+       camel-nntp-stream.c
+       camel-nntp-stream.h
+       camel-nntp-summary.c
+       camel-nntp-summary.h
+)
+
+set(DEPENDENCIES
+       camel
+)
+
+add_library(camelnntp MODULE ${SOURCES})
+
+add_dependencies(camelnntp
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(camelnntp PRIVATE
+       -DG_LOG_DOMAIN=\"camel-nntp-provider\"
+)
+
+target_compile_options(camelnntp PUBLIC
+       ${CAMEL_CFLAGS}
+)
+
+target_include_directories(camelnntp PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/camel
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/camel
+       ${CAMEL_INCLUDE_DIRS}
+)
+
+target_link_libraries(camelnntp
+       ${DEPENDENCIES}
+       ${CAMEL_LDFLAGS}
+)
+
+install(TARGETS camelnntp
+       DESTINATION ${camel_providerdir}
+)
+
+install(FILES libcamelnntp.urls
+       DESTINATION ${camel_providerdir}
+)
diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c
index ad65baf..8e45b11 100644
--- a/camel/providers/nntp/camel-nntp-folder.c
+++ b/camel/providers/nntp/camel-nntp-folder.c
@@ -19,9 +19,7 @@
  *           Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdlib.h>
 #include <string.h>
diff --git a/camel/providers/nntp/camel-nntp-private.h b/camel/providers/nntp/camel-nntp-private.h
index 6b7f0c3..e1df345 100644
--- a/camel/providers/nntp/camel-nntp-private.h
+++ b/camel/providers/nntp/camel-nntp-private.h
@@ -24,9 +24,7 @@
 /* need a way to configure and save this data, if this header is to
  * be installed.  For now, dont install it */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 G_BEGIN_DECLS
 
diff --git a/camel/providers/nntp/camel-nntp-provider.c b/camel/providers/nntp/camel-nntp-provider.c
index db28e25..a2382a1 100644
--- a/camel/providers/nntp/camel-nntp-provider.c
+++ b/camel/providers/nntp/camel-nntp-provider.c
@@ -19,9 +19,7 @@
  *   Chris Toshok <toshok ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/camel/providers/nntp/camel-nntp-store-summary.c b/camel/providers/nntp/camel-nntp-store-summary.c
index e3664a9..cacccce 100644
--- a/camel/providers/nntp/camel-nntp-store-summary.c
+++ b/camel/providers/nntp/camel-nntp-store-summary.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <stdlib.h>
diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
index fda075f..100dd09 100644
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@ -18,9 +18,7 @@
  *         Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <stdio.h>
diff --git a/camel/providers/nntp/camel-nntp-stream.c b/camel/providers/nntp/camel-nntp-stream.c
index eb39870..ad5d7da 100644
--- a/camel/providers/nntp/camel-nntp-stream.c
+++ b/camel/providers/nntp/camel-nntp-stream.c
@@ -16,9 +16,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <stdio.h>
diff --git a/camel/providers/nntp/camel-nntp-summary.c b/camel/providers/nntp/camel-nntp-summary.c
index 32b15a8..d4c47aa 100644
--- a/camel/providers/nntp/camel-nntp-summary.c
+++ b/camel/providers/nntp/camel-nntp-summary.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <errno.h>
diff --git a/camel/providers/pop3/CMakeLists.txt b/camel/providers/pop3/CMakeLists.txt
new file mode 100644
index 0000000..6a56cb4
--- /dev/null
+++ b/camel/providers/pop3/CMakeLists.txt
@@ -0,0 +1,52 @@
+set(SOURCES
+       camel-pop3-engine.c
+       camel-pop3-engine.h
+       camel-pop3-folder.c
+       camel-pop3-folder.h
+       camel-pop3-provider.c
+       camel-pop3-settings.c
+       camel-pop3-settings.h
+       camel-pop3-stream.c
+       camel-pop3-stream.h
+       camel-pop3-store.c
+       camel-pop3-store.h
+)
+
+set(DEPENDENCIES
+       camel
+)
+
+add_library(camelpop3 MODULE ${SOURCES})
+
+add_dependencies(camelpop3
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(camelpop3 PRIVATE
+       -DG_LOG_DOMAIN=\"camel-pop3-provider\"
+)
+
+target_compile_options(camelpop3 PUBLIC
+       ${CAMEL_CFLAGS}
+)
+
+target_include_directories(camelpop3 PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/camel
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/camel
+       ${CAMEL_INCLUDE_DIRS}
+)
+
+target_link_libraries(camelpop3
+       ${DEPENDENCIES}
+       ${CAMEL_LDFLAGS}
+)
+
+install(TARGETS camelpop3
+       DESTINATION ${camel_providerdir}
+)
+
+install(FILES libcamelpop3.urls
+       DESTINATION ${camel_providerdir}
+)
diff --git a/camel/providers/pop3/camel-pop3-engine.c b/camel/providers/pop3/camel-pop3-engine.c
index e9b99c6..7ac7b84 100644
--- a/camel/providers/pop3/camel-pop3-engine.c
+++ b/camel/providers/pop3/camel-pop3-engine.c
@@ -17,9 +17,7 @@
  * Authors: Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <string.h>
diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c
index 8f91e1c..bb7042e 100644
--- a/camel/providers/pop3/camel-pop3-folder.c
+++ b/camel/providers/pop3/camel-pop3-folder.c
@@ -19,9 +19,7 @@
  *          Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdlib.h>
 #include <string.h>
diff --git a/camel/providers/pop3/camel-pop3-provider.c b/camel/providers/pop3/camel-pop3-provider.c
index 6da8d00..c3e7d15 100644
--- a/camel/providers/pop3/camel-pop3-provider.c
+++ b/camel/providers/pop3/camel-pop3-provider.c
@@ -20,9 +20,7 @@
  *   Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n-lib.h>
 
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c
index 297f4db..7d92847 100644
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@ -19,9 +19,7 @@
  *          Michael Zucchi <notzed ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/camel/providers/pop3/camel-pop3-stream.c b/camel/providers/pop3/camel-pop3-stream.c
index 6de7b88..69398e5 100644
--- a/camel/providers/pop3/camel-pop3-stream.c
+++ b/camel/providers/pop3/camel-pop3-stream.c
@@ -19,9 +19,7 @@
 /* This is *identical* to the camel-nntp-stream, so should probably
  * work out a way to merge them */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <string.h>
diff --git a/camel/providers/sendmail/CMakeLists.txt b/camel/providers/sendmail/CMakeLists.txt
new file mode 100644
index 0000000..ad7fc82
--- /dev/null
+++ b/camel/providers/sendmail/CMakeLists.txt
@@ -0,0 +1,48 @@
+set(SOURCES
+       camel-sendmail-settings.c
+       camel-sendmail-settings.h
+       camel-sendmail-provider.c
+       camel-sendmail-transport.c
+       camel-sendmail-transport.h
+)
+
+set(DEPENDENCIES
+       camel
+)
+
+add_library(camelsendmail MODULE ${SOURCES})
+
+add_dependencies(camelsendmail
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(camelsendmail PRIVATE
+       -DG_LOG_DOMAIN=\"camel-sendmail-provider\"
+)
+
+target_compile_options(camelsendmail PUBLIC
+       ${CAMEL_CFLAGS}
+)
+
+target_include_directories(camelsendmail PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/camel
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/camel
+       ${CAMEL_INCLUDE_DIRS}
+)
+
+target_link_libraries(camelsendmail
+       ${DEPENDENCIES}
+       ${CAMEL_LDFLAGS}
+)
+
+install(TARGETS camelsendmail
+       DESTINATION ${camel_providerdir}
+)
+
+install(FILES libcamelsendmail.urls
+       DESTINATION ${camel_providerdir}
+)
+
+unset(SOURCES)
diff --git a/camel/providers/sendmail/camel-sendmail-provider.c 
b/camel/providers/sendmail/camel-sendmail-provider.c
index 4e92bd9..7a8124a 100644
--- a/camel/providers/sendmail/camel-sendmail-provider.c
+++ b/camel/providers/sendmail/camel-sendmail-provider.c
@@ -19,9 +19,7 @@
  *   Dan Winship <danw ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <camel/camel.h>
 #include <glib/gi18n-lib.h>
diff --git a/camel/providers/sendmail/camel-sendmail-transport.c 
b/camel/providers/sendmail/camel-sendmail-transport.c
index 15c6288..7767945 100644
--- a/camel/providers/sendmail/camel-sendmail-transport.c
+++ b/camel/providers/sendmail/camel-sendmail-transport.c
@@ -18,9 +18,7 @@
  * Authors: Dan Winship <danw ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <fcntl.h>
diff --git a/camel/providers/smtp/CMakeLists.txt b/camel/providers/smtp/CMakeLists.txt
new file mode 100644
index 0000000..d8b9cde
--- /dev/null
+++ b/camel/providers/smtp/CMakeLists.txt
@@ -0,0 +1,46 @@
+set(SOURCES
+       camel-smtp-provider.c
+       camel-smtp-settings.c
+       camel-smtp-settings.h
+       camel-smtp-transport.c
+       camel-smtp-transport.h
+)
+
+set(DEPENDENCIES
+       camel
+)
+
+add_library(camelsmtp MODULE ${SOURCES})
+
+add_dependencies(camelsmtp
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(camelsmtp PRIVATE
+       -DG_LOG_DOMAIN=\"camel-smtp-provider\"
+)
+
+target_compile_options(camelsmtp PUBLIC
+       ${CAMEL_CFLAGS}
+)
+
+target_include_directories(camelsmtp PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/camel
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/camel
+       ${CAMEL_INCLUDE_DIRS}
+)
+
+target_link_libraries(camelsmtp
+       ${DEPENDENCIES}
+       ${CAMEL_LDFLAGS}
+)
+
+install(TARGETS camelsmtp
+       DESTINATION ${camel_providerdir}
+)
+
+install(FILES libcamelsmtp.urls
+       DESTINATION ${camel_providerdir}
+)
diff --git a/camel/providers/smtp/camel-smtp-provider.c b/camel/providers/smtp/camel-smtp-provider.c
index 1ab3018..c7b667c 100644
--- a/camel/providers/smtp/camel-smtp-provider.c
+++ b/camel/providers/smtp/camel-smtp-provider.c
@@ -18,9 +18,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <camel/camel.h>
 #include <glib/gi18n-lib.h>
diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c
index de6bc6f..44e96bf 100644
--- a/camel/providers/smtp/camel-smtp-transport.c
+++ b/camel/providers/smtp/camel-smtp-transport.c
@@ -18,9 +18,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <errno.h>
diff --git a/camel/tests/CMakeLists.txt b/camel/tests/CMakeLists.txt
new file mode 100644
index 0000000..38c5369
--- /dev/null
+++ b/camel/tests/CMakeLists.txt
@@ -0,0 +1,52 @@
+macro(add_camel_test_one _part _name _src_file)
+       set(_test_ident cameltest-${_part}-${_name})
+
+       add_executable(${_test_ident} EXCLUDE_FROM_ALL ${_src_file})
+
+       target_compile_definitions(${_test_ident} PRIVATE
+               -DG_LOG_DOMAIN=\"${_test_ident}\"
+               -DSOURCEDIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"
+               -DTEST_DATA_DIR=\"${CMAKE_SOURCE_DIR}/camel/tests/data\"
+       )
+
+       target_compile_options(${_test_ident} PUBLIC
+               ${CAMEL_CFLAGS}
+       )
+
+       target_include_directories(${_test_ident} PUBLIC
+               ${CMAKE_BINARY_DIR}
+               ${CMAKE_BINARY_DIR}/camel
+               ${CMAKE_SOURCE_DIR}
+               ${CMAKE_SOURCE_DIR}/camel
+               ${CMAKE_SOURCE_DIR}/camel/tests/lib
+               ${CAMEL_INCLUDE_DIRS}
+       )
+
+       target_link_libraries(${_test_ident}
+               camel
+               cameltest
+               cameltest-provider
+               ${CAMEL_LDFLAGS}
+       )
+
+       set_target_properties(${_test_ident} PROPERTIES
+               OUTPUT_NAME ${_name}}
+       )
+
+       add_check_test(${_test_ident})
+endmacro(add_camel_test_one)
+
+macro(add_camel_tests _part _tests)
+       foreach(test IN LISTS ${_tests})
+               if(NOT "${test}" STREQUAL "")
+                       add_camel_test_one(${_part} ${test} ${test}.c)
+               endif(NOT "${test}" STREQUAL "")
+       endforeach(test)
+endmacro(add_camel_tests)
+
+add_subdirectory(lib)
+add_subdirectory(message)
+add_subdirectory(folder)
+add_subdirectory(smime)
+add_subdirectory(misc)
+add_subdirectory(mime-filter)
diff --git a/camel/tests/folder/CMakeLists.txt b/camel/tests/folder/CMakeLists.txt
new file mode 100644
index 0000000..adaea8f
--- /dev/null
+++ b/camel/tests/folder/CMakeLists.txt
@@ -0,0 +1,15 @@
+set(TESTS
+       test1
+       test2
+       test3
+       test4
+       test5
+       test6
+       test7
+       test8
+       test9
+       test10
+       test11
+)
+
+add_camel_tests(folder TESTS)
diff --git a/camel/tests/lib/CMakeLists.txt b/camel/tests/lib/CMakeLists.txt
new file mode 100644
index 0000000..ad70e44
--- /dev/null
+++ b/camel/tests/lib/CMakeLists.txt
@@ -0,0 +1,70 @@
+set(SOURCES
+       camel-test.c
+       camel-test.h
+       messages.c
+       messages.h
+       addresses.c
+       addresses.h
+       folders.c
+       folders.h
+       session.c
+       session.h
+       address-data.h
+)
+
+add_library(cameltest STATIC EXCLUDE_FROM_ALL
+       ${SOURCES}
+)
+
+add_dependencies(cameltest camel)
+
+target_compile_definitions(cameltest PRIVATE
+       -DG_LOG_DOMAIN=\"camel-test\"
+       -DCAMEL_BUILD_DIR=\"$(CMAKE_BINARY_DIR)/camel\"
+)
+
+target_compile_options(cameltest PUBLIC
+       ${CAMEL_CFLAGS}
+)
+
+target_include_directories(cameltest PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/camel
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/camel
+       ${CAMEL_INCLUDE_DIRS}
+)
+
+target_link_libraries(cameltest
+       camel
+       ${CAMEL_LDFLAGS}
+)
+
+add_library(cameltest-provider STATIC EXCLUDE_FROM_ALL
+       camel-test-provider.c
+       camel-test-provider.h
+)
+
+add_dependencies(cameltest-provider camel)
+
+target_compile_definitions(cameltest-provider PRIVATE
+       -DG_LOG_DOMAIN=\"camel-test-provider\"
+       -DCAMEL_BUILD_DIR=\"$(CMAKE_BINARY_DIR)/camel\"
+)
+
+target_compile_options(cameltest-provider PUBLIC
+       ${CAMEL_CFLAGS}
+)
+
+target_include_directories(cameltest-provider PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/camel
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/camel
+       ${CAMEL_INCLUDE_DIRS}
+)
+
+target_link_libraries(cameltest-provider
+       camel
+       ${CAMEL_LDFLAGS}
+)
diff --git a/camel/tests/lib/camel-test.h b/camel/tests/lib/camel-test.h
index 03cc827..d08c996 100644
--- a/camel/tests/lib/camel-test.h
+++ b/camel/tests/lib/camel-test.h
@@ -14,7 +14,7 @@
 
 /* some utilities for testing */
 
-#include "config.h"
+#include "evolution-data-server-config.h"
 
 #include <stdlib.h>
 #include <glib/gstdio.h>
diff --git a/camel/tests/lib/session.c b/camel/tests/lib/session.c
index fa6ee85..827fc59 100644
--- a/camel/tests/lib/session.c
+++ b/camel/tests/lib/session.c
@@ -12,9 +12,7 @@
  * along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "session.h"
 
diff --git a/camel/tests/message/CMakeLists.txt b/camel/tests/message/CMakeLists.txt
new file mode 100644
index 0000000..e9f9bea
--- /dev/null
+++ b/camel/tests/message/CMakeLists.txt
@@ -0,0 +1,7 @@
+set(TESTS
+       test1
+       test2
+       test4
+)
+
+add_camel_tests(message TESTS)
diff --git a/camel/tests/mime-filter/CMakeLists.txt b/camel/tests/mime-filter/CMakeLists.txt
new file mode 100644
index 0000000..3035488
--- /dev/null
+++ b/camel/tests/mime-filter/CMakeLists.txt
@@ -0,0 +1,8 @@
+set(TESTS
+       test1
+       test-crlf
+       test-charset
+       test-tohtml
+)
+
+add_camel_tests(mime-filter TESTS)
diff --git a/camel/tests/misc/CMakeLists.txt b/camel/tests/misc/CMakeLists.txt
new file mode 100644
index 0000000..7c0b02a
--- /dev/null
+++ b/camel/tests/misc/CMakeLists.txt
@@ -0,0 +1,11 @@
+set(TESTS
+       test1
+       test2
+       url
+       url-scan
+       utf7
+       split
+       rfc2047
+)
+
+add_camel_tests(misc TESTS)
diff --git a/camel/tests/misc/rfc2047.c b/camel/tests/misc/rfc2047.c
index 269aefd..0d57ac0 100644
--- a/camel/tests/misc/rfc2047.c
+++ b/camel/tests/misc/rfc2047.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj novell com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <stdio.h>
diff --git a/camel/tests/misc/split.c b/camel/tests/misc/split.c
index 0536c0e..eac9548 100644
--- a/camel/tests/misc/split.c
+++ b/camel/tests/misc/split.c
@@ -12,7 +12,8 @@
  * along with this library. If not, see <http://www.gnu.org/licenses/>.
  *
  */
-#include <config.h>
+
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <stdio.h>
diff --git a/camel/tests/misc/test1.c b/camel/tests/misc/test1.c
index 4b10f69..eb944c4 100644
--- a/camel/tests/misc/test1.c
+++ b/camel/tests/misc/test1.c
@@ -13,7 +13,7 @@
  *
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/camel/tests/misc/test2.c b/camel/tests/misc/test2.c
index 30d102e..2ca8ac3 100644
--- a/camel/tests/misc/test2.c
+++ b/camel/tests/misc/test2.c
@@ -13,7 +13,7 @@
  *
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <stdio.h>
diff --git a/camel/tests/misc/url-scan.c b/camel/tests/misc/url-scan.c
index def9ed2..5539db9 100644
--- a/camel/tests/misc/url-scan.c
+++ b/camel/tests/misc/url-scan.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/camel/tests/misc/url.c b/camel/tests/misc/url.c
index 082bfe2..0f519fd 100644
--- a/camel/tests/misc/url.c
+++ b/camel/tests/misc/url.c
@@ -13,7 +13,7 @@
  *
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <stdio.h>
diff --git a/camel/tests/misc/utf7.c b/camel/tests/misc/utf7.c
index 3f43a58..b79cf10 100644
--- a/camel/tests/misc/utf7.c
+++ b/camel/tests/misc/utf7.c
@@ -12,7 +12,7 @@
  * along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include <ctype.h>
 #include <stdio.h>
diff --git a/camel/tests/smime/CMakeLists.txt b/camel/tests/smime/CMakeLists.txt
new file mode 100644
index 0000000..3d122e6
--- /dev/null
+++ b/camel/tests/smime/CMakeLists.txt
@@ -0,0 +1,7 @@
+set(TESTS
+       pgp
+#      pgp-mime
+#      pkcs7
+)
+
+add_camel_tests(smime TESTS)
diff --git a/camel/tests/smime/pgp-mime.c b/camel/tests/smime/pgp-mime.c
index 19c4bab..eb44050 100644
--- a/camel/tests/smime/pgp-mime.c
+++ b/camel/tests/smime/pgp-mime.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/camel/tests/smime/pgp.c b/camel/tests/smime/pgp.c
index b5b6072..05f7771 100644
--- a/camel/tests/smime/pgp.c
+++ b/camel/tests/smime/pgp.c
@@ -17,9 +17,7 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/camel/tests/smime/pkcs7.c b/camel/tests/smime/pkcs7.c
index 0bcdfe3..3f1d845 100644
--- a/camel/tests/smime/pkcs7.c
+++ b/camel/tests/smime/pkcs7.c
@@ -13,7 +13,7 @@
  *
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
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..2551d3a
--- /dev/null
+++ b/cmake/modules/DistTargets.cmake
@@ -0,0 +1,87 @@
+# 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
+       COMMENT "Building from distribution tarball ${ARCHIVE_FULL_NAME}..."
+)
+
+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/FindKRB5.cmake b/cmake/modules/FindKRB5.cmake
new file mode 100644
index 0000000..941923f
--- /dev/null
+++ b/cmake/modules/FindKRB5.cmake
@@ -0,0 +1,109 @@
+# FindKRB5.cmake
+#
+# Searches for KRB5 library
+#
+# The output is:
+#    HAVE_KRB5 - set to ON, if Kerberos 5 support is enabled and libraries found
+#    HAVE_MIT_KRB5 - set to ON, when found MIT implementation
+#    HAVE_HEIMDAL_KRB5 - set to ON, when found Heimdal implementation
+#    KRB5_CFLAGS - CFLAGS to use with target_compile_options() and similar commands
+#    KRB5_LDFLAGS - LDFLAGS to use with target_link_libraries() and similar commands
+
+include(CheckCSourceCompiles)
+include(PkgConfigEx)
+include(PrintableOptions)
+
+add_printable_variable_path(WITH_KRB5 "Location of Kerberos 5 install dir, defaults to ON to search for it" 
"ON")
+add_printable_variable_path(WITH_KRB5_INCLUDES "Location of Kerberos 5 headers" "")
+add_printable_variable_path(WITH_KRB5_LIBS "Location of Kerberos 5 libraries" "")
+
+if(NOT WITH_KRB5)
+       return()
+endif(NOT WITH_KRB5)
+
+pkg_check_modules(KRB5 krb5 krb5-gssapi)
+
+if(KRB5_FOUND)
+       pkg_check_variable(KRB5_VENDOR krb5 vendor)
+
+       if(KRB5_VENDOR STREQUAL "MIT")
+               message(STATUS "Using MIT Kerberos 5 (found by pkg-config)")
+               set(WITH_KRB5 ON)
+               set(HAVE_MIT_KRB5 ON)
+               return()
+       endif(KRB5_VENDOR STREQUAL "MIT")
+
+       message(STATUS "Found Kerberos 5 with pkg-config, but unknown vendor '${KRB5_VENDOR}', continue with 
autodetection")
+endif()
+
+string(LENGTH "${CMAKE_BINARY_DIR}" bindirlen)
+string(SUBSTRING "${WITH_KRB5}" 0 ${bindirlen} substr)
+string(TOUPPER "${WITH_KRB5}" optupper)
+
+if(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+       set(WITH_KRB5 "/usr")
+endif(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+
+unset(bindirlen)
+unset(substr)
+unset(optupper)
+
+set(mit_includes "${WITH_KRB5}/include")
+set(mit_libs "-lkrb5 -lk5crypto -lcom_err -lgssapi_krb5")
+set(heimdal_includes "${WITH_KRB5}/include/heimdal")
+set(heimdal_libs "-lkrb5 -lcrypto -lasn1 -lcom_err -lroken -lgssapi")
+set(sun_includes "${WITH_KRB5}/include/kerberosv5")
+set(sun_libs "-lkrb5 -lgss")
+
+set(krb_libs "${WITH_KRB5}/lib${LIB_SUFFIX}")
+
+if(NOT (WITH_KRB5_INCLUDES STREQUAL ""))
+       set(mit_includes "${WITH_KRB5_INCLUDES}")
+       set(heimdal_includes "${WITH_KRB5_INCLUDES}")
+       set(sun_includes "${WITH_KRB5_INCLUDES}")
+endif(NOT (WITH_KRB5_INCLUDES STREQUAL ""))
+
+if(NOT (WITH_KRB5_LIBS STREQUAL ""))
+       set(krb_libs "${WITH_KRB5_LIBS}")
+endif(NOT (WITH_KRB5_LIBS STREQUAL ""))
+
+set(CMAKE_REQUIRED_INCLUDES "-I${mit_includes}")
+set(CMAKE_REQUIRED_LIBRARIES "-L${krb_libs} ${mit_libs}")
+CHECK_C_SOURCE_COMPILES("#include <krb5/krb5.h>
+                       int main(void) { krb5_init_context (NULL); return 0; }" HAVE_KRB5)
+
+if(HAVE_KRB5)
+       set(HAVE_MIT_KRB5 ON)
+       message(STATUS "Found MIT Kerberos 5")
+else(HAVE_KRB5)
+       set(CMAKE_REQUIRED_INCLUDES "-I${heimdal_includes}")
+       set(CMAKE_REQUIRED_LIBRARIES "-L${krb_libs} ${heimdal_libs}")
+       CHECK_C_SOURCE_COMPILES("#include <krb5.h>
+                               int main(void) { krb5_init_context (NULL); return 0; }" HAVE_KRB5)
+
+       if(HAVE_KRB5)
+               set(HAVE_HEIMDAL_KRB5 ON)
+               message(STATUS "Found Heimdal Kerberos 5")
+       endif(HAVE_KRB5)
+endif(HAVE_KRB5)
+
+if(NOT HAVE_KRB5)
+       set(CMAKE_REQUIRED_INCLUDES "-I${sun_includes}")
+       set(CMAKE_REQUIRED_LIBRARIES "-L${krb_libs} ${sun_libs}")
+       CHECK_C_SOURCE_COMPILES("#include <krb5/krb5.h>
+                               int main(void) { krb5_init_context (NULL); return 0; }" HAVE_KRB5)
+       if(HAVE_KRB5)
+               set(HAVE_SUN_KRB5 ON)
+               message(STATUS "Found Sun Kerberos 5")
+       endif(HAVE_KRB5)
+endif(NOT HAVE_KRB5)
+
+if(HAVE_KRB5)
+       set(KRB5_CFLAGS ${CMAKE_REQUIRED_INCLUDES})
+       set(KRB5_LDFLAGS ${CMAKE_REQUIRED_LIBRARIES})
+else(HAVE_KRB5)
+       message(FATAL_ERROR "Failed to find Kerberos 5 libraries. Use -DWITH_KRB5=OFF to disable Kerberos 5 
support")
+endif(HAVE_KRB5)
+
+unset(CMAKE_REQUIRED_LIBRARIES)
+unset(CMAKE_REQUIRED_INCLUDES)
diff --git a/cmake/modules/FindLDAP.cmake b/cmake/modules/FindLDAP.cmake
new file mode 100644
index 0000000..bc3bf86
--- /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_INCLUDE_DIRS - include directories to use with target_include_directories() and similar commands
+#    LDAP_LIBS - libraries 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_DIRS "${LDAP_PREFIX}/include")
+set(LDAP_LIBS "-L${LDAP_PREFIX}/lib${LIB_SUFFIX}")
+
+set(CMAKE_REQUIRED_INCLUDES "${LDAP_INCLUDE_DIRS}")
+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/FindPhonenumber.cmake b/cmake/modules/FindPhonenumber.cmake
new file mode 100644
index 0000000..cf54804
--- /dev/null
+++ b/cmake/modules/FindPhonenumber.cmake
@@ -0,0 +1,77 @@
+# FindPhonenumber.cmake
+#
+# Searches for Google's libphonenumber library
+#
+# Defines -DWITH_PHONENUMBER=PATH variable, which defaults to OFF.
+# The output is:
+#    ENABLE_PHONENUMBER - ON, when the libphonenumber is used
+#    PHONENUMBER_RAW_INPUT_NEEDED - Whether Parse() or ParseAndKeepRawInput() must be used to get the 
country-code source
+#    PHONENUMBER_CXXFLAGS - CXXFLAGS to use with target_compile_options() and similar commands
+#    PHONENUMBER_LDFLAGS - LDFLAGS to use with target_link_libraries() and similar commands
+
+include(PrintableOptions)
+include(CheckCXXSourceCompiles)
+
+add_printable_variable_path(WITH_PHONENUMBER "Path prefix where the libphonenumber is installed" OFF)
+
+if(NOT WITH_PHONENUMBER)
+       return()
+endif(NOT WITH_PHONENUMBER)
+
+set(PHONENUMBER_CXXFLAGS -DI18N_PHONENUMBERS_USE_BOOST)
+set(PHONENUMBER_LDFLAGS -lphonenumber)
+
+string(LENGTH "${CMAKE_BINARY_DIR}" bindirlen)
+string(SUBSTRING "${WITH_PHONENUMBER}" 0 ${bindirlen} substr)
+string(TOUPPER "${WITH_PHONENUMBER}" optupper)
+
+if(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+       set(WITH_PHONENUMBER "ON")
+else(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+       set(PHONENUMBER_CXXFLAGS "-I${WITH_PHONENUMBER}/include ${PHONENUMBER_CXXFLAGS}")
+       set(PHONENUMBER_LDFLAGS "-L${WITH_PHONENUMBER}/lib${LIB_SUFFIX} ${PHONENUMBER_LDFLAGS}")
+endif(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+
+unset(bindirlen)
+unset(substr)
+unset(optupper)
+
+set(CMAKE_REQUIRED_FLAGS "${PHONENUMBER_CXXFLAGS}")
+
+foreach(lib boost_thread-mt boost_thread)
+       set(CMAKE_REQUIRED_LIBRARIES "${PHONENUMBER_LDFLAGS} -l${lib}")
+       CHECK_CXX_SOURCE_COMPILES("#include <phonenumbers/phonenumberutil.h>
+
+                               int main(void) {
+                                       i18n::phonenumbers::PhoneNumberUtil::GetInstance();
+                                       return 0;
+                               }" phone_number_with_${lib})
+       if(phone_number_with_${lib})
+               set(ENABLE_PHONENUMBER ON)
+               set(PHONENUMBER_LDFLAGS "${CMAKE_REQUIRED_LIBRARIES}")
+               break()
+       endif(phone_number_with_${lib})
+endforeach(lib)
+
+if(NOT ENABLE_PHONENUMBER)
+       message(FATAL_ERROR "libphonenumber cannot be used. Use -DWITH_PHONENUMBER=PATH to specify the 
library prefix, or -DWITH_PHONENUMBER=OFF to disable it.")
+endif(NOT ENABLE_PHONENUMBER)
+
+CHECK_CXX_SOURCE_COMPILES("#include <phonenumbers/phonenumberutil.h>
+
+                       int main(void) {
+                               namespace pn = i18n::phonenumbers;
+
+                               pn::PhoneNumber n;
+
+                               if (pn::PhoneNumberUtil::GetInstance ()->
+                                       Parse(\"049(800)46663\", \"DE\", &n) == 
pn::PhoneNumberUtil::NO_PARSING_ERROR
+                                       && n.has_country_code_source ()
+                                       && n.country_code_source () == 49)
+                                       return EXIT_SUCCESS;
+
+                               return EXIT_FAILURE;
+                       }" PHONENUMBER_RAW_INPUT_NEEDED)
+
+unset(CMAKE_REQUIRED_FLAGS)
+unset(CMAKE_REQUIRED_LIBRARIES)
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..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/GObjectIntrospection.cmake b/cmake/modules/GObjectIntrospection.cmake
new file mode 100644
index 0000000..a5ae8a2
--- /dev/null
+++ b/cmake/modules/GObjectIntrospection.cmake
@@ -0,0 +1,227 @@
+# 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})
+       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..ec44553
--- /dev/null
+++ b/cmake/modules/InstalledTests.cmake
@@ -0,0 +1,88 @@
+# 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.
+#
+# install_behave_tests_if_enabled(_testsvar _type _environ)
+#    Adds rules to install the 'behave' tests as stored in _testsvar
+#    in the current source directory.
+
+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)
+
+macro(install_behave_tests_if_enabled _testsvar _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 "")
+
+               file(GLOB BEHAVE_FEATURES ${CMAKE_CURRENT_SOURCE_DIR}/*.feature)
+               file(GLOB BEHAVE_STEP_DEFINITIONS ${CMAKE_CURRENT_SOURCE_DIR}/steps/*.py)
+               set(BEHAVE_COMMON_FILES
+                       ${CMAKE_CURRENT_SOURCE_DIR}/environment.py
+                       ${CMAKE_CURRENT_SOURCE_DIR}/common_steps.py
+               )
+
+               install(FILES ${BEHAVE_FEATURES} ${BEHAVE_COMMON_FILES}
+                       DESTINATION ${INSTALLED_TESTS_EXEC_DIR}
+               )
+
+               install(FILES ${BEHAVE_STEP_DEFINITIONS}
+                       DESTINATION ${INSTALLED_TESTS_EXEC_DIR}/steps/
+               )
+
+               foreach(_test ${${_testsvar}})
+                       set(teststring "[Test]
+Type=${TEST_TYPE}
+Exec=${TEST_ENVIRONMENT}behave ${INSTALLED_TESTS_EXEC_DIR} -t ${_test} -k -f html -o ${_test}.html -f plain
+"
+)
+
+                       file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${_test}.test "${teststring}")
+
+                       install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_test}.test
+                               DESTINATION ${INSTALLED_TESTS_META_DIR}
+                       )
+               endforeach(_test)
+       endif(ENABLE_INSTALLED_TESTS)
+endmacro(install_behave_tests_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..98d8191
--- /dev/null
+++ b/cmake/verify-news-file.sh
@@ -0,0 +1,56 @@
+#!/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".
+#
+# The test can be skipped entirely when SKIP_NEWS_FILE_TEST=1 is set.
+
+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% *}"
+SUCCESS=1
+
+if [ "$NEWSVERSION" != "$EXPVERSION" ]; then
+       echo "Read NEWS version '$NEWSVERSION' doesn't match expected version '$EXPVERSION'" 1>&2
+       SUCCESS=0
+fi
+
+if [ "$NEWSDATE" != "$EXPDATE" ]; then
+       echo "Read NEWS date '$NEWSDATE' doesn't match expected date '$EXPDATE'" 1>&2
+       SUCCESS=0
+fi
+
+if [ "$SUCCESS" != "1" ]; then
+       if [ "$SKIP_NEWS_FILE_TEST" = "1" ]; then
+               echo "" 1>&2
+               echo "****************************************************************" 1>&2
+               echo "*  Failed NEWS file test ignored due to SKIP_NEWS_FILE_TEST=1  *" 1>&2
+               echo "****************************************************************" 1>&2
+               echo "" 1>&2
+               exit 0
+       else
+               echo "(This test can be skipped when SKIP_NEWS_FILE_TEST=1 is set.)" 1>&2
+       fi
+       exit 1
+fi
diff --git a/config.h.in b/config.h.in
new file mode 100644
index 0000000..549804f
--- /dev/null
+++ b/config.h.in
@@ -0,0 +1,192 @@
+/* @PROJECT_NAME@-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@"
+
+/* API version (Major.Minor) */
+#define API_VERSION "@API_VERSION@"
+
+/* Base version (Major.Minor) */
+#define BASE_VERSION "@BASE_VERSION@"
+
+/* Package name for gettext */
+#define GETTEXT_PACKAGE "@GETTEXT_PACKAGE@"
+
+/* D-Bus service name for the address book factory */
+#define ADDRESS_BOOK_DBUS_SERVICE_NAME "@ADDRESS_BOOK_DBUS_SERVICE_NAME@"
+
+/* D-Bus service name for the calendar factory */
+#define CALENDAR_DBUS_SERVICE_NAME "@CALENDAR_DBUS_SERVICE_NAME@"
+
+/* D-Bus service name for the source registry */
+#define SOURCES_DBUS_SERVICE_NAME "@SOURCES_DBUS_SERVICE_NAME@"
+
+/* D-Bus service name for the user prompter */
+#define USER_PROMPTER_DBUS_SERVICE_NAME "@USER_PROMPTER_DBUS_SERVICE_NAME@"
+
+/* Define Google OAuth 2.0 Client ID to use */
+#define GOOGLE_CLIENT_ID "@WITH_GOOGLE_CLIENT_ID@"
+
+/* Define Google OAuth 2.0 Client Secret to use */
+#define GOOGLE_CLIENT_SECRET "@WITH_GOOGLE_CLIENT_SECRET@"
+
+/* Path to a sendmail binary, or equivalent */
+#define SENDMAIL_PATH "@SENDMAIL_PATH@"
+
+/* Directory local mail is delivered to */
+#define SYSTEM_MAIL_DIR "@SYSTEM_MAIL_DIR@"
+
+/* Configured with enabled maintainer mode */
+#cmakedefine ENABLE_MAINTAINER_MODE 1
+
+/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
+#cmakedefine HAVE_SYS_WAIT_H 1
+
+/* Define to 1 if you have the `fsync' function. */
+#cmakedefine HAVE_FSYNC 1
+
+/* Define to 1 if you have the `strptime' function. */
+#cmakedefine HAVE_STRPTIME 1
+
+/* Define to 1 if you have the `nl_langinfo' function. */
+#cmakedefine HAVE_NL_LANGINFO 1
+
+/* Define to 1 if you have the gtk+-3.0 package. */
+#cmakedefine HAVE_GTK 1
+
+/* Define to 1 if Google autentication support is enabled. */
+#cmakedefine ENABLE_GOOGLE_AUTH 1
+
+/* Define to 1 if the examples should be built. */
+#cmakedefine BUILD_EXAMPLES 1
+
+/* Define to 1 if you have the goa-1.0 package. */
+#cmakedefine HAVE_GOA 1
+
+/* If backend-per-process is enabled */
+#cmakedefine ENABLE_BACKEND_PER_PROCESS 1
+
+/* Have libdb */
+#cmakedefine HAVE_LIBDB 1
+
+/* libc provides backtrace_symbols function */
+#cmakedefine HAVE_BACKTRACE_SYMBOLS 1
+
+/* have elfutils/libdwfl.h functions */
+#cmakedefine HAVE_ELFUTILS_LIBDWFL 1
+
+/* Have nl_langinfo (CODESET) */
+#cmakedefine HAVE_CODESET 1
+
+/* Have nl_langinfo (_NL_ADDRESS_COUNTRY_AB2) */
+#cmakedefine HAVE__NL_ADDRESS_COUNTRY_AB2 1
+
+/* strftime supports use of l and k */
+#cmakedefine HAVE_LKSTRFTIME 1
+
+/* Define if SMIME should be enabled */
+#cmakedefine ENABLE_SMIME 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 `gethostbyaddr_r' function. */
+#cmakedefine HAVE_GETHOSTBYADDR_R 1
+
+/* Define to 1 if you have the `gethostbyname_r' function. */
+#cmakedefine HAVE_GETHOSTBYNAME_R 1
+
+/* Enable IPv6 support */
+#cmakedefine ENABLE_IPv6 1
+
+/* Enable getaddrinfo emulation */
+#cmakedefine NEED_ADDRINFO 1
+
+/* Define if the system defines the AI_ADDRCONFIG flag for getaddrinfo */
+#cmakedefine HAVE_AI_ADDRCONFIG 1
+
+/* Have <wspiapi.h> */
+#cmakedefine HAVE_WSPIAPI_H 1
+
+/* Define to use dot locking for mbox files */
+#cmakedefine USE_DOT_LOCKING 1
+
+/* Define to use fcntl locking for mbox files */
+#cmakedefine USE_FCNTL_LOCKING 1
+
+/* Define to use flock locking for mbox files */
+#cmakedefine USE_FLOCK_LOCKING 1
+
+/* Define if mail delivered to the system mail directory is in broken Content-Length format */
+#cmakedefine ENABLE_BROKEN_SPOOL 1
+
+/* Define if you have Krb5 */
+#cmakedefine HAVE_KRB5 1
+
+/* Define if you have MIT Krb5 */
+#cmakedefine HAVE_MIT_KRB5 1
+
+/* Define if you have Heimdal */
+#cmakedefine HAVE_HEIMDAL_KRB5 1
+
+/* Define if you have Sun Kerberosv5 */
+#cmakedefine HAVE_SUN_KRB5 1
+
+/* Enable libphonenumber parsing */
+#cmakedefine ENABLE_PHONENUMBER 1
+
+/* Whether Parse() or ParseAndKeepRawInput() must be used to get the country-code source */
+#cmakedefine PHONENUMBER_RAW_INPUT_NEEDED 1
+
+/* Define if you have LDAP support */
+#cmakedefine HAVE_LDAP 1
+
+/* Define if you use SunLDAP */
+#cmakedefine SUNLDAP */
+
+/* Solaris-style gethostbyaddr_r */
+#cmakedefine GETHOSTBYADDR_R_SEVEN_ARGS 1
+
+/* Solaris-style gethostbyname_r */
+#cmakedefine GETHOSTBYNAME_R_FIVE_ARGS 1
+
+/* Have <com_err.h> */
+#cmakedefine HAVE_COM_ERR_H 1
+
+/* Have <et/com_err.h> */
+#cmakedefine HAVE_ET_COM_ERR_H 1
+
+/* Define if compiled with libical 2.0 */
+#cmakedefine HAVE_LIBICAL_2_0 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
+
+/* Define to 1 if you have the libgdata package. */
+#cmakedefine HAVE_LIBGDATA 1
+
+/* Define to 1 when have O_LARGEFILE open flag */
+#cmakedefine HAVE_O_LARGEFILE 1
+
+#ifndef HAVE_O_LARGEFILE
+/* Define to 0 if your system does not have the O_LARGEFILE flag */
+#define O_LARGEFILE 0
+#endif /* HAVE_O_LARGEFILE */
+
+/* Have libaccounts-glib */
+#cmakedefine HAVE_UOA 1
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
new file mode 100644
index 0000000..0403472
--- /dev/null
+++ b/data/CMakeLists.txt
@@ -0,0 +1,27 @@
+set(SCHEMAS
+       org.gnome.Evolution.DefaultSources.gschema.xml
+       org.gnome.evolution-data-server.gschema.xml
+       org.gnome.evolution-data-server.calendar.gschema.xml
+       org.gnome.evolution-data-server.addressbook.gschema.xml
+       org.gnome.evolution.shell.network-config.gschema.xml
+)
+
+set(BUILT_SCHEMAS)
+foreach(_schema IN LISTS SCHEMAS)
+       intltool_merge(${_schema}.in ${_schema} --no-translations --xml-style --utf8)
+       list(APPEND BUILT_SCHEMAS ${CMAKE_CURRENT_BINARY_DIR}/${_schema})
+endforeach(_schema)
+
+add_custom_command(OUTPUT gschemas.compiled
+       COMMAND ${GLIB_COMPILE_SCHEMAS} .
+)
+
+add_custom_target(data-files ALL
+       DEPENDS gschemas.compiled
+)
+
+add_gsettings_schemas(data-files ${BUILT_SCHEMAS})
+
+install(FILES evolution-data-server.convert
+       DESTINATION ${SHARE_INSTALL_DIR}/GConf/gsettings
+)
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
new file mode 100644
index 0000000..90bb2b5
--- /dev/null
+++ b/docs/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(reference)
diff --git a/docs/reference/CMakeLists.txt b/docs/reference/CMakeLists.txt
new file mode 100644
index 0000000..9a9144b
--- /dev/null
+++ b/docs/reference/CMakeLists.txt
@@ -0,0 +1,6 @@
+add_subdirectory(camel)
+add_subdirectory(evolution-data-server)
+
+if(WITH_PRIVATE_DOCS)
+       add_subdirectory(private)
+endif(WITH_PRIVATE_DOCS)
diff --git a/docs/reference/camel/CMakeLists.txt b/docs/reference/camel/CMakeLists.txt
new file mode 100644
index 0000000..da02752
--- /dev/null
+++ b/docs/reference/camel/CMakeLists.txt
@@ -0,0 +1,34 @@
+set(SOURCEDIRS
+       ${CMAKE_SOURCE_DIR}/camel
+       ${CMAKE_SOURCE_DIR}/camel/providers/local
+       ${CMAKE_SOURCE_DIR}/camel/providers/imapx
+       ${CMAKE_SOURCE_DIR}/camel/providers/nntp
+       ${CMAKE_SOURCE_DIR}/camel/providers/pop3
+       ${CMAKE_SOURCE_DIR}/camel/providers/sendmail
+       ${CMAKE_SOURCE_DIR}/camel/providers/smtp
+)
+
+set(DEPENDENCIES
+       camel
+       camellocal
+       camelimapx
+       camelnntp
+       camelpop3
+       camelsendmail
+       camelsmtp
+)
+
+set(IGNORE_HEADERS
+       camel-charset-map-private.h
+       camel-enumtypes.h
+       camel-i18n.h
+       camel-imapx-tokenise.h
+       camel-imapx-utils.h
+       camel-local-private.h
+       camel-nntp-private.h
+       camel-nntp-resp-codes.h
+       camel-search-private.h
+       camel-win32.h
+)
+
+add_gtkdoc(camel camel "CAMEL_DISABLE_DEPRECATED" SOURCEDIRS DEPENDENCIES IGNORE_HEADERS)
diff --git a/docs/reference/camel/camel-docs.sgml b/docs/reference/camel/camel-docs.sgml.in
similarity index 98%
rename from docs/reference/camel/camel-docs.sgml
rename to docs/reference/camel/camel-docs.sgml.in
index 2df9f3d..65cdf98 100644
--- a/docs/reference/camel/camel-docs.sgml
+++ b/docs/reference/camel/camel-docs.sgml.in
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
                "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; [
 <!ENTITY % local.common.attrib "xmlns:xi  CDATA  #FIXED 'http://www.w3.org/2003/XInclude'">
 ]>
@@ -27,7 +27,7 @@
 
     <abstract>
       <para>This manual documents the interfaces of the Camel
-      library.</para>
+      library @PROJECT_VERSION@.</para>
     </abstract>
   </bookinfo>
 
@@ -276,10 +276,6 @@
 
   </part>
 
-  <chapter id="ClassTree">
-    <title>Class Hierarchy</title>
-    <xi:include href="xml/tree_index.sgml"/>
-  </chapter>
   <index id="api-index-full">
     <title>Index</title>
     <xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
diff --git a/docs/reference/evolution-data-server/CMakeLists.txt 
b/docs/reference/evolution-data-server/CMakeLists.txt
new file mode 100644
index 0000000..c050c81
--- /dev/null
+++ b/docs/reference/evolution-data-server/CMakeLists.txt
@@ -0,0 +1,44 @@
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/evolution-data-server-cursor-example.sgml.in
+       ${CMAKE_CURRENT_BINARY_DIR}/xml/evolution-data-server-cursor-example.sgml
+       @ONLY
+)
+
+set(SOURCEDIRS
+       ${CMAKE_SOURCE_DIR}/libebackend
+       ${CMAKE_SOURCE_DIR}/libedataserver
+       ${CMAKE_BINARY_DIR}/libedataserver
+       ${CMAKE_SOURCE_DIR}/addressbook/libebook
+       ${CMAKE_SOURCE_DIR}/addressbook/libebook-contacts
+       ${CMAKE_SOURCE_DIR}/addressbook/libedata-book
+       ${CMAKE_SOURCE_DIR}/calendar/libecal
+       ${CMAKE_SOURCE_DIR}/calendar/libedata-cal
+       ${CMAKE_SOURCE_DIR}/tests/test-server-utils
+)
+
+set(DEPENDENCIES
+       ebackend
+       edataserver
+       ebook
+       ebook-contacts
+       edata-book
+       ecal
+       edata-cal
+       etestserverutils
+)
+
+set(IGNORE_HEADERS
+       e-alphabet-index-private.h
+       e-backend-enumtypes.h
+       e-book-enumtypes.h
+       e-book-contacts-enumtypes.h
+       e-cal-enumtypes.h
+       e-client-private.h
+       e-data-cal-types.h
+       e-phone-number-private.h
+       e-source-enumtypes.h
+       e-transliterator-private.h
+       libedataserver-private.h
+       ximian-vcard.h
+)
+
+add_gtkdoc(evolution-data-server e "EDS_DISABLE_DEPRECATED" SOURCEDIRS DEPENDENCIES IGNORE_HEADERS)
diff --git a/docs/reference/eds/eds-cursor-example.sgml.in 
b/docs/reference/evolution-data-server/evolution-data-server-cursor-example.sgml.in
similarity index 91%
rename from docs/reference/eds/eds-cursor-example.sgml.in
rename to docs/reference/evolution-data-server/evolution-data-server-cursor-example.sgml.in
index a29e7b1..5cb83b1 100644
--- a/docs/reference/eds/eds-cursor-example.sgml.in
+++ b/docs/reference/evolution-data-server/evolution-data-server-cursor-example.sgml.in
@@ -70,7 +70,7 @@
       <programlisting>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude";
                     parse="text"
-                    href="@SRCDIR@/examples/cursor/cursor-example.c"/>
+                    href="@CMAKE_SOURCE_DIR@/examples/cursor/cursor-example.c"/>
       </programlisting>
     </informalexample>
   </refsect1>
@@ -88,7 +88,7 @@
       <programlisting>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude";
                     parse="text"
-                    href="@SRCDIR@/examples/cursor/cursor-navigator.c"/>
+                    href="@CMAKE_SOURCE_DIR@/examples/cursor/cursor-navigator.c"/>
       </programlisting>
     </informalexample>
   </refsect1>
@@ -106,7 +106,7 @@
       <programlisting>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude";
                     parse="text"
-                    href="@SRCDIR@/examples/cursor/cursor-search.c"/>
+                    href="@CMAKE_SOURCE_DIR@/examples/cursor/cursor-search.c"/>
       </programlisting>
     </informalexample>
   </refsect1>
@@ -122,7 +122,7 @@
       <programlisting>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude";
                     parse="text"
-                    href="@SRCDIR@/examples/cursor/cursor-slot.c"/>
+                    href="@CMAKE_SOURCE_DIR@/examples/cursor/cursor-slot.c"/>
       </programlisting>
     </informalexample>
   </refsect1>
@@ -139,7 +139,7 @@
       <programlisting>
        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude";
                     parse="text"
-                    href="@SRCDIR@/examples/cursor/cursor-data.c"/>
+                    href="@CMAKE_SOURCE_DIR@/examples/cursor/cursor-data.c"/>
       </programlisting>
     </informalexample>
   </refsect1>
diff --git a/docs/reference/eds/eds-docs.sgml 
b/docs/reference/evolution-data-server/evolution-data-server-docs.sgml.in
similarity index 98%
rename from docs/reference/eds/eds-docs.sgml
rename to docs/reference/evolution-data-server/evolution-data-server-docs.sgml.in
index 8dcad26..c3684db 100644
--- a/docs/reference/eds/eds-docs.sgml
+++ b/docs/reference/evolution-data-server/evolution-data-server-docs.sgml.in
@@ -1,13 +1,12 @@
 <?xml version="1.0"?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
                "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; [
 <!ENTITY % local.common.attrib "xmlns:xi  CDATA  #FIXED 'http://www.w3.org/2003/XInclude'">
-<!ENTITY version SYSTEM "version.xml">
 ]>
 <book id="index" xmlns:xi="http://www.w3.org/2001/XInclude";>
   <bookinfo>
     <title>Evolution-Data-Server Reference Manual</title>
-    <releaseinfo>Reference Manual for &version;</releaseinfo>
+    <releaseinfo>Reference Manual for @PACKAGE_VERSION@</releaseinfo>
     <abstract>
       <para>
        Evolution-Data-Server is a collection of libraries and services
@@ -276,7 +275,7 @@
 
   <part id="examples">
     <title>Examples</title>
-    <xi:include href="xml/eds-cursor-example.sgml"/>
+    <xi:include href="xml/evolution-data-server-cursor-example.sgml"/>
   </part>
 
   <part id="unit-testing">
diff --git a/docs/reference/private/CMakeLists.txt b/docs/reference/private/CMakeLists.txt
new file mode 100644
index 0000000..2825ce6
--- /dev/null
+++ b/docs/reference/private/CMakeLists.txt
@@ -0,0 +1,13 @@
+set(SOURCEDIRS
+       ${CMAKE_BINARY_DIR}/private
+)
+
+set(DEPENDENCIES
+       edbus-private
+)
+
+set(IGNORE_HEADERS
+       e-dbus-localed.h
+)
+
+add_gtkdoc(libedbus-private e-dbus "EDS_DISABLE_DEPRECATED" SOURCEDIRS DEPENDENCIES IGNORE_HEADERS)
diff --git a/docs/reference/private/libedbus-private-docs.sgml.in 
b/docs/reference/private/libedbus-private-docs.sgml.in
index 7d6999e..8052aa4 100644
--- a/docs/reference/private/libedbus-private-docs.sgml.in
+++ b/docs/reference/private/libedbus-private-docs.sgml.in
@@ -5,7 +5,7 @@
 ]>
 <book id="index" xmlns:xi="http://www.w3.org/2001/XInclude";>
   <bookinfo>
-    <title>Evolution-Data-Server Manual: Private</title>
+    <title>Evolution-Data-Server Manual: Private, version @PROJECT_VERSION@</title>
   </bookinfo>
 
   <chapter>
@@ -25,19 +25,19 @@
 
   <chapter>
     <title>D-Bus Interfaces</title>
-    <xi:include href="@SRCDIR@/private/e-dbus-source-org.gnome.evolution.dataserver.Source.xml"/>
-    <xi:include href="@SRCDIR@/private/e-dbus-source-org.gnome.evolution.dataserver.Source.Removable.xml"/>
-    <xi:include href="@SRCDIR@/private/e-dbus-source-org.gnome.evolution.dataserver.Source.Writable.xml"/>
-    <xi:include 
href="@SRCDIR@/private/e-dbus-source-org.gnome.evolution.dataserver.Source.RemoteCreatable.xml"/>
-    <xi:include 
href="@SRCDIR@/private/e-dbus-source-org.gnome.evolution.dataserver.Source.RemoteDeletable.xml"/>
-    <xi:include 
href="@SRCDIR@/private/e-dbus-source-org.gnome.evolution.dataserver.Source.OAuth2Support.xml"/>
-    <xi:include 
href="@SRCDIR@/private/e-dbus-source-manager-org.gnome.evolution.dataserver.SourceManager.xml"/>
-    <xi:include 
href="@SRCDIR@/private/e-dbus-authenticator-org.gnome.evolution.dataserver.Authenticator.xml"/>
-    <xi:include href="@SRCDIR@/private/e-dbus-address-book-org.gnome.evolution.dataserver.AddressBook.xml"/>
-    <xi:include 
href="@SRCDIR@/private/e-dbus-address-book-factory-org.gnome.evolution.dataserver.AddressBookFactory.xml"/>
-    <xi:include href="@SRCDIR@/private/e-dbus-calendar-org.gnome.evolution.dataserver.Calendar.xml"/>
-    <xi:include 
href="@SRCDIR@/private/e-dbus-calendar-factory-org.gnome.evolution.dataserver.CalendarFactory.xml"/>
-    <xi:include 
href="@SRCDIR@/private/e-dbus-user-prompter-org.gnome.evolution.dataserver.UserPrompter.xml"/>
+    <xi:include href="@CMAKE_BINARY_DIR@/private/e-dbus-source-org.gnome.evolution.dataserver.Source.xml"/>
+    <xi:include 
href="@CMAKE_BINARY_DIR@/private/e-dbus-source-org.gnome.evolution.dataserver.Source.Removable.xml"/>
+    <xi:include 
href="@CMAKE_BINARY_DIR@/private/e-dbus-source-org.gnome.evolution.dataserver.Source.Writable.xml"/>
+    <xi:include 
href="@CMAKE_BINARY_DIR@/private/e-dbus-source-org.gnome.evolution.dataserver.Source.RemoteCreatable.xml"/>
+    <xi:include 
href="@CMAKE_BINARY_DIR@/private/e-dbus-source-org.gnome.evolution.dataserver.Source.RemoteDeletable.xml"/>
+    <xi:include 
href="@CMAKE_BINARY_DIR@/private/e-dbus-source-org.gnome.evolution.dataserver.Source.OAuth2Support.xml"/>
+    <xi:include 
href="@CMAKE_BINARY_DIR@/private/e-dbus-source-manager-org.gnome.evolution.dataserver.SourceManager.xml"/>
+    <xi:include 
href="@CMAKE_BINARY_DIR@/private/e-dbus-authenticator-org.gnome.evolution.dataserver.Authenticator.xml"/>
+    <xi:include 
href="@CMAKE_BINARY_DIR@/private/e-dbus-address-book-org.gnome.evolution.dataserver.AddressBook.xml"/>
+    <xi:include 
href="@CMAKE_BINARY_DIR@/private/e-dbus-address-book-factory-org.gnome.evolution.dataserver.AddressBookFactory.xml"/>
+    <xi:include 
href="@CMAKE_BINARY_DIR@/private/e-dbus-calendar-org.gnome.evolution.dataserver.Calendar.xml"/>
+    <xi:include 
href="@CMAKE_BINARY_DIR@/private/e-dbus-calendar-factory-org.gnome.evolution.dataserver.CalendarFactory.xml"/>
+    <xi:include 
href="@CMAKE_BINARY_DIR@/private/e-dbus-user-prompter-org.gnome.evolution.dataserver.UserPrompter.xml"/>
   </chapter>
 
   <index id="api-index-full">
diff --git a/evolution-data-server.pc.in b/evolution-data-server.pc.in
index 22d68e0..34bd271 100644
--- a/evolution-data-server.pc.in
+++ b/evolution-data-server.pc.in
@@ -1,15 +1,14 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+includedir=@INCLUDE_INSTALL_DIR@
 privlibdir=@privlibdir@
-datarootdir=@datarootdir@
-datadir=@datadir@
+datarootdir=@SHARE_INSTALL_DIR@
+datadir=@SHARE_INSTALL_DIR@
 privdatadir=@privdatadir@
 
 execversion=@BASE_VERSION@
 
 Name: evolution-data-server
 Description: The evolution data server for the calendar and addressbook
-Version: @VERSION@
-Requires: gio-2.0, @mozilla_nss@, @mozilla_nspr@
+Version: @PROJECT_VERSION@
+Requires: gio-2.0 @mozilla_nss@ @mozilla_nspr@
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
new file mode 100644
index 0000000..201678f
--- /dev/null
+++ b/examples/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(cursor)
diff --git a/examples/cursor/CMakeLists.txt b/examples/cursor/CMakeLists.txt
new file mode 100644
index 0000000..fd57c7e
--- /dev/null
+++ b/examples/cursor/CMakeLists.txt
@@ -0,0 +1,60 @@
+set(DEPENDENCIES
+       ebook
+       ebook-contacts
+       edataserver
+)
+
+set(SOURCES
+       cursor-data.c
+       cursor-data.h
+       cursor-example.c
+       cursor-example.h
+       cursor-navigator.c
+       cursor-navigator.h
+       cursor-search.c
+       cursor-search.h
+       cursor-slot.c
+       cursor-slot.h
+       main.c
+       ${CMAKE_CURRENT_BINARY_DIR}/cursor-example-resources.c
+       ${CMAKE_CURRENT_BINARY_DIR}/cursor-example-resources.h
+)
+
+add_executable(cursor-example
+       ${SOURCES}
+)
+
+add_dependencies(cursor-example
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(cursor-example PRIVATE
+       -DG_LOG_DOMAIN=\"cursor-example\"
+       -DSRCDIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"
+)
+
+target_compile_options(cursor-example PUBLIC
+       ${EXAMPLES_CFLAGS}
+)
+
+target_include_directories(cursor-example PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/addressbook
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/addressbook
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${EXAMPLES_INCLUDE_DIRS}
+)
+
+target_link_libraries(cursor-example
+       ${DEPENDENCIES}
+       ${EXAMPLES_LDFLAGS}
+)
+
+set(UI_FILES
+       cursor-example.ui
+       cursor-search.ui
+       cursor-slot.ui
+)
+
+glib_compile_resources(${CMAKE_CURRENT_SOURCE_DIR} cursor-example-resources _cursor_example 
cursor-example.gresources.xml ${UI_FILES})
diff --git a/iconv-detect.c b/iconv-detect.c
index c9c69bc..bc7d872 100644
--- a/iconv-detect.c
+++ b/iconv-detect.c
@@ -17,9 +17,9 @@
  * Authors: Jeffrey Stedfast <fejj ximian com>
  */
 
-#include <glib.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <iconv.h>
 
 enum {
@@ -87,18 +87,50 @@ 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;
-       GIConv cd;
+       iconv_t cd;
        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");
 
@@ -106,8 +138,8 @@ int main (int argc, char **argv)
        info = iso8859_tests;
        /*printf ("#define DEFAULT_ISO_FORMAT(iso,codepage)\t");*/
        for (i = 0; i < num_iso8859_tests; i++) {
-               cd = g_iconv_open (info[i].charset, "UTF-8");
-               if (cd != (GIConv) -1) {
+               cd = iconv_open (info[i].charset, "UTF-8");
+               if (cd != (iconv_t) -1) {
                        iconv_close (cd);
                        /*printf ("(\"%s\", (iso), (codepage))\n", info[i].format);*/
                        fprintf (stderr, "System prefers %s\n", info[i].charset);
@@ -119,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);
        }
@@ -131,8 +160,8 @@ int main (int argc, char **argv)
        /*printf ("#define ISO_2022_FORMAT(iso,codepage)\t");*/
        for (i = 0; i < num_iso2022_tests; i++) {
                cd = iconv_open (info[i].charset, "UTF-8");
-               if (cd != (GIConv) -1) {
-                       g_iconv_close (cd);
+               if (cd != (iconv_t) -1) {
+                       iconv_close (cd);
                        /*printf ("(\"%s\", (iso), (codepage))\n", info[i].format);*/
                        fprintf (stderr, "System prefers %s\n", info[i].charset);
                        iso2022 = info[i].id;
@@ -143,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);
        }
@@ -155,8 +181,8 @@ int main (int argc, char **argv)
        /*printf ("#define ISO_10646_FORMAT(iso,codepage)\t");*/
        for (i = 0; i < num_iso10646_tests; i++) {
                cd = iconv_open (info[i].charset, "UTF-8");
-               if (cd != (GIConv) -1) {
-                       g_iconv_close (cd);
+               if (cd != (iconv_t) -1) {
+                       iconv_close (cd);
                        /*if (info[i].id < ISO_DASH_D_LOWER)
                                printf ("(\"%s\", (iso), (codepage))\n", info[i].format);
                        else
@@ -171,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/libebackend/CMakeLists.txt b/libebackend/CMakeLists.txt
new file mode 100644
index 0000000..3bf371d
--- /dev/null
+++ b/libebackend/CMakeLists.txt
@@ -0,0 +1,136 @@
+glib_mkenums(e-backend-enumtypes e-backend-enums.h E_BACKEND_ENUMTYPES_H)
+
+add_pkgconfig_file(libebackend.pc.in libebackend-${API_VERSION}.pc)
+
+set(DEPENDENCIES
+       edataserver
+       edbus-private
+)
+
+set(SOURCES
+       e-backend.c
+       e-backend-factory.c
+       e-cache-reaper.c
+       e-cache-reaper-utils.c
+       e-cache-reaper-utils.h
+       e-collection-backend.c
+       e-collection-backend-factory.c
+       e-data-factory.c
+       e-dbus-server.c
+       e-file-cache.c
+       e-oauth2-support.c
+       e-offline-listener.c
+       e-server-side-source.c
+       e-server-side-source-credentials-provider.c
+       e-source-registry-server.c
+       e-sqlite3-vfs.c
+       e-subprocess-factory.c
+       e-user-prompter.c
+       e-user-prompter-server.c
+       e-user-prompter-server-extension.c
+       ${CMAKE_CURRENT_BINARY_DIR}/e-backend-enumtypes.c
+)
+
+set(HEADERS
+       libebackend.h
+       e-backend.h
+       e-backend-enums.h
+       e-backend-factory.h
+       e-cache-reaper.h
+       e-collection-backend.h
+       e-collection-backend-factory.h
+       e-data-factory.h
+       e-dbus-server.h
+       e-file-cache.h
+       e-oauth2-support.h
+       e-offline-listener.h
+       e-server-side-source.h
+       e-server-side-source-credentials-provider.h
+       e-source-registry-server.h
+       e-sqlite3-vfs.h
+       e-subprocess-factory.h
+       e-user-prompter.h
+       e-user-prompter-server.h
+       e-user-prompter-server-extension.h
+       ${CMAKE_CURRENT_BINARY_DIR}/e-backend-enumtypes.h
+)
+
+if(HAVE_LIBDB)
+       list(APPEND SOURCES
+               e-dbhash.c
+               e-db3-utils.c
+       )
+       list(APPEND HEADERS
+               e-dbhash.h
+               e-db3-utils.h
+       )
+endif(HAVE_LIBDB)
+
+add_library(ebackend SHARED
+       ${SOURCES}
+       ${HEADERS}
+)
+
+add_dependencies(ebackend
+       ${DEPENDENCIES}
+)
+
+set_target_properties(ebackend PROPERTIES
+       VERSION "${LIBEBACKEND_CURRENT}.${LIBEBACKEND_REVISION}.${LIBEBACKEND_AGE}"
+       SOVERSION ${LIBEBACKEND_CURRENT}
+       OUTPUT_NAME ebackend-${API_VERSION}
+)
+
+target_compile_definitions(ebackend PRIVATE
+       -DG_LOG_DOMAIN=\"e-backend\"
+       -DE_DATA_SERVER_PREFIX=\"${CMAKE_INSTALL_PREFIX}\"
+       -DMODULE_DIRECTORY=\"${moduledir}\"
+       -DE_DATA_SERVER_PRIVDATADIR=\"${privdatadir}\"
+       -DSYSTEM_WIDE_RO_SOURCES_DIRECTORY=\"${ro_sourcesdir}\"
+       -DSYSTEM_WIDE_RW_SOURCES_DIRECTORY=\"${rw_sourcesdir}\"
+       -DLIBEBACKEND_COMPILATION
+)
+
+target_compile_options(ebackend PUBLIC
+       ${BACKEND_CFLAGS}
+       ${LIBDB_CFLAGS}
+       ${CAMEL_CFLAGS}
+       ${SQLITE3_CFLAGS}
+       ${GCR_BASE_CFLAGS}
+       ${GIO_UNIX_CFLAGS}
+)
+
+target_include_directories(ebackend PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/private
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/private
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${BACKEND_INCLUDE_DIRS}
+       ${LIBDB_INCLUDE_DIRS}
+       ${CAMEL_INCLUDE_DIRS}
+       ${SQLITE3_INCLUDE_DIRS}
+       ${GCR_BASE_INCLUDE_DIRS}
+       ${GIO_UNIX_INCLUDE_DIRS}
+)
+
+target_link_libraries(ebackend
+       ${DEPENDENCIES}
+       ${BACKEND_LDFLAGS}
+       ${LIBDB_LDFLAGS}
+       ${LIBDB_LIBS}
+       ${CAMEL_LDFLAGS}
+       ${SQLITE3_LDFLAGS}
+       ${GCR_BASE_LDFLAGS}
+       ${GIO_UNIX_LDFLAGS}
+)
+
+install(TARGETS ebackend
+       DESTINATION ${LIB_INSTALL_DIR}
+)
+
+install(FILES ${HEADERS}
+       DESTINATION ${privincludedir}/libebackend
+)
+
+add_gsettings_schemas(ebackend org.gnome.evolution.eds-shell.gschema.xml)
diff --git a/libebackend/e-backend-factory.c b/libebackend/e-backend-factory.c
index b8ef063..e9b8493 100644
--- a/libebackend/e-backend-factory.c
+++ b/libebackend/e-backend-factory.c
@@ -33,14 +33,14 @@
  * to pair with the requested #ESource.
  **/
 
-#include "e-backend-factory.h"
-
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include <libedataserver/libedataserver.h>
 
 #include <libebackend/e-data-factory.h>
 
+#include "e-backend-factory.h"
+
 G_DEFINE_ABSTRACT_TYPE (EBackendFactory, e_backend_factory, E_TYPE_EXTENSION)
 
 static void
diff --git a/libebackend/e-backend.c b/libebackend/e-backend.c
index ab76092..bbe3144 100644
--- a/libebackend/e-backend.c
+++ b/libebackend/e-backend.c
@@ -30,7 +30,8 @@
  * All #EBackend instances are created by an #EBackendFactory.
  **/
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <glib/gi18n-lib.h>
 
 #include <gio/gio.h>
diff --git a/libebackend/e-cache-reaper.c b/libebackend/e-cache-reaper.c
index 862f2bf..a7e4c91 100644
--- a/libebackend/e-cache-reaper.c
+++ b/libebackend/e-cache-reaper.c
@@ -15,6 +15,8 @@
  *
  */
 
+#include "evolution-data-server-config.h"
+
 #include <errno.h>
 #include <time.h>
 #include <glib/gstdio.h>
diff --git a/libebackend/e-collection-backend.c b/libebackend/e-collection-backend.c
index e45bc4a..67c19de 100644
--- a/libebackend/e-collection-backend.c
+++ b/libebackend/e-collection-backend.c
@@ -37,9 +37,8 @@
  * its own #EAuthenticationSession instances to the #ESourceRegistryServer.
  **/
 
-#include "e-collection-backend.h"
+#include "evolution-data-server-config.h"
 
-#include <config.h>
 #include <glib/gi18n-lib.h>
 
 #include <libedataserver/libedataserver.h>
@@ -47,6 +46,8 @@
 #include <libebackend/e-server-side-source.h>
 #include <libebackend/e-source-registry-server.h>
 
+#include "e-collection-backend.h"
+
 #define E_COLLECTION_BACKEND_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
        ((obj), E_TYPE_COLLECTION_BACKEND, ECollectionBackendPrivate))
diff --git a/libebackend/e-data-factory.c b/libebackend/e-data-factory.c
index 85a2bd4..e1e78f1 100644
--- a/libebackend/e-data-factory.c
+++ b/libebackend/e-data-factory.c
@@ -21,9 +21,8 @@
  * @short_description: An abstract base class for a backend-based server
  **/
 
-#include "e-data-factory.h"
+#include "evolution-data-server-config.h"
 
-#include <config.h>
 #include <glib/gi18n-lib.h>
 
 #include <libedataserver/libedataserver.h>
@@ -33,6 +32,8 @@
 
 #include <e-dbus-subprocess-backend.h>
 
+#include "e-data-factory.h"
+
 #define E_DATA_FACTORY_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
        ((obj), E_TYPE_DATA_FACTORY, EDataFactoryPrivate))
diff --git a/libebackend/e-db3-utils.c b/libebackend/e-db3-utils.c
index 12803af..b1493da 100644
--- a/libebackend/e-db3-utils.c
+++ b/libebackend/e-db3-utils.c
@@ -21,7 +21,7 @@
  * Utilities for coping with Berkeley DB file format changes.
  **/
 
-#include "config.h"
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <sys/stat.h>
diff --git a/libebackend/e-dbhash.c b/libebackend/e-dbhash.c
index cfe729d..07d3010 100644
--- a/libebackend/e-dbhash.c
+++ b/libebackend/e-dbhash.c
@@ -25,7 +25,7 @@
  * file for permanent storage.
  **/
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include "e-dbhash.h"
 
diff --git a/libebackend/e-dbus-server.c b/libebackend/e-dbus-server.c
index 313ee78..cc67b14 100644
--- a/libebackend/e-dbus-server.c
+++ b/libebackend/e-dbus-server.c
@@ -21,9 +21,9 @@
  * @short_description: An abstract base class for a D-Bus server
  **/
 
-#include "e-dbus-server.h"
+#include "evolution-data-server-config.h"
 
-#include <config.h>
+#include <glib.h>
 
 #ifdef G_OS_UNIX
 #include <glib-unix.h>
@@ -33,6 +33,8 @@
 
 #include <libebackend/e-backend-enumtypes.h>
 
+#include "e-dbus-server.h"
+
 #define E_DBUS_SERVER_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
        ((obj), E_TYPE_DBUS_SERVER, EDBusServerPrivate))
diff --git a/libebackend/e-file-cache.c b/libebackend/e-file-cache.c
index 62b678d..529764f 100644
--- a/libebackend/e-file-cache.c
+++ b/libebackend/e-file-cache.c
@@ -27,7 +27,8 @@
  * the cache is temporarily frozen with e_file_cache_freeze_changes().
  **/
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <string.h>
 #include <unistd.h>
 
diff --git a/libebackend/e-offline-listener.c b/libebackend/e-offline-listener.c
index 645ccd2..b4b5b51 100644
--- a/libebackend/e-offline-listener.c
+++ b/libebackend/e-offline-listener.c
@@ -30,9 +30,7 @@
  * deprecated.  Use #GNetworkMonitor instead.
  **/
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-offline-listener.h"
 
diff --git a/libebackend/e-offline-listener.h b/libebackend/e-offline-listener.h
index fda0f1d..43617ac 100644
--- a/libebackend/e-offline-listener.h
+++ b/libebackend/e-offline-listener.h
@@ -27,10 +27,6 @@
 #ifndef E_OFFLINE_LISTENER_H
 #define E_OFFLINE_LISTENER_H
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 #include <glib-object.h>
 
 /* Standard GObject macros */
diff --git a/libebackend/e-server-side-source-credentials-provider.c 
b/libebackend/e-server-side-source-credentials-provider.c
index a23f907..503a737 100644
--- a/libebackend/e-server-side-source-credentials-provider.c
+++ b/libebackend/e-server-side-source-credentials-provider.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib.h>
 
diff --git a/libebackend/e-server-side-source.c b/libebackend/e-server-side-source.c
index 243003c..8393067 100644
--- a/libebackend/e-server-side-source.c
+++ b/libebackend/e-server-side-source.c
@@ -24,14 +24,15 @@
  * exclusive to the registry D-Bus service.
  **/
 
-#include "e-server-side-source.h"
+#include "evolution-data-server-config.h"
 
-#include <config.h>
 #include <stdio.h>
 #include <glib/gi18n-lib.h>
 
 /* Private D-Bus classes. */
-#include <e-dbus-source.h>
+#include "e-dbus-source.h"
+
+#include "e-server-side-source.h"
 
 #define E_SERVER_SIDE_SOURCE_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
diff --git a/libebackend/e-source-registry-server.c b/libebackend/e-source-registry-server.c
index 4552c95..01900d0 100644
--- a/libebackend/e-source-registry-server.c
+++ b/libebackend/e-source-registry-server.c
@@ -31,19 +31,20 @@
  * advertise available data sources on a remote server.
  **/
 
-#include "e-source-registry-server.h"
+#include "evolution-data-server-config.h"
 
-#include <config.h>
 #include <string.h>
 #include <glib/gi18n-lib.h>
 
 /* Private D-Bus classes. */
-#include <e-dbus-source.h>
-#include <e-dbus-source-manager.h>
+#include "e-dbus-source.h"
+#include "e-dbus-source-manager.h"
 
 #include "e-server-side-source.h"
 #include "e-server-side-source-credentials-provider.h"
 
+#include "e-source-registry-server.h"
+
 #define E_SOURCE_REGISTRY_SERVER_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
        ((obj), E_TYPE_SOURCE_REGISTRY_SERVER, ESourceRegistryServerPrivate))
diff --git a/libebackend/e-sqlite3-vfs.c b/libebackend/e-sqlite3-vfs.c
index 1980a33..579e36f 100644
--- a/libebackend/e-sqlite3-vfs.c
+++ b/libebackend/e-sqlite3-vfs.c
@@ -16,9 +16,10 @@
  *
  */
 
+#include "evolution-data-server-config.h"
+
 #include <sqlite3.h>
 #include <glib.h>
-#include <config.h>
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libebackend/e-subprocess-factory.c b/libebackend/e-subprocess-factory.c
index d59d9bc..83fbf2b 100644
--- a/libebackend/e-subprocess-factory.c
+++ b/libebackend/e-subprocess-factory.c
@@ -22,9 +22,7 @@
  * @short_description: An abstract base class for a backend-subprocess server
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n-lib.h>
 
diff --git a/libebackend/e-user-prompter-server-extension.c b/libebackend/e-user-prompter-server-extension.c
index 10b9864..e0f85c8 100644
--- a/libebackend/e-user-prompter-server-extension.c
+++ b/libebackend/e-user-prompter-server-extension.c
@@ -35,9 +35,7 @@
  * e_user_prompter_server_extension_response() call.
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/libebackend/e-user-prompter-server.c b/libebackend/e-user-prompter-server.c
index 7d497df..8358def 100644
--- a/libebackend/e-user-prompter-server.c
+++ b/libebackend/e-user-prompter-server.c
@@ -23,9 +23,7 @@
  * Acting as a global singleton for user prompts from backends.
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 #include <glib/gi18n-lib.h>
diff --git a/libebackend/e-user-prompter.c b/libebackend/e-user-prompter.c
index 5a1e7a8..71dd81e 100644
--- a/libebackend/e-user-prompter.c
+++ b/libebackend/e-user-prompter.c
@@ -23,9 +23,7 @@
  * Use this to initiate a user prompt from an #EBackend descendant.
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include "evolution-data-server-config.h"
 
 #include <libedataserver/libedataserver.h>
 
diff --git a/libebackend/libebackend.pc.in b/libebackend/libebackend.pc.in
index becf4e7..176601c 100644
--- a/libebackend/libebackend.pc.in
+++ b/libebackend/libebackend.pc.in
@@ -1,9 +1,8 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-datarootdir=@datarootdir@
-datadir=@datadir@
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+includedir=@INCLUDE_INSTALL_DIR@
+datarootdir=@SHARE_INSTALL_DIR@
+datadir=@SHARE_INSTALL_DIR@
 
 privlibdir=@privlibdir@
 privincludedir=@privincludedir@
@@ -12,7 +11,7 @@ moduledir=@moduledir@
 
 Name: libebackend
 Description: Utility library for Evolution Data Server Backends
-Version: @VERSION@
-Requires: libedataserver-1.2
+Version: @PROJECT_VERSION@
+Requires: libedataserver-@API_VERSION@
 Libs: -L${libdir} -lebackend-@API_VERSION@
 Cflags: -I${privincludedir}
diff --git a/libedataserver/CMakeLists.txt b/libedataserver/CMakeLists.txt
new file mode 100644
index 0000000..3c89ced
--- /dev/null
+++ b/libedataserver/CMakeLists.txt
@@ -0,0 +1,295 @@
+glib_mkenums(e-source-enumtypes e-source-enums.h E_SOURCE_ENUMTYPES_H)
+
+add_pkgconfig_file(libedataserver.pc.in libedataserver-${API_VERSION}.pc)
+
+configure_file(
+       ${CMAKE_CURRENT_SOURCE_DIR}/eds-version.h.in
+       ${CMAKE_CURRENT_BINARY_DIR}/eds-version.h
+       @ONLY
+)
+
+# We put the C++ code into a separate static library, so that we can use
+# the C linker for libebook-contacts.
+
+add_library(edataserver-private STATIC
+       e-alphabet-index-private.cpp
+       e-transliterator-private.cpp
+)
+
+target_compile_definitions(edataserver-private PRIVATE
+       -DG_LOG_DOMAIN=\"e-data-server\"
+       -DLIBEDATASERVER_COMPILATION
+)
+
+target_compile_options(edataserver-private PUBLIC
+       ${DATA_SERVER_CFLAGS}
+       ${ICU_CFLAGS}
+)
+
+target_include_directories(edataserver-private PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${DATA_SERVER_INCLUDE_DIRS}
+       ${ICU_INCLUDE_DIRS}
+)
+
+target_link_libraries(edataserver-private
+       ${DATA_SERVER_LDFLAGS}
+       ${ICU_LDFLAGS}
+)
+
+set(DEPENDENCIES
+       camel
+       edataserver-private
+       edbus-private
+)
+
+set(SOURCES
+       e-alphabet-index-private.h
+       e-cancellable-locks.c
+       e-categories.c
+       e-client.c
+       e-client-private.h
+       e-collator.c
+       e-credentials.c
+       e-extensible.c
+       e-extension.c
+       e-flag.c
+       e-free-form-exp.c
+       e-gdbus-templates.c
+       e-iterator.c
+       e-list.c
+       e-list-iterator.c
+       e-memory.c
+       e-module.c
+       e-network-monitor.c
+       e-operation-pool.c
+       e-proxy.c
+       e-secret-store.c
+       e-sexp.c
+       e-soup-auth-bearer.c
+       e-soup-ssl-trust.c
+       e-source.c
+       e-source-extension.c
+       e-source-address-book.c
+       e-source-alarms.c
+       e-source-authentication.c
+       e-source-autocomplete.c
+       e-source-backend.c
+       e-source-calendar.c
+       e-source-camel.c
+       e-source-collection.c
+       e-source-contacts.c
+       e-source-credentials-provider.c
+       e-source-credentials-provider-impl.c
+       e-source-credentials-provider-impl-google.c
+       e-source-credentials-provider-impl-password.c
+       e-source-goa.c
+       e-source-ldap.c
+       e-source-local.c
+       e-source-mail-account.c
+       e-source-mail-composition.c
+       e-source-mail-identity.c
+       e-source-mail-signature.c
+       e-source-mail-submission.c
+       e-source-mail-transport.c
+       e-source-mdn.c
+       e-source-offline.c
+       e-source-openpgp.c
+       e-source-proxy.c
+       e-source-refresh.c
+       e-source-registry.c
+       e-source-resource.c
+       e-source-revision-guards.c
+       e-source-security.c
+       e-source-selectable.c
+       e-source-smime.c
+       e-source-uoa.c
+       e-source-weather.c
+       e-source-webdav.c
+       e-debug-log.c
+       e-time-utils.c
+       e-transliterator-private.h
+       e-uid.c
+       e-url.c
+       e-webdav-discover.c
+       e-data-server-util.c
+       e-xml-utils.c
+       e-xml-hash-utils.c
+       libedataserver-private.h
+       eds-version.c
+       ${CMAKE_CURRENT_BINARY_DIR}/e-source-enumtypes.c
+)
+
+set(HEADERS
+       libedataserver.h
+       e-cancellable-locks.h
+       e-categories.h
+       e-client.h
+       e-collator.h
+       e-credentials.h
+       e-extensible.h
+       e-extension.h
+       e-flag.h
+       e-free-form-exp.h
+       e-gdbus-templates.h
+       e-iterator.h
+       e-list.h
+       e-list-iterator.h
+       e-memory.h
+       e-module.h
+       e-network-monitor.h
+       e-operation-pool.h
+       e-proxy.h
+       e-secret-store.h
+       e-sexp.h
+       e-soup-auth-bearer.h
+       e-soup-ssl-trust.h
+       e-source.h
+       e-source-address-book.h
+       e-source-alarms.h
+       e-source-authentication.h
+       e-source-autocomplete.h
+       e-source-backend.h
+       e-source-calendar.h
+       e-source-camel.h
+       e-source-collection.h
+       e-source-contacts.h
+       e-source-credentials-provider.h
+       e-source-credentials-provider-impl.h
+       e-source-credentials-provider-impl-google.h
+       e-source-credentials-provider-impl-password.h
+       e-source-enums.h
+       e-source-extension.h
+       e-source-goa.h
+       e-source-ldap.h
+       e-source-local.h
+       e-source-mail-account.h
+       e-source-mail-composition.h
+       e-source-mail-identity.h
+       e-source-mail-signature.h
+       e-source-mail-submission.h
+       e-source-mail-transport.h
+       e-source-mdn.h
+       e-source-offline.h
+       e-source-openpgp.h
+       e-source-proxy.h
+       e-source-refresh.h
+       e-source-registry.h
+       e-source-resource.h
+       e-source-revision-guards.h
+       e-source-security.h
+       e-source-selectable.h
+       e-source-smime.h
+       e-source-uoa.h
+       e-source-weather.h
+       e-source-webdav.h
+       e-debug-log.h
+       e-time-utils.h
+       e-uid.h
+       e-url.h
+       e-webdav-discover.h
+       e-data-server-util.h
+       e-xml-utils.h
+       e-xml-hash-utils.h
+       ${CMAKE_CURRENT_BINARY_DIR}/e-source-enumtypes.h
+       ${CMAKE_CURRENT_BINARY_DIR}/eds-version.h
+)
+
+add_library(edataserver SHARED
+       ${SOURCES}
+       ${HEADERS}
+)
+
+add_dependencies(edataserver
+       ${DEPENDENCIES}
+)
+
+set_target_properties(edataserver PROPERTIES
+       VERSION "${LIBEDATASERVER_CURRENT}.${LIBEDATASERVER_REVISION}.${LIBEDATASERVER_AGE}"
+       SOVERSION ${LIBEDATASERVER_CURRENT}
+       OUTPUT_NAME edataserver-${API_VERSION}
+)
+
+target_compile_definitions(edataserver PRIVATE
+       -DG_LOG_DOMAIN=\"e-data-server\"
+       -DE_DATA_SERVER_PREFIX=\"${CMAKE_INSTALL_PREFIX}\"
+       -DE_DATA_SERVER_LOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+       -DE_DATA_SERVER_IMAGESDIR=\"${imagesdir}\"
+       -DE_DATA_SERVER_CREDENTIALMODULEDIR=\"${credentialmoduledir}\"
+       -DE_DATA_SERVER_PRIVDATADIR=\"${privdatadir}\"
+       -DLIBEDATASERVER_COMPILATION
+)
+
+target_compile_options(edataserver PUBLIC
+       ${DATA_SERVER_CFLAGS}
+       ${GCR_BASE_CFLAGS}
+       ${GIO_UNIX_CFLAGS}
+       ${ICU_CFLAGS}
+       ${GOOGLE_AUTH_CFLAGS}
+)
+
+target_include_directories(edataserver PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/private
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/private
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${DATA_SERVER_INCLUDE_DIRS}
+       ${GCR_BASE_INCLUDE_DIRS}
+       ${GIO_UNIX_INCLUDE_DIRS}
+       ${ICU_INCLUDE_DIRS}
+       ${GOOGLE_AUTH_INCLUDE_DIRS}
+)
+
+target_link_libraries(edataserver
+       ${DEPENDENCIES}
+       ${DATA_SERVER_LDFLAGS}
+       ${GCR_BASE_LDFLAGS}
+       ${GIO_UNIX_LDFLAGS}
+       ${ICU_LDFLAGS}
+       ${GOOGLE_AUTH_LDFLAGS}
+)
+
+install(TARGETS edataserver
+       DESTINATION ${LIB_INSTALL_DIR}
+)
+
+install(FILES ${HEADERS}
+       DESTINATION ${privincludedir}/libedataserver
+)
+
+set(gir_sources ${SOURCES} ${HEADERS})
+set(gir_identifies_prefixes E)
+set(gir_includes GObject-2.0 Gio-2.0 Soup-2.4 libxml2-2.0)
+set(gir_cflags
+       ${CAMEL_CFLAGS}
+       ${DATA_SERVER_CFLAGS}
+       -DLIBEDATASERVER_COMPILATION
+)
+set(gir_libdirs
+       ${CMAKE_BINARY_DIR}/private
+       ${CMAKE_BINARY_DIR}/camel
+)
+set(gir_libs
+       camel
+       edataserver
+)
+set(gir_deps)
+
+gir_filter_out_sources(gir_sources e-sexp.h)
+gir_filter_out_sources(gir_sources -private.h)
+
+gir_add_introspection_simple(
+       EDataServer
+       libedataserver
+       ${API_VERSION}
+       "libedataserver/libedataserver.h"
+       gir_identifies_prefixes
+       gir_includes
+       gir_cflags
+       gir_libdirs
+       gir_libs
+       gir_deps
+       gir_sources
+)
diff --git a/libedataserver/e-alphabet-index-private.cpp b/libedataserver/e-alphabet-index-private.cpp
index 9b73d96..d3e44f4 100644
--- a/libedataserver/e-alphabet-index-private.cpp
+++ b/libedataserver/e-alphabet-index-private.cpp
@@ -17,9 +17,7 @@
  * Authors: Tristan Van Berkom <tristanvb openismus com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-alphabet-index-private.h"
 
diff --git a/libedataserver/e-cancellable-locks.c b/libedataserver/e-cancellable-locks.c
index ca4ddd5..4eb1ada 100644
--- a/libedataserver/e-cancellable-locks.c
+++ b/libedataserver/e-cancellable-locks.c
@@ -16,9 +16,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-cancellable-locks.h"
 
diff --git a/libedataserver/e-categories.c b/libedataserver/e-categories.c
index 626dcc1..803bef8 100644
--- a/libedataserver/e-categories.c
+++ b/libedataserver/e-categories.c
@@ -16,9 +16,7 @@
  *
  */
 
-#if HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <errno.h>
 #include <string.h>
diff --git a/libedataserver/e-client.c b/libedataserver/e-client.c
index aa5cad4..dc27150 100644
--- a/libedataserver/e-client.c
+++ b/libedataserver/e-client.c
@@ -34,9 +34,7 @@
  * such as #EBookClient and #ECalClient.
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n-lib.h>
 #include <gio/gio.h>
diff --git a/libedataserver/e-collator.c b/libedataserver/e-collator.c
index f8a9a17..d7c8f69 100644
--- a/libedataserver/e-collator.c
+++ b/libedataserver/e-collator.c
@@ -29,9 +29,7 @@
  * letter in the user's alphabet.
  */
 
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <string.h>
diff --git a/libedataserver/e-credentials.c b/libedataserver/e-credentials.c
index 20e1f61..3237257 100644
--- a/libedataserver/e-credentials.c
+++ b/libedataserver/e-credentials.c
@@ -17,9 +17,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <string.h>
diff --git a/libedataserver/e-data-server-util.c b/libedataserver/e-data-server-util.c
index 39351ba..abdbb61 100644
--- a/libedataserver/e-data-server-util.c
+++ b/libedataserver/e-data-server-util.c
@@ -19,7 +19,7 @@
  *          Tristan Van Berkom <tristanvb openismus com>
  */
 
-#include "config.h"
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 #include <sys/stat.h>
@@ -1808,9 +1808,7 @@ static const gchar *prefix = NULL;
 static const gchar *cp_prefix;
 
 static const gchar *localedir;
-static const gchar *extensiondir;
 static const gchar *imagesdir;
-static const gchar *ui_uidir;
 static const gchar *credentialmoduledir;
 
 static HMODULE hmodule;
@@ -1918,9 +1916,7 @@ setup (void)
        g_free (cp_pfx);
 
        localedir = replace_prefix (cp_prefix, E_DATA_SERVER_LOCALEDIR);
-       extensiondir = replace_prefix (prefix, E_DATA_SERVER_EXTENSIONDIR);
        imagesdir = replace_prefix (prefix, E_DATA_SERVER_IMAGESDIR);
-       ui_uidir = replace_prefix (prefix, E_DATA_SERVER_UI_UIDIR);
        credentialmoduledir = replace_prefix (prefix, E_DATA_SERVER_CREDENTIALMODULEDIR);
 
        G_UNLOCK (mutex);
@@ -1944,9 +1940,7 @@ const gchar * \
 e_util_get_##varbl (void) \
        GETTER_IMPL (varbl)
 
-PRIVATE_GETTER (extensiondir)
 PRIVATE_GETTER (imagesdir)
-PRIVATE_GETTER (ui_uidir)
 PRIVATE_GETTER (credentialmoduledir);
 
 PUBLIC_GETTER (prefix)
diff --git a/libedataserver/e-debug-log.c b/libedataserver/e-debug-log.c
index 9180eed..4a31397 100644
--- a/libedataserver/e-debug-log.c
+++ b/libedataserver/e-debug-log.c
@@ -18,7 +18,8 @@
  * Authors: Federico Mena-Quintero <federico novell com>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>
diff --git a/libedataserver/e-extensible.c b/libedataserver/e-extensible.c
index bcf1e57..8f3d7fa 100644
--- a/libedataserver/e-extensible.c
+++ b/libedataserver/e-extensible.c
@@ -55,9 +55,7 @@
  * </informalexample>
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-extension.h"
 #include "e-data-server-util.h"
diff --git a/libedataserver/e-extension.c b/libedataserver/e-extension.c
index f9edd7d..3133c9c 100644
--- a/libedataserver/e-extension.c
+++ b/libedataserver/e-extension.c
@@ -38,9 +38,7 @@
  *    registered in the library module's e_module_load() function.
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-extension.h"
 
diff --git a/libedataserver/e-free-form-exp.c b/libedataserver/e-free-form-exp.c
index b2192b7..b6e22e7 100644
--- a/libedataserver/e-free-form-exp.c
+++ b/libedataserver/e-free-form-exp.c
@@ -17,9 +17,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/libedataserver/e-iterator.c b/libedataserver/e-iterator.c
index 1b4b783..7f3633e 100644
--- a/libedataserver/e-iterator.c
+++ b/libedataserver/e-iterator.c
@@ -17,7 +17,7 @@
  * Authors: Christopher James Lahey <clahey umich edu>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include "e-iterator.h"
 
diff --git a/libedataserver/e-list-iterator.c b/libedataserver/e-list-iterator.c
index 80c9adb..3ee066e 100644
--- a/libedataserver/e-list-iterator.c
+++ b/libedataserver/e-list-iterator.c
@@ -17,7 +17,7 @@
  * Authors: Christopher James Lahey <clahey umich edu>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include "e-list-iterator.h"
 #include "e-list.h"
diff --git a/libedataserver/e-list.c b/libedataserver/e-list.c
index 0595b21..9632a04 100644
--- a/libedataserver/e-list.c
+++ b/libedataserver/e-list.c
@@ -17,7 +17,7 @@
  * Authors: Christopher James Lahey <clahey umich edu>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include "e-list.h"
 #include "e-list-iterator.h"
diff --git a/libedataserver/e-module.c b/libedataserver/e-module.c
index b25c04f..da8c3c0 100644
--- a/libedataserver/e-module.c
+++ b/libedataserver/e-module.c
@@ -21,9 +21,7 @@
  * @short_description: A module loader
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib.h>
 
diff --git a/libedataserver/e-network-monitor.c b/libedataserver/e-network-monitor.c
index f2b15d4..42df560 100644
--- a/libedataserver/e-network-monitor.c
+++ b/libedataserver/e-network-monitor.c
@@ -14,9 +14,7 @@
  * along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <gio/gio.h>
 
diff --git a/libedataserver/e-proxy.c b/libedataserver/e-proxy.c
index 02a7d05..7a1e136 100644
--- a/libedataserver/e-proxy.c
+++ b/libedataserver/e-proxy.c
@@ -17,9 +17,7 @@
  *          Veerapuram Varadhan <vvaradhan novell com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 #include <stdlib.h>
diff --git a/libedataserver/e-secret-store.c b/libedataserver/e-secret-store.c
index aeca476..0a133dc 100644
--- a/libedataserver/e-secret-store.c
+++ b/libedataserver/e-secret-store.c
@@ -24,9 +24,7 @@
  * lookup and delete secrets from the keyring.
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib.h>
 
diff --git a/libedataserver/e-sexp.c b/libedataserver/e-sexp.c
index f5b922b..2aeaff5 100644
--- a/libedataserver/e-sexp.c
+++ b/libedataserver/e-sexp.c
@@ -78,9 +78,7 @@
  *         Execute a sequence.  The last function return is the return type.
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libedataserver/e-soup-auth-bearer.c b/libedataserver/e-soup-auth-bearer.c
index 2e0583f..5070d2b 100644
--- a/libedataserver/e-soup-auth-bearer.c
+++ b/libedataserver/e-soup-auth-bearer.c
@@ -30,9 +30,7 @@
  * and pass the results to e_soup_auth_bearer_set_access_token().
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-soup-auth-bearer.h"
 
diff --git a/libedataserver/e-soup-ssl-trust.c b/libedataserver/e-soup-ssl-trust.c
index c12d46a..a97a7f2 100644
--- a/libedataserver/e-soup-ssl-trust.c
+++ b/libedataserver/e-soup-ssl-trust.c
@@ -23,9 +23,7 @@
  * 
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-source-authentication.h"
 #include "e-source-webdav.h"
diff --git a/libedataserver/e-source-collection.c b/libedataserver/e-source-collection.c
index 0347a5b..540c793 100644
--- a/libedataserver/e-source-collection.c
+++ b/libedataserver/e-source-collection.c
@@ -34,16 +34,17 @@
  * ]|
  **/
 
-#include "e-source-collection.h"
+#include "evolution-data-server-config.h"
 
-#include <config.h>
 #include <glib/gi18n-lib.h>
 
 /* Private D-Bus classes. */
-#include <e-dbus-source.h>
+#include "e-dbus-source.h"
 
 #include <libedataserver/e-data-server-util.h>
 
+#include "e-source-collection.h"
+
 #define E_SOURCE_COLLECTION_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
        ((obj), E_TYPE_SOURCE_COLLECTION, ESourceCollectionPrivate))
diff --git a/libedataserver/e-source-contacts.c b/libedataserver/e-source-contacts.c
index 85bbb77..7107ff6 100644
--- a/libedataserver/e-source-contacts.c
+++ b/libedataserver/e-source-contacts.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-source-address-book.h"
 
diff --git a/libedataserver/e-source-credentials-provider-impl-google.c 
b/libedataserver/e-source-credentials-provider-impl-google.c
index b3642e2..3c70956 100644
--- a/libedataserver/e-source-credentials-provider-impl-google.c
+++ b/libedataserver/e-source-credentials-provider-impl-google.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib.h>
 #include <glib/gi18n-lib.h>
diff --git a/libedataserver/e-source-credentials-provider-impl-password.c 
b/libedataserver/e-source-credentials-provider-impl-password.c
index 25315bf..d9e71d5 100644
--- a/libedataserver/e-source-credentials-provider-impl-password.c
+++ b/libedataserver/e-source-credentials-provider-impl-password.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib.h>
 #include <glib/gi18n-lib.h>
diff --git a/libedataserver/e-source-credentials-provider-impl.c 
b/libedataserver/e-source-credentials-provider-impl.c
index 109e7f6..69d063f 100644
--- a/libedataserver/e-source-credentials-provider-impl.c
+++ b/libedataserver/e-source-credentials-provider-impl.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib.h>
 #include <glib/gi18n-lib.h>
diff --git a/libedataserver/e-source-credentials-provider.c b/libedataserver/e-source-credentials-provider.c
index 2a9a8da..f30b186 100644
--- a/libedataserver/e-source-credentials-provider.c
+++ b/libedataserver/e-source-credentials-provider.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib.h>
 
diff --git a/libedataserver/e-source-ldap.c b/libedataserver/e-source-ldap.c
index 7b0e881..8e2daf2 100644
--- a/libedataserver/e-source-ldap.c
+++ b/libedataserver/e-source-ldap.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-source-authentication.h"
 #include "e-source-security.h"
diff --git a/libedataserver/e-source-local.c b/libedataserver/e-source-local.c
index ec171fb..c8a3261 100644
--- a/libedataserver/e-source-local.c
+++ b/libedataserver/e-source-local.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-source-local.h"
 
diff --git a/libedataserver/e-source-mail-composition.c b/libedataserver/e-source-mail-composition.c
index f47953b..46d0065 100644
--- a/libedataserver/e-source-mail-composition.c
+++ b/libedataserver/e-source-mail-composition.c
@@ -34,9 +34,7 @@
  * ]|
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <libedataserver/e-data-server-util.h>
 
diff --git a/libedataserver/e-source-mail-signature.c b/libedataserver/e-source-mail-signature.c
index 27b404c..7f52c4c 100644
--- a/libedataserver/e-source-mail-signature.c
+++ b/libedataserver/e-source-mail-signature.c
@@ -34,14 +34,15 @@
  * ]|
  **/
 
-#include "e-source-mail-signature.h"
+#include "evolution-data-server-config.h"
 
-#include <config.h>
 #include <string.h>
 #include <glib/gi18n-lib.h>
 
 #include <libedataserver/e-data-server-util.h>
 
+#include "e-source-mail-signature.h"
+
 #define E_SOURCE_MAIL_SIGNATURE_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
        ((obj), E_TYPE_SOURCE_MAIL_SIGNATURE, ESourceMailSignaturePrivate))
diff --git a/libedataserver/e-source-proxy.c b/libedataserver/e-source-proxy.c
index 43c8a20..733a8a6 100644
--- a/libedataserver/e-source-proxy.c
+++ b/libedataserver/e-source-proxy.c
@@ -35,14 +35,15 @@
  * ]|
  **/
 
-#include "e-source-proxy.h"
+#include "evolution-data-server-config.h"
 
-#include <config.h>
 #include <glib/gi18n-lib.h>
 
 #include <libedataserver/e-source-enumtypes.h>
 #include <libedataserver/e-data-server-util.h>
 
+#include "e-source-proxy.h"
+
 #define E_SOURCE_PROXY_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
        ((obj), E_TYPE_SOURCE_PROXY, ESourceProxyPrivate))
diff --git a/libedataserver/e-source-registry.c b/libedataserver/e-source-registry.c
index 1cd6331..235be5e 100644
--- a/libedataserver/e-source-registry.c
+++ b/libedataserver/e-source-registry.c
@@ -41,9 +41,8 @@
  * thus it requires a running main loop for its proper functionality.
  **/
 
-#include "e-source-registry.h"
+#include "evolution-data-server-config.h"
 
-#include <config.h>
 #include <glib/gstdio.h>
 #include <glib/gi18n-lib.h>
 
@@ -53,18 +52,20 @@
 #include <gcr/gcr-base.h>
 
 /* Private D-Bus classes. */
-#include <e-dbus-source.h>
-#include <e-dbus-source-manager.h>
+#include "e-dbus-source.h"
+#include "e-dbus-source-manager.h"
 
-#include <libedataserver/e-data-server-util.h>
-#include <libedataserver/e-source-collection.h>
-#include <libedataserver/e-source-enumtypes.h>
+#include "e-data-server-util.h"
+#include "e-source-collection.h"
+#include "e-source-enumtypes.h"
 
 /* Needed for the defaults API. */
-#include <libedataserver/e-source-address-book.h>
-#include <libedataserver/e-source-calendar.h>
-#include <libedataserver/e-source-mail-account.h>
-#include <libedataserver/e-source-mail-identity.h>
+#include "e-source-address-book.h"
+#include "e-source-calendar.h"
+#include "e-source-mail-account.h"
+#include "e-source-mail-identity.h"
+
+#include "e-source-registry.h"
 
 #define E_SOURCE_REGISTRY_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
diff --git a/libedataserver/e-source-weather.c b/libedataserver/e-source-weather.c
index 47c5da1..a0e4fa4 100644
--- a/libedataserver/e-source-weather.c
+++ b/libedataserver/e-source-weather.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-source-enumtypes.h"
 #include "e-source-weather.h"
diff --git a/libedataserver/e-source-webdav.c b/libedataserver/e-source-webdav.c
index 5ad2135..59e2ad5 100644
--- a/libedataserver/e-source-webdav.c
+++ b/libedataserver/e-source-webdav.c
@@ -43,9 +43,7 @@
  * ]|
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n-lib.h>
 
diff --git a/libedataserver/e-source.c b/libedataserver/e-source.c
index ee81465..1a9c80b 100644
--- a/libedataserver/e-source.c
+++ b/libedataserver/e-source.c
@@ -65,14 +65,13 @@
  * fail with %G_IO_ERROR_NOT_SUPPORTED.
  **/
 
-#include "e-source.h"
+#include "evolution-data-server-config.h"
 
-#include <config.h>
 #include <string.h>
 #include <glib/gi18n-lib.h>
 
 /* Private D-Bus classes. */
-#include <e-dbus-source.h>
+#include "e-dbus-source.h"
 
 #include "e-data-server-util.h"
 #include "e-secret-store.h"
@@ -112,6 +111,8 @@
 #include "e-source-weather.h"
 #include "e-source-webdav.h"
 
+#include "e-source.h"
+
 #define E_SOURCE_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
        ((obj), E_TYPE_SOURCE, ESourcePrivate))
diff --git a/libedataserver/e-time-utils.c b/libedataserver/e-time-utils.c
index 7bb7d75..b4cd61b 100644
--- a/libedataserver/e-time-utils.c
+++ b/libedataserver/e-time-utils.c
@@ -18,7 +18,8 @@
  * Authors: Damon Chaplin (damon ximian com)
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #define _XOPEN_SOURCE
 #define _XOPEN_SOURCE_EXTENDED 1  /* for strptime */
 
@@ -197,9 +198,7 @@ enum ptime_locale_status { not, loc, raw };
  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  * 02110 - 1301 USA.  */
 
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <assert.h>
 #include <ctype.h>
diff --git a/libedataserver/e-transliterator-private.cpp b/libedataserver/e-transliterator-private.cpp
index f06ba2c..bb15593 100644
--- a/libedataserver/e-transliterator-private.cpp
+++ b/libedataserver/e-transliterator-private.cpp
@@ -17,9 +17,7 @@
  * Authors: Tristan Van Berkom <tristanvb openismus com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-transliterator-private.h"
 
diff --git a/libedataserver/e-url.c b/libedataserver/e-url.c
index 7acaab7..288f926 100644
--- a/libedataserver/e-url.c
+++ b/libedataserver/e-url.c
@@ -19,7 +19,8 @@
  *          Rodrigo Moya <rodrigo ximian com>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/libedataserver/e-webdav-discover.c b/libedataserver/e-webdav-discover.c
index 8fe1e3a..b5db819 100644
--- a/libedataserver/e-webdav-discover.c
+++ b/libedataserver/e-webdav-discover.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n-lib.h>
 
diff --git a/libedataserver/e-xml-hash-utils.c b/libedataserver/e-xml-hash-utils.c
index fa0a9c0..816f6e3 100644
--- a/libedataserver/e-xml-hash-utils.c
+++ b/libedataserver/e-xml-hash-utils.c
@@ -16,7 +16,7 @@
  *
  */
 
-#include "config.h"
+#include "evolution-data-server-config.h"
 
 #include <stdlib.h>
 #include <string.h>
diff --git a/libedataserver/e-xml-utils.c b/libedataserver/e-xml-utils.c
index 77bf015..5545afd 100644
--- a/libedataserver/e-xml-utils.c
+++ b/libedataserver/e-xml-utils.c
@@ -16,7 +16,7 @@
  *
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include <unistd.h>
 #include <fcntl.h>
diff --git a/libedataserver/eds-version.h.in b/libedataserver/eds-version.h.in
index 6a39715..fb709f2 100644
--- a/libedataserver/eds-version.h.in
+++ b/libedataserver/eds-version.h.in
@@ -29,7 +29,7 @@
  * time, rather than from the library linked against at application run
  * time.
  **/
-#define EDS_MAJOR_VERSION @EDS_MAJOR_VERSION@
+#define EDS_MAJOR_VERSION @PROJECT_VERSION_MAJOR@
 
 /**
  * EDS_MINOR_VERSION:
@@ -39,7 +39,7 @@
  * time, rather than from the library linked against at application run
  * time.
  **/
-#define EDS_MINOR_VERSION @EDS_MINOR_VERSION@
+#define EDS_MINOR_VERSION @PROJECT_VERSION_MINOR@
 
 /**
  * EDS_MICRO_VERSION:
@@ -49,7 +49,7 @@
  * time, rather than from the library linked against at application run
  * time.
  **/
-#define EDS_MICRO_VERSION @EDS_MICRO_VERSION@
+#define EDS_MICRO_VERSION @PROJECT_VERSION_PATCH@
 
 /**
  * EDS_CHECK_VERSION:
diff --git a/libedataserver/libedataserver-private.h b/libedataserver/libedataserver-private.h
index 42f366e..b9733f0 100644
--- a/libedataserver/libedataserver-private.h
+++ b/libedataserver/libedataserver-private.h
@@ -23,20 +23,12 @@
 
 #ifdef G_OS_WIN32
 
-const gchar *  _libedataserver_get_extensiondir        (void) G_GNUC_CONST;
 const gchar *  _libedataserver_get_imagesdir           (void) G_GNUC_CONST;
-const gchar *  _libedataserver_get_ui_uidir            (void) G_GNUC_CONST;
 const gchar *  _libedataserver_get_credentialmoduledir (void) G_GNUC_CONST;
 
-#undef E_DATA_SERVER_EXTENSIONDIR
-#define E_DATA_SERVER_EXTENSIONDIR _libedataserver_get_extensiondir ()
-
 #undef E_DATA_SERVER_IMAGESDIR
 #define E_DATA_SERVER_IMAGESDIR _libedataserver_get_imagesdir ()
 
-#undef E_DATA_SERVER_UI_UIDIR
-#define E_DATA_SERVER_UI_UIDIR _libedataserver_get_ui_uidir ()
-
 #undef E_DATA_SERVER_CREDENTIALMODULEDIR
 #define E_DATA_SERVER_CREDENTIALMODULEDIR _libedataserver_get_credentialmoduledir ()
 
diff --git a/libedataserver/libedataserver.pc.in b/libedataserver/libedataserver.pc.in
index 524d88b..9b04279 100644
--- a/libedataserver/libedataserver.pc.in
+++ b/libedataserver/libedataserver.pc.in
@@ -1,9 +1,8 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-datarootdir=@datarootdir@
-datadir=@datadir@
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+includedir=@INCLUDE_INSTALL_DIR@
+datarootdir=@SHARE_INSTALL_DIR@
+datadir=@SHARE_INSTALL_DIR@
 
 privlibdir=@privlibdir@
 privincludedir=@privincludedir@
@@ -12,7 +11,7 @@ credentialmoduledir=@credentialmoduledir@
 
 Name: libedataserver
 Description: Utility library for Evolution Data Server
-Version: @VERSION@
+Version: @PROJECT_VERSION@
 Requires: gio-2.0 gmodule-2.0 libsecret-1 libxml-2.0 libsoup-2.4
 Requires.private: camel-@API_VERSION@
 Libs: -L${libdir} -ledataserver-@API_VERSION@
diff --git a/libedataserverui/CMakeLists.txt b/libedataserverui/CMakeLists.txt
new file mode 100644
index 0000000..d9eb313
--- /dev/null
+++ b/libedataserverui/CMakeLists.txt
@@ -0,0 +1,96 @@
+add_pkgconfig_file(libedataserverui.pc.in libedataserverui-${API_VERSION}.pc)
+
+set(SOURCES
+       e-cell-renderer-color.c
+       e-credentials-prompter.c
+       e-credentials-prompter-impl.c
+       e-credentials-prompter-impl-google.c
+       e-credentials-prompter-impl-password.c
+       e-trust-prompt.c
+       e-webdav-discover-widget.c
+)
+
+set(HEADERS
+       libedataserverui.h
+       e-cell-renderer-color.h
+       e-credentials-prompter.h
+       e-credentials-prompter-impl.h
+       e-credentials-prompter-impl-google.h
+       e-credentials-prompter-impl-password.h
+       e-trust-prompt.h
+       e-webdav-discover-widget.h
+)
+
+set(DEPENDENCIES
+       camel
+       ebackend
+       edataserver
+)
+
+add_library(edataserverui SHARED
+       ${SOURCES}
+       ${HEADERS}
+)
+
+add_dependencies(edataserverui
+       ${DEPENDENCIES}
+)
+
+set_target_properties(edataserverui PROPERTIES
+       VERSION "${LIBEDATASERVERUI_CURRENT}.${LIBEDATASERVERUI_REVISION}.${LIBEDATASERVERUI_AGE}"
+       SOVERSION ${LIBEDATASERVERUI_CURRENT}
+       OUTPUT_NAME edataserverui-${API_VERSION}
+)
+
+target_compile_definitions(edataserverui PRIVATE
+       -DG_LOG_DOMAIN=\"e-data-server-ui\"
+       -DLIBEDATASERVERUI_COMPILATION
+)
+
+target_compile_options(edataserverui PUBLIC
+       ${BACKEND_CFLAGS}
+       ${DATA_SERVER_CFLAGS}
+       ${CAMEL_CFLAGS}
+       ${CODE_COVERAGE_CFLAGS}
+       ${GNOME_PLATFORM_CFLAGS}
+       ${GCR_BASE_CFLAGS}
+       ${GCR_CFLAGS}
+       ${GTK_CFLAGS}
+       ${GOOGLE_AUTH_CFLAGS}
+)
+
+target_include_directories(edataserverui PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${BACKEND_INCLUDE_DIRS}
+       ${DATA_SERVER_INCLUDE_DIRS}
+       ${CAMEL_INCLUDE_DIRS}
+       ${CODE_COVERAGE_INCLUDE_DIRS}
+       ${GNOME_PLATFORM_INCLUDE_DIRS}
+       ${GCR_BASE_INCLUDE_DIRS}
+       ${GCR_INCLUDE_DIRS}
+       ${GTK_INCLUDE_DIRS}
+       ${GOOGLE_AUTH_INCLUDE_DIRS}
+)
+
+target_link_libraries(edataserverui
+       ${DEPENDENCIES}
+       ${BACKEND_LDFLAGS}
+       ${DATA_SERVER_LDFLAGS}
+       ${CAMEL_LDFLAGS}
+       ${CODE_COVERAGE_LDFLAGS}
+       ${GNOME_PLATFORM_LDFLAGS}
+       ${GCR_BASE_LDFLAGS}
+       ${GCR_LDFLAGS}
+       ${GTK_LDFLAGS}
+       ${GOOGLE_AUTH_LDFLAGS}
+)
+
+install(TARGETS edataserverui
+       DESTINATION ${LIB_INSTALL_DIR}
+)
+
+install(FILES ${HEADERS}
+       DESTINATION ${privincludedir}/libedataserverui
+)
diff --git a/libedataserverui/e-cell-renderer-color.c b/libedataserverui/e-cell-renderer-color.c
index 761afa5..2f35064 100644
--- a/libedataserverui/e-cell-renderer-color.c
+++ b/libedataserverui/e-cell-renderer-color.c
@@ -16,9 +16,7 @@
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-cell-renderer-color.h"
 
diff --git a/libedataserverui/e-credentials-prompter-impl-google.c 
b/libedataserverui/e-credentials-prompter-impl-google.c
index 2e8fe3b..c675366 100644
--- a/libedataserverui/e-credentials-prompter-impl-google.c
+++ b/libedataserverui/e-credentials-prompter-impl-google.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib.h>
 #include <glib/gi18n-lib.h>
diff --git a/libedataserverui/e-credentials-prompter-impl-password.c 
b/libedataserverui/e-credentials-prompter-impl-password.c
index 512f32f..fd90b81 100644
--- a/libedataserverui/e-credentials-prompter-impl-password.c
+++ b/libedataserverui/e-credentials-prompter-impl-password.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib.h>
 #include <glib/gi18n-lib.h>
diff --git a/libedataserverui/e-credentials-prompter-impl.c b/libedataserverui/e-credentials-prompter-impl.c
index 4a432f6..3ca2404 100644
--- a/libedataserverui/e-credentials-prompter-impl.c
+++ b/libedataserverui/e-credentials-prompter-impl.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-credentials-prompter.h"
 #include "e-credentials-prompter-impl.h"
diff --git a/libedataserverui/e-credentials-prompter.c b/libedataserverui/e-credentials-prompter.c
index 1e0458e..a5cf238 100644
--- a/libedataserverui/e-credentials-prompter.c
+++ b/libedataserverui/e-credentials-prompter.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib.h>
 #include <glib/gi18n-lib.h>
diff --git a/libedataserverui/e-trust-prompt.c b/libedataserverui/e-trust-prompt.c
index 6f232ee..6086486 100644
--- a/libedataserverui/e-trust-prompt.c
+++ b/libedataserverui/e-trust-prompt.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <string.h>
 
diff --git a/libedataserverui/e-webdav-discover-widget.c b/libedataserverui/e-webdav-discover-widget.c
index d1abf68..5cfed0f 100644
--- a/libedataserverui/e-webdav-discover-widget.c
+++ b/libedataserverui/e-webdav-discover-widget.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <glib.h>
 #include <glib/gi18n-lib.h>
diff --git a/libedataserverui/libedataserverui.pc.in b/libedataserverui/libedataserverui.pc.in
index e7bd6e8..90e478e 100644
--- a/libedataserverui/libedataserverui.pc.in
+++ b/libedataserverui/libedataserverui.pc.in
@@ -1,9 +1,9 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-datarootdir=@datarootdir@
-datadir=@datadir@
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+libexecdir=@LIBEXEC_INSTALL_DIR@
+includedir=@INCLUDE_INSTALL_DIR@
+datarootdir=@SHARE_INSTALL_DIR@
+datadir=@SHARE_INSTALL_DIR@
 
 privlibdir=@privlibdir@
 privincludedir=@privincludedir@
@@ -12,7 +12,7 @@ credentialmoduledir=@credentialmoduledir@
 
 Name: libedataserverui
 Description: UI utility library for Evolution Data Server
-Version: @VERSION@
+Version: @PROJECT_VERSION@
 Requires: gio-2.0 gmodule-2.0 libsecret-1 libxml-2.0 libsoup-2.4 gtk+-3.0 libedataserver-@API_VERSION@
 Requires.private: camel-@API_VERSION@
 Libs: -L${libdir} -ledataserver-@API_VERSION@ -ledataserverui-@API_VERSION@
diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt
new file mode 100644
index 0000000..d9fabf8
--- /dev/null
+++ b/modules/CMakeLists.txt
@@ -0,0 +1,84 @@
+macro(add_simple_module _name _sourcesvar _depsvar _defsvar _cflagsvar _incdirsvar _ldflagsvar _destination)
+       set(DEPENDENCIES
+               ebackend
+               edataserver
+       )
+
+       set(SOURCES
+               ${${_sourcesvar}}
+       )
+
+       add_library(${_name} MODULE
+               ${SOURCES}
+       )
+
+       set_target_properties(${_name} PROPERTIES
+               PREFIX ""
+       )
+
+       add_dependencies(${_name}
+               ${DEPENDENCIES}
+               ${${_depsvar}}
+       )
+
+       target_compile_definitions(${_name} PRIVATE
+               -DG_LOG_DOMAIN=\"${_name}\"
+               ${${_defsvar}}
+       )
+
+       target_compile_options(${_name} PUBLIC
+               ${BACKEND_CFLAGS}
+               ${DATA_SERVER_CFLAGS}
+               ${${_cflagsvar}}
+       )
+
+       target_include_directories(${_name} PUBLIC
+               ${CMAKE_BINARY_DIR}
+               ${CMAKE_SOURCE_DIR}
+               ${BACKEND_INCLUDE_DIRS}
+               ${DATA_SERVER_INCLUDE_DIRS}
+               ${${_incdirsvar}}
+       )
+
+       target_link_libraries(${_name}
+               ${DEPENDENCIES}
+               ${${_depsvar}}
+               ${BACKEND_LDFLAGS}
+               ${DATA_SERVER_LDFLAGS}
+               ${${_ldflagsvar}}
+       )
+
+       install(TARGETS ${_name}
+               DESTINATION ${_destination}
+       )
+endmacro(add_simple_module)
+
+macro(add_source_registry_module _name _sourcesvar _depsvar _defsvar _cflagsvar _incdirsvar _ldflagsvar)
+       add_simple_module(${_name} ${_sourcesvar} ${_depsvar} ${_defsvar} ${_cflagsvar} ${_incdirsvar} 
${_ldflagsvar} ${moduledir})
+endmacro(add_source_registry_module)
+
+macro(add_credentials_module _name _sourcesvar _depsvar _defsvar _cflagsvar _incdirsvar _ldflagsvar)
+       add_simple_module(${_name} ${_sourcesvar} ${_depsvar} ${_defsvar} ${_cflagsvar} ${_incdirsvar} 
${_ldflagsvar} ${credentialmoduledir})
+endmacro(add_credentials_module)
+
+add_subdirectory(cache-reaper)
+add_subdirectory(google-backend)
+add_subdirectory(outlook-backend)
+add_subdirectory(owncloud-backend)
+add_subdirectory(yahoo-backend)
+
+if(HAVE_GTK)
+       add_subdirectory(trust-prompt)
+endif(HAVE_GTK)
+
+if(HAVE_GOA)
+       add_subdirectory(gnome-online-accounts)
+endif(HAVE_GOA)
+
+if(HAVE_UOA)
+       add_subdirectory(ubuntu-online-accounts)
+endif(HAVE_UOA)
+
+if(NOT WIN32)
+       add_subdirectory(secret-monitor)
+endif(NOT WIN32)
diff --git a/modules/cache-reaper/CMakeLists.txt b/modules/cache-reaper/CMakeLists.txt
new file mode 100644
index 0000000..375cfcc
--- /dev/null
+++ b/modules/cache-reaper/CMakeLists.txt
@@ -0,0 +1,17 @@
+set(extra_deps)
+set(sources
+       module-cache-reaper.c
+)
+set(extra_defines)
+set(extra_cflags)
+set(extra_incdirs)
+set(extra_ldflags)
+
+add_source_registry_module(module-cache-reaper
+       sources
+       extra_deps
+       extra_defines
+       extra_cflags
+       extra_incdirs
+       extra_ldflags
+)
diff --git a/modules/cache-reaper/module-cache-reaper.c b/modules/cache-reaper/module-cache-reaper.c
index 2d15b50..a513908 100644
--- a/modules/cache-reaper/module-cache-reaper.c
+++ b/modules/cache-reaper/module-cache-reaper.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <libebackend/libebackend.h>
 
diff --git a/modules/gnome-online-accounts/CMakeLists.txt b/modules/gnome-online-accounts/CMakeLists.txt
new file mode 100644
index 0000000..e86cc72
--- /dev/null
+++ b/modules/gnome-online-accounts/CMakeLists.txt
@@ -0,0 +1,38 @@
+set(extra_deps)
+set(sources
+       module-gnome-online-accounts.c
+       e-goa-client.c
+       e-goa-client.h
+       goaewsclient.c
+       goaewsclient.h
+)
+set(extra_defines)
+set(extra_cflags ${GOA_SERVER_CFLAGS})
+set(extra_incdirs ${GOA_INCLUDE_DIRS})
+set(extra_ldflags ${GOA_LDFLAGS})
+
+add_source_registry_module(module-gnome-online-accounts
+       sources
+       extra_deps
+       extra_defines
+       extra_cflags
+       extra_incdirs
+       extra_ldflags
+)
+
+set(sources
+       module-credentials-goa.c
+       e-goa-client.c
+       e-goa-client.h
+       e-goa-password-based.c
+       e-goa-password-based.h
+)
+
+add_credentials_module(module-credentials-goa
+       sources
+       extra_deps
+       extra_defines
+       extra_cflags
+       extra_incdirs
+       extra_ldflags
+)
diff --git a/modules/gnome-online-accounts/e-goa-client.c b/modules/gnome-online-accounts/e-goa-client.c
index 11f361b..48e3953 100644
--- a/modules/gnome-online-accounts/e-goa-client.c
+++ b/modules/gnome-online-accounts/e-goa-client.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <libedataserver/libedataserver.h>
 
diff --git a/modules/gnome-online-accounts/e-goa-password-based.c 
b/modules/gnome-online-accounts/e-goa-password-based.c
index dea674a..85f0450 100644
--- a/modules/gnome-online-accounts/e-goa-password-based.c
+++ b/modules/gnome-online-accounts/e-goa-password-based.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 /* XXX Yeah, yeah... */
 #define GOA_API_IS_SUBJECT_TO_CHANGE
diff --git a/modules/gnome-online-accounts/goaewsclient.c b/modules/gnome-online-accounts/goaewsclient.c
index 884dda5..b4384c0 100644
--- a/modules/gnome-online-accounts/goaewsclient.c
+++ b/modules/gnome-online-accounts/goaewsclient.c
@@ -23,7 +23,8 @@
  * evolution-ews/src/server/e-ews-connection.c
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <glib/gi18n-lib.h>
 
 #include <libsoup/soup.h>
diff --git a/modules/gnome-online-accounts/module-credentials-goa.c 
b/modules/gnome-online-accounts/module-credentials-goa.c
index 4d5ea1a..00a36a7 100644
--- a/modules/gnome-online-accounts/module-credentials-goa.c
+++ b/modules/gnome-online-accounts/module-credentials-goa.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-goa-password-based.h"
 
diff --git a/modules/gnome-online-accounts/module-gnome-online-accounts.c 
b/modules/gnome-online-accounts/module-gnome-online-accounts.c
index 929c0e4..e662180 100644
--- a/modules/gnome-online-accounts/module-gnome-online-accounts.c
+++ b/modules/gnome-online-accounts/module-gnome-online-accounts.c
@@ -15,7 +15,8 @@
  *
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <glib/gi18n-lib.h>
 #include <libsoup/soup.h>
 
diff --git a/modules/google-backend/CMakeLists.txt b/modules/google-backend/CMakeLists.txt
new file mode 100644
index 0000000..fcd78a8
--- /dev/null
+++ b/modules/google-backend/CMakeLists.txt
@@ -0,0 +1,17 @@
+set(extra_deps)
+set(sources
+       module-google-backend.c
+)
+set(extra_defines)
+set(extra_cflags ${LIBGDATA_CFLAGS})
+set(extra_incdirs ${LIBGDATA_INCLUDE_DIRS})
+set(extra_ldflags ${LIBGDATA_LDFLAGS})
+
+add_source_registry_module(module-google-backend
+       sources
+       extra_deps
+       extra_defines
+       extra_cflags
+       extra_incdirs
+       extra_ldflags
+)
diff --git a/modules/google-backend/module-google-backend.c b/modules/google-backend/module-google-backend.c
index 2e52742..8bbbb48 100644
--- a/modules/google-backend/module-google-backend.c
+++ b/modules/google-backend/module-google-backend.c
@@ -15,12 +15,13 @@
  *
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <glib/gi18n-lib.h>
 
 #include <libebackend/libebackend.h>
 
-#ifdef HAVE_GOOGLE
+#ifdef HAVE_LIBGDATA
 #include <gdata/gdata.h>
 #endif
 
diff --git a/modules/outlook-backend/CMakeLists.txt b/modules/outlook-backend/CMakeLists.txt
new file mode 100644
index 0000000..d0a7294
--- /dev/null
+++ b/modules/outlook-backend/CMakeLists.txt
@@ -0,0 +1,17 @@
+set(extra_deps)
+set(sources
+       module-outlook-backend.c
+)
+set(extra_defines)
+set(extra_cflags)
+set(extra_incdirs)
+set(extra_ldflags)
+
+add_source_registry_module(module-outlook-backend
+       sources
+       extra_deps
+       extra_defines
+       extra_cflags
+       extra_incdirs
+       extra_ldflags
+)
diff --git a/modules/outlook-backend/module-outlook-backend.c 
b/modules/outlook-backend/module-outlook-backend.c
index e1c3b60..a787982 100644
--- a/modules/outlook-backend/module-outlook-backend.c
+++ b/modules/outlook-backend/module-outlook-backend.c
@@ -21,7 +21,8 @@
  *     as a placeholder with hopes that Microsoft will eventually provide
  *     access to calendar+contacts via CalDAV/CardDAV or even EWS. */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <glib/gi18n-lib.h>
 
 #include <libebackend/libebackend.h>
diff --git a/modules/owncloud-backend/CMakeLists.txt b/modules/owncloud-backend/CMakeLists.txt
new file mode 100644
index 0000000..91bad5a
--- /dev/null
+++ b/modules/owncloud-backend/CMakeLists.txt
@@ -0,0 +1,17 @@
+set(extra_deps)
+set(sources
+       module-owncloud-backend.c
+)
+set(extra_defines)
+set(extra_cflags)
+set(extra_incdirs)
+set(extra_ldflags)
+
+add_source_registry_module(module-owncloud-backend
+       sources
+       extra_deps
+       extra_defines
+       extra_cflags
+       extra_incdirs
+       extra_ldflags
+)
diff --git a/modules/owncloud-backend/module-owncloud-backend.c 
b/modules/owncloud-backend/module-owncloud-backend.c
index 238cd7e..900e241 100644
--- a/modules/owncloud-backend/module-owncloud-backend.c
+++ b/modules/owncloud-backend/module-owncloud-backend.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <libebackend/libebackend.h>
 #include <libedataserver/libedataserver.h>
diff --git a/modules/secret-monitor/CMakeLists.txt b/modules/secret-monitor/CMakeLists.txt
new file mode 100644
index 0000000..05e49e2
--- /dev/null
+++ b/modules/secret-monitor/CMakeLists.txt
@@ -0,0 +1,17 @@
+set(extra_deps)
+set(sources
+       module-secret-monitor.c
+)
+set(extra_defines)
+set(extra_cflags ${LIBSECRET_CFLAGS})
+set(extra_incdirs ${LIBSECRET_INCLUDE_DIRS})
+set(extra_ldflags ${LIBSECRET_LDFLAGS})
+
+add_source_registry_module(module-secret-monitor
+       sources
+       extra_deps
+       extra_defines
+       extra_cflags
+       extra_incdirs
+       extra_ldflags
+)
diff --git a/modules/secret-monitor/module-secret-monitor.c b/modules/secret-monitor/module-secret-monitor.c
index 07d12b0..817c401 100644
--- a/modules/secret-monitor/module-secret-monitor.c
+++ b/modules/secret-monitor/module-secret-monitor.c
@@ -15,6 +15,8 @@
  *
  */
 
+#include "evolution-data-server-config.h"
+
 /* XXX Yeah, yeah... */
 #define SECRET_API_SUBJECT_TO_CHANGE
 
diff --git a/modules/trust-prompt/CMakeLists.txt b/modules/trust-prompt/CMakeLists.txt
new file mode 100644
index 0000000..b3f1f88
--- /dev/null
+++ b/modules/trust-prompt/CMakeLists.txt
@@ -0,0 +1,41 @@
+set(TRUST_PROMPT_SOURCES
+       trust-prompt-gtk.c
+)
+
+set(TRUST_PROMPT_CFLAGS
+       ${GNOME_PLATFORM_CFLAGS}
+       ${GTK_CFLAGS}
+       ${GCR_CFLAGS}
+)
+
+set(TRUST_PROMPT_INCLUDE_DIRS
+       ${GNOME_PLATFORM_INCLUDE_DIRS}
+       ${GTK_INCLUDE_DIRS}
+       ${GCR_INCLUDE_DIRS}
+)
+
+set(TRUST_PROMPT_LDFLAGS
+       ${GNOME_PLATFORM_LDFLAGS}
+       ${GTK_LDFLAGS}
+       ${GCR_LDFLAGS}
+)
+
+set(extra_deps)
+set(sources
+       module-trust-prompt.c
+       trust-prompt.h
+       ${TRUST_PROMPT_SOURCES}
+)
+set(extra_defines)
+set(extra_cflags ${TRUST_PROMPT_CFLAGS})
+set(extra_incdirs ${TRUST_PROMPT_INCLUDE_DIRS})
+set(extra_ldflags ${TRUST_PROMPT_LDFLAGS})
+
+add_source_registry_module(module-trust-prompt
+       sources
+       extra_deps
+       extra_defines
+       extra_cflags
+       extra_incdirs
+       extra_ldflags
+)
diff --git a/modules/trust-prompt/module-trust-prompt.c b/modules/trust-prompt/module-trust-prompt.c
index 4005516..4bfbf68 100644
--- a/modules/trust-prompt/module-trust-prompt.c
+++ b/modules/trust-prompt/module-trust-prompt.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n-lib.h>
 
diff --git a/modules/trust-prompt/trust-prompt-gtk.c b/modules/trust-prompt/trust-prompt-gtk.c
index 8907c88..c6e99a7 100644
--- a/modules/trust-prompt/trust-prompt-gtk.c
+++ b/modules/trust-prompt/trust-prompt-gtk.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include "evolution-data-server-config.h"
 
 #include <gtk/gtk.h>
 #include <glib/gi18n-lib.h>
diff --git a/modules/ubuntu-online-accounts/CMakeLists.txt b/modules/ubuntu-online-accounts/CMakeLists.txt
new file mode 100644
index 0000000..4eeb7c8
--- /dev/null
+++ b/modules/ubuntu-online-accounts/CMakeLists.txt
@@ -0,0 +1,158 @@
+# ******************************
+# Data files
+# ******************************
+
+set(filedeps)
+
+set(servicetype_files)
+set(servicetype_files_gen)
+list(APPEND servicetype_files
+       mail.service-type
+       calendar.service-type
+       contacts.service-type
+)
+
+set(service_files)
+set(service_files_gen)
+list(APPEND service_files
+       google-gmail.service
+       google-calendar.service
+       google-contacts.service
+       windows-live-mail.service
+       yahoo-mail.service
+       yahoo-calendar.service
+)
+
+configure_file(evolution-data-server.application.in.in
+       evolution-data-server.application.in
+       @ONLY
+)
+
+intltool_merge(${CMAKE_CURRENT_BINARY_DIR}/evolution-data-server.application.in 
evolution-data-server.application --no-translations --xml-style --utf8)
+
+configure_file(evolution-data-server-uoa.desktop.in.in
+       evolution-data-server-uoa.desktop.in
+       @ONLY
+)
+
+intltool_merge(${CMAKE_CURRENT_BINARY_DIR}/evolution-data-server-uoa.desktop.in 
evolution-data-server-uoa.desktop --desktop-style --utf8)
+
+list(APPEND filedeps ${CMAKE_CURRENT_BINARY_DIR}/evolution-data-server.application)
+list(APPEND filedeps ${CMAKE_CURRENT_BINARY_DIR}/evolution-data-server-uoa.desktop)
+
+foreach(_file IN LISTS servicetype_files)
+       configure_file(${_file}.in.in
+               ${_file}.in
+               @ONLY
+       )
+       intltool_merge(${CMAKE_CURRENT_BINARY_DIR}/${_file}.in ${_file} --no-translations --xml-style --utf8)
+       list(APPEND servicetype_files_gen ${CMAKE_CURRENT_BINARY_DIR}/${_file})
+       list(APPEND filedeps ${CMAKE_CURRENT_BINARY_DIR}/${_file})
+endforeach(_file)
+
+foreach(_file IN LISTS service_files)
+       configure_file(${_file}.in.in
+               ${_file}.in
+               @ONLY
+       )
+       intltool_merge(${CMAKE_CURRENT_BINARY_DIR}/${_file}.in ${_file} --no-translations --xml-style --utf8)
+       list(APPEND service_files_gen ${CMAKE_CURRENT_BINARY_DIR}/${_file})
+       list(APPEND filedeps ${CMAKE_CURRENT_BINARY_DIR}/${_file})
+endforeach(_file)
+
+set(desktopdir ${SHARE_INSTALL_DIR}/applications)
+pkg_check_variable(libaccountsprefixdir libaccounts-glib prefix)
+pkg_check_variable(applicationdir libaccounts-glib applicationfilesdir)
+pkg_check_variable(servicetypedir libaccounts-glib servicetypefilesdir)
+pkg_check_variable(servicedir libaccounts-glib servicefilesdir)
+
+# To honor configured prefix, but still use the right place
+string(REPLACE "${libaccountsprefixdir}" "${CMAKE_INSTALL_PREFIX}" applicationdir "${applicationdir}")
+string(REPLACE "${libaccountsprefixdir}" "${CMAKE_INSTALL_PREFIX}" servicetypedir "${servicetypedir}")
+string(REPLACE "${libaccountsprefixdir}" "${CMAKE_INSTALL_PREFIX}" servicedir "${servicedir}")
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/evolution-data-server.application
+       DESTINATION ${applicationdir}
+)
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/evolution-data-server-uoa.desktop
+       DESTINATION ${desktopdir}
+)
+
+install(FILES ${servicetype_files_gen}
+       DESTINATION ${servicetypedir}
+)
+
+install(FILES ${service_files_gen}
+       DESTINATION ${servicedir}
+)
+
+# ******************************
+# Source registry module
+# ******************************
+
+set(sources
+       module-ubuntu-online-accounts.c
+       uoa-utils.c
+       uoa-utils.h
+)
+set(extra_deps)
+set(extra_filedeps
+       ${CMAKE_CURRENT_BINARY_DIR}/evolution-data-server.application
+       ${CMAKE_CURRENT_BINARY_DIR}/evolution-data-server-uoa.desktop
+       ${servicetype_files_gen}
+       ${service_files_gen}
+)
+set(extra_defines)
+set(extra_cflags
+       ${LIBACCOUNTS_GLIB_CFLAGS}
+       ${LIBSIGNON_GLIB_CFLAGS}
+       ${JSON_GLIB_CFLAGS}
+       ${REST_CFLAGS}
+)
+set(extra_incdirs
+       ${LIBACCOUNTS_GLIB_INCLUDE_DIRS}
+       ${LIBSIGNON_GLIB_INCLUDE_DIRS}
+       ${JSON_GLIB_INCLUDE_DIRS}
+       ${REST_INCLUDE_DIRS}
+)
+set(extra_ldflags
+       ${LIBACCOUNTS_GLIB_LDFLAGS}
+       ${LIBSIGNON_GLIB_LDFLAGS}
+       ${JSON_GLIB_LDFLAGS}
+       ${REST_LDFLAGS}
+)
+
+add_source_registry_module(module-ubuntu-online-accounts
+       sources
+       extra_deps
+       extra_defines
+       extra_cflags
+       extra_incdirs
+       extra_ldflags
+)
+
+add_custom_target(module-ubuntu-online-accounts-files
+       DEPENDS ${filedeps}
+)
+
+add_dependencies(module-ubuntu-online-accounts module-ubuntu-online-accounts-files)
+
+# ******************************
+# Credentials module
+# ******************************
+
+set(sources
+       module-credentials-uoa.c
+       e-signon-session-password.c
+       e-signon-session-password.h
+)
+
+add_credentials_module(module-credentials-uoa
+       sources
+       extra_deps
+       extra_defines
+       extra_cflags
+       extra_incdirs
+       extra_ldflags
+)
diff --git a/modules/ubuntu-online-accounts/e-signon-session-password.c 
b/modules/ubuntu-online-accounts/e-signon-session-password.c
index 12b22c8..6f4144b 100644
--- a/modules/ubuntu-online-accounts/e-signon-session-password.c
+++ b/modules/ubuntu-online-accounts/e-signon-session-password.c
@@ -15,14 +15,15 @@
  *
  */
 
-#include "e-signon-session-password.h"
+#include "evolution-data-server-config.h"
 
-#include <config.h>
 #include <glib/gi18n-lib.h>
 #include <libsignon-glib/signon-glib.h>
 
 #include "uoa-utils.h"
 
+#include "e-signon-session-password.h"
+
 #define SIGNON_METHOD_PASSWORD    "password"
 #define SIGNON_MECHANISM_PASSWORD "password"
 
diff --git a/modules/ubuntu-online-accounts/module-credentials-uoa.c 
b/modules/ubuntu-online-accounts/module-credentials-uoa.c
index 30c2a46..0233ee9 100644
--- a/modules/ubuntu-online-accounts/module-credentials-uoa.c
+++ b/modules/ubuntu-online-accounts/module-credentials-uoa.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-signon-session-password.h"
 
diff --git a/modules/ubuntu-online-accounts/module-ubuntu-online-accounts.c 
b/modules/ubuntu-online-accounts/module-ubuntu-online-accounts.c
index 51feee6..f51ea39 100644
--- a/modules/ubuntu-online-accounts/module-ubuntu-online-accounts.c
+++ b/modules/ubuntu-online-accounts/module-ubuntu-online-accounts.c
@@ -15,7 +15,8 @@
  *
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <glib/gi18n-lib.h>
 #include <libsignon-glib/signon-glib.h>
 #include <libaccounts-glib/accounts-glib.h>
diff --git a/modules/ubuntu-online-accounts/uoa-utils.c b/modules/ubuntu-online-accounts/uoa-utils.c
index 59676b1..3884789 100644
--- a/modules/ubuntu-online-accounts/uoa-utils.c
+++ b/modules/ubuntu-online-accounts/uoa-utils.c
@@ -15,14 +15,15 @@
  *
  */
 
-#include "uoa-utils.h"
+#include "evolution-data-server-config.h"
 
-#include <config.h>
 #include <glib/gi18n-lib.h>
 #include <rest/rest-proxy.h>
 #include <json-glib/json-glib.h>
 #include <libsignon-glib/signon-glib.h>
 
+#include "uoa-utils.h"
+
 #define GOOGLE_USERINFO_URI \
        "https://www.googleapis.com/oauth2/v2/userinfo";
 
diff --git a/modules/yahoo-backend/CMakeLists.txt b/modules/yahoo-backend/CMakeLists.txt
new file mode 100644
index 0000000..dab6654
--- /dev/null
+++ b/modules/yahoo-backend/CMakeLists.txt
@@ -0,0 +1,17 @@
+set(extra_deps)
+set(sources
+       module-yahoo-backend.c
+)
+set(extra_defines)
+set(extra_cflags)
+set(extra_incdirs)
+set(extra_ldflags)
+
+add_source_registry_module(module-yahoo-backend
+       sources
+       extra_deps
+       extra_defines
+       extra_cflags
+       extra_incdirs
+       extra_ldflags
+)
diff --git a/modules/yahoo-backend/module-yahoo-backend.c b/modules/yahoo-backend/module-yahoo-backend.c
index 3e784a4..0a34236 100644
--- a/modules/yahoo-backend/module-yahoo-backend.c
+++ b/modules/yahoo-backend/module-yahoo-backend.c
@@ -15,7 +15,8 @@
  *
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <glib/gi18n-lib.h>
 
 #include <libebackend/libebackend.h>
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/po/POTFILES.skip b/po/POTFILES.skip
index 861b981..fe29d74 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -1,3 +1,4 @@
+build/
 camel/camel-news-address.c
 camel/camel-process.c
 camel/providers/nntp/camel-nntp-auth.c
diff --git a/private/CMakeLists.txt b/private/CMakeLists.txt
new file mode 100644
index 0000000..0de19ea
--- /dev/null
+++ b/private/CMakeLists.txt
@@ -0,0 +1,189 @@
+
+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)
+
+set(GENERATED_DBUS_SOURCE
+       e-dbus-source.c
+       e-dbus-source.h
+       e-dbus-source-org.gnome.evolution.dataserver.Source.xml
+       e-dbus-source-org.gnome.evolution.dataserver.Source.Removable.xml
+       e-dbus-source-org.gnome.evolution.dataserver.Source.Writable.xml
+       e-dbus-source-org.gnome.evolution.dataserver.Source.RemoteCreatable.xml
+       e-dbus-source-org.gnome.evolution.dataserver.Source.RemoteDeletable.xml
+       e-dbus-source-org.gnome.evolution.dataserver.Source.OAuth2Support.xml
+)
+
+gdbus_codegen_custom(org.gnome.evolution.dataserver.Source.xml
+       org.gnome.evolution.dataserver.
+       E_DBus
+       e-dbus-source
+       GENERATED_DBUS_SOURCE
+       --c-generate-object-manager)
+
+set(GENERATED_DBUS_SOURCE_MANAGER
+       e-dbus-source-manager.c
+       e-dbus-source-manager.h
+       e-dbus-source-manager-org.gnome.evolution.dataserver.SourceManager.xml
+)
+
+gdbus_codegen(org.gnome.evolution.dataserver.SourceManager.xml
+       org.gnome.evolution.dataserver.
+       E_DBus
+       e-dbus-source-manager
+       GENERATED_DBUS_SOURCE_MANAGER)
+
+set(GENERATED_DBUS_AUTHENTICATOR
+       e-dbus-authenticator.c
+       e-dbus-authenticator.h
+       e-dbus-authenticator-org.gnome.evolution.dataserver.Authenticator.xml
+)
+
+gdbus_codegen(org.gnome.evolution.dataserver.Authenticator.xml
+       org.gnome.evolution.dataserver.
+       E_DBus
+       e-dbus-authenticator
+       GENERATED_DBUS_AUTHENTICATOR)
+
+set(GENERATED_DBUS_USER_PROMPTER
+       e-dbus-user-prompter.c
+       e-dbus-user-prompter.h
+       e-dbus-user-prompter-org.gnome.evolution.dataserver.UserPrompter.xml
+)
+
+gdbus_codegen(org.gnome.evolution.dataserver.UserPrompter.xml
+       org.gnome.evolution.dataserver.
+       E_DBus
+       e-dbus-user-prompter
+       GENERATED_DBUS_USER_PROMPTER)
+
+set(GENERATED_DBUS_ADDRESS_BOOK
+       e-dbus-address-book.c
+       e-dbus-address-book.h
+       e-dbus-address-book-org.gnome.evolution.dataserver.AddressBook.xml
+)
+
+gdbus_codegen(org.gnome.evolution.dataserver.AddressBook.xml
+       org.gnome.evolution.dataserver.
+       E_DBus
+       e-dbus-address-book
+       GENERATED_DBUS_ADDRESS_BOOK)
+
+set(GENERATED_DBUS_ADDRESS_BOOK_CURSOR
+       e-dbus-address-book-cursor.c
+       e-dbus-address-book-cursor.h
+       e-dbus-address-book-cursor-org.gnome.evolution.dataserver.AddressBookCursor.xml
+)
+
+gdbus_codegen(org.gnome.evolution.dataserver.AddressBookCursor.xml
+       org.gnome.evolution.dataserver.
+       E_DBus
+       e-dbus-address-book-cursor
+       GENERATED_DBUS_ADDRESS_BOOK_CURSOR)
+
+set(GENERATED_DBUS_DIRECT_BOOK
+       e-dbus-direct-book.c
+       e-dbus-direct-book.h
+       e-dbus-direct-book-org.gnome.evolution.dataserver.DirectBook.xml
+)
+
+gdbus_codegen(org.gnome.evolution.dataserver.DirectBook.xml
+       org.gnome.evolution.dataserver.
+       E_DBus
+       e-dbus-direct-book
+       GENERATED_DBUS_DIRECT_BOOK)
+
+set(GENERATED_DBUS_ADDRESS_BOOK_FACTORY
+       e-dbus-address-book-factory.c
+       e-dbus-address-book-factory.h
+       e-dbus-address-book-factory-org.gnome.evolution.dataserver.AddressBookFactory.xml
+)
+
+gdbus_codegen(org.gnome.evolution.dataserver.AddressBookFactory.xml
+       org.gnome.evolution.dataserver.
+       E_DBus
+       e-dbus-address-book-factory
+       GENERATED_DBUS_ADDRESS_BOOK_FACTORY)
+
+set(GENERATED_DBUS_CALENDAR
+       e-dbus-calendar.c
+       e-dbus-calendar.h
+       e-dbus-calendar-org.gnome.evolution.dataserver.Calendar.xml
+)
+
+gdbus_codegen(org.gnome.evolution.dataserver.Calendar.xml
+       org.gnome.evolution.dataserver.
+       E_DBus
+       e-dbus-calendar
+       GENERATED_DBUS_CALENDAR)
+
+set(GENERATED_DBUS_CALENDAR_FACTORY
+       e-dbus-calendar-factory.c
+       e-dbus-calendar-factory.h
+       e-dbus-calendar-factory-org.gnome.evolution.dataserver.CalendarFactory.xml
+)
+
+gdbus_codegen(org.gnome.evolution.dataserver.CalendarFactory.xml
+       org.gnome.evolution.dataserver.
+       E_DBus
+       e-dbus-calendar-factory
+       GENERATED_DBUS_CALENDAR_FACTORY)
+
+set(GENERATED_DBUS_SUBPROCESS_BACKEND
+       e-dbus-subprocess-backend.c
+       e-dbus-subprocess-backend.h
+       e-dbus-subprocess-backend-org.gnome.evolution.dataserver.Subprocess.Backend.xml
+)
+
+gdbus_codegen_custom(org.gnome.evolution.dataserver.Subprocess.Backend.xml
+       org.gnome.evolution.dataserver.Subprocess
+       E_DBus_Subprocess
+       e-dbus-subprocess-backend
+       GENERATED_DBUS_SUBPROCESS_BACKEND
+       --c-generate-object-manager)
+
+add_library(edbus-private SHARED
+       ${GENERATED_DBUS_LOCALE}
+       ${GENERATED_DBUS_SOURCE}
+       ${GENERATED_DBUS_SOURCE_MANAGER}
+       ${GENERATED_DBUS_AUTHENTICATOR}
+       ${GENERATED_DBUS_ADDRESS_BOOK}
+       ${GENERATED_DBUS_ADDRESS_BOOK_CURSOR}
+       ${GENERATED_DBUS_DIRECT_BOOK}
+       ${GENERATED_DBUS_ADDRESS_BOOK_FACTORY}
+       ${GENERATED_DBUS_CALENDAR}
+       ${GENERATED_DBUS_CALENDAR_FACTORY}
+       ${GENERATED_DBUS_USER_PROMPTER}
+       ${GENERATED_DBUS_SUBPROCESS_BACKEND}
+)
+
+target_compile_definitions(edbus-private PRIVATE
+       -DG_LOG_DOMAIN=\"libedbus-private\"
+)
+
+target_compile_options(edbus-private PUBLIC
+       ${DATA_SERVER_CFLAGS}
+       ${GIO_UNIX_CFLAGS}
+)
+
+target_include_directories(edbus-private PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${DATA_SERVER_INCLUDE_DIRS}
+       ${GIO_UNIX_INCLUDE_DIRS}
+)
+
+target_link_libraries(edbus-private
+       ${DATA_SERVER_LDFLAGS}
+       ${GIO_UNIX_LDFLAGS}
+)
+
+install(TARGETS edbus-private
+       DESTINATION ${privsolibdir}
+)
diff --git a/services/CMakeLists.txt b/services/CMakeLists.txt
new file mode 100644
index 0000000..a3f1c3f
--- /dev/null
+++ b/services/CMakeLists.txt
@@ -0,0 +1,7 @@
+add_subdirectory(evolution-addressbook-factory)
+add_subdirectory(evolution-calendar-factory)
+add_subdirectory(evolution-source-registry)
+
+if(HAVE_GTK)
+       add_subdirectory(evolution-user-prompter)
+endif(HAVE_GTK)
diff --git a/services/evolution-addressbook-factory/CMakeLists.txt 
b/services/evolution-addressbook-factory/CMakeLists.txt
new file mode 100644
index 0000000..9eb501e
--- /dev/null
+++ b/services/evolution-addressbook-factory/CMakeLists.txt
@@ -0,0 +1,75 @@
+set(SYSTEMD_SERVICE)
+if(WITH_SYSTEMD_USER_UNITS)
+       set(SYSTEMD_SERVICE "SystemdService=evolution-addressbook-factory.service")
+
+       configure_file(evolution-addressbook-factory.service.in
+               evolution-addressbook-factory.service
+               @ONLY
+       )
+
+       install(FILES ${CMAKE_CURRENT_BINARY_DIR}/evolution-addressbook-factory.service
+               DESTINATION ${WITH_SYSTEMDUSERUNITDIR}
+       )
+endif(WITH_SYSTEMD_USER_UNITS)
+
+configure_file(org.gnome.evolution.dataserver.AddressBook.service.in
+       org.gnome.evolution.dataserver.AddressBook.service
+       @ONLY
+)
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.gnome.evolution.dataserver.AddressBook.service
+       DESTINATION ${WITH_DBUS_SERVICE_DIR}
+)
+
+set(DEPENDENCIES
+       ebackend
+       ebook
+       ebook-contacts
+       edata-book
+       edataserver
+)
+
+set(SOURCES
+       evolution-addressbook-factory.c
+)
+
+add_executable(evolution-addressbook-factory
+       ${SOURCES}
+)
+
+add_dependencies(evolution-addressbook-factory
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(evolution-addressbook-factory PRIVATE
+       -DG_LOG_DOMAIN=\"evolution-addressbook-factory\"
+       -DLOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+)
+
+target_compile_options(evolution-addressbook-factory PUBLIC
+       ${BACKEND_CFLAGS}
+       ${DATA_SERVER_CFLAGS}
+       ${ADDRESSBOOK_CFLAGS}
+       ${GTK_CFLAGS}
+)
+
+target_include_directories(evolution-addressbook-factory PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${BACKEND_INCLUDE_DIRS}
+       ${DATA_SERVER_INCLUDE_DIRS}
+       ${ADDRESSBOOK_INCLUDE_DIRS}
+       ${GTK_INCLUDE_DIRS}
+)
+
+target_link_libraries(evolution-addressbook-factory
+       ${DEPENDENCIES}
+       ${BACKEND_LDFLAGS}
+       ${DATA_SERVER_LDFLAGS}
+       ${ADDRESSBOOK_LDFLAGS}
+       ${GTK_LDFLAGS}
+)
+
+install(TARGETS evolution-addressbook-factory
+       DESTINATION ${LIBEXEC_INSTALL_DIR}
+)
diff --git a/services/evolution-addressbook-factory/evolution-addressbook-factory.c 
b/services/evolution-addressbook-factory/evolution-addressbook-factory.c
index 08ed333..b9e3fe5 100644
--- a/services/evolution-addressbook-factory/evolution-addressbook-factory.c
+++ b/services/evolution-addressbook-factory/evolution-addressbook-factory.c
@@ -15,7 +15,8 @@
  *
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <locale.h>
 #include <stdlib.h>
 #include <glib/gi18n.h>
diff --git a/services/evolution-addressbook-factory/evolution-addressbook-factory.service.in 
b/services/evolution-addressbook-factory/evolution-addressbook-factory.service.in
index 172b363..e547069 100644
--- a/services/evolution-addressbook-factory/evolution-addressbook-factory.service.in
+++ b/services/evolution-addressbook-factory/evolution-addressbook-factory.service.in
@@ -4,4 +4,4 @@ Description=Evolution address book service
 [Service]
 Type=dbus
 BusName=@ADDRESS_BOOK_DBUS_SERVICE_NAME@
-ExecStart=@libexecdir@/evolution-addressbook-factory
+ExecStart=@LIBEXEC_INSTALL_DIR@/evolution-addressbook-factory
diff --git a/services/evolution-addressbook-factory/org.gnome.evolution.dataserver.AddressBook.service.in 
b/services/evolution-addressbook-factory/org.gnome.evolution.dataserver.AddressBook.service.in
index e5a05b8..e38f1ae 100644
--- a/services/evolution-addressbook-factory/org.gnome.evolution.dataserver.AddressBook.service.in
+++ b/services/evolution-addressbook-factory/org.gnome.evolution.dataserver.AddressBook.service.in
@@ -1,4 +1,4 @@
 [D-BUS Service]
 Name=@ADDRESS_BOOK_DBUS_SERVICE_NAME@
-Exec=@libexecdir@/evolution-addressbook-factory
-SystemdService=evolution-addressbook-factory.service
+Exec=@LIBEXEC_INSTALL_DIR@/evolution-addressbook-factory
+@SYSTEMD_SERVICE@
diff --git a/services/evolution-calendar-factory/CMakeLists.txt 
b/services/evolution-calendar-factory/CMakeLists.txt
new file mode 100644
index 0000000..80b2d15
--- /dev/null
+++ b/services/evolution-calendar-factory/CMakeLists.txt
@@ -0,0 +1,74 @@
+set(SYSTEMD_SERVICE)
+if(WITH_SYSTEMD_USER_UNITS)
+       set(SYSTEMD_SERVICE "SystemdService=evolution-calendar-factory.service")
+
+       configure_file(evolution-calendar-factory.service.in
+               evolution-calendar-factory.service
+               @ONLY
+       )
+
+       install(FILES ${CMAKE_CURRENT_BINARY_DIR}/evolution-calendar-factory.service
+               DESTINATION ${WITH_SYSTEMDUSERUNITDIR}
+       )
+endif(WITH_SYSTEMD_USER_UNITS)
+
+configure_file(org.gnome.evolution.dataserver.Calendar.service.in
+       org.gnome.evolution.dataserver.Calendar.service
+       @ONLY
+)
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.gnome.evolution.dataserver.Calendar.service
+       DESTINATION ${WITH_DBUS_SERVICE_DIR}
+)
+
+set(DEPENDENCIES
+       ebackend
+       ecal
+       edata-cal
+       edataserver
+)
+
+set(SOURCES
+       evolution-calendar-factory.c
+)
+
+add_executable(evolution-calendar-factory
+       ${SOURCES}
+)
+
+add_dependencies(evolution-calendar-factory
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(evolution-calendar-factory PRIVATE
+       -DG_LOG_DOMAIN=\"evolution-calendar-factory\"
+       -DLOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+)
+
+target_compile_options(evolution-calendar-factory PUBLIC
+       ${BACKEND_CFLAGS}
+       ${DATA_SERVER_CFLAGS}
+       ${CALENDAR_CFLAGS}
+       ${GTK_CFLAGS}
+)
+
+target_include_directories(evolution-calendar-factory PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${BACKEND_INCLUDE_DIRS}
+       ${DATA_SERVER_INCLUDE_DIRS}
+       ${CALENDAR_INCLUDE_DIRS}
+       ${GTK_INCLUDE_DIRS}
+)
+
+target_link_libraries(evolution-calendar-factory
+       ${DEPENDENCIES}
+       ${BACKEND_LDFLAGS}
+       ${DATA_SERVER_LDFLAGS}
+       ${CALENDAR_LDFLAGS}
+       ${GTK_LDFLAGS}
+)
+
+install(TARGETS evolution-calendar-factory
+       DESTINATION ${LIBEXEC_INSTALL_DIR}
+)
diff --git a/services/evolution-calendar-factory/evolution-calendar-factory.c 
b/services/evolution-calendar-factory/evolution-calendar-factory.c
index 76beda4..6b76ff0 100644
--- a/services/evolution-calendar-factory/evolution-calendar-factory.c
+++ b/services/evolution-calendar-factory/evolution-calendar-factory.c
@@ -15,7 +15,8 @@
  *
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <locale.h>
 #include <stdlib.h>
 #include <glib/gi18n.h>
diff --git a/services/evolution-calendar-factory/evolution-calendar-factory.service.in 
b/services/evolution-calendar-factory/evolution-calendar-factory.service.in
index 4271253..d56c6c6 100644
--- a/services/evolution-calendar-factory/evolution-calendar-factory.service.in
+++ b/services/evolution-calendar-factory/evolution-calendar-factory.service.in
@@ -4,4 +4,4 @@ Description=Evolution calendar service
 [Service]
 Type=dbus
 BusName=@CALENDAR_DBUS_SERVICE_NAME@
-ExecStart=@libexecdir@/evolution-calendar-factory
+ExecStart=@LIBEXEC_INSTALL_DIR@/evolution-calendar-factory
diff --git a/services/evolution-calendar-factory/org.gnome.evolution.dataserver.Calendar.service.in 
b/services/evolution-calendar-factory/org.gnome.evolution.dataserver.Calendar.service.in
index 51dec95..a0e7b3b 100644
--- a/services/evolution-calendar-factory/org.gnome.evolution.dataserver.Calendar.service.in
+++ b/services/evolution-calendar-factory/org.gnome.evolution.dataserver.Calendar.service.in
@@ -1,4 +1,4 @@
 [D-BUS Service]
 Name=@CALENDAR_DBUS_SERVICE_NAME@
-Exec=@libexecdir@/evolution-calendar-factory
-SystemdService=evolution-calendar-factory.service
+Exec=@LIBEXEC_INSTALL_DIR@/evolution-calendar-factory
+@SYSTEMD_SERVICE@
diff --git a/services/evolution-source-registry/CMakeLists.txt 
b/services/evolution-source-registry/CMakeLists.txt
new file mode 100644
index 0000000..fa105b2
--- /dev/null
+++ b/services/evolution-source-registry/CMakeLists.txt
@@ -0,0 +1,151 @@
+set(SYSTEMD_SERVICE)
+if(WITH_SYSTEMD_USER_UNITS)
+       set(SYSTEMD_SERVICE "SystemdService=evolution-source-registry.service")
+
+       configure_file(evolution-source-registry.service.in
+               evolution-source-registry.service
+               @ONLY
+       )
+
+       install(FILES ${CMAKE_CURRENT_BINARY_DIR}/evolution-source-registry.service
+               DESTINATION ${WITH_SYSTEMDUSERUNITDIR}
+       )
+endif(WITH_SYSTEMD_USER_UNITS)
+
+configure_file(org.gnome.evolution.dataserver.Sources.service.in
+       org.gnome.evolution.dataserver.Sources.service
+       @ONLY
+)
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.gnome.evolution.dataserver.Sources.service
+       DESTINATION ${WITH_DBUS_SERVICE_DIR}
+)
+
+set(builtin_sources_files
+       caldav-stub.source
+       contacts-stub.source
+       google-stub.source
+       ldap-stub.source
+       local-stub.source
+       weather-stub.source
+       webcal-stub.source
+       webdav-stub.source
+       birthdays.source
+       local.source
+       sendmail.source
+       system-address-book.source
+       system-calendar.source
+       system-memo-list.source
+       system-proxy.source
+       system-task-list.source
+       vfolder.source
+)
+
+if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/builtin)
+       file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/builtin)
+endif(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/builtin)
+
+set(builtin_sources)
+foreach(_file ${builtin_sources_files})
+       intltool_merge(${CMAKE_CURRENT_SOURCE_DIR}/builtin/${_file}.in 
${CMAKE_CURRENT_BINARY_DIR}/builtin/${_file} -d -u)
+       list(APPEND builtin_sources ${CMAKE_CURRENT_BINARY_DIR}/builtin/${_file})
+endforeach(_file)
+
+glib_compile_resources(${CMAKE_CURRENT_BINARY_DIR}/builtin evolution-source-registry-resource 
evolution_source_registry evolution-source-registry-resource.xml ${builtin_sources})
+
+set(DEPENDENCIES
+       ebackend
+       edataserver
+)
+
+set(SOURCES
+       evolution-source-registry.c
+       evolution-source-registry-migrate-basedir.c
+       evolution-source-registry-migrate-proxies.c
+       evolution-source-registry-migrate-sources.c
+       evolution-source-registry-migrate-imap-to-imapx.c
+       ${CMAKE_CURRENT_BINARY_DIR}/evolution-source-registry-resource.c
+       ${CMAKE_CURRENT_BINARY_DIR}/evolution-source-registry-resource.h
+)
+
+add_executable(evolution-source-registry
+       ${SOURCES}
+)
+
+add_dependencies(evolution-source-registry
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(evolution-source-registry PRIVATE
+       -DG_LOG_DOMAIN=\"evolution-source-registry\"
+       -DLOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+)
+
+target_compile_options(evolution-source-registry PUBLIC
+       ${BACKEND_CFLAGS}
+       ${DATA_SERVER_CFLAGS}
+       ${GTK_CFLAGS}
+)
+
+target_include_directories(evolution-source-registry PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${BACKEND_INCLUDE_DIRS}
+       ${DATA_SERVER_INCLUDE_DIRS}
+       ${GTK_INCLUDE_DIRS}
+)
+
+target_link_libraries(evolution-source-registry
+       ${DEPENDENCIES}
+       ${BACKEND_LDFLAGS}
+       ${DATA_SERVER_LDFLAGS}
+       ${GTK_LDFLAGS}
+)
+
+install(TARGETS evolution-source-registry
+       DESTINATION ${LIBEXEC_INSTALL_DIR}
+)
+
+set(SOURCES
+       evolution-scan-gconf-tree-xml.c
+       evolution-source-registry-migrate-sources.c
+)
+
+add_executable(evolution-scan-gconf-tree-xml
+       ${SOURCES}
+)
+
+add_dependencies(evolution-scan-gconf-tree-xml
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(evolution-scan-gconf-tree-xml PRIVATE
+       -DG_LOG_DOMAIN=\"evolution-scan-gconf-tree-xml\"
+       -DLOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+)
+
+target_compile_options(evolution-scan-gconf-tree-xml PUBLIC
+       ${BACKEND_CFLAGS}
+       ${DATA_SERVER_CFLAGS}
+       ${GTK_CFLAGS}
+)
+
+target_include_directories(evolution-scan-gconf-tree-xml PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${BACKEND_INCLUDE_DIRS}
+       ${DATA_SERVER_INCLUDE_DIRS}
+       ${GTK_INCLUDE_DIRS}
+)
+
+target_link_libraries(evolution-scan-gconf-tree-xml
+       ${DEPENDENCIES}
+       ${BACKEND_LDFLAGS}
+       ${DATA_SERVER_LDFLAGS}
+       ${GTK_LDFLAGS}
+)
+
+install(TARGETS evolution-scan-gconf-tree-xml
+       DESTINATION ${LIBEXEC_INSTALL_DIR}
+)
diff --git a/services/evolution-source-registry/evolution-scan-gconf-tree-xml.c 
b/services/evolution-source-registry/evolution-scan-gconf-tree-xml.c
index d4f2316..f0456aa 100644
--- a/services/evolution-source-registry/evolution-scan-gconf-tree-xml.c
+++ b/services/evolution-source-registry/evolution-scan-gconf-tree-xml.c
@@ -15,7 +15,8 @@
  *
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <locale.h>
 #include <stdlib.h>
 #include <glib/gi18n.h>
diff --git a/services/evolution-source-registry/evolution-source-registry-migrate-proxies.c 
b/services/evolution-source-registry/evolution-source-registry-migrate-proxies.c
index 88a4bd6..1a1caa1 100644
--- a/services/evolution-source-registry/evolution-source-registry-migrate-proxies.c
+++ b/services/evolution-source-registry/evolution-source-registry-migrate-proxies.c
@@ -15,7 +15,8 @@
  *
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <glib/gi18n-lib.h>
 
 #include <libebackend/libebackend.h>
diff --git a/services/evolution-source-registry/evolution-source-registry.c 
b/services/evolution-source-registry/evolution-source-registry.c
index ef05287..9805fbd 100644
--- a/services/evolution-source-registry/evolution-source-registry.c
+++ b/services/evolution-source-registry/evolution-source-registry.c
@@ -15,7 +15,8 @@
  *
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <locale.h>
 #include <stdlib.h>
 #include <glib/gi18n.h>
diff --git a/services/evolution-source-registry/evolution-source-registry.service.in 
b/services/evolution-source-registry/evolution-source-registry.service.in
index 0e6993c..2e2b4bb 100644
--- a/services/evolution-source-registry/evolution-source-registry.service.in
+++ b/services/evolution-source-registry/evolution-source-registry.service.in
@@ -4,4 +4,4 @@ Description=Evolution source registry
 [Service]
 Type=dbus
 BusName=@SOURCES_DBUS_SERVICE_NAME@
-ExecStart=@libexecdir@/evolution-source-registry
+ExecStart=@LIBEXEC_INSTALL_DIR@/evolution-source-registry
diff --git a/services/evolution-source-registry/org.gnome.evolution.dataserver.Sources.service.in 
b/services/evolution-source-registry/org.gnome.evolution.dataserver.Sources.service.in
index 76f93f0..c4f8821 100644
--- a/services/evolution-source-registry/org.gnome.evolution.dataserver.Sources.service.in
+++ b/services/evolution-source-registry/org.gnome.evolution.dataserver.Sources.service.in
@@ -1,4 +1,4 @@
 [D-BUS Service]
 Name=@SOURCES_DBUS_SERVICE_NAME@
-Exec=@libexecdir@/evolution-source-registry
-SystemdService=evolution-source-registry.service
+Exec=@LIBEXEC_INSTALL_DIR@/evolution-source-registry
+@SYSTEMD_SERVICE@
diff --git a/services/evolution-user-prompter/CMakeLists.txt b/services/evolution-user-prompter/CMakeLists.txt
new file mode 100644
index 0000000..aa9cb8a
--- /dev/null
+++ b/services/evolution-user-prompter/CMakeLists.txt
@@ -0,0 +1,77 @@
+set(SYSTEMD_SERVICE)
+if(WITH_SYSTEMD_USER_UNITS)
+       set(SYSTEMD_SERVICE "SystemdService=evolution-user-prompter.service")
+
+       configure_file(evolution-user-prompter.service.in
+               evolution-user-prompter.service
+               @ONLY
+       )
+
+       install(FILES ${CMAKE_CURRENT_BINARY_DIR}/evolution-user-prompter.service
+               DESTINATION ${WITH_SYSTEMDUSERUNITDIR}
+       )
+endif(WITH_SYSTEMD_USER_UNITS)
+
+configure_file(org.gnome.evolution.dataserver.UserPrompter.service.in
+       org.gnome.evolution.dataserver.UserPrompter.service
+       @ONLY
+)
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.gnome.evolution.dataserver.UserPrompter.service
+       DESTINATION ${WITH_DBUS_SERVICE_DIR}
+)
+
+set(DEPENDENCIES
+       ebackend
+       ebook
+       ebook-contacts
+       edata-book
+       edataserver
+)
+
+set(SOURCES
+       prompt-user.h
+       prompt-user-gtk.c
+       evolution-user-prompter.c
+)
+
+add_executable(evolution-user-prompter
+       ${SOURCES}
+)
+
+add_dependencies(evolution-user-prompter
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(evolution-user-prompter PRIVATE
+       -DG_LOG_DOMAIN=\"evolution-user-prompter\"
+       -DLOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+)
+
+target_compile_options(evolution-user-prompter PUBLIC
+       ${BACKEND_CFLAGS}
+       ${DATA_SERVER_CFLAGS}
+       ${GNOME_PLATFORM_CFLAGS}
+       ${GTK_CFLAGS}
+)
+
+target_include_directories(evolution-user-prompter PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${BACKEND_INCLUDE_DIRS}
+       ${DATA_SERVER_INCLUDE_DIRS}
+       ${GNOME_PLATFORM_INCLUDE_DIRS}
+       ${GTK_INCLUDE_DIRS}
+)
+
+target_link_libraries(evolution-user-prompter
+       ${DEPENDENCIES}
+       ${BACKEND_LDFLAGS}
+       ${DATA_SERVER_LDFLAGS}
+       ${GNOME_PLATFORM_LDFLAGS}
+       ${GTK_LDFLAGS}
+)
+
+install(TARGETS evolution-user-prompter
+       DESTINATION ${LIBEXEC_INSTALL_DIR}
+)
diff --git a/services/evolution-user-prompter/evolution-user-prompter.c 
b/services/evolution-user-prompter/evolution-user-prompter.c
index 21d1ad2..3f37163 100644
--- a/services/evolution-user-prompter/evolution-user-prompter.c
+++ b/services/evolution-user-prompter/evolution-user-prompter.c
@@ -15,7 +15,8 @@
  *
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <locale.h>
 #include <libintl.h>
 #include <glib/gi18n.h>
diff --git a/services/evolution-user-prompter/evolution-user-prompter.service.in 
b/services/evolution-user-prompter/evolution-user-prompter.service.in
index 7bd021c..07bb909 100644
--- a/services/evolution-user-prompter/evolution-user-prompter.service.in
+++ b/services/evolution-user-prompter/evolution-user-prompter.service.in
@@ -4,4 +4,4 @@ Description=Evolution user prompter
 [Service]
 Type=dbus
 BusName=@USER_PROMPTER_DBUS_SERVICE_NAME@
-ExecStart=@libexecdir@/evolution-user-prompter
+ExecStart=@LIBEXEC_INSTALL_DIR@/evolution-user-prompter
diff --git a/services/evolution-user-prompter/org.gnome.evolution.dataserver.UserPrompter.service.in 
b/services/evolution-user-prompter/org.gnome.evolution.dataserver.UserPrompter.service.in
index c66d861..7364156 100644
--- a/services/evolution-user-prompter/org.gnome.evolution.dataserver.UserPrompter.service.in
+++ b/services/evolution-user-prompter/org.gnome.evolution.dataserver.UserPrompter.service.in
@@ -1,4 +1,4 @@
 [D-BUS Service]
 Name=@USER_PROMPTER_DBUS_SERVICE_NAME@
-Exec=@libexecdir@/evolution-user-prompter
-SystemdService=evolution-user-prompter.service
+Exec=@LIBEXEC_INSTALL_DIR@/evolution-user-prompter
+@SYSTEMD_SERVICE@
diff --git a/services/evolution-user-prompter/prompt-user-gtk.c 
b/services/evolution-user-prompter/prompt-user-gtk.c
index 851a35d..9a7fcaa 100644
--- a/services/evolution-user-prompter/prompt-user-gtk.c
+++ b/services/evolution-user-prompter/prompt-user-gtk.c
@@ -15,9 +15,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include "evolution-data-server-config.h"
 
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644
index 0000000..045b706
--- /dev/null
+++ b/tests/CMakeLists.txt
@@ -0,0 +1,61 @@
+macro(build_only_installable_test _test_ident _sourcesvar _depsvar _defsvar _cflagsvar _incdirsvar 
_ldflagsvar)
+       set(DEPENDENCIES
+               edataserver
+               etestserverutils
+       )
+
+       # Not using EXCLUDE_FROM_ALL here, to have these built always
+       add_executable(${_test_ident} ${${_sourcesvar}})
+
+       add_dependencies(${_test_ident}
+               ${DEPENDENCIES}
+               ${${_depsvar}}
+       )
+
+       target_compile_definitions(${_test_ident} PRIVATE
+               -DG_LOG_DOMAIN=\"${_test_ident}\"
+               -DSRCDIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"
+               -DINSTALLED_TEST_DIR=\"${INSTALLED_TESTS_EXEC_DIR}\"
+               ${${_defsvar}}
+       )
+
+       target_compile_options(${_test_ident} PUBLIC
+               ${BACKEND_CFLAGS}
+               ${DATA_SERVER_CFLAGS}
+               ${${_cflagsvar}}
+       )
+
+       target_include_directories(${_test_ident} PUBLIC
+               ${CMAKE_BINARY_DIR}
+               ${CMAKE_BINARY_DIR}/tests/test-server-utils
+               ${CMAKE_SOURCE_DIR}
+               ${CMAKE_SOURCE_DIR}/tests/test-server-utils
+               ${BACKEND_INCLUDE_DIRS}
+               ${DATA_SERVER_INCLUDE_DIRS}
+               ${${_incdirsvar}}
+       )
+
+       target_link_libraries(${_test_ident}
+               ${DEPENDENCIES}
+               ${${_depsvar}}
+               ${BACKEND_LDFLAGS}
+               ${DATA_SERVER_LDFLAGS}
+               ${${_ldflagsvar}}
+       )
+endmacro(build_only_installable_test)
+
+macro(add_installable_test _test_ident _sourcesvar _depsvar _defsvar _cflagsvar _incdirsvar _ldflagsvar 
_ittype _itenviron)
+       build_only_installable_test(${_test_ident} ${_sourcesvar} ${_depsvar} ${_defsvar} ${_cflagsvar} 
${_incdirsvar} ${_ldflagsvar})
+
+       add_check_test(${_test_ident})
+       install_test_if_enabled(${_test_ident} ${_ittype} ${_itenviron})
+endmacro(add_installable_test)
+
+add_subdirectory(book-migration)
+add_subdirectory(libebook)
+add_subdirectory(libebook-contacts)
+add_subdirectory(libecal)
+add_subdirectory(libedata-book)
+add_subdirectory(libedata-cal)
+add_subdirectory(libedataserver)
+add_subdirectory(test-server-utils)
diff --git a/tests/book-migration/CMakeLists.txt b/tests/book-migration/CMakeLists.txt
new file mode 100644
index 0000000..93a6571
--- /dev/null
+++ b/tests/book-migration/CMakeLists.txt
@@ -0,0 +1,96 @@
+set(extra_deps
+       ebook
+       ebook-contacts
+       edbus-private
+       client-test-utils
+)
+
+
+set(extra_defines
+       -DEDS_TEST_WORK_DIR=\"${CMAKE_BINARY_DIR}/tests/test-server-utils/cache\"
+       -DEDS_TEST_SQLITE_BOOKS=\"${CMAKE_SOURCE_DIR}/tests/book-migration/db\"
+       -DEDS_TEST_BUILT_BOOKS=\"${CMAKE_BINARY_DIR}/tests/book-migration/db\"
+)
+
+# If db_load is detected at configure time, then we've built
+# an addressbook.db to test the migration from 3.6 -> Current.
+#
+# Instead of committing a BDB file directly which might have
+# compatibility issues, we use a text dump (for SQLite we
+# rely on compatilbility).
+if(HAVE_DB_LOAD)
+       list(APPEND extra_defines
+               -DTEST_VERSIONS_WITH_BDB
+       )
+endif(HAVE_DB_LOAD)
+
+set(extra_cflags
+       ${ADDRESSBOOK_CFLAGS}
+)
+
+set(extra_incdirs
+       ${ADDRESSBOOK_INCLUDE_DIRS}
+       ${CMAKE_BINARY_DIR}/tests/libebook/client
+       ${CMAKE_SOURCE_DIR}/tests/libebook/client
+)
+
+set(extra_ldflags
+       ${ADDRESSBOOK_LDFLAGS}
+)
+
+# Should be kept ordered approximately from least to most difficult/complex
+set(TESTS
+       test-migration
+)
+
+foreach(_test ${TESTS})
+       set(SOURCES ${_test}.c)
+
+       build_only_installable_test(${_test}
+               SOURCES
+               extra_deps
+               extra_defines
+               extra_cflags
+               extra_incdirs
+               extra_ldflags
+       )
+       add_check_test(${_test})
+endforeach(_test)
+
+# This is a little cheat, it's not a real test, but can be built with the macro
+set(SOURCES setup-migration-test.c)
+
+build_only_installable_test(setup-migration-test
+       SOURCES
+       extra_deps
+       extra_defines
+       extra_cflags
+       extra_incdirs
+       extra_ldflags
+)
+
+# This rule should be run once every stable release and then the
+# newly created 'contacts.db' file added to git.
+#
+# For instance, when the EDS version is 3.12, the file:
+#   $(top_srcdir)/tests/book-migration/db/3.12/contacts.db
+# will be created as a result of running 'make setup-migration'.
+#
+# Note that the 'setup-migration-test' program can be compiled
+# with EDS versions back to 3.0. If you really need to rebuild
+# the older test sandboxes, then setup-migration-test can be
+# manually compiled and used with older builds of EDS.
+set(_use_db_version "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
+add_custom_target(setup-migration
+       COMMAND ${CMAKE_COMMAND} -E echo "Setting up new migration sandbox in 
${CMAKE_SOURCE_DIR}/tests/book-migration/db/${_use_db_version}..."
+       COMMAND ${CMAKE_BINARY_DIR}/tests/book-migration/setup-migration-test
+               --use-test-sandbox --book-id ${_use_db_version}
+               --contacts-directory ${CMAKE_SOURCE_DIR}/tests/book-migration/vcards
+       COMMAND ${CMAKE_COMMAND} -E make_directory 
${CMAKE_SOURCE_DIR}/tests/book-migration/db/${_use_db_version}
+       COMMAND ${CMAKE_COMMAND} -E copy 
${CMAKE_BINARY_DIR}/tests/test-server-utils/cache/evolution/addressbook/${_use_db_version}/contacts.db
+               ${CMAKE_SOURCE_DIR}/tests/book-migration/db/${_use_db_version}/
+       COMMAND ${CMAKE_COMMAND} -E echo "Done."
+       DEPENDS setup-migration-test
+)
+
+add_subdirectory(db)
diff --git a/tests/book-migration/db/CMakeLists.txt b/tests/book-migration/db/CMakeLists.txt
new file mode 100644
index 0000000..38a9d8d
--- /dev/null
+++ b/tests/book-migration/db/CMakeLists.txt
@@ -0,0 +1,27 @@
+if(HAVE_DB_LOAD)
+
+       set(GENERATED_DBS_VERSIONS
+               3.0
+               3.2
+               3.4
+               3.6
+       )
+
+       set(GENERATED_DBS)
+
+       foreach(_ver ${GENERATED_DBS_VERSIONS})
+               add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_ver}/addressbook.db
+                       COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${_ver}
+                       COMMAND ${DB_LOAD} -f ${CMAKE_CURRENT_SOURCE_DIR}/${_ver}/addressbook.dump 
${CMAKE_CURRENT_BINARY_DIR}/${_ver}/addressbook.db
+                       DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_ver}/addressbook.dump
+               )
+               list(APPEND GENERATED_DBS ${CMAKE_CURRENT_BINARY_DIR}/${_ver}/addressbook.db)
+       endforeach(_ver)
+
+       add_custom_target(libdb-addressbooks
+               DEPENDS ${GENERATED_DBS}
+       )
+
+       add_dependencies(check libdb-addressbooks)
+
+endif(HAVE_DB_LOAD)
diff --git a/tests/book-migration/test-migration.c b/tests/book-migration/test-migration.c
index 81bcd37..81eb7ee 100644
--- a/tests/book-migration/test-migration.c
+++ b/tests/book-migration/test-migration.c
@@ -17,7 +17,7 @@
  * Authors: Tristan Van Berkom <tristanvb openismus com>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include <stdlib.h>
 #include <libebook/libebook.h>
diff --git a/tests/libebook-contacts/CMakeLists.txt b/tests/libebook-contacts/CMakeLists.txt
new file mode 100644
index 0000000..bd68cda
--- /dev/null
+++ b/tests/libebook-contacts/CMakeLists.txt
@@ -0,0 +1,41 @@
+set(extra_deps
+       ebook-contacts
+)
+
+set(extra_defines)
+
+set(extra_cflags
+       ${ADDRESSBOOK_CFLAGS}
+)
+
+set(extra_incdirs
+       ${ADDRESSBOOK_INCLUDE_DIRS}
+)
+
+set(extra_ldflags
+       ${ADDRESSBOOK_LDFLAGS}
+)
+
+# Should be kept ordered approximately from least to most difficult/complex
+set(TESTS
+       test-contact-types
+       test-vcard-parsing
+       test-untyped-phones
+       test-query
+       test-phone-number
+)
+
+foreach(_test ${TESTS})
+       set(SOURCES ${_test}.c)
+
+       add_installable_test(${_test}
+               SOURCES
+               extra_deps
+               extra_defines
+               extra_cflags
+               extra_incdirs
+               extra_ldflags
+               "session-exclusive"
+               "TEST_INSTALLED_SERVICES=1"
+       )
+endforeach(_test)
diff --git a/tests/libebook-contacts/test-phone-number.c b/tests/libebook-contacts/test-phone-number.c
index fb4dcbc..2f0fbc7 100644
--- a/tests/libebook-contacts/test-phone-number.c
+++ b/tests/libebook-contacts/test-phone-number.c
@@ -17,9 +17,7 @@
  * Authors: Mathias Hasselmann <mathias openismus com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <libebook-contacts/libebook-contacts.h>
 #include <locale.h>
diff --git a/tests/libebook/CMakeLists.txt b/tests/libebook/CMakeLists.txt
new file mode 100644
index 0000000..5dafa9d
--- /dev/null
+++ b/tests/libebook/CMakeLists.txt
@@ -0,0 +1,114 @@
+set(extra_deps
+       ebook
+       ebook-contacts
+)
+
+set(extra_defines
+       -DSRCDIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"
+       -DINSTALLED_TEST_DIR=\"${INSTALLED_TESTS_EXEC_DIR}\"
+)
+
+set(extra_cflags
+       ${ADDRESSBOOK_CFLAGS}
+       ${GIO_UNIX_CFLAGS}
+)
+
+set(extra_incdirs
+       ${ADDRESSBOOK_INCLUDE_DIRS}
+       ${GIO_UNIX_INCLUDE_DIRS}
+)
+
+set(extra_ldflags
+       ${ADDRESSBOOK_LDFLAGS}
+       ${GIO_UNIX_LDFLAGS}
+)
+
+set(SOURCES
+       ebook-test-utils.c
+       ebook-test-utils.h
+)
+
+add_library(ebook-test-utils STATIC
+       ${SOURCES}
+)
+
+add_dependencies(ebook-test-utils
+       edataserver
+       ${extra_deps}
+)
+
+target_compile_definitions(ebook-test-utils PRIVATE
+       -DG_LOG_DOMAIN=\"ebook-test-utils\"
+       ${extra_defines}
+)
+
+target_compile_options(ebook-test-utils PUBLIC
+       ${BACKEND_CFLAGS}
+       ${DATA_SERVER_CFLAGS}
+       ${extra_cflags}
+)
+
+target_include_directories(ebook-test-utils PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${BACKEND_INCLUDE_DIRS}
+       ${DATA_SERVER_INCLUDE_DIRS}
+       ${extra_incdirs}
+)
+
+target_link_libraries(ebook-test-utils
+       edataserver
+       ${extra_deps}
+       ${BACKEND_LDFLAGS}
+       ${DATA_SERVER_LDFLAGS}
+       ${extra_ldflags}
+)
+
+set(extra_deps
+       ebook
+       ebook-contacts
+       ebook-test-utils
+)
+
+set(extra_defines)
+
+# Should be kept ordered approximately from least to most difficult/complex
+set(TESTS
+       test-ebook-add-contact
+       test-ebook-get-contact
+       test-ebook-commit-contact
+       test-ebook-remove-contact
+       test-ebook-get-required-fields
+       test-ebook-get-static-capabilities
+       test-ebook-get-supported-fields
+       test-ebook-get-supported-auth-methods
+       test-ebook-remove-contact-by-id
+       test-ebook-remove-contacts
+       test-ebook-get-book-view
+)
+
+foreach(_test ${TESTS})
+       set(SOURCES ${_test}.c)
+
+       add_installable_test(${_test}
+               SOURCES
+               extra_deps
+               extra_defines
+               extra_cflags
+               extra_incdirs
+               extra_ldflags
+               "session-exclusive"
+               "TEST_INSTALLED_SERVICES=1"
+       )
+endforeach(_test)
+
+if(ENABLE_INSTALLED_TESTS)
+       file(GLOB ${CMAKE_CURRENT_SOURCE_DIR}/data/vcards/*.vcf VCARDS)
+
+       install(FILES ${VCARDS}
+               DESTINATION ${INSTALLED_TESTS_EXEC_DIR}/vcards
+       )
+endif(ENABLE_INSTALLED_TESTS)
+
+add_subdirectory(client)
+add_subdirectory(vcard)
diff --git a/tests/libebook/client/CMakeLists.txt b/tests/libebook/client/CMakeLists.txt
new file mode 100644
index 0000000..1ef69b1
--- /dev/null
+++ b/tests/libebook/client/CMakeLists.txt
@@ -0,0 +1,143 @@
+set(extra_deps
+       ebook
+       ebook-contacts
+       edbus-private
+       etestserverutils
+)
+
+set(extra_defines
+       -DSRCDIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"
+       -DINSTALLED_TEST_DIR=\"${INSTALLED_TESTS_EXEC_DIR}\"
+)
+
+set(extra_cflags
+       ${ADDRESSBOOK_CFLAGS}
+       ${GIO_UNIX_CFLAGS}
+)
+
+set(extra_incdirs
+       ${ADDRESSBOOK_INCLUDE_DIRS}
+       ${GIO_UNIX_INCLUDE_DIRS}
+)
+
+set(extra_ldflags
+       ${ADDRESSBOOK_LDFLAGS}
+       ${GIO_UNIX_LDFLAGS}
+)
+
+set(SOURCES
+       client-test-utils.c
+       client-test-utils.h
+)
+
+add_library(client-test-utils STATIC
+       ${SOURCES}
+)
+
+add_dependencies(client-test-utils
+       edataserver
+       ${extra_deps}
+)
+
+target_compile_definitions(client-test-utils PRIVATE
+       -DG_LOG_DOMAIN=\"client-test-utils\"
+       ${extra_defines}
+)
+
+target_compile_options(client-test-utils PUBLIC
+       ${BACKEND_CFLAGS}
+       ${DATA_SERVER_CFLAGS}
+       ${extra_cflags}
+)
+
+target_include_directories(client-test-utils PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/addressbook
+       ${CMAKE_BINARY_DIR}/tests/test-server-utils
+       ${CMAKE_BINARY_DIR}/private
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/addressbook
+       ${CMAKE_SOURCE_DIR}/tests/test-server-utils
+       ${CMAKE_SOURCE_DIR}/private
+       ${BACKEND_INCLUDE_DIRS}
+       ${DATA_SERVER_INCLUDE_DIRS}
+       ${extra_incdirs}
+)
+
+target_link_libraries(client-test-utils
+       edataserver
+       ${extra_deps}
+       ${BACKEND_LDFLAGS}
+       ${DATA_SERVER_LDFLAGS}
+       ${extra_ldflags}
+)
+
+set(extra_deps
+       client-test-utils
+       ebook
+       ebook-contacts
+       edbus-private
+       etestserverutils
+)
+
+set(extra_defines)
+
+# Should be kept ordered approximately from least to most difficult/complex
+set(TESTS
+       test-book-client-refresh
+       test-book-client-add-contact
+       test-book-client-get-contact
+       test-book-client-get-contact-uids
+       test-book-client-modify-contact
+       test-book-client-remove-contact
+       test-book-client-remove-contact-by-uid
+       test-book-client-remove-contacts
+       test-book-client-add-and-get-sync
+       test-book-client-add-and-get-async
+       test-book-client-self
+       test-book-client-preserve-uid
+       test-book-client-photo-is-uri
+       test-book-client-e164-param
+        test-book-client-custom-summary
+       test-book-client-get-revision
+       test-book-client-write-write
+       test-book-client-get-view
+       test-book-client-uid-only-view
+       test-book-client-revision-view
+       test-book-client-view-operations
+       test-book-client-suppress-notifications
+       test-book-client-cursor-create
+)
+
+# Skip these from 'make check' and installed tests, they take too long or require special setup
+set(TESTS_SKIP
+       test-book-client-cursor-operations
+)
+
+foreach(_test ${TESTS})
+       set(SOURCES ${_test}.c)
+
+       add_installable_test(${_test}
+               SOURCES
+               extra_deps
+               extra_defines
+               extra_cflags
+               extra_incdirs
+               extra_ldflags
+               "session-exclusive"
+               "TEST_INSTALLED_SERVICES=1"
+       )
+endforeach(_test)
+
+foreach(_test ${TESTS_SKIP})
+       set(SOURCES ${_test}.c)
+
+       build_only_installable_test(${_test}
+               SOURCES
+               extra_deps
+               extra_defines
+               extra_cflags
+               extra_incdirs
+               extra_ldflags
+       )
+endforeach(_test)
diff --git a/tests/libebook/client/test-book-client-cursor-operations.c 
b/tests/libebook/client/test-book-client-cursor-operations.c
index 72daa80..b57add1 100644
--- a/tests/libebook/client/test-book-client-cursor-operations.c
+++ b/tests/libebook/client/test-book-client-cursor-operations.c
@@ -17,7 +17,7 @@
  * Authors: Tristan Van Berkom <tristanvb openismus com>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include <libebook/libebook.h>
 
diff --git a/tests/libebook/client/test-book-client-custom-summary.c 
b/tests/libebook/client/test-book-client-custom-summary.c
index 4168a81..80f0cfc 100644
--- a/tests/libebook/client/test-book-client-custom-summary.c
+++ b/tests/libebook/client/test-book-client-custom-summary.c
@@ -18,7 +18,7 @@
  *          Mathias Hasselmann <mathias openismus com>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
 
 #include <stdlib.h>
 #include <libebook/libebook.h>
diff --git a/tests/libebook/client/test-book-client-e164-param.c 
b/tests/libebook/client/test-book-client-e164-param.c
index 660bdcf..3d2ea54 100644
--- a/tests/libebook/client/test-book-client-e164-param.c
+++ b/tests/libebook/client/test-book-client-e164-param.c
@@ -17,7 +17,8 @@
  * Authors: Tristan Van Berkom <tristanvb openismus com>
  */
 
-#include <config.h>
+#include "evolution-data-server-config.h"
+
 #include <stdlib.h>
 #include <libebook/libebook.h>
 
diff --git a/tests/libebook/vcard/CMakeLists.txt b/tests/libebook/vcard/CMakeLists.txt
new file mode 100644
index 0000000..c999130
--- /dev/null
+++ b/tests/libebook/vcard/CMakeLists.txt
@@ -0,0 +1,39 @@
+add_executable(dump-vcard
+       dump-vcard.c
+)
+
+set(DEPENDENCIES
+       ebook
+       edataserver
+)
+
+add_dependencies(dump-vcard
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(dump-vcard PRIVATE
+       -DG_LOG_DOMAIN=\"dump-vcard\"
+)
+
+target_compile_options(dump-vcard PUBLIC
+       ${BACKEND_CFLAGS}
+       ${DATA_SERVER_CFLAGS}
+       ${ADDRESSBOOK_CFLAGS}
+)
+
+target_include_directories(dump-vcard PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/addressbook
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/addressbook
+       ${BACKEND_INCLUDE_DIRS}
+       ${DATA_SERVER_INCLUDE_DIRS}
+       ${ADDRESSBOOK_INCLUDE_DIRS}
+)
+
+target_link_libraries(dump-vcard
+       ${DEPENDENCIES}
+       ${BACKEND_LDFLAGS}
+       ${DATA_SERVER_LDFLAGS}
+       ${ADDRESSBOOK_LDFLAGS}
+)
diff --git a/tests/libecal/CMakeLists.txt b/tests/libecal/CMakeLists.txt
new file mode 100644
index 0000000..b70c9ae
--- /dev/null
+++ b/tests/libecal/CMakeLists.txt
@@ -0,0 +1,125 @@
+set(extra_deps
+       ecal
+       etestserverutils
+)
+
+set(extra_defines
+       -DLOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+)
+
+set(extra_cflags
+       ${CALENDAR_CFLAGS}
+)
+
+set(extra_incdirs
+       ${CMAKE_BINARY_DIR}/calendar
+       ${CMAKE_SOURCE_DIR}/calendar
+       ${CALENDAR_INCLUDE_DIRS}
+)
+
+set(extra_ldflags
+       ${CALENDAR_LDFLAGS}
+)
+
+set(SOURCES
+       ecal-test-utils.c
+       ecal-test-utils.h
+)
+
+add_library(ecal-test-utils STATIC
+       ${SOURCES}
+)
+
+add_dependencies(ecal-test-utils
+       edataserver
+       ${extra_deps}
+)
+
+target_compile_definitions(ecal-test-utils PRIVATE
+       -DG_LOG_DOMAIN=\"ecal-test-utils\"
+       ${extra_defines}
+)
+
+target_compile_options(ecal-test-utils PUBLIC
+       ${BACKEND_CFLAGS}
+       ${DATA_SERVER_CFLAGS}
+       ${extra_cflags}
+)
+
+target_include_directories(ecal-test-utils PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${BACKEND_INCLUDE_DIRS}
+       ${DATA_SERVER_INCLUDE_DIRS}
+       ${extra_incdirs}
+)
+
+target_link_libraries(ecal-test-utils
+       edataserver
+       ${extra_deps}
+       ${BACKEND_LDFLAGS}
+       ${DATA_SERVER_LDFLAGS}
+       ${extra_ldflags}
+)
+
+set(extra_deps
+       ecal
+       ecal-test-utils
+)
+
+# Should be kept ordered approximately from least to most difficult/complex
+set(TESTS
+       test-ecal-get-timezone
+       test-ecal-add-timezone
+       test-ecal-set-default-timezone
+       test-ecal-get-alarm-email-address
+       test-ecal-get-cal-address
+       test-ecal-get-ldap-attribute
+       test-ecal-get-capabilities
+       test-ecal-get-default-object
+       test-ecal-create-object
+       test-ecal-create-object--2
+       test-ecal-get-objects-for-uid
+       test-ecal-remove-object
+       test-ecal-get-object-list
+       test-ecal-modify-object
+       test-ecal-send-objects
+       test-ecal-receive-objects
+       test-ecal-get-query
+)
+
+foreach(_test ${TESTS})
+       set(SOURCES ${_test}.c)
+
+       add_installable_test(${_test}
+               SOURCES
+               extra_deps
+               extra_defines
+               extra_cflags
+               extra_incdirs
+               extra_ldflags
+               "session-exclusive"
+               "TEST_INSTALLED_SERVICES=1"
+       )
+endforeach(_test)
+
+# test-ecal-get-free-busy:
+#   broken by design, the API needs to be fixed.
+set(TESTS_SKIP
+       test-ecal-get-free-busy
+)
+
+foreach(_test ${TESTS_SKIP})
+       set(SOURCES ${_test}.c)
+
+       build_only_installable_test(${_test}
+               SOURCES
+               extra_deps
+               extra_defines
+               extra_cflags
+               extra_incdirs
+               extra_ldflags
+       )
+endforeach(_test)
+
+add_subdirectory(client)
diff --git a/tests/libecal/client/CMakeLists.txt b/tests/libecal/client/CMakeLists.txt
new file mode 100644
index 0000000..b580028
--- /dev/null
+++ b/tests/libecal/client/CMakeLists.txt
@@ -0,0 +1,50 @@
+set(extra_deps
+       ecal
+)
+
+set(extra_defines)
+
+set(extra_cflags
+       ${CALENDAR_CFLAGS}
+)
+
+set(extra_incdirs
+       ${CALENDAR_INCLUDE_DIRS}
+)
+
+set(extra_ldflags
+       ${CALENDAR_LDFLAGS}
+)
+
+# Should be kept ordered approximately from least to most difficult/complex
+set(TESTS
+       test-cal-client-refresh
+       test-cal-client-add-timezone
+       test-cal-client-create-object
+       test-cal-client-remove-object
+       test-cal-client-get-object-list
+       test-cal-client-modify-object
+       test-cal-client-send-objects
+       test-cal-client-receive-objects
+        test-cal-client-bulk-methods
+       test-cal-client-get-attachment-uris
+       test-cal-client-get-view
+       test-cal-client-revision-view
+       test-cal-client-get-revision
+       test-cal-client-get-free-busy
+)
+
+foreach(_test ${TESTS})
+       set(SOURCES ${_test}.c)
+
+       add_installable_test(${_test}
+               SOURCES
+               extra_deps
+               extra_defines
+               extra_cflags
+               extra_incdirs
+               extra_ldflags
+               "session-exclusive"
+               "TEST_INSTALLED_SERVICES=1"
+       )
+endforeach(_test)
diff --git a/tests/libedata-book/CMakeLists.txt b/tests/libedata-book/CMakeLists.txt
new file mode 100644
index 0000000..4227858
--- /dev/null
+++ b/tests/libedata-book/CMakeLists.txt
@@ -0,0 +1,129 @@
+set(extra_deps
+       camel
+       ebook
+       ebook-contacts
+       edata-book
+       edbus-private
+       etestserverutils
+)
+
+set(extra_defines
+       -DSRCDIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"
+       -DINSTALLED_TEST_DIR=\"${INSTALLED_TESTS_EXEC_DIR}\"
+       -DBACKENDDIR=\"${ebook_backenddir}\"
+       -DDATADIR=\"${SHARE_INSTALL_DIR}\"
+       -DBUILDDIR=\"${CAMKE_BINARY_DIR}\"
+       -DCAMEL_PROVIDERDIR=\"${camel_providerdir}\"
+)
+
+set(extra_cflags
+       ${ADDRESSBOOK_CFLAGS}
+       ${CAMEL_CFLAGS}
+       ${GIO_UNIX_CFLAGS}
+)
+
+set(extra_incdirs
+       ${ADDRESSBOOK_INCLUDE_DIRS}
+       ${CAMEL_INCLUDE_DIRS}
+       ${GIO_UNIX_INCLUDE_DIRS}
+)
+
+set(extra_ldflags
+       ${ADDRESSBOOK_LDFLAGS}
+       ${CAMEL_LDFLAGS}
+       ${GIO_UNIX_LDFLAGS}
+)
+
+set(SOURCES
+       data-test-utils.c
+       data-test-utils.h
+)
+
+add_library(data-test-utils STATIC
+       ${SOURCES}
+)
+
+add_dependencies(data-test-utils
+       edataserver
+       ${extra_deps}
+)
+
+target_compile_definitions(data-test-utils PRIVATE
+       -DG_LOG_DOMAIN=\"data-test-utils\"
+       ${extra_defines}
+)
+
+target_compile_options(data-test-utils PUBLIC
+       ${BACKEND_CFLAGS}
+       ${DATA_SERVER_CFLAGS}
+       ${extra_cflags}
+)
+
+target_include_directories(data-test-utils PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${BACKEND_INCLUDE_DIRS}
+       ${DATA_SERVER_INCLUDE_DIRS}
+       ${extra_incdirs}
+)
+
+target_link_libraries(data-test-utils
+       edataserver
+       ${extra_deps}
+       ${BACKEND_LDFLAGS}
+       ${DATA_SERVER_LDFLAGS}
+       ${extra_ldflags}
+)
+
+set(extra_deps
+       ebook
+       ebook-contacts
+       data-test-utils
+)
+
+set(extra_defines)
+
+# Should be kept ordered approximately from least to most difficult/complex
+#
+# Note that these tests must be run in order:
+#   test-sqlite-cursor-posix-initial,
+#   test-sqlite-cursor-en-US-migrated,
+#   test-sqlite-cursor-posix-migrated
+#
+# This is because each migrated test changes the
+# locale and reloads the same addressbook of the previous test.
+set(TESTS
+       test-sqlite-get-contact
+       test-sqlite-create-cursor
+       test-sqlite-cursor-move-by-posix
+       test-sqlite-cursor-move-by-en-US
+       test-sqlite-cursor-move-by-fr-CA
+       test-sqlite-cursor-move-by-de-DE
+       test-sqlite-cursor-set-target
+       test-sqlite-cursor-calculate
+       test-sqlite-cursor-set-sexp
+       test-sqlite-cursor-change-locale
+)
+
+foreach(_test ${TESTS})
+       set(SOURCES ${_test}.c)
+
+       add_installable_test(${_test}
+               SOURCES
+               extra_deps
+               extra_defines
+               extra_cflags
+               extra_incdirs
+               extra_ldflags
+               "session-exclusive"
+               "TEST_INSTALLED_SERVICES=1"
+       )
+endforeach(_test)
+
+if(ENABLE_INSTALLED_TESTS)
+       file(GLOB ${CMAKE_CURRENT_SOURCE_DIR}/data/vcards/*.vcf VCARDS)
+
+       install(FILES ${VCARDS}
+               DESTINATION ${INSTALLED_TESTS_EXEC_DIR}/vcards
+       )
+endif(ENABLE_INSTALLED_TESTS)
diff --git a/tests/libedata-book/data-test-utils.c b/tests/libedata-book/data-test-utils.c
index 29bba5e..31af1a5 100644
--- a/tests/libedata-book/data-test-utils.c
+++ b/tests/libedata-book/data-test-utils.c
@@ -17,9 +17,7 @@
  * Authors: Tristan Van Berkom <tristanvb openismus com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
diff --git a/tests/libedata-cal/CMakeLists.txt b/tests/libedata-cal/CMakeLists.txt
new file mode 100644
index 0000000..d42a64b
--- /dev/null
+++ b/tests/libedata-cal/CMakeLists.txt
@@ -0,0 +1,40 @@
+set(extra_deps
+       ebackend
+       ecal
+       edata-cal
+)
+
+set(extra_defines)
+
+set(extra_cflags
+       ${CALENDAR_CFLAGS}
+)
+
+set(extra_incdirs
+       ${CALENDAR_INCLUDE_DIRS}
+)
+
+set(extra_ldflags
+       ${CALENDAR_LDFLAGS}
+)
+
+# Should be kept ordered approximately from least to most difficult/complex
+set(TESTS
+       test-cal-backend-sexp
+       test-intervaltree
+)
+
+foreach(_test ${TESTS})
+       set(SOURCES ${_test}.c)
+
+       add_installable_test(${_test}
+               SOURCES
+               extra_deps
+               extra_defines
+               extra_cflags
+               extra_incdirs
+               extra_ldflags
+               "session-exclusive"
+               "TEST_INSTALLED_SERVICES=1"
+       )
+endforeach(_test)
diff --git a/tests/libedataserver/CMakeLists.txt b/tests/libedataserver/CMakeLists.txt
new file mode 100644
index 0000000..1383306
--- /dev/null
+++ b/tests/libedataserver/CMakeLists.txt
@@ -0,0 +1,62 @@
+set(extra_deps
+       ecal
+)
+
+set(extra_defines)
+
+set(extra_cflags
+       ${CALENDAR_CFLAGS}
+)
+
+set(extra_incdirs
+       ${CALENDAR_INCLUDE_DIRS}
+)
+
+set(extra_ldflags
+       ${CALENDAR_LDFLAGS}
+)
+
+# Should be kept ordered approximately from least to most difficult/complex
+set(TESTS
+       e-source-registry-test
+)
+
+foreach(_test ${TESTS})
+       set(SOURCES ${_test}.c)
+
+       add_installable_test(${_test}
+               SOURCES
+               extra_deps
+               extra_defines
+               extra_cflags
+               extra_incdirs
+               extra_ldflags
+               "session-exclusive"
+               "TEST_INSTALLED_SERVICES=1"
+       )
+endforeach(_test)
+
+set(TESTS_SKIP
+       e-collator-test
+)
+
+if(HAVE_GTK)
+       list(APPEND TESTS_SKIP
+               e-user-prompter-test
+       )
+endif(HAVE_GTK)
+
+foreach(_test ${TESTS_SKIP})
+       set(SOURCES ${_test}.c)
+
+       build_only_installable_test(${_test}
+               SOURCES
+               extra_deps
+               extra_defines
+               extra_cflags
+               extra_incdirs
+               extra_ldflags
+               "session-exclusive"
+               "TEST_INSTALLED_SERVICES=1"
+       )
+endforeach(_test)
diff --git a/tests/test-server-utils/CMakeLists.txt b/tests/test-server-utils/CMakeLists.txt
new file mode 100644
index 0000000..70c8bd9
--- /dev/null
+++ b/tests/test-server-utils/CMakeLists.txt
@@ -0,0 +1,108 @@
+add_subdirectory(services)
+
+set(SOURCES
+       e-test-server-utils.c
+       e-test-server-utils.h
+)
+
+set(extra_deps
+       ebook
+       ecal
+)
+
+set(extra_defines
+       -DEDS_TEST_DBUS_SERVICE_DIR=\"${CMAKE_BINARY_DIR}/tests/test-server-utils/services\"
+       -DEDS_TEST_WORK_DIR=\"${CMAKE_BINARY_DIR}/tests/test-server-utils/cache\"
+       -DEDS_TEST_SCHEMA_DIR=\"${CMAKE_BINARY_DIR}/data\"
+       -DEDS_TEST_ADDRESS_BOOK_DIR=\"${CMAKE_BINARY_DIR}/addressbook/backends/file\"
+       -DEDS_TEST_CALENDAR_DIR=\"${CMAKE_BINARY_DIR}/calendar/backends/file\"
+       -DEDS_TEST_REGISTRY_DIR=\"${CMAKE_BINARY_DIR}/modules/cache-reaper\"
+       -DEDS_TEST_CAMEL_DIR=\"${CMAKE_BINARY_DIR}/camel/providers/local\"
+       
-DEDS_TEST_SUBPROCESS_CAL_PATH=\"${CMAKE_BINARY_DIR}/calendar/libedata-cal/evolution-calendar-factory-subprocess\"
+       
-DEDS_TEST_SUBPROCESS_BOOK_PATH=\"${CMAKE_BINARY_DIR}/addressbook/libedata-book/evolution-addressbook-factory-subprocess\"
+       -DEDS_TEST_TOP_BUILD_DIR=\"${CMAKE_BINARY_DIR}\"
+)
+
+set(extra_cflags
+       ${ADDRESSBOOK_CFLAGS}
+       ${CALENDAR_CFLAGS}
+       ${GIO_UNIX_CFLAGS}
+)
+
+set(extra_incdirs
+       ${ADDRESSBOOK_INCLUDE_DIRS}
+       ${CALENDAR_INCLUDE_DIRS}
+       ${GIO_UNIX_INCLUDE_DIRS}
+)
+
+set(extra_ldflags
+       ${ADDRESSBOOK_LDFLAGS}
+       ${CALENDAR_LDFLAGS}
+       ${GIO_UNIX_LDFLAGS}
+)
+
+# ***************************
+# Utility library
+# ***************************
+
+add_library(etestserverutils SHARED ${SOURCES})
+
+add_dependencies(etestserverutils
+       edataserver
+       evolution-addressbook-factory
+       evolution-calendar-factory
+       evolution-source-registry
+       ${extra_deps}
+)
+
+target_compile_definitions(etestserverutils PRIVATE
+       -DG_LOG_DOMAIN=\"e-test-server-utils\"
+       ${extra_defines}
+)
+
+target_compile_options(etestserverutils PUBLIC
+       ${BACKEND_CFLAGS}
+       ${DATA_SERVER_CFLAGS}
+       ${extra_cflags}
+)
+
+target_include_directories(etestserverutils PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_SOURCE_DIR}
+       ${BACKEND_INCLUDE_DIRS}
+       ${DATA_SERVER_INCLUDE_DIRS}
+       ${extra_incdirs}
+)
+
+target_link_libraries(etestserverutils
+       edataserver
+       ${extra_deps}
+       ${BACKEND_LDFLAGS}
+       ${DATA_SERVER_LDFLAGS}
+       ${extra_ldflags}
+)
+
+if(ENABLE_INSTALLED_FLAGS)
+       install(TARGETS etestserverutils
+               DESTINATION ${LIB_INSTALL_DIR}
+       )
+endif(ENABLE_INSTALLED_FLAGS)
+
+# ***************************
+# Local Unit Test
+# ***************************
+
+set(SOURCES
+       test-fixture.c
+)
+
+add_installable_test(test-fixture
+       SOURCES
+       extra_deps
+       extra_defines
+       extra_cflags
+       extra_incdirs
+       extra_ldflags
+       "session-exclusive"
+       "TEST_INSTALLED_SERVICES=1"
+)
diff --git a/tests/test-server-utils/e-test-server-utils.c b/tests/test-server-utils/e-test-server-utils.c
index 180ef03..4c177ea 100644
--- a/tests/test-server-utils/e-test-server-utils.c
+++ b/tests/test-server-utils/e-test-server-utils.c
@@ -34,9 +34,7 @@
  * and e_test_server_utils_teardown() in thier fixture's setup and teardown routines.
  **/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include "e-test-server-utils.h"
 
diff --git a/tests/test-server-utils/services/CMakeLists.txt b/tests/test-server-utils/services/CMakeLists.txt
new file mode 100644
index 0000000..491d4da
--- /dev/null
+++ b/tests/test-server-utils/services/CMakeLists.txt
@@ -0,0 +1,11 @@
+configure_file(org.gnome.evolution.dataserver.AddressBook.service.in
+       org.gnome.evolution.dataserver.AddressBook.service
+       @ONLY)
+
+configure_file(org.gnome.evolution.dataserver.Calendar.service.in
+       org.gnome.evolution.dataserver.Calendar.service
+       @ONLY)
+
+configure_file(org.gnome.evolution.dataserver.Sources.service.in
+       org.gnome.evolution.dataserver.Sources.service
+       @ONLY)
diff --git a/tests/test-server-utils/services/org.gnome.evolution.dataserver.AddressBook.service.in 
b/tests/test-server-utils/services/org.gnome.evolution.dataserver.AddressBook.service.in
index b32af72..f7ae528 100644
--- a/tests/test-server-utils/services/org.gnome.evolution.dataserver.AddressBook.service.in
+++ b/tests/test-server-utils/services/org.gnome.evolution.dataserver.AddressBook.service.in
@@ -1,3 +1,3 @@
 [D-BUS Service]
 Name=@ADDRESS_BOOK_DBUS_SERVICE_NAME@
-Exec=@abs_top_builddir@/services/evolution-addressbook-factory/evolution-addressbook-factory
+Exec=@CMAKE_BINARY_DIR@/services/evolution-addressbook-factory/evolution-addressbook-factory
diff --git a/tests/test-server-utils/services/org.gnome.evolution.dataserver.Calendar.service.in 
b/tests/test-server-utils/services/org.gnome.evolution.dataserver.Calendar.service.in
index aa148e3..17b3c3d 100644
--- a/tests/test-server-utils/services/org.gnome.evolution.dataserver.Calendar.service.in
+++ b/tests/test-server-utils/services/org.gnome.evolution.dataserver.Calendar.service.in
@@ -1,3 +1,3 @@
 [D-BUS Service]
 Name=@CALENDAR_DBUS_SERVICE_NAME@
-Exec=@abs_top_builddir@/services/evolution-calendar-factory/evolution-calendar-factory
+Exec=@CMAKE_BINARY_DIR@/services/evolution-calendar-factory/evolution-calendar-factory
diff --git a/tests/test-server-utils/services/org.gnome.evolution.dataserver.Sources.service.in 
b/tests/test-server-utils/services/org.gnome.evolution.dataserver.Sources.service.in
index cd88998..d39ef96 100644
--- a/tests/test-server-utils/services/org.gnome.evolution.dataserver.Sources.service.in
+++ b/tests/test-server-utils/services/org.gnome.evolution.dataserver.Sources.service.in
@@ -1,3 +1,3 @@
 [D-BUS Service]
 Name=@SOURCES_DBUS_SERVICE_NAME@
-Exec=@abs_top_builddir@/services/evolution-source-registry/evolution-source-registry
+Exec=@CMAKE_BINARY_DIR@/services/evolution-source-registry/evolution-source-registry
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
new file mode 100644
index 0000000..35017f9
--- /dev/null
+++ b/tools/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(addressbook-export)
diff --git a/tools/addressbook-export/CMakeLists.txt b/tools/addressbook-export/CMakeLists.txt
new file mode 100644
index 0000000..04ab5bc
--- /dev/null
+++ b/tools/addressbook-export/CMakeLists.txt
@@ -0,0 +1,59 @@
+set(DEPENDENCIES
+       ebook
+       ebook-contacts
+       edataserver
+)
+
+set(SOURCES
+       addressbook-export.c
+)
+
+add_executable(addressbook-export
+       ${SOURCES}
+)
+
+add_dependencies(addressbook-export
+       ${DEPENDENCIES}
+)
+
+target_compile_definitions(addressbook-export PRIVATE
+       -DG_LOG_DOMAIN=\"addressbook-export\"
+       -DLOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
+)
+
+target_compile_options(addressbook-export PUBLIC
+       ${ADDRESSBOOK_CFLAGS}
+)
+
+target_include_directories(addressbook-export PUBLIC
+       ${CMAKE_BINARY_DIR}
+       ${CMAKE_BINARY_DIR}/addressbook
+       ${CMAKE_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/addressbook
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${ADDRESSBOOK_INCLUDE_DIRS}
+)
+
+target_link_libraries(addressbook-export
+       ${DEPENDENCIES}
+       ${ADDRESSBOOK_LDFLAGS}
+)
+
+install(TARGETS addressbook-export
+       DESTINATION ${privlibexecdir}
+)
+
+find_program(PERL perl)
+if(PERL)
+       configure_file(
+               ${CMAKE_CURRENT_SOURCE_DIR}/csv2vcard.in
+               ${CMAKE_CURRENT_BINARY_DIR}/csv2vcard
+               @ONLY
+       )
+
+       install(FILES ${CMAKE_CURRENT_BINARY_DIR}/csv2vcard
+               DESTINATION ${privlibexecdir}
+       )
+else(PERL)
+       message(WARNING "The 'perl' not found, not installing csv2vcard")
+endif(PERL)
diff --git a/tools/addressbook-export/addressbook-export.c b/tools/addressbook-export/addressbook-export.c
index 7c19614..0dcff94 100644
--- a/tools/addressbook-export/addressbook-export.c
+++ b/tools/addressbook-export/addressbook-export.c
@@ -17,9 +17,7 @@
  * Authors: Gilbert Fang <gilbert fang sun com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "evolution-data-server-config.h"
 
 #include <stdlib.h>
 #include <string.h>
diff --git a/vala/CMakeLists.txt b/vala/CMakeLists.txt
new file mode 100644
index 0000000..90f32c5
--- /dev/null
+++ b/vala/CMakeLists.txt
@@ -0,0 +1,141 @@
+set(valafiles
+       ${CMAKE_CURRENT_SOURCE_DIR}/libedataserver-${API_VERSION}.deps
+       ${CMAKE_CURRENT_BINARY_DIR}/libedataserver-${API_VERSION}.vapi
+       ${CMAKE_CURRENT_SOURCE_DIR}/libebook-${API_VERSION}.deps
+       ${CMAKE_CURRENT_BINARY_DIR}/libebook-${API_VERSION}.vapi
+       ${CMAKE_CURRENT_SOURCE_DIR}/libebook-contacts-${API_VERSION}.deps
+       ${CMAKE_CURRENT_BINARY_DIR}/libebook-contacts-${API_VERSION}.vapi
+)
+
+add_custom_target(vala ALL)
+
+# ***********************************
+# camel
+# ***********************************
+
+set(gir_fullname ${CMAKE_BINARY_DIR}/camel/Camel-${API_VERSION}.gir)
+gir_girfilename_to_target(gir_deps Camel-${API_VERSION}.gir)
+
+list(APPEND valafiles
+       ${CMAKE_CURRENT_SOURCE_DIR}/camel-${API_VERSION}.deps
+       ${CMAKE_CURRENT_BINARY_DIR}/camel-${API_VERSION}.vapi
+)
+
+add_dependencies(vala ${gir_deps})
+
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/camel-${API_VERSION}.vapi
+       COMMAND ${VAPIGEN}
+               --vapidir=${CMAKE_CURRENT_SOURCE_DIR}
+               --vapidir=${CMAKE_CURRENT_BINARY_DIR}
+               --girdir=${CMAKE_BINARY_DIR}/camel
+               --pkg gio-2.0
+               --pkg libxml-2.0
+               --pkg posix
+               --library camel-${API_VERSION}
+               --metadatadir=${CMAKE_CURRENT_SOURCE_DIR}
+               ${gir_fullname}
+       DEPENDS camel-${API_VERSION}.deps
+               ${gir_deps}
+               ${gir_fullname}
+)
+
+# ***********************************
+# libedataserver
+# ***********************************
+
+set(gir_fullname ${CMAKE_BINARY_DIR}/libedataserver/EDataServer-${API_VERSION}.gir)
+gir_girfilename_to_target(gir_deps EDataServer-${API_VERSION}.gir)
+
+add_dependencies(vala ${gir_deps})
+
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libedataserver-${API_VERSION}.vapi
+       COMMAND ${VAPIGEN}
+               --vapidir=${CMAKE_CURRENT_SOURCE_DIR}
+               --vapidir=${CMAKE_CURRENT_BINARY_DIR}
+               --girdir=${CMAKE_BINARY_DIR}/libedataserver
+               --pkg gio-2.0
+               --pkg libxml-2.0
+               --pkg libsoup-2.4
+               --pkg posix
+               --library libedataserver-${API_VERSION}
+               --metadatadir=${CMAKE_CURRENT_SOURCE_DIR}
+               ${gir_fullname}
+       DEPENDS libedataserver-${API_VERSION}.deps
+               ${gir_deps}
+               ${gir_fullname}
+)
+
+# ***********************************
+# libebook-contacts
+# ***********************************
+
+set(gir_fullname ${CMAKE_BINARY_DIR}/addressbook/libebook-contacts/EBookContacts-${API_VERSION}.gir)
+gir_girfilename_to_target(gir_deps EBookContacts-${API_VERSION}.gir)
+
+add_dependencies(vala ${gir_deps})
+
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libebook-contacts-${API_VERSION}.vapi
+       COMMAND ${VAPIGEN}
+               --vapidir=${CMAKE_CURRENT_SOURCE_DIR}
+               --vapidir=${CMAKE_CURRENT_BINARY_DIR}
+               --girdir=${CMAKE_BINARY_DIR}/libedataserver
+               --pkg libedataserver-${API_VERSION}
+               --pkg gio-2.0
+               --pkg libxml-2.0
+               --pkg libsoup-2.4
+               --pkg posix
+               --library libebook-contacts-${API_VERSION}
+               --metadatadir=${CMAKE_CURRENT_SOURCE_DIR}
+               ${gir_fullname}
+               ${CMAKE_CURRENT_SOURCE_DIR}/libebook-contacts-${API_VERSION}-custom.vala
+       DEPENDS libebook-contacts-${API_VERSION}.deps
+               libebook-contacts-${API_VERSION}-custom.vala
+               ${CMAKE_CURRENT_BINARY_DIR}/libedataserver-${API_VERSION}.vapi
+               ${gir_fullname}
+               ${gir_deps}
+)
+
+# ***********************************
+# libebook
+# ***********************************
+
+set(gir_fullname ${CMAKE_BINARY_DIR}/addressbook/libebook/EBook-${API_VERSION}.gir)
+gir_girfilename_to_target(gir_deps EBook-${API_VERSION}.gir)
+
+add_dependencies(vala ${gir_deps})
+
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libebook-${API_VERSION}.vapi
+       COMMAND ${VAPIGEN}
+               --vapidir=${CMAKE_CURRENT_SOURCE_DIR}
+               --vapidir=${CMAKE_CURRENT_BINARY_DIR}
+               --girdir=${CMAKE_BINARY_DIR}/libedataserver
+               --girdir=${CMAKE_BINARY_DIR}/addressbook/libebook-contacts
+               --pkg libedataserver-${API_VERSION}
+               --pkg libebook-contacts-${API_VERSION}
+               --pkg gio-2.0
+               --pkg libxml-2.0
+               --pkg libsoup-2.4
+               --pkg posix
+               --library libebook-${API_VERSION}
+               --metadatadir=${CMAKE_CURRENT_SOURCE_DIR}
+               ${gir_fullname}
+       DEPENDS libebook-${API_VERSION}.deps
+               ${CMAKE_CURRENT_BINARY_DIR}/libedataserver-${API_VERSION}.vapi
+               ${CMAKE_CURRENT_BINARY_DIR}/libebook-contacts-${API_VERSION}.vapi
+               ${gir_fullname}
+               ${gir_deps}
+)
+
+# ***********************************
+# Install all VAPI files
+# ***********************************
+
+add_custom_target(vala-files
+       DEPENDS ${valafiles}
+)
+
+add_dependencies(vala vala-files)
+
+install(FILES ${valafiles}
+       DESTINATION ${SHARE_INSTALL_DIR}/vala/vapi
+)



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