fixup_bundle on macOS does not use LC_RPATH of dependencies to find dependencies of dependencies.
Tested on CMake 3.21.1, macOS 11.5, toolchain and Qt built with Spack.
I have a program that links to Qt, which through some avenue needs libfreetype.6.dylib
, which needs libbz2.1.dylib
. The linkage in libfreetype.6.dylib
is @rpath/libbz2.1.dylib
, and there is an LC_RPATH
entry which fills in the rest of the info.
When I run fixup_bundle(exe "" "$ENV{QTDIR}/lib")
, I get the following error:
otool -l failed: 1
error:
.../otool-classic:
can't open file: @rpath/libbz2.1.dylib (No such file or directory)
Call Stack (most recent call first):
[cmake-path]/Modules/BundleUtilities.cmake:527 (get_item_rpaths)
[cmake-path]/Modules/BundleUtilities.cmake:658 (set_bundle_key_values)
[cmake-path]/Modules/BundleUtilities.cmake:943 (get_bundle_keys)
...
Examining BundleUtilities.cmake
, I find that the call to get_item_rpaths
on libfreetype.6.dylib
successfully extracts the library path to bzip2 and thus libbz2.1.dylib
. The value of item_rpaths
is then set to libfreetype.6.dylib_RPATHS
, and then is not used as the dirs
argument later during set_bundle_key_values
for libbz2.1.dylib
.
I am cognizant Qt is usually handled through other means, but I thought I'd report this as it might be a more broad issue.