[cmake-developers] Separate components for library and .so link

Daniele E. Domenichelli ddomenichelli at drdanz.it
Tue Dec 23 06:24:58 EST 2014


Is there a way to separate components for a library with a SONAME and
the link?

For example if I do something like this:

  add_library(foo ${foo_SRCS})
  set_target_properties(foo PROPERTIES SOVERSION 1)
  install(TARGETS foo
          LIBRARY DESTINATION lib)

This will install

  <prefix>/lib/libfoo.so.1
  <prefix>/lib/libfoo.so -> libfoo.so.1


When packaging (at least for Debian and derived distributions), the .so
link is considered part of the "-dev" package (and installed with the
header files), while the library is part of the library package.

Is there a way to separate these 2 components with just one install command?
As far as I understand, it is possible to install the target twice using
NAMELINK_SKIP and NAMELINK_ONLY, but that seems a bit too redundant to me...

  install(TARGETS foo
          LIBRARY DESTINATION lib COMPONENT library NAMELINK_SKIP)
  install(TARGETS foo
          LIBRARY DESTINATION lib COMPONENT devel NAMELINK_ONLY)

I think it would be nice to be able to do something like

  install(TARGETS foo
          LIBRARY DESTINATION lib COMPONENT library
                                  NAMELINK_COMPONENT devel)


What do you think?

Cheers,
 Daniele


More information about the cmake-developers mailing list