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

Scott Fowler s.fowler at tecplot.com
Tue Feb 1 13:19:21 EST 2011


How well does @loader_path work with line 372 in BundleUtilities.cmake?  It doesn't seem to make any allowances for @loader_path or @rpath.

    string(REPLACE "@executable_path" "${exepath}" resolved_embedded_item "${embedded_item}")
    get_filename_component(resolved_embedded_item "${resolved_embedded_item}" ABSOLUTE)

Scott

-----Original Message-----
From: Sean McBride [mailto:sean at rogue-research.com]
Sent: Tuesday, February 01, 2011 9:26 AM
To: Scott Fowler; cmake at cmake.org
Subject: Re: [CMake] Help with fixup_bundle for Mac OS - @executable_path, @loader_path, @rpath

On Tue, 1 Feb 2011 08:39:08 -0800, Scott Fowler said:

>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.

Install names are such a PITA.  Here's a great overview:
<http://www.mikeash.com/pyblog/friday-qa-2009-11-06-linking-and-install-
names.html>

@loader_path was added in 10.4, and assuming you don't need to support
anything older, you should never use @executable_path because
@loader_path is the same or better.  Not sure if it will solve your
problem though.

--
____________________________________________________________
Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada



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.


More information about the CMake mailing list