# tell CPack generator to use component packaging
set(CPACK_DEB_COMPONENT_INSTALL 1)
# tell CPack which kind of grouping you want
set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP)
Thank you so much for this! Building upon the toy example and the provided solution I think I figured out my similar issue of wanting to group multiple targets into separate debs and correct the file names. Posting for anyone else who ends up here since I could not find any other examples.
I am finding a solution to build a library on busybox with OPKG package format, which documented supported by DEB CPack generator. This made me to give CPACK_DEBIAN_FILE_NAME in cmake script.
To make both devel and runtime package from the same source repo, I have to make the CPACK_DEBIAN_FILE_NAME contains the component part.
Your solution gives me a method that done it:
install(FILES foo.h COMPONENT dev)
install(FILES libfoo.so COMPONENT runtime)
set(CPACK_PACKAGE_NAME libfoo)
set(CPACK_PACKAGE_VERSION "0.1.2")
set(CPACK_PACKAGE_CONTACT "Name <name@example.com>")
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_COMPONENT_GROUPING ONE_PER_GROUP)
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "all")
# Do NOT set the CPACK_DEBIAN_FILE_NAME
#set(CPACK_DEBIAN_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.ipk")
# use CPACK_DEBIAN_<COMPONENT>_FILE_NAME instead
# and <COMPONENT> part *must* be UPPERCASE
set(CPACK_DEBIAN_DEVEL_FILE_NAME "${CPACK_PACKAGE_NAME}-devel-${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.ipk") set(CPACK_DEBIAN_RUNTIME_FILE_NAME "${CPACK_PACKAGE_NAME}-runtime-${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.ipk")
set(CPACK_DEBIAN_PACKAGE_DEBUG TRUE)
include(CPack)
# group name *can* be lowercase
cpack_add_component(dev GROUP devel)
cpack_add_component(runtime GROUP runtime)