[evolution-data-server/wip/cmake] data/ and tests/ folders; some build fixes related to RPATH and gsettings schemas compilation after



commit 450fd10224aceac89c55af79565380c65fd12dfa
Author: Milan Crha <mcrha redhat com>
Date:   Tue Sep 27 23:45:31 2016 +0200

    data/ and tests/ folders; some build fixes related to RPATH and gsettings schemas compilation after 
install

 CMakeLists.txt                                     |   22 +++-
 cmake/modules/CheckTarget.cmake                    |    2 +-
 cmake/modules/GLibTools.cmake                      |   52 ++++++--
 cmake/modules/InstalledTests.cmake                 |   45 ++++++
 cmake/modules/UninstallTarget.cmake                |   14 +-
 data/CMakeLists.txt                                |   27 ++++
 modules/CMakeLists.txt                             |    1 +
 tests/CMakeLists.txt                               |   61 +++++++++
 tests/book-migration/CMakeLists.txt                |   96 +++++++++++++
 tests/book-migration/db/CMakeLists.txt             |   27 ++++
 tests/libebook-contacts/CMakeLists.txt             |   41 ++++++
 tests/libebook/CMakeLists.txt                      |  114 ++++++++++++++++
 tests/libebook/client/CMakeLists.txt               |  143 ++++++++++++++++++++
 tests/libebook/vcard/CMakeLists.txt                |   39 ++++++
 tests/libecal/CMakeLists.txt                       |  125 +++++++++++++++++
 tests/libecal/client/CMakeLists.txt                |   50 +++++++
 tests/libedata-book/CMakeLists.txt                 |  129 ++++++++++++++++++
 tests/libedata-cal/CMakeLists.txt                  |   40 ++++++
 tests/libedataserver/CMakeLists.txt                |   62 +++++++++
 tests/test-server-utils/CMakeLists.txt             |  108 +++++++++++++++
 tests/test-server-utils/services/CMakeLists.txt    |   11 ++
 ...ome.evolution.dataserver.AddressBook.service.in |    2 +-
 ....gnome.evolution.dataserver.Calendar.service.in |    2 +-
 ...g.gnome.evolution.dataserver.Sources.service.in |    2 +-
 24 files changed, 1192 insertions(+), 23 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c4624ec..8b36116 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -112,6 +112,10 @@ set(webkit2gtk_minimum_version 2.11.91)
 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)
@@ -146,6 +150,8 @@ 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
@@ -209,6 +215,7 @@ include(CheckTarget)
 include(DistTarget)
 include(GLibTools)
 include(GObjectIntrospection)
+include(InstalledTests)
 include(PkgConfigEx)
 include(SetupBuildFlags)
 include(UninstallTarget)
@@ -258,6 +265,18 @@ if(NOT PYTHON)
 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
 # ******************************
 
@@ -869,13 +888,14 @@ 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(tests)
 add_subdirectory(tools)
 
 if(HAVE_GTK)
diff --git a/cmake/modules/CheckTarget.cmake b/cmake/modules/CheckTarget.cmake
index a6a1427..71824a9 100644
--- a/cmake/modules/CheckTarget.cmake
+++ b/cmake/modules/CheckTarget.cmake
@@ -10,7 +10,7 @@
 
 include(CTest)
 
-# Disable this not have verbose tests
+# Disable this to not have verbose tests
 set(CMAKE_CTEST_COMMAND ${CMAKE_CTEST_COMMAND} -V)
 
 add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
diff --git a/cmake/modules/GLibTools.cmake b/cmake/modules/GLibTools.cmake
index b726049..250b756 100644
--- a/cmake/modules/GLibTools.cmake
+++ b/cmake/modules/GLibTools.cmake
@@ -40,6 +40,7 @@
 #    beside _sourcedir. The optional arguments are other dependencies.
 
 include(PkgConfigEx)
+include(UninstallTarget)
 
 find_program(GLIB_MKENUMS glib-mkenums)
 if(NOT GLIB_MKENUMS)
@@ -171,15 +172,43 @@ set(GSETTINGS_SCHEMAS_DIR "${SHARE_INSTALL_DIR}/glib-2.0/schemas/")
 macro(add_gsettings_schemas _target _schema0)
        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=${CMAKE_CURRENT_SOURCE_DIR}/${_schema}
-                       COMMAND cmake -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/${_schema}" 
"${CMAKE_CURRENT_BINARY_DIR}/${_outputfile}"
+                       COMMAND ${GLIB_COMPILE_SCHEMAS} --strict --dry-run --schema-file=${_schema_fullname}
+                       COMMAND cmake -E copy_if_different "${_schema_fullname}" 
"${CMAKE_CURRENT_BINARY_DIR}/${_outputfile}"
+                       DEPENDS ${_schema_fullname}
                        VERBATIM
                )
