[CMake] Suppress a specific path in the RPATH of an executable explicitly

Cornelis Bockemühl cornelis at bockemuehl.ch
Thu Dec 19 04:52:30 EST 2019


In a project setup I am copying a number of shared library files into the executable directory (basically with a mechanism involving configure_file - because the "install" logic was simply too complicated for the project and for my limited brain capacity!).

On a Windows system this works nicely, but on a Linux system there is always some logic that puts the original shared library location into the executable's RUNPATH, with the effect that they are not found in the place where they are supposed to be found.

I tried to avoid this by using
set_target_properties(
    <imported targets>
    PROPERTIES
        CMAKE_SKIP_RPATH TRUE)However, any effect was not visible: the "old" path is still included in RUNPATH. Maybe I overlooked one more imported target, overriding the effect of above, or it does not work on imported targets at all. Anyway, it would be much easier if I could simply drop one specific path explicitly with some setting! Dropping all is again too much - because I need other entries for other libraries.

Is there such an option available?

Maybe a workaround would be to explicitly prepend "$ORIGIN" to the RUNPATH in the executable: In this way the shared libs would be found in the executable directory first and any other "wrong" paths would not hurt.

Many thanks and regards,
Cornelis Bockemühl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20191219/34b6ebf3/attachment.html>


More information about the CMake mailing list