[CMake] RPATH not set for "first" build library

Martin Vogt mvogt1 at gmail.com
Sat Aug 25 15:26:10 EDT 2012


Hello,

On Sat, Aug 25, 2012 at 7:03 PM, Eric Noulard <eric.noulard at gmail.com> wrote:
> 2012/8/25 Martin Vogt <mvogt1 at gmail.com>:
> The fact that libdummy.so is in the rpath of one of the library the executable
> is linked against is just a coincidence or did I miss something?

I think, its the correct behavior for libmyopen not to open libdummy.
Its only a coincidence that libmyopen1 _can_ load libdummy

For example:

Even in the case, that the rpath would be in libmyopen it can only
open libdummy.so
if its in the same directory, so this would fail again if libdummy is elsewhere.
But I would like to run my binaries from the "in tree build" during
developement,
so I can do in cmake:

SET(CMAKE_INSTALL_RPATH "")
target_link_libraries(myopen dl -Wl,-rpath,${CMAKE_BINARY_DIR})
install(TARGETS myopen LIBRARY DESTINATION myopen)

Then it will work in the "in tree build". (because I set the rpath manually.)

But if I do "make install", it does not remove the RPATH.

cmake -DCMAKE_INSTALL_PREFIX:PATH=/tmp/b ..
make install
[...]
(*)
readelf -d /tmp/b/myopen/libmyopen.so
[...]
 0x000000000000000e (SONAME)             Library soname: [libmyopen.so]
 0x000000000000000f (RPATH)              Library rpath:
[/tmp/a/rpath_not_set_in_first_lib/build]
 0x000000000000001d (RUNPATH)            Library runpath:
[/tmp/a/rpath_not_set_in_first_lib/build]
 0x000000000000000c (INIT)               0x670

I think, that is not what I would have in the installed version.

from: http://www.cmake.org/Wiki/CMake_RPATH_handling
>Default RPATH settings
>
>By default if you don't change any RPATH related settings, CMake will link the executables and >shared libraries with full RPATH to all used libraries in the build tree. When installing, it will clear >the RPATH of these targets so they are installed with an empty RPATH.

In my example (*) the RPATH is not empty (cmake  version 2.8.3.).

Is this correct?

regards,

Martin


More information about the CMake mailing list