[CMake] CMake and soversions in Linux

Alan W. Irwin irwin at beluga.phys.uvic.ca
Tue Sep 25 10:43:16 EDT 2007


On 2007-09-25 12:41+0200 Pau Garcia i Quiles wrote:

> Hello,
>
> I am trying to set soversion and information in a library in Linux using 
> CMake 2.4.7.
>
> Assuming version = 2.0.6 and soversion = 0.0.0 (because it's going to be the 
> first soversioned release and we are not going to check the history of the 
> library and see where ABI compatibility was broken and in what way), if I 
> use:
>
>  SET_TARGET_PROPERTIES(
>    wt
>  PROPERTIES
>    VERSION 2.0.6
>    SOVERSION 0.0.0
>  )
>
> I get this:
> lrwxrwxrwx 1 root root      14 2007-09-24 09:56 /usr/lib/libwt.so -> 
> libwt.so.0.0.0
> lrwxrwxrwx 1 root root      14 2007-09-24 09:56 /usr/lib/libwt.so.0.0.0 -> 
> libwt.so.2.0.6
> -rw-r--r-- 1 root root 1935368 2007-09-22 13:02 /usr/lib/libwt.so.2.0.6
>
> Which is fine according to the libtool manual 
> (http://www.gnu.org/software/libtool/manual.html#Versioning)

I don't think that is the case.  The libtool manual is coy about the
relationship between their CURRENT/REVISION/AGE scheme and what the resulting
symbolic links and actual library name will be on Linux.  However, 
a year and a half
ago (truly the dark ages) we were using the libtool CURRENT/REVISION/AGE scheme and the results
had the following pattern where the soname integer agreed with the first part
of the version:

/usr/lib/libwt.so -> libwt.so.0.0.0
/usr/lib/libwt.so.0 -> libwt.so.0.0.0

where libwt.so.0.0.0 is the real library.

Alternatively, if you are not starting over with the soname then the pattern
would be

/usr/lib/libwt.so -> libwt.so.2.0.6
/usr/lib/libwt.so.2 -> libwt.so.2.0.6

where libwt.so.2.0.6 is the name of the real library.

(Note, you don't have to take my word for it.  If you look in /usr/lib, the
above pattern with soname integer corresponding to first part of version
is what you see in the vast majority of cases.)

CMake does not create exactly the above pattern.  Instead, if you specify

SET_TARGET_PROPERTIES(
     wt
   PROPERTIES
     SOVERSION 0
     VERSION 0.0.0
   )

(note the agreement between the SOVERSION integer and the first integer of
the VERSION triplet) you will get

/usr/lib/libwt.so -> libwt.so.0
/usr/lib/libwt.so.0 -> libwt.so.0.0.0

and similarly for SOVERSION 2, VERSION 2.0.6 (again note the agreement
between the SOVERSION integer and the first part of the VERSION triplet)
you get

/usr/lib/libwt.so -> libwt.so.2
/usr/lib/libwt.so.2 -> libwt.so.2.0.6

I think this slight rearrangement of the symbolic links compared to
the vast majority of Linux libraries does not matter.  Anyhow, for PLplot
we enforce the rule that SOVERSION is an integer which agrees with the
first part of the VERSION triplet, and nobody has complained about the
resulting symlink arrangment.

> [Instead] I'd like to 
> follow section 6.4 in the libtool manual 
> (http://www.gnu.org/software/libtool/manual.html#Release-numbers), thus 
> getting this:
>
> lrwxrwxrwx 1 root root      14 2007-09-24 09:56 /usr/lib/libwt.so -> 
> libwt-2.0.6.so.0.0.0
> lrwxrwxrwx 1 root root      14 2007-09-24 09:56 /usr/lib/libwt-2.0.6.so.0 -> 
> libwt-2.0.6.so.0.0.0
> -rw-r--r-- 1 root root 1935368 2007-09-22 13:02 
> /usr/lib/libwt-2.0.6.so.0.0.0

Actually, that is not what they said.  According to this "trick" scheme

/usr/lib/libwt.so  -> libwt-2.0.6.so

there is no "soname" symbolic link, and libwt-2.0.6.so is the name of the
real library.  My advice is to use the above rule enforcing equality between
the SONAME and the first part of VERSION and avoid this "trick" scheme since
it is so rarely used (again checking with /usr/lib).  However, if you
absolutely insist about going against what is normally expected, then you
can do anything you like when you install libraries since the facility
exist in the INSTALL(FILES... signature to RENAME files arbitrarily, and you
can also (with a bit of trickery) run cmake -E create_symlink at install
time to create any symlink you like.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list