[CMake] Link something to future installed library
Martin Koller
martin.koller at etm.at
Wed Mar 13 06:35:13 EDT 2013
On Tuesday 12 March 2013 20:53:21 David Demelier wrote:
> Thanks for your answer, however target_link_libraries() my modules to the
> target of core will link to the build binary directory as expected :
>
> markand at Melon .../src/magicstat-2/_build_ $ ldd modules/battery/battery.so
> modules/battery/battery.so:
> libcore.so =>
> /home/markand/work/src/magicstat-2/_build_/core/libcore.so (0x801204000)
> libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x801405000)
> libm.so.5 => /lib/libm.so.5 (0x801715000)
> libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x801936000)
> libc.so.7 => /lib/libc.so.7 (0x80081a000)
>
> once installed..
>
> markand at Melon .../src/magicstat-2/_build_ $ ldd
> /usr/local/lib/magicstat/modules/battery/battery.so
> /usr/local/lib/magicstat/modules/battery/battery.so:
> libcore.so => not found (0)
> libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x801204000)
> libm.so.5 => /lib/libm.so.5 (0x801514000)
> libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x801735000)
> libc.so.7 => /lib/libc.so.7 (0x80081a000)
what you see is a different RPATH in the .so file.
check this with "objdump -x yourfile.so | grep RPATH"
To define a different RPATH on installed targets, use e.g.:
set_target_properties(${target} PROPERTIES INSTALL_RPATH \$ORIGIN)
(Where \$ORIGIN is a special keyword which is always relative to the directory
the .so file is installed to. If you need different dirs, you can use other relative
dirs, e.g.: "../../core" in your case (or similar - you get the picture).
Check "man ld.so"
>
> The installation hierarchy are the same as the build directory :
>
> build/core/libcore.so
> build/modules/battery.so
>
> and /usr/local/lib/magicstat/libcore.so
> /usr/local/lib/magicstat/modules/battery/battery.so
--
Best Regards/Schöne Grüße
Martin
-----------------------------------------------------------------
Ing. Martin Koller , mailto:martin.koller at etm.at , http://www.etm.at
ETM professional control GmbH, A-7000 Eisenstadt Marktstr. 3
Phone:+43 2682/741-62603, Fax:+43 2682/741-52555
-----------------------------------------------------------------
A: Because it breaks the logical sequence of discussion
Q: Why is top posting bad?
More information about the CMake
mailing list