[cmake-developers] rpaths on Mac

Clinton Stimpson clinton at elemtech.com
Mon Nov 21 16:06:19 EST 2011


On Monday, November 21, 2011 01:41:57 pm James Bigler wrote:
> Would what you are proposing make the following easier?  This is how I
> setup @rpath on my system.
> 
> Why do you need something special?  I use @rpath for the install name by
> doing the following:
> 
>   if(RELEASE_PUBLIC)
>     set_target_properties( my_target PROPERTIES
>       INSTALL_NAME_DIR "@rpath"
>       BUILD_WITH_INSTALL_RPATH ON
>       )
>   endif()
> 
> Then I do the following for my executables:
> 
>     if( RELEASE_INSTALL_BINARY_SAMPLES )
>       target_link_libraries( ${target_name}
>         -Wl,-rpath, at executable_path/.
>         -Wl,-rpath, at executable_path/../../lib
>         )
>     elseif( RELEASE_PUBLIC)
>       target_link_libraries( ${target_name}
>         -Wl,-rpath, at executable_path/../lib
>         )
>     endif()
> 
> I also have some code to do some special stuff for BundleUtilities, but I'm
> not sure if it's related to the rpath stuff.

Yes, it'll be simpler.  You'll be able to avoid setting the link flags like 
that.  Instead you can do
set_target_properties(${target_name} PROPERTIES INSTALL_RPATH 
"@executable_path")
which is similar to Linux's
set_target_properties(${target_name} PROPERTIES INSTALL_RPATH "\$ORIGIN")

BUILD_WITH_INSTALL_RPATH will then become optional.

Then perhaps we can make 
INSTALL_NAME_DIR=@rpath be the default.

-- 
Clinton Stimpson
Elemental Technologies, Inc
Computational Simulation Software, LLC
www.csimsoft.com



More information about the cmake-developers mailing list