[CMake] Mac @loader_path for @rpath questions

Eric Wing ewmailing at gmail.com
Wed Jun 11 09:08:18 EDT 2014


On 5/24/14, clinton at elemtech.com <clinton at elemtech.com> wrote:
>
>
> ----- Original Message -----
>> I have a bunch of libraries and frameworks that properly use @rpath.
>> Now I am trying to build an application that uses those library and
>> frameworks via CMake.
>>
>> From this blog:
>> http://www.kitware.com/blog/home/post/510
>> I see I am supposed to do:
>> set(CMAKE_MACOSX_RPATH 1)
>
> The above should be set before declaring an @rpath target, which is one that
> has an install name with @rpath.

Okay, the ordering was one thing I screwed up. That was a major reason
it didn't work for me.



>
> Setting CMAKE_BUILD_WITH_INSTALL_RPATH should have an effect, if set before
> any targets that link with the @rpath libraries.
> Can you provide an example of what you are doing, so we can find out why its
> not working for you?

That was my ordering screw up. It's working now.


> I understand drag-and-drop, but it doesn't work for my situations.  I have
> several 3rd party libraries that are not in system locations, and are not
> part of the build tree, so setting CMAKE_BUILD_WITH_INSTALL_RPATH breaks my
> builds.  Install time is where I get a complete .app bundle.

So 3rd party libraries should be bundled in the .app. This avoids that
problem. Notice that a real/native Xcode project always does this copy
phase. I have this working for my stuff now with CMake using some
aggressive code I wrote. (Similar to the Visual Studio thread I was
in.)


> With a list.
> set_target_properties(bar PROPERTIES INSTALL_RPATH
>  "@loader_path/../Frameworks;@loader_path/../lib")

Didn't think of that. Thanks that worked.


>>
>> 3) What is the common way people copy their frameworks into their .app
>> bundle now-a-days?
>
> I do it at install time by setting the install destination to be inside the
> .app bundle.

Incidentally, I found BundleUtilities/fix_up_bundle, but it seems to
break if you use @rpath. It doesn't seem to do build time, but install
time, which is another problem for me.


Thanks,
Eric


More information about the CMake mailing list