[CMake] BundleUtilities

Michael Jackson mike.jackson at bluequartz.net
Wed Nov 17 09:32:45 EST 2010


I tool a little different approach in my own projects. I end up  
"configuring" a shell script that gets run at install time (OS X  
Only). Inside that shell script are all the copying to the  
CMAKE_INSTALL_PREFIX, ensuring destination directories inside the OS X  
App bundle are setup (Plugins, libs, Frameworks) and then finally  
calling the BundleUtilities to copy all the dependent libraries and  
plugins into the App bundle and "fixing" the install_name embedded in  
each library so that they point to libraries inside the bundle. For Qt  
projects I also make sure a blank qt.conf file and qtmenu.nib file are  
properly copied into the bundle.

   There are some "dark" issues when it comes to plugins. The basic  
BundleUtilities will look for files that end with .dylib (on OS X) and  
copy those to the "lib" directory and frameworks into the Framework  
directory. The issue for me was when I had plugins with .dylib file  
extensions these would always be copied into the wrong directory. I  
had to make sure I used a set properties to set the file extension of  
my own plugins to .plugin so I had a guaranteed way to tell the  
difference between a support library that should go into "lib" and a  
plugin that should get copied into Plugins. One form of this can be  
found at <http://scm.bluequartz.net/support-libraries/cmp/blobs/master/OSX_Tools/CompleteBundle.cmake.in 
 >
   There may be some Qt specific lines in the file and it is OS X  
specific. Also note that you can over-ride some of the BundleUtilities  
commands in order to implement variations that suit your own needs.

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



On Nov 17, 2010, at 7:52 AM, David Doria wrote:

> Tyler,
>
> You seem to be right in that I should not escape the $, but I DID need
> to add "DESTINATION bin". Without it, I got a:
>
> CMake Error at CMakeLists.txt:23 (INSTALL):
>  install FILES given no DESTINATION!
>
> This seems to work:
> INSTALL(FILES "${VTK_DIR}/bin/libvtkHybrid.a" DESTINATION bin)
>
> The package generated is 2MB, so I'm assuming it worked? How would you
> test a package on a machine that DOES have the library installed and
> configured?
>
> David,
>
> Thanks for the history. It sounds like an excellent goal (and what I
> was looking for when I stumbled across it). Now we just need to ensure
> people know how to use it :)
>
> Now that I have a working version of the "manual" way (
> INSTALL(FILES... ) ), I would like to convert it to the "automatic"
> way (INSTALL(CODE...) )
>
> This is the relevant line from the Qt example:
>
> INSTALL(CODE "
>    file(GLOB_RECURSE QTPLUGINS
>      \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/plugins/*$ 
> {CMAKE_SHARED_LIBRARY_SUFFIX}\")
>    include(BundleUtilities)
>    fixup_bundle(\"${APPS}\" \"\${QTPLUGINS}\" \"${DIRS}\")
>    " COMPONENT Runtime)
>
> Can someone decode this? The reason I thought the Qt example was not
> very general is that this line looks like it is very Qt specific
> (dealing with plugins and what not).
>
> Can you explain the syntax "line by line":
>
> INSTALL(CODE  - start the automatic library search
>
> file(GLOB_RECURSE - look for files
> QTPLUGINS - what is this?
>
> \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/plugins/*$ 
> {CMAKE_SHARED_LIBRARY_SUFFIX}\")
> - ???
>
> include(BundleUtilities) - Just copy and paste this every time?
>
> fixup_bundle(\"${APPS}\" \"\${QTPLUGINS}\" \"${DIRS}\") - what is
> fixup_bundle? What is the APPS and DIRS variable?
>
> " COMPONENT Runtime) - What is the COMPONENT? What else would it be  
> but Runtime?
>
> Sorry for the lengthy email, but I think we should try to get this
> ironed out so I can make some more examples :)
>
> Thanks,
>
> David
> _______________________________________________
> 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