I am currently trying to generate more than one debian package from my project. My only problem with this is setting the name, description, group and so forth of the packages.
# --------------------------------------------------------------
# Required CMake version
# --------------------------------------------------------------
CMAKE_MINIMUM_REQUIRED (VERSION 2.8)
# --------------------------------------------------------------
# Project name
# --------------------------------------------------------------
PROJECT (MyProject)
# --------------------------------------------------------------
# Find all source and header files
# --------------------------------------------------------------
FILE (GLOB all_H "*.h")
FILE (GLOB all_SRC "*.cpp")
# --------------------------------------------------------------
# Set compiler flags
# --------------------------------------------------------------
SET (CMAKE_CXX_FLAGS "-Wall -Wextra -O0 -g3")
# --------------------------------------------------------------
# Add a shared library
# --------------------------------------------------------------
ADD_LIBRARY (mylib SHARED ${all_H} ${all_SRC})
# --------------------------------------------------------------
# Configure components
# --------------------------------------------------------------
SET (CPACK_DEB_COMPONENT_INSTALL 1)
# --------------------------------------------------------------
# Install
# --------------------------------------------------------------
INSTALL(TARGETS mylib DESTINATION ../lib COMPONENT main)
INSTALL(FILES ${all_H} DESTINATION ../include COMPONENT dev)
# --------------------------------------------------------------
# CPack package and package_source targets
# --------------------------------------------------------------
SET (CPACK_GENERATOR "TGZ;DEB")
SET (CPACK_SET_DESTDIR ON)
SET (CPACK_PACKAGE_NAME "mypackage")
SET (CPACK_PACKAGE_VENDOR "me")
SET (CPACK_PACKAGE_DESCRIPTION_SUMMARY "this is my package description")
SET (CPACK_DEBIAN_PACKAGE_DESCRIPTION "this is my package description
here comes detailed description text.")
INCLUDE (CPack)
The manual has some properties and commands for CPack Components but I doesn't seem to find the right ones or the right place to change at least name and description for every single package/component.
I tried using SET (CPACK_COMPONENT_MAIN_DISPLAY_NAME "main display name")
and SET (CPACK_COMPONENT_main_DISPLAY_NAME "main display name")
as well as cpack_add_component() before INCLUDE(CPack) (which gives me an error) and after (which seems to be ignored).
Did anybody get this to work and knows the right way to do this?
I'm a bit late to the party but in CMake before version 3.5 components packaging was not supported for CPack debian packages.
From version 3.5 on quite a few per component features were added so the easiest way to solve you problem would be to bump the version of CMake and set the variables described in the documentation:
https://cmake.org/cmake/help/v3.5/module/CPackDeb.html or a newer one https://cmake.org/cmake/help/v3.9/module/CPackDeb.html
From last few days I am searching for such solution. Let me first explain first my requirement and then how did i managed to solve problem.
I want to create 4 package from my single project
Generating Master package is easy one and straight forward. But If I use that way then I am unable to use other packages. So after struggling and scraping documents and mail archives, I came to one solution or workaround.
In my solution I am creating One extra custom target for each package I want to create. On that target I am creating other cmake project, which has list of files(Absolute location of file) to be install in that package, build that project and last create package by calling cpack.
Here is my solution.
There may be better/scale-able solution than this, If any one come across that please let me know.