Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prevent creation of namelink for installed shared libraries when using CPack

Tags:

c++

cmake

cpack

I'm building two packages in a distribution:

  1. runtime shared library package
  2. dev libary package

The problem is to include a correct symlink into any of them. Currently I use:

set_target_properties(mylib PROPERTIES 
                        SOVERSION "${PROJECT_VERSION_MAJOR}"
                        VERSION "${PROJECT_VERSION}")

and when specifying the following CPack configuration:

install (TARGETS mylib
          LIBRARY
          DESTINATION /usr/lib
          COMPONENT runtime)

install (TARGETS mylib
          LIBRARY
          DESTINATION /usr/lib
          COMPONENT dev)

install (DIRECTORY include/
          DESTINATION /usr/include/mylib 
          COMPONENT dev)

the runtime shared library package then contains the following symlink chain:

/usr/lib/libmylib.so -> libmylib.so.0
/usr/lib/libmylib.so.0 -> libmylib.so.0.0.1
/usr/lib/libmylib.so.0.0.1

The problem is /usr/lib/libmylib.so -> libmylib.so.0 is redundant in the runtime shared library package since it is only necessary when building a binary that uses this libmylib.

Question: Is there a way to excelude that /usr/lib/libmylib.so -> libmylib.so.0 symlink from runtime shared library package?

like image 727
St.Antario Avatar asked Jan 16 '26 23:01

St.Antario


1 Answers

You should be able to do this using the NAMELINK_SKIP parameter of the install(TARGETS) command.

NAMELINK_SKIP

Similar to NAMELINK_ONLY, but it has the opposite effect: it causes the installation of library files other than the namelink when a library target is installed. When neither NAMELINK_ONLY or NAMELINK_SKIP are given, both portions are installed. On platforms where versioned shared libraries do not have symlinks or when a library is not versioned, NAMELINK_SKIP installs the library. It is an error to use this parameter outside of a LIBRARY block.

If NAMELINK_SKIP is specified, NAMELINK_COMPONENT has no effect. It is not recommended to use NAMELINK_SKIP in conjunction with NAMELINK_COMPONENT.

like image 174
starball Avatar answered Jan 19 '26 16:01

starball



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!