BundleUtilities fails to detect "weak" dylibs on MacOS 10.15+
I'm developing a game using SDL2 and SDL2_mixer. SDL2_mixer is for audio and depends on a few optional frameworks, such as mpg123, Ogg, Vorbis.
Since switching to a CI using macos 10.15, the optional frameworks are no longer copied into my application bundle using BundleUtilities. This worked fine on CI using 10.13 and locally using 10.14.
Running otool -L
on the framework library, which is already processed by BundleUtilities, gives the following output:
cmaketest.app/Contents/Frameworks/SDL2_mixer.framework/SDL2_mixer:
@executable_path/../Frameworks/SDL2_mixer.framework/Versions/A/SDL2_mixer (compatibility version 3.0.0, current version 3.2.0)
@rpath/FLAC.framework/Versions/A/FLAC (compatibility version 12.0.0, current version 12.0.0, weak)
@rpath/modplug.framework/Versions/A/modplug (compatibility version 2.0.0, current version 2.0.0, weak)
@rpath/mpg123.framework/Versions/A/mpg123 (compatibility version 45.0.0, current version 45.5.0, weak)
@rpath/Vorbis.framework/Versions/A/Vorbis (compatibility version 5.0.0, current version 5.8.0, weak)
@rpath/OpusFile.framework/Versions/A/OpusFile (compatibility version 5.0.0, current version 5.3.0, weak)
/System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 492.0.0)
/System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 933.0.0)
@executable_path/../Frameworks/SDL2.framework/Versions/A/SDL2 (compatibility version 1.0.0, current version 10.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1555.10.0)
Note the , weak
addition to the optional libraries, which isn't there in MacOS 10.14 and below.
I debugged this and the PreRequisites.cmake module executes this grep command on the otool output:
set(gp_regex "^\t([^\t]+) \\(compatibility version ([0-9]+.[0-9]+.[0-9]+), current version ([0-9]+.[0-9]+.[0-9]+)\\)${eol_char}$")
This is the reason why the "weak" libraries are not picked up, copied or their rpaths fixed.
Is omitting those "weak" dependencies intentional? If it is, how can I include the necessary libraries in my app bundle? The only solution I've found so far is manually copying them to my app bundle and manually running install_name_tool
, which is not ideal.
Minimal sample project is available here: https://github.com/bvschaik/cmake-weak-dependency