[CMake] Help with fixup_bundle for Mac OS - @executable_path, @loader_path, @rpath

Michael Jackson mike.jackson at bluequartz.net
Tue Feb 1 12:24:37 EST 2011


Basically you need to implement the following cmake function:

function(gp_item_default_embedded_path_override item default_embedded_path_var)

You can set to use @executable_path or @loader_path or what ever you really want in there.

which BundleUtilities will use if it finds it. The trick here is that where you write the function needs to be available at "install" time. What some projects do (including mine) is to create a template file (CompleteOSXBundle.cmake.in) that has your own implementation of the function along with the appropriate calls to fixup_bundle(). The you use this file as an argument to the following piece of code:

install(SCRIPT "${OSX_MAKE_STANDALONE_BUNDLE_CMAKE_SCRIPT}" COMPONENT "Applications")

The entire template that I use can be found at:

<http://scm.bluequartz.net/support-libraries/cmp/blobs/master/OSX_Tools/CompleteBundle.cmake.in>

which is configured from <http://scm.bluequartz.net/support-libraries/cmp/blobs/master/cmpCMakeMacros.cmake> in the function "BuildQtAppBundle"

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



On Feb 1, 2011, at 11:39 AM, Scott Fowler wrote:

> I have an application "Foo" which distributes a plugin for a separate application "Bar".  My plugin is dependent on libraries distributed with application "Foo".  When application "Bar" tries to load the plugin, the plugin will not load, as it cannot find the libraries distributed with "Foo".
>  
> As far as I can tell this boils down to the @executable_path reference which fixup_bundle inserts into my binaries.
>  
> >otool -L plugin.dylib
> @executable_path/../MacOS/libsomedependency.dylib
> @executable_path/../MacOS/libsomeotherdependency.dylib
> etc...
>  
> When application "Bar" loads my plugin, I'm assuming that @executable_path resolves to the location of "Bar", but the plugin's dependent libraries are in Foo.app/Contents/MacOS, not in Bar.app/Contents/MacOS.
>  
> All this leads me to believe that I should be using @loader_path or @rpath instead, but I don't see a way to do this using CMake as it appears that BundleUtilities.cmake and GetPrerequisites.cmake are hardcoded to use @executable_path.
>  
> Any advice would be greatly appreciated.
>  
> Thanks!
> Scott
> 
> This e-mail and any files transmitted with it are confidential and are intended solely for the use of the individual or entity to whom they are addressed. If you are NOT the intended recipient or the person responsible for delivering the e-mail to the intended recipient, be advised that you have received this e-mail in error and that any use, dissemination, forwarding, printing or copying this e-mail is strictly prohibited.
> _______________________________________________
> 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