Name and description of multiple debian packages with CMake and CPack

时光毁灭记忆、已成空白 提交于 2019-12-07 10:40:59

问题


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?


回答1:


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

  1. Master package: Which contains all binary,static/shared libraries,header files,configuration files and scripts.
  2. Runtime package: Which contains only executable which are required to run my application i.e. binary ,shared library and scripts.
  3. Configuration package: Which contains basic skeleton and place holder for configuration file.
  4. Development packages: Which contains shared/static library and header files.

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.




回答2:


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



来源:https://stackoverflow.com/questions/13600848/name-and-description-of-multiple-debian-packages-with-cmake-and-cpack

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!