Saturday, February 19, 2022

[SOLVED] SONAME incosistency of shared protobuf lib when building with autogen and cmake

Issue

When I build shared protobuf (Version 3.15.8) libs with autogen I get libprotoc.so.26:

./autogen.sh
./configure --enable-shared
make

When I build it with cmake I get libprotobuf.so.3.15.8.0.

cd cmake && mkdir build && cd build
cmake -Dprotobuf_BUILD_SHARED_LIBS=on ..
make 

Is there a way to build libprotoc.so.26 with cmake? (How can I set the SONAME there?)


Solution

You appear to be looking for the SOVERSION property of the shared library target. As far as I am aware, there is no command-line option to affect target properties, so you would need to modify the appropriate CMakeLists.txt file. You'll need to identify the CMake target name chosen for the library (a characteristic of the project, not of CMake itself), say "protobuf_lib". You would then add a command of the form

target_set_properties(protobuf_lib
    PROPERTIES SOVERSION 26)

Alternatively, if there is already a target_set_properties command for the target in question, you could add the SOVERSION 26 to the property list in that command.



Answered By - John Bollinger
Answer Checked By - Mary Flores (WPSolving Volunteer)