-               add_custom_target(gsettings-schemas-${_schema} ALL DEPENDS ${_outputfile})
-               add_dependencies(${_target} gsettings-schemas-${_schema})
-               install(FILES ${_schema}
+               add_custom_target(gsettings-schemas-${_schema_filename} ALL DEPENDS ${_outputfile})
+               add_dependencies(${_target} gsettings-schemas-${_schema_filename})
+               if(ENABLE_SCHEMAS_COMPILE)
+                       # This is very inefficient, because the glib-compile-schemas is callad as many times
+                       # as the schema files are provided by the project, but there is no better way
+                       # in CMake to run a code/script after the whole `make install`
+                       install(CODE
+                               "if(\"${_schema_fullname}\" IS_NEWER_THAN 
\"${GSETTINGS_SCHEMAS_DIR}/${_schema_filename}\")
+                                       message(STATUS \"Installing: 
${GSETTINGS_SCHEMAS_DIR}/${_schema_filename}\")
+                                       execute_process(COMMAND cmake -E copy_if_different 
\"${_schema_fullname}\" \"${GSETTINGS_SCHEMAS_DIR}\"
+                                               COMMAND cmake -E chdir . \"${GLIB_COMPILE_SCHEMAS}\" 
\"${GSETTINGS_SCHEMAS_DIR}\"
+                                       )
+                               else()
+                                       message(STATUS \"Up-to-date: 
${GSETTINGS_SCHEMAS_DIR}/${_schema_filename}\")
+                               endif()
+                               ")
+               endif(ENABLE_SCHEMAS_COMPILE)
+
+               # Do both, to have 'uninstall' working properly
+               install(FILES ${_schema_fullname}
                        DESTINATION ${GSETTINGS_SCHEMAS_DIR})
        endforeach(_schema)
 endmacro(add_gsettings_schemas)
@@ -191,13 +220,12 @@ endmacro(add_gsettings_schemas)
 #    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.
 #
-#macro(compile_gsettings_schemas)
-#      if(ENABLE_SCHEMAS_COMPILE)
-#              install(CODE
-#                      "message(STATUS \"Compiling GSettings schemas at '${GSETTINGS_SCHEMAS_DIR}'\")
-#                      execute_process(COMMAND cmake -E chdir . \"${GLIB_COMPILE_SCHEMAS}\" 
\"${GSETTINGS_SCHEMAS_DIR}\")")
-#      endif(ENABLE_SCHEMAS_COMPILE)
-#endmacro(compile_gsettings_schemas)
+if(ENABLE_SCHEMAS_COMPILE)
+       add_custom_command(TARGET uninstall POST_BUILD
+               COMMAND cmake -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)
diff --git a/cmake/modules/InstalledTests.cmake b/cmake/modules/InstalledTests.cmake
new file mode 100644
index 0000000..ed1faa8
--- /dev/null
+++ b/cmake/modules/InstalledTests.cmake
@@ -0,0 +1,45 @@
+# InstalledTests.cmake
+#
+# Adds option ENABLE_INSTALLED_TESTS and helper macros to manage
+# installed test. There are also set variables:
+# INSTALLED_TESTS_EXEC_DIR - where to store installed tests and eventually its data
+# INSTALLED_TESTS_META_DIR - where to store .test meta files for installed tests
+#
+# install_test_if_enabled(_test_target _type _environ)
+#    Adds rules to install a test whose target is _test_target (the one
+#    used for add_executable()), while the target name should match
+#    the executable name. The _type and _environ are used for populating
+#    the .test meta file.
+
+include(PrintableOptions)
+
+add_printable_option(ENABLE_INSTALLED_TESTS "Enable installed tests" OFF)
+
+set(INSTALLED_TESTS_EXEC_DIR ${privlibexecdir}/installed-tests)
+set(INSTALLED_TESTS_META_DIR ${SHARE_INSTALL_DIR}/installed-tests/${PROJECT_NAME})
+
+macro(install_test_if_enabled _test_target _type _environ)
+       if(ENABLE_INSTALLED_TESTS)
+               set(TEST_TYPE ${_type})
+               set(TEST_ENVIRONMENT)
+               if(NOT ${_environ} STREQUAL "")
+                       set(TEST_ENVIRONMENT "env ${_environ} ")
+               endif(NOT ${_environ} STREQUAL "")
+
+               set(teststring "[Test]
+Type=${TEST_TYPE}
+Exec=${TEST_ENVIRONMENT}${INSTALLED_TESTS_EXEC_DIR}/${_test_target}
+"
+)
+
+               file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${_test_target}.test "${teststring}")
+
+               install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_test_target}.test
+                       DESTINATION ${INSTALLED_TESTS_META_DIR}
+               )
+
+               install(TARGETS ${_test_target}
+                       DESTINATION ${INSTALLED_TESTS_EXEC_DIR}
+               )
+       endif(ENABLE_INSTALLED_TESTS)
+endmacro(install_test_if_enabled)
diff --git a/cmake/modules/UninstallTarget.cmake b/cmake/modules/UninstallTarget.cmake
index 44ca442..7ccfcf3 100644
--- a/cmake/modules/UninstallTarget.cmake
+++ b/cmake/modules/UninstallTarget.cmake
@@ -2,10 +2,12 @@
 #
 # Defines a custom target named 'uninstall'
 
-configure_file(
-       "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
-       "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
-       IMMEDIATE @ONLY)
+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_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
+       add_custom_target(uninstall
+               COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake)
+endif(NOT TARGET uninstall)
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/modules/CMakeLists.txt b/modules/CMakeLists.txt
index ad432d2..d9fabf8 100644
--- a/modules/CMakeLists.txt
+++ b/modules/CMakeLists.txt
@@ -42,6 +42,7 @@ macro(add_simple_module _name _sourcesvar _depsvar _defsvar _cflagsvar _incdirsv
 
        target_link_libraries(${_name}
                ${DEPENDENCIES}
+               ${${_depsvar}}
                ${BACKEND_LDFLAGS}
                ${DATA_SERVER_LDFLAGS}
                ${${_ldflagsvar}}
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..8164ea1
--- /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 -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 -E make_directory ${CMAKE_SOURCE_DIR}/tests/book-migration/db/${_use_db_version}
+       COMMAND cmake -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 -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..e684701
--- /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 -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/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/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/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-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/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



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