[CMake] Problem with QtTest Bundle Utility Example?

Michael Jackson mike.jackson at bluequartz.net
Fri Mar 12 16:08:03 EST 2010


___________________________________________________________
Mike Jackson                      www.bluequartz.net
Principal Software Engineer       mike.jackson at bluequartz.net
BlueQuartz Software               Dayton, Ohio


On Mar 12, 2010, at 4:01 PM, Bradley Lowekamp wrote:

> Thanks for the prompt answer. This looks like a quick fix.
>
> The other problem I narrowed down (the actual reason the QTest.app  
> failed to launch) is that the Cocoa build requires Resources that  
> are not copied. So it's exiting with the following error:
>
> Qt internal error: qt_menu.nib could not be loaded. The .nib file  
> should be placed in QtGui.framework/Versions/Current/Resources/  or  
> in the resources directory of your application bundle.
> Abort trap
>
> Which makes me really wonder if this bundle utility is ready for  
> prime time?
>
> Brad
>

I am including a complete file that gets "configured" from a template  
for my Qt projects. The QtTest does not quite follow what I do, but we  
all generally get to the same ending. Use/Abuse/Ask questions.

http://www.bluequartz.net/cgi-bin/gitweb/gitweb.cgi?p=EmMpmGUI.git;a=summary

  Then go to Resources/OSX_Tools. The project isn't the best use of  
CMake but it works. Eventually I am going to clean it up. Any ways,  
you can probably follow what I am doing during "CMake Time".


#-------------------------------------------------------------------------------------
message (STATUS "#------------ Starting OS X Bundle Fixup  
--------------------------")
cmake_minimum_required(VERSION 2.6)

#-- Need this for link line stuff?
if(COMMAND cmake_policy)
   cmake_policy(SET CMP0009 NEW)
endif(COMMAND cmake_policy)


if (${CMAKE_VERSION} VERSION_GREATER 2.6.2)
if(COMMAND cmake_policy)
   cmake_policy(SET CMP0011 NEW)
endif(COMMAND cmake_policy)
endif()

# gp_item_default_embedded_path item default_embedded_path_var
#
# Return the path that others should refer to the item by when the item
# is embedded inside a bundle.
#
# Override on a per-project basis by providing a project-specific
# gp_item_default_embedded_path_override function.
#
function(gp_item_default_embedded_path_override item  
default_embedded_path_var)
   #
   # The assumption here is that all executables in the bundle will be
   # in same-level-directories inside the bundle. The parent directory
   # of an executable inside the bundle should be MacOS or a sibling of
   # MacOS and all embedded paths returned from here will begin with
   # "@executable_path/../" and will work from all executables in all
   # such same-level-directories inside the bundle.
   #

   # By default, embed things right next to the main bundle executable:
   #
   set(path "@executable_path/../../Contents/MacOS")

   set(overridden 0)
   # For Qt Based Plugins for the image formats, the plugins MUST  
reside in
   # the "PlugIns/imageformats" directory. Since THIS particular  
project ONLY has
   # the Qt Frameworks AND the plugins the below regex will suffice to  
separate
   # them from each other. On other projects we could use better logic  
to
   # put things where they go. Maybe using some "configured" CMake  
List of libraries
   # then looking through each list for the currect library being  
fixed up.
   # Embed .dylibs right next to the main bundle executable:
   #
   if(item MATCHES "\\.dylib$")
     set(path "@executable_path/../PlugIns/imageformats")
     set(overridden 1)
   endif(item MATCHES "\\.dylib$")

   # Embed .so right next to the main bundle executable:
   #
   if(item MATCHES "\\.so$")
     set(path "@executable_path/../Plugins/imageformats")
     set(overridden 1)
   endif(item MATCHES "\\.so$")

   # Embed frameworks in the embedded "Frameworks" directory (sibling  
of MacOS):
   #
   if(NOT overridden)
     if(item MATCHES "[^/]+\\.framework/")
       set(path "@executable_path/../Frameworks")
       set(overridden 1)
     endif(item MATCHES "[^/]+\\.framework/")
   endif(NOT overridden)

   set(${default_embedded_path_var} "${path}" PARENT_SCOPE)
endfunction(gp_item_default_embedded_path_override)


#-- Be sure all the internal directories are created first before  
calling the 'fixup_bundle'
#file(MAKE_DIRECTORY "/Users/Shared/Toolkits/EmMpm/QEmMpm_debug.app/ 
Contents/Libraries")
file(MAKE_DIRECTORY "/Users/Shared/Toolkits/EmMpm/QEmMpm_debug.app/ 
Contents/Plugins")
file(MAKE_DIRECTORY "/Users/Shared/Toolkits/EmMpm/QEmMpm_debug.app/ 
Contents/Frameworks")
#file(MAKE_DIRECTORY "/Users/Shared/Toolkits/EmMpm/QEmMpm_debug.app/ 
Contents/Support")

#--------------------------------------------------------------------------------
# install a qt.conf file
# this inserts some cmake code into the install script to write the file
file(WRITE "/Users/Shared/Toolkits/EmMpm/QEmMpm_debug.app/Contents/ 
Resources/qt.conf" "")

#-- Check for Qt4 stuff
if ("1" STREQUAL "1")
   message(STATUS "Copying qt_menu.nib into QEmMpm_debug.app/Contents/ 
Resources")
   file(MAKE_DIRECTORY "/Users/Shared/Toolkits/EmMpm/QEmMpm_debug.app/ 
Contents/Resources/qt_menu.nib")
   execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "/Users/ 
Shared/Toolkits/Qt-4.6.1-UBFramework/lib/QtGui.framework/Resources/ 
qt_menu.nib" "/Users/Shared/Toolkits/EmMpm/QEmMpm_debug.app/Contents/ 
Resources/qt_menu.nib")
endif()

set (QTPLUGINS "/Users/Shared/Toolkits/Qt-4.6.1-UBFramework/plugins/ 
imageformats/libqgif.dylib;/Users/Shared/Toolkits/Qt-4.6.1-UBFramework/ 
plugins/imageformats/libqjpeg.dylib;/Users/Shared/Toolkits/Qt-4.6.1- 
UBFramework/plugins/imageformats/libqtiff.dylib")

# -- Run the BundleUtilities cmake code
include(BundleUtilities)
fixup_bundle("/Users/Shared/Toolkits/EmMpm/QEmMpm_debug.app" "$ 
{QTPLUGINS}" "/Users/Shared/Toolkits/Qt-4.6.1-UBFramework/plugins/ 
imageformats")

message (STATUS "#------------ End OS X Bundle Fixup  
--------------------------")



More information about the CMake mailing list