[CMake] INSTALL_NAME_DIR ignored in add_library?

Clinton Stimpson clinton at elemtech.com
Thu Jun 13 10:54:03 EDT 2013


On Tuesday, June 11, 2013 02:27:49 AM Vittorio Giovara wrote:
> Hi, I'm trying to modify the install_name path of a library created with
> add_library(SHARED) on MacOS, using Unix Makefiles, cmake 2.8.10.2 and
> 2.8.11.
> 
> I've tried setting the global variable
>   set(CMAKE_INSTALL_NAME_DIR "@executable_path/../Frameworks/")
> I've tried editing the target properties with
>   set_target_properties(aname PROPERTIES INSTALL_NAME_DIR
> "@executable_path/../Frameworks/")
> and also tried manually editing the link flags with
>   set_target_properties(aname PROPERTIES LINK_FLAGS "-install_name
> @executable_path/../Frameworks/libaname.dylib")
> 
> However NONE of these methods worked! In the link line there is always an
> -install_name command that just outputs the name of the library. I've dug
> around a lot before resorting to the mailing list and found this old
> threads like http://www.cmake.org/pipermail/cmake/2011-April/043826.html or
> http://www.cmake.org/pipermail/cmake/2010-August/038959.html and and a few
> patches that are supposedly working like
> http://robotcub-hackers.2198711.n2.nabble.com/CMake-RPATH-in-OS-X-td7578206.
> htmlso I don't understand what's wrong.
> 
> I've even doublechecked with get_target_property and the INSTALL_NAME_DIR
> is correctly initialized.
> So I'm completely out of options, any help is appreciated.
> Vittorio

The INSTALL_NAME_DIR property applies at install time.  If you want it to 
apply at build time, where it would show up on the link line, you need to set 
BUILD_WITH_INSTALL_RPATH.

And since you referenced previous mailing list rpath/Mac discussions, you may 
want to look at this blog, which includes the recommendation to not set 
INSTALL_NAME_DIR anymore (available in the upcoming CMake 2.8.12 or available 
now on if you compile the current master).
http://www.kitware.com/blog/home/post/510

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


More information about the CMake mailing list