[CMake] VERSION and SOVERSION in a module

Kristian kristianonline28 at gmail.com
Mon Apr 4 04:33:04 EDT 2016


Hey,

I have a question. I have a project, which is compiled on two
different build machines with ninja (trunk and branch). The
CMakeLists.txt is the same when it comes to a part, where the VERSION
and SOVERSION part is set through the function
'set_target_properties'.

But on the first build machines, setting the VERSION and SOVERSION
works, on the other machine it does not work. On the second machine
(where the build fails), I recently upgraded CMake to 3.5 (I compiled
and installed it on my own). The first build machine has CMake with
version 2.8.11 (installed from local package manager yum).

I've tried some things till I got a minimum example, where I could
reproduce the error. The problem is calling add_library with MODULE.

So, first the CMakeLists.txt
=====
cmake_minimum_required(VERSION 2.8)
project(test1)

set(SOURCES func.cpp)

set(VER1 "1")
set(VER2 "2")
set(VER3 "3")

add_library(${PROJECT_NAME} MODULE ${SOURCES})
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS
-Wl,-Bsymbolic VERSION ${VER1}.${VER2}.${VER3} SOVERSION 0)
=====

When running this script with the commands on the first build machine
(CMake 2.8.11 / this is also reproducable with Unix Makefiles
generator)
> cmake . && make && ls
then I get this

> CMakeCache.txt
> cmake_install.cmake
> func.cpp
> libtest1.so.0
> Makefile
> CMakeFiles
> CMakeLists.txt
> libtest1.so
> libtest1.so.1.2.3

(which seems ok to me)

But running the same CMakeLists.txt on the second build machine (CMake
3.5), then I get this:

> CMakeCache.txt
> CMakeFiles
> cmake_install.cmake
> CMakeLists.txt
> func.cpp
> libtest1.so
> Makefile

Is this an error? Or what should I add to the CMakeLists.txt on the
second build machine, to get the same output (i.e. libtest1.so.0
libtest1.so.1.2.3)?


More information about the CMake mailing list