[CMake] Problems to use fixup_bundle on Mac OS X

Romain LEGUAY romain.leguay at gmail.com
Tue May 13 08:32:11 EDT 2014


Hello everyone,
I try to build a small Qt application (helloGUI) with a shared library (hello).
Here is my application and library tree:
├── CMakeLists.txt
├── gui
│   ├── CMakeLists.txt
│   ├── bundle.cmake
│   ├── include
│   │   └── MainWindow.hpp
│   ├── src
│   │   ├── MainWindow.cpp
│   │   └── main.cpp
│   └── ui
│       └── mainwindow.ui
└── lib
    ├── CMakeLists.txt
    ├── Hello.cpp
    └── Hello.h

My root CMakeLists.txt add the two sub directory: lib then gui.
The lib CMakeLists.txt build a shared library (.dylib) and installed it inside ${CMAKE_INSTALL_PREFIX}/helloGUI.app/Contents/Libraries.
The gui CMakeLists.txt build my Qt bundle (helloGUI.app) and installed it inside ${CMAKE_INSTALL_PREFIX} then launch the script bundle.cmake.
bundle.cmake contains:
include(BundleUtilities)
fixup_bundle("${CMAKE_INSTALL_PREFIX}/helloGUI.app" "${CMAKE_INSTALL_PREFIX}/helloGUI.app/Contents/Libraries/libHello.dylib" "lib")

If I don’t install it, my application works just fine. But after installation, I have some errors:

Install the project...
-- Install configuration: ""
-- Installing: /MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/Libraries/libHello.dylib
-- Installing: /MYPATH/TestQtCMake/build/install/./helloGUI.app
-- Installing: /MYPATH/TestQtCMake/build/install/./helloGUI.app/Contents
-- Installing: /MYPATH/TestQtCMake/build/install/./helloGUI.app/Contents/Info.plist
-- Installing: /MYPATH/TestQtCMake/build/install/./helloGUI.app/Contents/MacOS
-- Installing: /MYPATH/TestQtCMake/build/install/./helloGUI.app/Contents/MacOS/helloGUI
-- fixup_bundle
--   app='/MYPATH/TestQtCMake/build/install/helloGUI.app'
--   libs='/MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/Libraries/libHello.dylib'
--   dirs='lib'
-- fixup_bundle: preparing...
-- fixup_bundle: copying...
-- 1/10: *NOT* copying '/MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/Libraries/libHello.dylib'
-- 2/10: *NOT* copying '/MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/MacOS/helloGUI'
-- 3/10: copying '/Users/rleguay/Qt5.2.1/5.2.1/clang_64/lib/QtCore.framework/Versions/5/QtCore'
-- 4/10: copying '/Users/rleguay/Qt5.2.1/5.2.1/clang_64/lib/QtGui.framework/Versions/5/QtGui'
-- 5/10: copying '/Users/rleguay/Qt5.2.1/5.2.1/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets'
-- fixup_bundle: fixing...
-- 6/10: fixing up '/MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/Libraries/libHello.dylib'
-- 7/10: fixing up '/MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/MacOS/helloGUI'
-- 8/10: fixing up '/MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/Frameworks/QtCore.framework/Versions/5/QtCore'
-- 9/10: fixing up '/MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/Frameworks/QtGui.framework/Versions/5/QtGui'
-- 10/10: fixing up '/MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/Frameworks/QtWidgets.framework/Versions/5/QtWidgets'
-- fixup_bundle: cleaning up...
-- fixup_bundle: verifying...
-- ===========================================================================
-- Analyzing app='/MYPATH/TestQtCMake/build/install/helloGUI.app'
-- bundle='/MYPATH/TestQtCMake/build/install/helloGUI.app'
-- executable='/MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/MacOS/helloGUI'
-- valid='1'
-- executable file 1: /MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/MacOS/helloGUI
-- warning: embedded item does not exist '/MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/MacOS/libHello.dylib'
-- 
warning: cannot resolve item '@executable_path/../MacOS/libHello.dylib'

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

warning: target '@executable_path/../MacOS/libHello.dylib' is not absolute...
warning: target '@executable_path/../MacOS/libHello.dylib' does not exist...
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool: can't open file: @executable_path/../MacOS/libHello.dylib (No such file or directory)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool: can't open file: @executable_path/../MacOS/libHello.dylib (No such file or directory)
-- verified='1'
-- info='Verified 1 executable files in '/MYPATH/TestQtCMake/build/install/helloGUI.app''
-- 
-- verified='1'
-- info=''
-- 
-- fixup_bundle: done

I see that the script search libHello.dylib inside Contents/MacOS but I don’t understand why. 
Can we set this path please?

Thank you.

Best regards,
Romain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140513/602f4b73/attachment.html>


More information about the CMake mailing list