2
1
mirror of https://github.com/qpdf/qpdf.git synced 2025-01-05 08:02:11 +00:00
qpdf/zlib-flate
Michael Witten 2371d70132 build: Tell cmake to set 'rpath' intelligently
Before this commit, when QPDF's products were installed in an
unorthodox location, it was possible for one of the executable
products not to be able to find the necessary library product
(i.e., the necessary 'libqpdf'); that is, an executable didn't
inform the dynamic linker where to look. For example:

  $ ldd /path/to/installed/files/bin/qpdf
          linux-gate.so.1 (0xb7ee6000)
          libqpdf.so.29 => not found
          [...]

Now, because of this commit, an executable's 'rpath' setting
(or equivalent) is set upon installation, thereby providing the
required search directory:

  $ ldd /path/to/installed/files/bin/qpdf
          linux-gate.so.1 (0xb7ee6000)
          libqpdf.so.29 => /path/to/installed/files/lib/libqpdf.so.29 (0xb7bc3000)
          [...]

There is some intelligence behind whether rpath is set at all:

  * If 'CMAKE_INSTALL_RPATH' is set, then it is used; this
    allows the user to set a single, overriding value, and it
    allows the 'AppImage' build script to continue working in
    exactly the same way that it has been doing so far.

  * Otherwise, the base-case rpath is determined by the following:

      "${CMAKE_INSTALL_FULL_LIBDIR}"

    If that path is a standard location, then the base-case rpath
    is the empty string (meaning, in the base case, no rpath will
    be set); otherwise, the base-case rpath is set to that path.

  * The base-case rpath is used to set various targets' 'INSTALL_RPATH'
    property. This is done explicitly, so as to avoid the setting of
    an rpath unnecessarily on some target; for instance, as of this
    commit, only some of the executable targets have this property set,
    but the 'libqpdf' target does not. In the long run, having such
    fine-grained control will likely be the best policy.

  * In addition, cmake has been instructed to add to each target's
    rpath any directories that it thinks might contain potential
    unorthodox dependencies from outside the project; most of the time,
    there will be no such dependencies, and so nothing will be added.
    However, this is a simple way to account for unforeseen needs.

Of course, this will only help on a system that supports an rpath
feature known to cmake; for example, Windows has no such feature,
and so all of this will presumably be ignored when building under
that system.
2024-04-25 20:37:48 +00:00
..
qtest zlib-flate: make test work with alternative zlib 2023-12-20 07:07:35 -05:00
CMakeLists.txt build: Tell cmake to set 'rpath' intelligently 2024-04-25 20:37:48 +00:00
zlib-flate.cc Format code, bump clang-format version to 18 2023-12-22 21:45:10 -05:00