gnucash unstable: Rework directory determination in CMake builds.

John Ralls jralls at
Tue Dec 5 20:26:45 EST 2017

Updated	 via (commit)
	from (commit)

commit 66817bb997d601b74b25b7a465a318387fb81594
Author: John Ralls <jralls at>
Date:   Tue Dec 5 14:48:45 2017 -0800

    Rework directory determination in CMake builds.
    Sets paths for finding componenents depending on the state of ENABLE_BINRELOC,
    GNC_UNINSTALLED, GNC_BUILDDIR and whether any install paths have been set
    outside of CMAKE_INSTALL_PREFIX.
    GNUInstallDirs changes the name of CMAKE_INSTALL_LIBDIR depending on the
    operating system and distro. When CMAKE_INSTALL_PREFIX is /usr,
    /usr/local, or any subdirectory of /opt it also changes
    CMAKE_INSTALL_FULL_SYSCONFDIR to /etc. An earlier commit by Aaron Laws
    mirrors the name of CMAKE_INSTALL_LIBDIR to the build library directory.
    It's possible for builders to set any of the install directories
    anywhere they please.
    Setting any directory outside of CMAKE_INSTALL_PREFIX breaks Binreloc so
    the toplevel CMakeLists.txt now detects that and disables Binreloc.
    If Binreloc is enabled then all path queries use it to find paths. This
    works in the build directory because the gnucash executable and all of
    the test programs are in build_directory/bin and LIBDIR, DATADIR, and
    SYSCONFDIR can be found in the same root path.
    If Binreloc is disabled then in order to build or run programs from the
    build directory one must set GNC_UNINSTALLED and set GNC_BUILDDIR to the
    absolute path of the build directory. When those are set GNC_BUILDDIR
    replaces CMAKE_INSTALL_PREFIX in all paths that are subdirectories of
    CMAKE_INSTALL_PREFIX; paths that are not in CMAKE_INSTALL_PREFIX are
    appended whole to GNC_BUILDDIR. This process is constent between CMake
    and gnc_path_get_foo. GnuCash is unlikely to run from a DESTDIR without

Summary of changes:
 CMakeLists.txt                                     |  19 ++-
 libgnucash/core-utils/CMakeLists.txt               |  17 ++-
 libgnucash/core-utils/binreloc.c                   | 128 +++++++--------------
 libgnucash/core-utils/gnc-filepath-utils.cpp       |   8 ++
 libgnucash/core-utils/gnc-filepath-utils.h         |   8 ++
 libgnucash/core-utils/gnc-path.c                   |  15 ++-
 libgnucash/core-utils/               |   2 +-
 libgnucash/core-utils/test/CMakeLists.txt          |  34 +++++-
 .../core-utils/test/gtest-path-utilities.cpp       | 125 ++++++++++++++++++++
 libgnucash/engine/qof-backend.cpp                  |   7 +-
 10 files changed, 254 insertions(+), 109 deletions(-)
 create mode 100644 libgnucash/core-utils/test/gtest-path-utilities.cpp

More information about the gnucash-patches mailing list