Suggestion for smarter handling for RPATH on MacOS and Linux
I have the feeling that it should be possible to handle RPATH more conveniently on MacOS and Linux, without referring to absolute paths. More conveniently in that it should be possible to use relative RPATHs, so that later changes to the install-prefix
are possible, and even the whole installed folder could be relocated.
if a package is installed in the "usual" GNU style, the executables will end up in _prefix_/bin
and the shared libraries in _prefix_/lib
, so on Linux we could use an RPATH of $ORIGIN/../lib
and on MacOS @loader_path/../lib
. And if executables end up in a different place, let's say _prefix_/libexec/mypackage/auxiliaryprogram
, cmake could still work out the relative path to the lib
folder.
(On windows there is no issue, because usually the executables and dynamic libraries of a package all end up in the same directory).
The handling of executables in the toplevel bin directory I could handle myself, globally for my project, with careful coding, but I don't think it's possible to globally handle the case of executables (or dependent shared objects) that will be installed elsewhere in the tree.