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

Kim Walisch kim.walisch at gmail.com
Thu Dec 15 13:57:40 EST 2016


Thanks for your answer.

Lets suppose I do not want to stick to my previous libtool versioning
but instead version my library according to cmake best practices. How
should I set VERSION and SOVERSION given my API version is 3.5 and my
old ABI version 4:7:0. By browsing a few CMakeLists.txt on GitHub of
other projects it seems to me that most of these projects set VERSION
to the project/API version (e.g. 3.5) and the SOVERSION to the
project/API major version (e.g 3).

-Kim

On Thu, Dec 15, 2016 at 7:07 PM, Brad King <brad.king at kitware.com> wrote:
> 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