From b00a95c0b39e2666eac09bf13304782492d886b8 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Sun, 6 Oct 2019 21:27:10 +0200 Subject: [PATCH] Tweak install rule to be able to compile glib's schema's on Windows as well (Cherry picked from master) It's a bit of a hack based on the assumption DESTDIR is never set on Windows. A install time guard is added to assert this. It needed a few changes to make this working: - Have cmake expand DESTDIR instead of delaying this to bash If not, bash would see "$DESTDIRC:/gcdev64/..." and we'd loose the drive letter in bash' expansion of $DESTDIRC. So work with $ENV{DESTDIR} instead - To prevent cmake from already expanding this in the build system generation step add the appropriate escapes to that variable. - Add guard code in the install command that asserts DESTDIR is not set on Windows. Use similar escapes as necessary to ensure the evaluation happens at install time rather than in the generation step. --- CMakeLists.txt | 2 ++ gnucash/gschemas/CMakeLists.txt | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d1c327b1a..20ec5ce101 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,6 +86,8 @@ foreach(install_dir ${CMAKE_INSTALL_FULL_BINDIR} break() endif() endforeach() +message(STATUS "CMAKE_INSTALL_FULL_DATADIR: ${CMAKE_INSTALL_FULL_DATADIR}") +message(STATUS "DESTDIR: ${DESTDIR}") # GnuCash installs two files in ${CMAKE_INSTALL_SYSCONFDIR} set(BINDIR ${CMAKE_INSTALL_BINDIR} CACHE STRING "user executables") diff --git a/gnucash/gschemas/CMakeLists.txt b/gnucash/gschemas/CMakeLists.txt index 0b1fcb91b7..735e5c11d0 100644 --- a/gnucash/gschemas/CMakeLists.txt +++ b/gnucash/gschemas/CMakeLists.txt @@ -32,10 +32,20 @@ if (COMPILE_GSCHEMAS) add_custom_target(compiled-schemas ALL DEPENDS ${SCHEMADIR_BUILD}/gschemas.compiled) - - install(CODE "execute_process( - COMMAND ${SHELL} -c \"echo Compiling gschema files in $DESTDIR${CMAKE_INSTALL_FULL_DATADIR}/glib-2.0/schemas ; - ${GLIB_COMPILE_SCHEMAS} $DESTDIR${CMAKE_INSTALL_FULL_DATADIR}/glib-2.0/schemas\")") + # On Windows concatenating two absolute paths results in an invalid path (having two drive letters) + # If DESTDIR is not set on the other hand, the below install command works just fine + # So verify DESTDIR is not set on Windows + # Note we have to do this at build time, not configure time so the guard is part of the custom install command + install(CODE " + if (WIN32) + set (DESTDIR \$ENV\{DESTDIR\}) + if (DESTDIR) + message(SEND_ERROR \"GnuCash can't be built with the DESTDIR environment variable set on Windows (due to bad interference with glib-compile-schemas).\") + endif() + endif() + execute_process( + COMMAND ${SHELL} -c \"echo Compiling gschema files in \$ENV\{DESTDIR\}${CMAKE_INSTALL_FULL_DATADIR}/glib-2.0/schemas ; + ${GLIB_COMPILE_SCHEMAS} \$ENV\{DESTDIR\}${CMAKE_INSTALL_FULL_DATADIR}/glib-2.0/schemas\")") endif () set(gschemas_DIST_local "")