Is there a way to prevent CMake from creating a symlink for shared libraries like libfoo.so
when you are using so-versioning (which means you would have something like libfoo.so.0.8
)?
The reason why I am asking this is that I have a project where I would like to make multiple versions of that project installable in parallel. Most package managers however reject a parallel installation if a file like the symlink is present in multiple packages.
As a background info: we are using CPack to build the packages and ultimately I think it is a flaw of CPack that you cannot prevent this symlink or at least being able to separate dev and runtime packages e.g. for debian. However, so far I have the illusions that just preventing CMake from creating the symlink at all might be the easier thing to do than patching CPack.
For shared libraries you can use the NAMELINK_SKIP
option of the install command to prevent the generation of the versionless library name symbolic link to the versioned library file.
The generated CPack installer will honor that setting upon installation. The library version has to specified by setting the SOVERSION
property of the shared library target:
The following sample code sketches the required steps:
add_library(foo SHARED foo.c)
set_target_properties(foo PROPERTIES SOVERSION "0.8")
install(TARGETS foo LIBRARY DESTINATION lib NAMELINK_SKIP)
include(CPack)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With