[CMake] How to prevent relinking targets with shared libraries

BlinkEye gentoo at blinkeye.ch
Fri Feb 22 05:40:07 EST 2008


On Fri, February 22, 2008 10:07, Bill Hoffman wrote:
> BlinkEye wrote:
>> On Thu, February 21, 2008 22:23, Alan W. Irwin wrote:
>>> On 2008-02-21 21:57+0100 blinkeye wrote:
>>>> [...]At the moment I'm just creating plain .so libs, without any version number
(so far I didn't happen to come across a shared library tutorial with cmake),
maybe this is the problem? Does cmake support such a versioning and would that
resolve the relinking?
>>> There is full support for shared libraries (at least on my Linux platform). Look
at the documentation of SET_TARGET_PROPERTIES (especially where it mentions
VERSION, SOVERSION, and RPATH.)
>> Great, thanks for the hint. So, I set a VERSION and SOVERSION on my library:
add_library( mylib SHARED ${SRCS} )
>> set_target_properties( mylib PROPERTIES VERSION 1 SOVERSION 1 ) But still, any
change to 'mylib' requires all targets linked against 'mylib' to
be
>> relinked again ...
> No, I don't think so.  I don't see how CMake can tell if the interface changed or
not.  How did the makefiles do that?
>
> -Bill
>
Hmm, ok, scenario: I download cmake-2.4.8.tar.gz and built it from source. The
finale cmake executable is linked against:

# ldd bin/cmake
        linux-gate.so.1 =>  (0xb7f4b000)
        libdl.so.2 => /lib/libdl.so.2 (0xb7f2d000)
        libstdc++.so.6 => /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6
(0xb7e50000)
        libm.so.6 => /lib/libm.so.6 (0xb7e2a000)
        libgcc_s.so.1 => /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libgcc_s.so.1
(0xb7e20000)
        libc.so.6 => /lib/libc.so.6 (0xb7cf0000)
        /lib/ld-linux.so.2 (0xb7f4c000)

I can touch (change the timestamp) of say '/lib/libc.so.6' and execute make withou
cmake getting relinked again. This is the desired effect I try to achieve.
CMake/Make cannot know anything about interface changes - this is where we
developers create a new shared library version if this happens. But if I fix some
minor bug in say mylib.so.1 and mytarget is linked against mylib.so.1 I try to
prevent mytarget to get relinked. I guess the problem is that the libs are built
from within the project itself because I merely have to touch mylib (change the
timestamp) and cmake will relink all targets ...









More information about the CMake mailing list