[CMake] CPack and install_name_tool on the Mac

Brad King brad.king at kitware.com
Fri Jun 16 14:36:17 EDT 2006


Karl Merkley wrote:
> 
> On Jun 16, 2006, at 11:47 AM, Brad King wrote:
> 
>> Karl Merkley wrote:
>>
>>> Does CPack have any ability to help with the install_name_tool on  
>>> the  Mac?  Mac applications avoid DLL hell by creating an  
>>> application  bundle that is really a directory structure that  
>>> includes the  application, the resources, and the shared libraries  
>>> used by the  application.   My understanding is that the  
>>> install_name_tool  essentially modifies the RPATH of the  distributed 
>>> application so that  it looks for the shared libraries  in the bundle 
>>> rather than some  random location.   I have a script  that I run to 
>>> make this all work,  but it has to be modified as  libraries change.  
>>> Or, if I somehow  forget to run this step the  whole distribution is 
>>> bad.   Does CPack  help with this?
>>
>> In CMake 2.4 there is an INSTALL_NAME_DIR property that you can use  
>> to control the install_name of the installed library or executable.
> 
> So this is actually part of the make install process then, right?

Yes, but it can be made to happen at build time too if you do not care 
about running from the build tree (the BUILD_WITH_INSTALL_RPATH property).

 > Are
> there any examples anywhere?   I'd even be willing to write it up  in 
> the wiki ;-)

If you get it working a Wiki entry would be great.  Here is an example 
to get you started (from memory):

ADD_LIBRARY(mylib SHARED ...)
SET_TARGET_PROPERTIES(mylib PROPERTIES
   INSTALL_NAME_DIR "@executable_path/../lib"
   )
ADD_EXECUTABLE(myexe ...)
TARGET_LINK_LIBRARIES(myexe mylib)
INSTALL(TARGETS mylib DESTINATION lib)
INSTALL(TARGETS myexe DESTINATION bin)

You'll have to modify this example to be bundle-specific.

-Brad


More information about the CMake mailing list