[CMake] How to set Install_name on OS X

Brad King brad.king at kitware.com
Tue Oct 10 16:56:19 EDT 2006


Mike Jackson wrote:
> On 10/10/06 4:08 PM, "Brad King" <brad.king at kitware.com> wrote:
>> cmake --help-command SET_TARGET_PROPERTIES
> 
> OK.. Reading all the output from that command there seems to be some
> mutually exclusive settings. Also, the output has settings like
> INSTALL_NAME_DIR, should those be CMAKE_INSTALL_NAME_DIR instead?
> 
> I tried the following in my Cmake file and it just is not working.
> 
> # ------- Create a Shared Library ---------------------------------
> ADD_LIBRARY(DislocationIO SHARED ${SOURCES} )
> 
> #---------- Link the Library  ---------------------------------
> TARGET_LINK_LIBRARIES(DislocationIO
>   ${vtkLocal_LIBS}
> )
> SET_TARGET_PROPERTIES (DislocationIO
> PROPERTIES BUILD_WITH_INSTALL_RPATH ON
>            CMAKE_INSTALL_NAME_DIR "@executable_path/../PlugIns"
>            )
> 
> I don't mean to be difficult, but could you lend me a bit more help? I have
> tried a few different versions of the above all with out success.

The property is called INSTALL_NAME_DIR.  The variable
CMAKE_INSTALL_NAME_DIR is used to initialize the value of the property
on the ADD_LIBRARY line.  Try this:

SET_TARGET_PROPERTIES (DislocationIO
  PROPERTIES BUILD_WITH_INSTALL_RPATH 1
             INSTALL_NAME_DIR "@executable_path/../PlugIns"
  )

If you leave off the BUILD_WITH_INSTALL_RPATH property then it will not
be built with this install_name but when you run "make install" the
installed copy of the library will get the proper value.

-Brad


More information about the CMake mailing list