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

John R. Cary cary at txcorp.com
Mon Apr 11 15:49:21 EDT 2011


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


More information about the CMake mailing list