[CMake] FIXUP_BUNDLE creating empty frameworks on OS X

Jason Shipman thearmorywars at gmail.com
Thu Aug 9 20:06:00 EDT 2012


I am trying to use the CMake function FIXUP_BUNDLE to fix up an application
bundle, but am getting install-time warnings and for lack of better
terminology, not a fixed-up bundle.

The installed bundle has the right structure, but the frameworks it uses
aren't correctly copied in. Only each framework's directory structure is
copied in and not the actual shared library binary. For example, my bundle
uses SFML 2.0's System framework. Note that all SFML frameworks I use are
stored in /Library/Frameworks. Here is what I get in
MyApp.app/Contents/Frameworks/ with respect to this SFML component:

sfml-system.framework/
    Versions/
        2.0.0/

And that's all I get, just the directories. The actual SFML System
framework has a structure like this:

sfml-system.framework/
    Resources  (this is a symlink)
    sfml-system  (this is a symlink)
    Versions/
        2.0.0/
            Resources/
                Info.plist
            sfml-system  (this is the actual library binary)
        Current  (this is a symlink)

In my project, executables all have the same format so I have a small
function to add them using this common format. The function just adds
the executable, sets the libraries to link against, and at install time,
installs the application bundle and calls FIXUP_BUNDLE on it. Here is
that function:

FUNCTION(ADD_CUSTOM_EXECUTABLE TARGET HEADERS SOURCES DEPENDENCIES)
    ADD_EXECUTABLE(${TARGET} MACOSX_BUNDLE ${HEADERS} ${SOURCES} ${ARGN})
    TARGET_LINK_LIBRARIES(${TARGET} ${DEPENDENCIES})

    INSTALL(TARGETS ${TARGET} BUNDLE DESTINATION .)

    INSTALL(CODE "
        INCLUDE(BundleUtilities)
        FIXUP_BUNDLE(${CMAKE_INSTALL_PREFIX}/${TARGET}.app \"\" \"\") 
    ")
ENDFUNCTION(ADD_CUSTOM_EXECUTABLE)

I don't pass in anything for the LIBS or DIRS parameters of FIXUP_BUNDLE
because I am currently not using any plugins. The ALL_BUILD project builds
fine in Xcode, and the install project runs without failing, but produces
many warnings like this for each library discovered via otool -L. Here's
an example showing the start of the warnings for SFML's System framework,
almost immediately after FIXUP_BUNDLE is called:

fixup_bundle
    app='/Users/user/Desktop/SFML_Testing_BUILD/dist/MyApp.app'
    libs=''
    dirs=''
fixup_bundle: preparing...
warning: embedded item does not exist 'Users/user/Desktop/SFML_Testing_BUILD/
dist/MyApp.app/Contents/Frameworks/sfml-system.framework/Versions/2.0.0/
sfml-system'
warning: cannot resolve item '@executable_path/../Frameworks/
sfml-system.framework/Versions/2.0.0/sfml-system'

possible problems:
    need more directories?
    need to use InstallRequiredSystemLibraries?
    run in install tree instead of build tree?

And a short bit later, stuff like this:

warning: target '@executable_path/../Frameworks/sfml-system.framework/
Versions/2.0.0/sfml-system' is not absolute...
warning: target '@executable_path/../Frameworks/sfml-system.framework/
Versions/2.0.0/sfml-system' does not exist...
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/
usr/bin/otool: can't open file: @executable_path/../Frameworks/
sfml-system.framework/Versions/2.0.0/sfml-system (No such file or directory)
otool: can't open file: @executable_path/../Frameworks/
sfml-system.framework/Versions/2.0.0/sfml-system
(No such file or directory)

Does anyone know how to resolve this issue?  FIXUP_BUNDLE seems like it could be
a very useful function, so hopefully I am just using it incorrectly.  I scoured the internet
for a solution, but had no luck.



More information about the CMake mailing list