[CMake] Use CMAKE_MACOSX_RPATH to link a library outside build tree

Oleg Zhylin ovz at yahoo.com
Mon Aug 24 15:14:35 EDT 2015


Thanks for your response Clint. 
I ended up copying my external library to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}. Works for my use case better than patching that external library that might get updated by a 3rd party installer.  WBR Oleg Zhylin ovz at yahoo.com 


     On Monday, August 24, 2015 7:22 AM, Clinton Stimpson <clinton at elemtech.com> wrote:
   

 On Sunday, August 23, 2015 04:46:17 AM Oleg Zhylin via CMake wrote:
> Hi All,
> I still need help with 0015708: Use CMAKE_MACOSX_RPATH to link a library
> outside build tree - MantisBT. Could you please suggest are there any CMake
> mechanisms to ensure a library outside build tree on mac is linked with
> either @rpath and using hard-coded path on build machine? Either option
> would actually help. 
> |  |
> |  |  |  |  |  |
> | 0015708: Use CMAKE_MACOSX_RPATH to link a library outside build tree -
> | MantisBTThis issue is Mac OS X specific. I would like to link a library
> | lib_xxx that sits outside my build tree at some arbitrary location. It
> | will be at the same location in all systems.  |
> | 
> | View on www.cmake.org | Preview by Yahoo |
> | 
> |  |
> 
>  WBR ovz

There is no CMake mechanism to control references when linking with external 
libraries.  If you still want to do this, you'll need to edit the references 
in your binaries after linking.


You'll be much better off if you modify the external libraries.

For @rpath, use a command like this:
<install_name_tool -id @rpath/libwupienginemac.dylib 
/path/to/libwupienginemac.dylib>

or

For absolute path
<install_name_tool -id /path/to/libwupienginemac.dylib 
/path/to/libwupienginemac.dylib>

If those external libraries have additional dependencies using 
@executable_path, you may also need to use "install_name_tool -change ..."

Clint


  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150824/478da7a6/attachment.html>


More information about the CMake mailing list