QMAKE_BUNDLE_DATA doesn’t bundle frameworks

Mon 16 December 2013, tagged: C++ Dev

I’ve been playing with building an App using qmake as the build system. I started with a simple QT App built using the wizard in QTCreator and tweaking it.

I ran in to the problem that I needed to copy the SFML frameworks in to the App Bundle. The QT docs say to use the variable QMAKE_BUNDLE_DATA to trigger the copy but I couldn’t get it to work in QT5.2.

1
2
3
4
5
mac{
    PRIVATE_FRAMEWORKS.files = /Users/dazza/work/SFML-2.1-osx-clang-universal/Frameworks/sfml-audio.framework
    PRIVATE_FRAMEWORKS.path = Contents/Frameworks
    QMAKE_BUNDLE_DATA += PRIVATE_FRAMEWORKS
}

No matter what I tried I couldn’t trigger the copying of the framework.

The work around I came up with involves adding a post link step to copy the frameworks using ditto

1
2
3
4
5
6
7
mac{
    BUNDLE_DIR = $$OUT_PWD/$$TARGET$$quote(.app)/Contents
    QMAKE_POST_LINK += echo Copy Frameworks; \
                   mkdir -p $$BUNDLE_DIR/Frameworks;\
                   ditto \"/Users/dazza/work/SFML-2.1-osx-clang-universal/Frameworks/\" \"$$BUNDLE_DIR/Frameworks\";\
                   ditto \"/Users/dazza/work/SFML-2.1-osx-clang-universal/extlibs/\" \"$$BUNDLE_DIR/Frameworks\";
}

The QMAKE_POST_LINK variable has a script to

  1. echo that it’s copying the frameworks across.
  2. make sure there is a framework directory in the App Bundle.
  3. Copy the SFML frameworks across.
  4. Copy the SFML external dependencies across.

Note I know there is a horrible hardcoded path in there that shouldn’t be there but this is just for testing!

Comments