[CMake] macosx fix bundle problems

Petr Vanek petr at scribus.info
Thu Sep 10 10:02:13 EDT 2009


cool, thanks. It's working now. I had to play with order of the steps  
in install procedure. Something should go before fix_bundle call,  
something after. But plugins are packed together and contains correct  
(otool -L) paths.

But - all plugins are stored in my.app/Contents/MacOS dir and aren't  
loaded even if I set qt.conf file - paths setup.

It's strange, that plugins are "*.bundle" and not "*.dylib" or "*.so",  
but it's mac and it's still full of secret for me.

Shouldn't be set some more env variables? Or anything else?

all the best,
Petr

detailed info:

these are steps before "bundle fix" - note that plugins are copied  
into Plugins dir in destination before fix:
        install(DIRECTORY ${QT_PLUGINS_DIR}/
                DESTINATION ${PROJECT_BINARY_DIR}/Contents/Plugins/
                REGEX "(designer|script|phonon_backend|debug|sqlite)"  
EXCLUDE)

        install(CODE "
            # glob for previously installed qt plugins to include in  
fixup_bundle
            file(GLOB_RECURSE PluginList
                 ${PROJECT_BINARY_DIR}/Contents/Plugins/*.bundle)
        ")

and the final structure:

rimmer:release pvanek$ tree TOra.app
`-- TOra.app
    `-- Contents
        |-- Frameworks
        |   |-- QtCore.framework
        |   |   `-- Versions
        |   |       `-- 4
        |   |           `-- QtCore
        |   |-- QtGui.framework
        |   |   `-- Versions
        |   |       `-- 4
        |   |           `-- QtGui
        |   |-- QtNetwork.framework
        |   |   `-- Versions
        |   |       `-- 4
        |   |           `-- QtNetwork
        |   |-- QtOpenGL.framework
        |   |   `-- Versions
        |   |       `-- 4
        |   |           `-- QtOpenGL
        |   |-- QtSql.framework
        |   |   `-- Versions
        |   |       `-- 4
        |   |           `-- QtSql
        |   |-- QtSvg.framework
        |   |   `-- Versions
        |   |       `-- 4
        |   |           `-- QtSvg
        |   `-- QtXml.framework
        |       `-- Versions
        |           `-- 4
        |               `-- QtXml
        |-- Info.plist
        |-- Libraries
        |   |-- libcrypto.0.9.8.dylib
        |   |-- libiconv.2.dylib
        |   |-- libjpeg.62.dylib
        |   |-- liblcms.1.dylib
        |   |-- libmng.1.dylib
        |   |-- libmysqlclient_r.15.dylib
        |   |-- libodbc.1.dylib
        |   |-- libpng12.0.dylib
        |   |-- libpq.5.dylib
        |   |-- libqscintilla2.5.dylib
        |   |-- libssl.0.9.8.dylib
        |   |-- libtiff.3.dylib
        |   `-- libz.1.dylib
        |-- MacOS
        |   |-- TOra
        |   |-- libclntsh.dylib.10.1
        |   |-- libocci.dylib.10.1
        |   |-- libqcncodecs.bundle
        |   |-- libqgif.bundle
        |   |-- libqglgraphicssystem.bundle
        |   |-- libqico.bundle
        |   |-- libqjpcodecs.bundle
        |   |-- libqjpeg.bundle
        |   |-- libqkrcodecs.bundle
        |   |-- libqmng.bundle
        |   |-- libqsqlmysql.bundle
        |   |-- libqsqlodbc.bundle
        |   |-- libqsqlpsql.bundle
        |   |-- libqsvg.bundle
        |   |-- libqsvgicon.bundle
        |   |-- libqtaccessiblewidgets.bundle
        |   |-- libqtiff.bundle
        |   `-- libqtwcodecs.bundle
        |-- Resources
        |   |-- qt.conf
        |   |-- qt_menu.nib
        |   |   |-- classes.nib
        |   |   |-- info.nib
        |   |   `-- keyedobjects.nib
        |   `-- tora.icns
        `-- Support

rimmer:release pvanek$ cat TOra.app/Contents/Resources/qt.conf
[Paths]
Plugins = MacOS


On Sep 9, 2009, at 5:22 PM, Clinton Stimpson wrote:

>
>
> To install Qt plugins you can do something like the following.  You  
> can tweak
> the regex to pick which plugins you want.
> # include Qt plugins
> install(DIRECTORY ${QT_PLUGINS_DIR}
>       DESTINATION ${CMAKE_INSTALL_BINARY_DIR}
>       COMPONENT Runtime
>       REGEX "(.debug|d4.dll|designer|.exp|.lib|.ilk|.pdb)" EXCLUDE )
>
>
> I also specify the Qt plugins when calling fixup_bundle() so  
> rerequisites
> needed for plugins get satisfied as well.  For example, an image  
> plugin may
> need QtSvg while you application does not.
>
> install(CODE "
>  # glob for previously installed qt plugins to include in fixup_bundle
>  file(GLOB_RECURSE QT_PLUGINS
> \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINARY_DIR}/plugins/*$ 
> {CMAKE_SHARED_LIBRARY_SUFFIX}\")
>  ...
>  fixup_bundle(\"${app}\"  \"\${QT_PLUGINS}\" ....)
>
> Clint
>
> On Wednesday 09 September 2009 09:10:31 am Petr Vanek wrote:
>> yup. The reaso was really in splitted CMakeListst.txt files. It looks
>> like app is "fixed" now - from otool -L point of view.
>>
>> Of course it required more tweaking - add and empty qt.conf to  
>> prevent
>> duplication of libs/frameworks etc. But it's much more clearer now.
>>
>> BTW is there any script/template for cmake to find and bundle all
>> required (or specified) qt plugins? Something like macdeployqt. Or
>> should I use this binary instead of scripting?
>>
>> thanks and cheers!
>> Petr
>>
>> On Sep 8, 2009, at 11:22 PM, David Cole wrote:
>>> These lines of output near the beginning:
>>>
>>> -- warning: *NOT* handled - .app directory case...
>>> -- error: fixup_bundle: not a valid bundle
>>>
>>> ...indicate that fixup_bundle is not getting a .app bundle as its
>>> input...
>>>
>>> The assumption made by fixup_bundle is that there is an executable
>>> in the .app/Contents/MacOS folder to begin analyzing. Then, based on
>>> what its prerequisites are, various libraries get copied into the
>>> bundle as well. This output looks like that initial executable is
>>> not there yet.
>>>
>>> Looks like your "INSTALL(SCRIPT" snippet occurs before the install
>>> rule for the bundle executable. Make sure they both occur in the
>>> same CMakeLists.txt file and that the script snippet comes after the
>>> install rule for the executable. Then it should work like you
>>> expect...
>>>
>>>
>>> HTH,
>>> David
>>>
>>>
>>> On Sat, Sep 5, 2009 at 4:15 PM, Petr Vanek <petr at scribus.info>  
>>> wrote:
>>> hi all,
>>>
>>> I have a Qt4 application with bundle build support taken from cmake
>>> wiki example.
>>>
>>> When I run "deploy" phase with make install, the correct structure
>>> is created in CMAKE_INSTALL_PREFIX.
>>>
>>> But it looks like cmake's fixup_bundle function from BundleUtilities
>>> does its job only partially.
>>>
>>> All Qt frameworks are fixed correctly to use @executable_path, but
>>> the main binary still contains links to my development environment.
>>>
>>> What could be the issue?
>>>
>>> thanks,
>>> Petr Vanek
>>>
>>>
>>> code:
>>> http://tora.svn.sourceforge.net/viewvc/tora/trunk/tora/
>>>
>>> 1st make install run:
>>>
>>> rimmer:build-bundle pvanek$ make install
>>> [  1%] Built target tora_loki_lib
>>> [100%] Built target tora
>>> Install the project...
>>> -- Install configuration: "RELEASE"
>>> Removing Previous TOra.app bundle at /Users/pvanek/oss/tora/bundle/
>>> Copying TOra.app from the build tree to /Users/pvanek/oss/tora/ 
>>> bundle/
>>> -- fixup_bundle
>>> --   app='/Users/pvanek/oss/tora/bundle/TOra.app'
>>> --   libs=''
>>> --   dirs='Plugins'
>>> -- warning: *NOT* handled - .app directory case...
>>> -- error: fixup_bundle: not a valid bundle
>>> -- fixup_bundle: done
>>> CMake Warning (dev) at cmake_install.cmake:31 (INCLUDE):
>>> Policy CMP0011 is not set: Included scripts do automatic
>>> cmake_policy PUSH
>>> and POP.  Run "cmake --help-policy CMP0011" for policy details.  Use
>>> the
>>> cmake_policy command to set the policy and suppress this warning.
>>>
>>> The included script
>>>
>>> /Users/pvanek/oss/tora/trunk/tora/build-bundle/
>>> TOra_OSX_MakeStandAloneBundle.cmake
>>>
>>> affects policy settings.  CMake is implying the NO_POLICY_SCOPE
>>> option for
>>> compatibility, so the effects are applied to the including context.
>>> This warning is for project developers.  Use -Wno-dev to suppress  
>>> it.
>>>
>>> -- Installing: /Users/pvanek/oss/tora/bundle/tora.app
>>> -- Installing: /Users/pvanek/oss/tora/bundle/tora.app/Contents
>>> -- Installing: /Users/pvanek/oss/tora/bundle/tora.app/Contents/
>>> Info.plist
>>> -- Installing: /Users/pvanek/oss/tora/bundle/tora.app/Contents/MacOS
>>> -- Installing: /Users/pvanek/oss/tora/bundle/tora.app/Contents/ 
>>> MacOS/
>>> tora
>>> -- Installing: /Users/pvanek/oss/tora/bundle/tora.app/Contents/
>>> Resources
>>> -- Installing: /Users/pvanek/oss/tora/bundle/tora.app/Contents/
>>> Resources/tora.icns
>>>
>>> 2nd make install
>>> rimmer:build-bundle pvanek$ make install
>>> [  1%] Built target tora_loki_lib
>>> [100%] Built target tora
>>> Install the project...
>>> -- Install configuration: "RELEASE"
>>> Removing Previous TOra.app bundle at /Users/pvanek/oss/tora/bundle/
>>> Copying TOra.app from the build tree to /Users/pvanek/oss/tora/ 
>>> bundle/
>>> -- fixup_bundle
>>> --   app='/Users/pvanek/oss/tora/bundle/TOra.app'
>>> --   libs=''
>>> --   dirs='Plugins'
>>> -- fixup_bundle: preparing...
>>> -- fixup_bundle: copying...
>>> -- 1/28: *NOT* copying '/Users/pvanek/oss/tora/bundle/TOra.app/
>>> Contents/MacOS/tora'
>>> -- 2/28: copying '/opt/local/lib/libcrypto.0.9.8.dylib'
>>> -- 3/28: copying '/opt/local/lib/libpng12.0.dylib'
>>> -- 4/28: copying '/opt/local/lib/libssl.0.9.8.dylib'
>>> -- 5/28: copying '/opt/local/lib/libz.1.dylib'
>>> -- 6/28: copying '/opt/local/lib/oracle/libclntsh.dylib.10.1'
>>> -- 7/28: copying '/opt/local/lib/oracle/libocci.dylib.10.1'
>>> -- 8/28: copying '/opt/local/lib/postgresql83/libpq.5.dylib'
>>> -- 9/28: copying '/opt/local/libexec/qt4-mac/lib/QtCore.framework/
>>> Versions/4/QtCore'
>>> -- 10/28: copying '/opt/local/libexec/qt4-mac/lib/QtGui.framework/
>>> Versions/4/QtGui'
>>> -- 11/28: copying '/opt/local/libexec/qt4-mac/lib/
>>> QtNetwork.framework/Versions/4/QtNetwork'
>>> -- 12/28: copying '/opt/local/libexec/qt4-mac/lib/QtSql.framework/
>>> Versions/4/QtSql'
>>> -- 13/28: copying '/opt/local/libexec/qt4-mac/lib/QtXml.framework/
>>> Versions/4/QtXml'
>>> -- 14/28: copying '/opt/local/libexec/qt4-mac/lib/
>>> libqscintilla2.5.dylib'
>>> -- fixup_bundle: fixing...
>>> -- 15/28: fixing up '/Users/pvanek/oss/tora/bundle/TOra.app/ 
>>> Contents/
>>> MacOS/tora'
>>> -- 16/28: fixing up '/Users/pvanek/oss/tora/bundle/TOra.app/ 
>>> Contents/
>>> Libraries/libcrypto.0.9.8.dylib'
>>> -- 17/28: fixing up '/Users/pvanek/oss/tora/bundle/TOra.app/ 
>>> Contents/
>>> Libraries/libpng12.0.dylib'
>>> -- 18/28: fixing up '/Users/pvanek/oss/tora/bundle/TOra.app/ 
>>> Contents/
>>> Libraries/libssl.0.9.8.dylib'
>>> -- 19/28: fixing up '/Users/pvanek/oss/tora/bundle/TOra.app/ 
>>> Contents/
>>> Libraries/libz.1.dylib'
>>> -- 20/28: fixing up '/Users/pvanek/oss/tora/bundle/TOra.app/ 
>>> Contents/
>>> MacOS/libclntsh.dylib.10.1'
>>> -- 21/28: fixing up '/Users/pvanek/oss/tora/bundle/TOra.app/ 
>>> Contents/
>>> MacOS/libocci.dylib.10.1'
>>> -- 22/28: fixing up '/Users/pvanek/oss/tora/bundle/TOra.app/ 
>>> Contents/
>>> Libraries/libpq.5.dylib'
>>> -- 23/28: fixing up '/Users/pvanek/oss/tora/bundle/TOra.app/ 
>>> Contents/
>>> Frameworks/QtCore.framework/Versions/4/QtCore'
>>> -- 24/28: fixing up '/Users/pvanek/oss/tora/bundle/TOra.app/ 
>>> Contents/
>>> Frameworks/QtGui.framework/Versions/4/QtGui'
>>> -- 25/28: fixing up '/Users/pvanek/oss/tora/bundle/TOra.app/ 
>>> Contents/
>>> Frameworks/QtNetwork.framework/Versions/4/QtNetwork'
>>> -- 26/28: fixing up '/Users/pvanek/oss/tora/bundle/TOra.app/ 
>>> Contents/
>>> Frameworks/QtSql.framework/Versions/4/QtSql'
>>> -- 27/28: fixing up '/Users/pvanek/oss/tora/bundle/TOra.app/ 
>>> Contents/
>>> Frameworks/QtXml.framework/Versions/4/QtXml'
>>> -- 28/28: fixing up '/Users/pvanek/oss/tora/bundle/TOra.app/ 
>>> Contents/
>>> Libraries/libqscintilla2.5.dylib'
>>> -- fixup_bundle: cleaning up...
>>> -- fixup_bundle: verifying...
>>> --
>>> =
>>> =
>>> =
>>> =
>>> =
>>> = 
>>> = 
>>> ====================================================================
>>> -- Analyzing app='/Users/pvanek/oss/tora/bundle/TOra.app'
>>> -- bundle='/Users/pvanek/oss/tora/bundle/TOra.app'
>>> -- executable='/Users/pvanek/oss/tora/bundle/TOra.app/Contents/ 
>>> MacOS/
>>> tora'
>>> -- valid='1'
>>> -- executable file: /Users/pvanek/oss/tora/bundle/TOra.app/Contents/
>>> MacOS/tora
>>> -- verified='1'
>>> -- info='Verified 1 executable files in '/Users/pvanek/oss/tora/
>>> bundle/TOra.app''
>>> --
>>> -- verified='1'
>>> -- info=''
>>> --
>>> -- fixup_bundle: done
>>> CMake Warning (dev) at cmake_install.cmake:31 (INCLUDE):
>>> Policy CMP0011 is not set: Included scripts do automatic
>>> cmake_policy PUSH
>>> and POP.  Run "cmake --help-policy CMP0011" for policy details.  Use
>>> the
>>> cmake_policy command to set the policy and suppress this warning.
>>>
>>> The included script
>>>
>>> /Users/pvanek/oss/tora/trunk/tora/build-bundle/
>>> TOra_OSX_MakeStandAloneBundle.cmake
>>>
>>> affects policy settings.  CMake is implying the NO_POLICY_SCOPE
>>> option for
>>> compatibility, so the effects are applied to the including context.
>>> This warning is for project developers.  Use -Wno-dev to suppress  
>>> it.
>>>
>>> -- Installing: /Users/pvanek/oss/tora/bundle/tora.app
>>> -- Installing: /Users/pvanek/oss/tora/bundle/tora.app/Contents
>>> -- Up-to-date: /Users/pvanek/oss/tora/bundle/tora.app/Contents/
>>> Info.plist
>>> -- Installing: /Users/pvanek/oss/tora/bundle/tora.app/Contents/MacOS
>>> -- Installing: /Users/pvanek/oss/tora/bundle/tora.app/Contents/ 
>>> MacOS/
>>> tora
>>> -- Installing: /Users/pvanek/oss/tora/bundle/tora.app/Contents/
>>> Resources
>>> -- Up-to-date: /Users/pvanek/oss/tora/bundle/tora.app/Contents/
>>> Resources/tora.icns
>>>
>>>
>>>
>>> rimmer:build-bundle pvanek$ otool -L ~/oss/tora/bundle/TOra.app/
>>> Contents/MacOS/tora
>>> /Users/pvanek/oss/tora/bundle/TOra.app/Contents/MacOS/tora:
>>>    /opt/local/libexec/qt4-mac/lib/QtGui.framework/Versions/4/QtGui
>>> (compatibility version 4.5.0, current version 4.5.1)
>>>    /opt/local/lib/libpng12.0.dylib (compatibility version 39.0.0,
>>> current version 39.0.0)
>>>    /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
>>> (compatibility version 2.0.0, current version 136.0.0)
>>>    /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
>>> (compatibility version 45.0.0, current version 949.54.0)
>>>    /opt/local/libexec/qt4-mac/lib/QtXml.framework/Versions/4/QtXml
>>> (compatibility version 4.5.0, current version 4.5.1)
>>>    /opt/local/libexec/qt4-mac/lib/QtSql.framework/Versions/4/QtSql
>>> (compatibility version 4.5.0, current version 4.5.1)
>>>    /opt/local/libexec/qt4-mac/lib/QtNetwork.framework/Versions/4/
>>> QtNetwork (compatibility version 4.5.0, current version 4.5.1)
>>>    /usr/lib/libssl.0.9.7.dylib (compatibility version 0.9.7,
>>> current version 0.9.7)
>>>    /opt/local/libexec/qt4-mac/lib/QtCore.framework/Versions/4/
>>> QtCore (compatibility version 4.5.0, current version 4.5.1)
>>>    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current
>>> version 1.2.3)
>>>    /opt/local/lib/oracle/libocci.dylib.10.1 (compatibility version
>>> 0.0.0, current version 0.0.0)
>>>    /opt/local/lib/oracle/libclntsh.dylib.10.1 (compatibility
>>> version 0.0.0, current version 0.0.0)
>>>    /opt/local/libexec/qt4-mac/lib/libqscintilla2.5.dylib
>>> (compatibility version 5.1.0, current version 5.1.0)
>>>    /opt/local/lib/postgresql83/libpq.5.dylib (compatibility
>>> version 5.0.0, current version 5.1.0)
>>>    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0,
>>> current version 7.4.0)
>>>    /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current
>>> version 1.0.0)
>>>    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0,
>>> current version 111.1.4)
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the CMake FAQ at:
>>> http://www.cmake.org/Wiki/CMake_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.cmake.org/mailman/listinfo/cmake
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
>



More information about the CMake mailing list