[cmake-developers] Remove RPATH on install

Ruslan Baratov ruslan_baratov at yahoo.com
Wed Sep 28 16:54:52 EDT 2016


On 28-Sep-16 23:34, Brad King wrote:
> On 09/28/2016 04:09 PM, Ruslan Baratov via cmake-developers wrote:
>> `<libname> -Wl,-rpath,<libdir>` to CMAKE_EXE_LINKER_FLAGS.
> That adds it in a way that hides its presence from CMake.  CMake has its
> own way to specify RPATH entries in the build tree.  It will replace the
> build-tree-only entries with install-tree-only entries (if any) during
> installation.
I'm not aware of any better ways to apply global settings for all 
targets without modifying CMakeLists.txt

>    Any entries it doesn't know about are assumed to be added
> by the toolchain and are thus preserved.
I can't save them because it's full path hence will be not relocatable.

>
> If one uses target_link_libraries to link each executable explicitly
> to the shared library via absolute path to the library file then IIRC
> CMake will put the RPATH in the build tree for that and remove it on
> installation.
Yep, I know.

>
>> adding new one, like CMAKE_INSTALL_DELETE_RPATH?
> We don't actually define any kind of first-class RPATH-update operation.
> It is only an implementation detail that we edit the RPATH on installation.
> In principle the design is that there is a build tree RPATH and an install
> tree RPATH.  On non-ELF platforms we actually need to re-run the linker
> to produce the install tree version.  Therefore CMAKE_INSTALL_DELETE_RPATH
> would not fit within our model.
Ok

> Instead one could add a BUILD_RPATH target property with CMAKE_BUILD_RPATH
> variable that specifies additional entries to put in the build tree RPATH.
> This would be the build-tree equivalent to the INSTALL_PATH target property.

Should work too. I will do the tests and send a patch.

Ruslo



More information about the cmake-developers mailing list