简体   繁体   English

如何使用 CPack 命令(不是来自 CMake 的文件)创建 debian package?

[英]How to create debian package with CPack command (not from CMake's files)?

I have CMake project built and installed.我已经构建并安装了 CMake 项目。 Now I want to generate debian package (*.deb) from this.现在我想从中生成 debian package (*.deb) 。 In the Internet there are many instructions how to create debian package with adding something to CMake's files, but the project, which I've built does not belongs to me, so I shouldn't modify its source.在互联网上有很多说明如何创建 debian package 并在 CMake 的文件中添加一些内容,但是我构建的项目不属于我,所以我不应该修改它的源代码。 I've found command cpack , which is can also generate deb packages.我找到了命令cpack ,它也可以生成 deb 包。 Unfortunately when I try to use the command:不幸的是,当我尝试使用命令时:

cpack -G DEB -C cmake/build/directory -P myPackage.deb -R 1.0.

I see:我懂了:

CPack Error: Please specify build tree of the project that uses CMake using CPACK_INSTALL_CMAKE_PROJECTS, specify CPACK_INSTALL_COMMANDS, CPACK_INSTALL_SCRIPT, or CPACK_INSTALLED_DIRECTORIES.

Unfortunately the options can't be specified in commands in help:不幸的是,无法在帮助中的命令中指定选项:

cpack --help

So is it possible to generate debian package with command cpack without any changes to CMake files?那么是否可以使用命令cpack生成 debian package 而不对 CMake 文件进行任何更改?

When the CMakeLists.txt includes the CPack module, it produces CPackConfig.cmake in the top build directory.CMakeLists.txt包含CPack模块时,它会在顶部构建目录中生成CPackConfig.cmake This config file is the default for CPack, but you can override it w/ --config option.此配置文件是 CPack 的默认配置,但您可以--config选项覆盖它。

The file consists of a bunch of set() commands to set various CPACK_* variables .该文件由一组set()命令组成,用于设置各种CPACK_*变量 To produce a package (the DEB in your question) you ought to write the config file "manually" and set vital variables for CPack, as well as some for DEB generator (ie CPACK_DEBIAN_* ).要生成 package(您问题中的 DEB),您应该“手动”编写配置文件并为 CPack 设置重要变量,以及为DEB生成器设置一些变量(即CPACK_DEBIAN_* )。

Generally, this config (the variables in it) describes what project(s) and it's components to include to package(s), define some meta-data & so on... In theory, you can pass all that defines via -D options to cpack(1) .通常,此配置(其中的变量)描述了要包含到包中的项目及其组件,定义一些元数据等等...理论上,您可以通过-D传递所有定义cpack(1)的选项。 In practice, IMHO, it'll be easier to write the CPackConfig.cmake %)在实践中,恕我直言,编写CPackConfig.cmake %) 会更容易

Having that config file this command should to what you want:有了那个配置文件,这个命令应该是你想要的:

$ cpack -G DEB

(or just cpack alone if your config describes only Debian package to build). (或者如果您的配置仅描述cpack package 来构建,则仅 cpack)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM