4

I am trying to convince cmake/cpack to build a shared library package (component lib) and a development package (component dev).

The lib component should only contain the shared library, and should have no dependencies.

The dev component should only contain the header file, and should depend on the lib component.

Here is my CMakeLists.txt file:

cmake_minimum_required(VERSION 3.5)

project(libmy)

add_library(my SHARED src/main/my.c)

target_include_directories(my PUBLIC include)

set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_CONTACT "peter.spierenburg@nautel.com")

install(TARGETS my
  LIBRARY
  DESTINATION /usr/local/lib
  COMPONENT lib)

install(FILES include/my.h
  DESTINATION /usr/local/include
  COMPONENT dev)

set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS ON)

include(CPack)

cpack_add_component(lib REQUIRED)
cpack_add_component(dev DEPENDS lib)

A build nets me two deb packages libmy-0.1.1-Linux-dev.deb and libmy-0.1.1-Linux-lib.deb. However, the dev package does not depend on the lib package.

spierepf
  • 2,774
  • 2
  • 30
  • 52

0 Answers0