[cmake-developers] CMake vs libtool versioning of shared libraries

Brad King brad.king at kitware.com
Thu Dec 15 13:07:39 EST 2016


On 12/15/2016 11:54 AM, Kim Walisch wrote:
> I am currently in the process of switching the build system of my
> primecount project from Autotools to CMake and the shared library
> versioning in CMake is not yet clear to myself. My current project
> version (API version) is 3.5 and the libtool version (ABI version) is
> 4:7:0. So I have set the VERSION and SOVERSION to my libtool
> version (in CMakeLists.txt):
> 
> set_target_properties(libprimecount PROPERTIES SOVERSION 4)
> set_target_properties(libprimecount PROPERTIES VERSION "4.7.0")
> 
> Is this correct? Or should I set the VERSION to my current project
> version (API version):
> 
> set_target_properties(libprimecount PROPERTIES SOVERSION 4)
> set_target_properties(libprimecount PROPERTIES VERSION "3.5")

The CMake properties give direct control over the way the files
are constructed:

    libfoo.so -> libfoo.so.$soversion
    libfoo.so.$soversion -> libfoo.so.$version
    libfoo.so.$version (actual file)

Libtool instead defines version components [1] "current", "revision",
and "age", and somehow maps them to the version and soversion above.
I don't recall the mapping off the top of my head, but if you want to
reproduce what you were doing before you should do that mapping to
select the values for the CMake SOVERSION and VERSION properties.

-Brad

[1] https://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html



More information about the cmake-developers mailing list