[cmake-developers] RPATH bug + patch suggestion

Lior Goldberg liorgol.dev+cmake at gmail.com
Fri Jan 15 09:47:56 EST 2016


Hi,

I think there is a bug in the way CMake handles rpath for installed targets.
My GCC installation contains the following definition in the specs file:
    *link_libgcc:
    %D -rpath <<some specific rpath in which libstdc++.so can be found>>

This configuration leads to the following bug in CMake:
Whenever a target (which depends on a library in the project) is created,
the rpath is completely removed from the installed targets (including the
linker's predefined rpath). This is not the case when there are no
dependencies on other libraries in the project.
Of course this can be fixed by changing CMake rpath-related variables but
I think that this suggests that the default rpath handling should be fixed.

(Note that the same behavior happens when "-Wl,-rpath" is used in
CMAKE_EXE_LINKER_FLAGS)

Specifically, I think that the command "FILE(RPATH_REMOVE ...)" is not subtle
enough, as it removes the compiler's predefined rpath together with the rpath
added by CMake. I suggest replacing it with the command "FILE(RPATH_CHANGE ...)"
(even when NEW_RPATH is empty) and allowing this command to decide
(based on the actual rpath defined in the file) whether the rpath entry should
be removed.

Attached is the suggested patch.

Please let me know what you think.

Thanks,
Lior
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Use-RPATH_CHANGE-instead-of-RPATH_REMOVE.patch
Type: application/octet-stream
Size: 3588 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20160115/cf4691a3/attachment.obj>


More information about the cmake-developers mailing list