Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cmake won't create .so version and soversion symlinks

Tags:

cmake

What are all the necessary conditions for cmake to create and install shared objects with a proper soname version and relevant symlinks?

I have recently upgraded my system, and what used to work with cmake 2.8, doesn't work anymore with cmake 3.7. I've checked the latest documentation but I can't make sense of it, with regard to my problem.

I used to have .so files installed, with the real .so file with the full version, in addition to symlinks.

 pluginname.so.1 => pluginname.so.1.1.0
 pluginname.so.1.1.0

Now, cmake only builds and installs pluginname.so without any version suffix nor symlinks.

I don't use NO_SONAME anywhere:
https://cmake.org/cmake/help/v3.7/prop_tgt/NO_SONAME.html#prop_tgt:NO_SONAME

add_library(${PLUGIN_NAME} MODULE ${SRC})

# I call message(...) to check that the values are indeed set:
message("plugin ${PLUGIN_NAME}") 
message("version ${CORE_MAJOR_VERSION}.${PLUGIN_MAJOR_VERSION}.${PLUGIN_BUGFIX_VERSION}") 
message("soversion: ${CORE_MAJOR_VERSION}")
message("prefix ${PLUGIN_PREFIX}") 

if (NOT NO_SONAME)
   message("Ok, no_soname is not set!")
endif()

set_target_properties(${PLUGIN_NAME} PROPERTIES
    VERSION ${CORE_MAJOR_VERSION}.${PLUGIN_MAJOR_VERSION}.${PLUGIN_BUGFIX_VERSION}
    SOVERSION ${CORE_MAJOR_VERSION} 
    PREFIX ${PLUGIN_PREFIX}
)
 install(TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})

What other debugging strategies would work here?

I have tried changing the add_library(${PLUGIN_NAME} MODULE ${SRC}) line replacing MODULE with SHARED but it does not seem to make a difference.

like image 872
augustin Avatar asked Oct 27 '25 09:10

augustin


1 Answers

You are adding a "MODULE" library and not a "SHARED" one.

I think this might be related to the following:
https://gitlab.kitware.com/cmake/cmake/commit/f799ffb5cb895855ac2aba54765622b81db5be38

and here is stressed again: https://gitlab.kitware.com/cmake/cmake/raw/f799ffb5cb895855ac2aba54765622b81db5be38/Help/release/dev/modules-no-soname.rst

  • The SONAME field is no longer set for MODULE libraries created with the :command:add_library command. MODULE
    libraries are meant for explicit dynamic loading at runtime. They cannot be linked so SONAME is not useful.

Before you could have set SONAME and have VERSION and SOVERSION set also for MODULE libraries.
That's the only thing I can think of is preventing you to set the VERSION and SOVERSION for your library.

More references:
https://gitlab.cern.ch/dss/eos/commit/18ff0746ff4bc1263648fe3fdda79075ce262093
https://gitlab.cern.ch/dss/eos/commit/a7a6d486168e4de9a25eddd84cb19af0bab1ab5f


IMPORTANT NOTE: When you switch between MODULE to SHARED configuration or viceversa, it's a good practice to remove the "old" CMake configuration files.
If your build is out-of-source (which I suggest) and the directory is called build, then from the root directory of your project, after you've changed the desired configuration in the CMakeLists.txt, you will do something like:

rm -rf build && mkdir build && cd build && cmake ..  

This will assure you that you start from a clean configuration state before building the project.

like image 69
fedepad Avatar answered Oct 29 '25 09:10

fedepad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!