[evolution-etesync/wip/mcrha/force-install-prefix] CMake: Add FORCE_INSTALL_PREFIX compile time option



commit b0c3fd2ff6525b328c1c7c870c566f2d5cbebf2c
Author: Milan Crha <mcrha redhat com>
Date:   Thu Feb 25 08:32:54 2021 +0100

    CMake: Add FORCE_INSTALL_PREFIX compile time option
    
    This allows to install evolution-data-server and evolution files
    files into the CMAKE_INSTALL_PREFIX instead of the prefix advertised
    by respective pkg-config files. It's useful, when the eds/evo prefixes
    are not writable for the builder.
    
    Also use EBookMetaBackendClass::backend_module_directory, which is
    closely related to this new option.

 CMakeLists.txt                           | 28 +++++++++++++++++++++++++---
 config.h.in                              |  3 +++
 src/addressbook/e-book-backend-etesync.c |  3 +++
 3 files changed, 31 insertions(+), 3 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f9f840d..728af36 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -124,19 +124,41 @@ pkg_check_modules(GNOME_PLATFORM REQUIRED
 
 pkg_check_modules(ETESYNC REQUIRED etebase)
 
+set(CMAKE_REQUIRED_FLAGS ${LIBEDATABOOK_CFLAGS})
+set(CMAKE_REQUIRED_INCLUDES ${LIBEDATABOOK_INCLUDE_DIRS})
+set(CMAKE_REQUIRED_LIBRARIES ${LIBEDATABOOK_LIBS})
+CHECK_C_SOURCE_COMPILES("#include <libedata-book/libedata-book.h>
+                       int main(void) { EBookMetaBackendClass cls; cls.backend_module_directory = NULL; 
return 0; }" HAVE_BACKEND_MODULE_DIRECTORY)
+unset(CMAKE_REQUIRED_FLAGS)
+unset(CMAKE_REQUIRED_INCLUDES)
+unset(CMAKE_REQUIRED_LIBRARIES)
+
 # ******************************
 # Special directories
 # ******************************
 
 set(privlibdir "${LIB_INSTALL_DIR}/${PROJECT_NAME}")
 
-pkg_check_variable(errordir evolution-shell-3.0 errordir)
-pkg_check_variable(evo_privlibdir evolution-shell-3.0 privlibdir)
 pkg_check_variable(ebook_backenddir libedata-book-1.2 backenddir)
 pkg_check_variable(ecal_backenddir libedata-cal-2.0 backenddir)
 pkg_check_variable(eds_moduledir libebackend-1.2 moduledir)
-pkg_check_variable(evo_moduledir evolution-shell-3.0 moduledir)
 pkg_check_variable(cred_moduledir libedataserver-1.2 credentialmoduledir)
+pkg_check_variable(evo_privlibdir evolution-shell-3.0 privlibdir)
+pkg_check_variable(errordir evolution-shell-3.0 errordir)
+pkg_check_variable(evo_moduledir evolution-shell-3.0 moduledir)
+
+add_printable_variable(FORCE_INSTALL_PREFIX "Whether to force install evolution-data-server and evolution 
files into the install prefix" OFF)
+if(FORCE_INSTALL_PREFIX)
+       pkg_check_variable(eds_prefix evolution-data-server-1.2 prefix)
+       string(REGEX REPLACE "^${eds_prefix}" "${CMAKE_INSTALL_PREFIX}" ebook_backenddir 
"${ebook_backenddir}")
+       string(REGEX REPLACE "^${eds_prefix}" "${CMAKE_INSTALL_PREFIX}" ecal_backenddir "${ecal_backenddir}")
+       string(REGEX REPLACE "^${eds_prefix}" "${CMAKE_INSTALL_PREFIX}" eds_moduledir "${eds_moduledir}")
+       string(REGEX REPLACE "^${eds_prefix}" "${CMAKE_INSTALL_PREFIX}" cred_moduledir "${cred_moduledir}")
+
+       pkg_check_variable(evo_prefix evolution-shell-3.0 prefix)
+       string(REGEX REPLACE "^${evo_prefix}" "${CMAKE_INSTALL_PREFIX}" errordir "${errordir}")
+       string(REGEX REPLACE "^${evo_prefix}" "${CMAKE_INSTALL_PREFIX}" evo_moduledir "${evo_moduledir}")
+endif(FORCE_INSTALL_PREFIX)
 
 SET(CMAKE_INSTALL_RPATH "${privlibdir}:${evo_privlibdir}")
 
diff --git a/config.h.in b/config.h.in
index 1bca002..310ba1d 100644
--- a/config.h.in
+++ b/config.h.in
@@ -11,3 +11,6 @@
 
 /* Package name for gettext */
 #define GETTEXT_PACKAGE "@GETTEXT_PACKAGE@"
+
+/* Define to 1 when EBookMetaBackendClass::backend_module_directory exists. */
+#cmakedefine HAVE_BACKEND_MODULE_DIRECTORY 1
diff --git a/src/addressbook/e-book-backend-etesync.c b/src/addressbook/e-book-backend-etesync.c
index e7b802e..5fa2a4a 100644
--- a/src/addressbook/e-book-backend-etesync.c
+++ b/src/addressbook/e-book-backend-etesync.c
@@ -658,6 +658,9 @@ e_book_backend_etesync_class_init (EBookBackendEteSyncClass *klass)
        EBookMetaBackendClass *book_meta_backend_class;
 
        book_meta_backend_class = E_BOOK_META_BACKEND_CLASS (klass);
+#ifdef HAVE_BACKEND_MODULE_DIRECTORY
+       book_meta_backend_class->backend_module_directory = BACKENDDIR;
+#endif
        book_meta_backend_class->backend_module_filename = "libebookbackendetesync.so";
        book_meta_backend_class->backend_factory_type_name = "EBookBackendEteSyncFactory";
        book_meta_backend_class->connect_sync = ebb_etesync_connect_sync;


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