Parent rpaths are searched with GET_RUNTIME_DEPENDENCIES, but parent runpaths aren't. Is this intended or an oversight?
When scanning dependencies via Source/cmBinUtilsLinuxELFLinker.cxx
(link), the parent's rpath(s) are added to searchPaths
but the parent runpath(s) are not added to searchPaths
.
There are two third-party libraries liba.so
and libb.so
and a first-party executable.
binary | RUNPATH | NEEDED-dependency |
---|---|---|
./myexec |
$ORIGIN |
liba.so |
./liba.so |
$ORIGIN/lib |
libb.so |
./libb.so |
$ORIGIN/lib |
N/A |
Observed behavior: When I install a RUNTIME_DEPENDENCY_SET
for my myexec
-target, then it fails since liba.so
can't find libb.so
in ./lib/
, and hence libb.so
is reported as an unresolved dependency and the install-step fails (I built CMake from source and stepped into the code and concluded that this is what happens).
Expected behavior: I'd expect the parent RUNPATH (=RUNPATH of ./myexec
, which is $ORIGIN in this case ./
) to be included in the search path, as is the case for RPATH. If that was the case, then both $ORIGIN
and $ORIGIN/lib
would be searched for libb.so
and it would be resolved. I might be mistaken, but I believe this corresponds to how libraries are resolved when executing ELF-binaries.
I am dabbling in the world of RPATHs and RUNPATHs, so it may be that there exists a good reason as to why only RPATH is added from parent and RUNPATH is not, but I have not been able to find any reason for this in my quest for understanding... Or maybe it is really just an oversight in CMake. What do you think?