Cannot set debian package dependency after include(CPack)
I am using Ubuntu 16.04 and CMake 3.5
My goal is to produce two debian packages, a -lib package that contains a shared library, and a -dev package that contains the headers and depends on the -lib.
I originally tried to use the cpack_add_component
defined by CPack, but couldn't make it work. I've posted about that on StackOverflow: https://stackoverflow.com/questions/44166400/cmake-cpack-doesnt-recognize-inter-component-dependencies
As an alternative I decided instead to try using CPACK_DEBIAN_<component>_PACKAGE_DEPENDS
. Here is my CMakeLists.txt
file:
cmake_minimum_required(VERSION 3.5)
project(libmy)
include_directories(include)
add_library(my SHARED src/main/my.c)
install(TARGETS my
DESTINATION /usr/local/lib/
COMPONENT lib)
install(FILES include/my.h
DESTINATION /usr/local/include
COMPONENT dev)
set(CPACK_GENERATOR "DEB")
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Me")
include(CPack)
set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "${CPACK_PACKAGE_NAME}-lib (=${CPACK_PACKAGE_VERSION})")
This seems to fall down on the order of the include(CPack)
and the set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "${CPACK_PACKAGE_NAME}-lib (=${CPACK_PACKAGE_VERSION})")
In the order listed above, CPack ignores the CPACK_DEBIAN_DEV_PACKAGE_DEPENDS
directive entirely, not adding an appropriate entry to the control file.
However, if I switch the order, I get an entry that has no ${CPACK_PACKAGE_NAME}
or ${CPACK_PACKAGE_VERSION}
.