[CMake] How do folks work with rpath on OS X using cmake?

Clinton Stimpson clinton at elemtech.com
Mon Apr 11 17:15:22 EDT 2011


On Monday, April 11, 2011 01:49:21 pm John R. Cary wrote:
> Scenario:
> 
> A library libA.dylib is found somewhere in the building of
> executable B.  Doing the typical link, otool -L shows that B
> references:
> 
>    libA.dylib
> 
> or possibly
> 
>    /A/prefix/lib/libA.dylib.
> 
> I want B to run from either the build directory or the
> installation directory, which I want to be portable.
> 
> A possible solution is to have libA.dylib encoded into B as:
> 
>    @rpath/libA.dylib
> 
> and then to put  @loader_path/ and /A/installdir/lib
> into the rpath of B, and finally to install libA.dylib
> alongside B.
> 
> What is the best way to get this done using CMake?
> 
> What other approaches are there to this basic problem?
> 
> Thx.....John Cary


You could do something like this in your CMakeLists.txt file.
IF(APPLE)
  SET(CMAKE_INSTALL_NAME_DIR @executable_path)
  SET(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
ENDIF(APPLE)

Or use BundleUtilities script when you create an install.

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


More information about the CMake mailing list