macOS: include weak dependencies in GetPrerequisites and file(GET_RUNTIME_DEPENDENCIES)
On macOS, it's possible to weakly link to libraries and frameworks using the -weak_library
and -weak_framework
linker flags. Those weakly linked libraries are considered optional and can be absent at runtime.
Starting with Clang 12, `otool` output differs for these weakly linked libraries/frameworks:
Output of otool -L
:
Clang 11:
@rpath/libtestlib.dylib (compatibility version 0.0.0, current version 0.0.0)
Clang 12:
@rpath/libtestlib.dylib (compatibility version 0.0.0, current version 0.0.0, weak)
Output of otool -l
:
Clang 11:
Load command 13
cmd LC_LOAD_DYLIB
cmdsize 48
name @rpath/libtestlib.dylib (offset 24)
time stamp 2 Thu Jan 1 01:00:02 1970
current version 0.0.0
compatibility version 0.0.0
Clang 12:
Load command 13
cmd LC_LOAD_WEAK_DYLIB
cmdsize 48
name @rpath/libtestlib.dylib (offset 24)
time stamp 2 Thu Jan 1 01:00:02 1970
current version 0.0.0
compatibility version 0.0.0
Both GetPrerequisites
(used by BundleUtilities
) and file(GET_RUNTIME_DEPENDENCIES)
didn't take these changes into account.
Fixes: #21684 (closed)
Backport: release
Topic-rename: macos-include-weak-dependencies
Edited by Brad King