使用 cmake 生成手册页/打包/安装

发布于 2024-09-12 09:04:43 字数 50 浏览 5 评论 0原文

我正在寻找一些关于如何使用 CMake 在项目中生成、打包和安装手册页的好示例/教程。

I am looking for some good examples / tutorials on how to generate, package, and install man pages in projects using CMake.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

小ぇ时光︴ 2024-09-19 09:04:43

对于 Linux 下的 cmake 2.8.12,以下内容对我有用:

ADD_CUSTOM_TARGET(man ALL)

ADD_CUSTOM_COMMAND(
  TARGET man
  SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/myprog.pod
  COMMAND pod2man ARGS -s 1 -c "myprog manual" ${CMAKE_CURRENT_SOURCE_DIR}/myprog.pod ${CMAKE_CURRENT_BINARY_DIR}/myprog.1
  OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/myprog.1
)

ADD_CUSTOM_COMMAND(
  TARGET man
  SOURCE man
  DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/myprog.1
)

INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/myprog.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/man/man1)

即使按照 CMake 标准,它看起来也不优雅。我希望看到一个更少口吃的解决方案。

With cmake 2.8.12 under Linux, the following works for me:

ADD_CUSTOM_TARGET(man ALL)

ADD_CUSTOM_COMMAND(
  TARGET man
  SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/myprog.pod
  COMMAND pod2man ARGS -s 1 -c "myprog manual" ${CMAKE_CURRENT_SOURCE_DIR}/myprog.pod ${CMAKE_CURRENT_BINARY_DIR}/myprog.1
  OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/myprog.1
)

ADD_CUSTOM_COMMAND(
  TARGET man
  SOURCE man
  DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/myprog.1
)

INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/myprog.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/man/man1)

Which looks unelegant even by CMake standards. I would like to see a solution with less stammering.

空城旧梦 2024-09-19 09:04:43

也许您会对以下解决方案感兴趣,它允许生成和安装用 Markdown 或 AsciiDoc 编写的手册页:

https://github.com/rnpgp/cmake-modules/

要生成并安装用 Markdown 编写的手册页,只需在 CMakeLists.txt 中添加两行:

include(PandocMan)
add_pandoc_man("${CMAKE_CURRENT_SOURCE_DIR}/utility.1.md")

与 AsciiDoc 和 AsciiDoctor 相同:

include(AdocMan)
add_adoc_man("${CMAKE_CURRENT_SOURCE_DIR}/utility.1.adoc")

Maybe you would be interested in the following solution, which allows to generate and install man pages, written in Markdown or AsciiDoc:

https://github.com/rnpgp/cmake-modules/

To generate and install man page, written in Markdown, it would be as easy as add two lines to your CMakeLists.txt:

include(PandocMan)
add_pandoc_man("${CMAKE_CURRENT_SOURCE_DIR}/utility.1.md")

The same with AsciiDoc and AsciiDoctor:

include(AdocMan)
add_adoc_man("${CMAKE_CURRENT_SOURCE_DIR}/utility.1.adoc")
眼中杀气 2024-09-19 09:04:43

这是一个非常简单的解决方案,适用于 deb 和 rpm 软件包:

install(FILES manfile.1 TYPE MAN)

可以在此处找到官方文档:
https://cmake.org/cmake/help/latest/command/ install.html#install
查找大小写匹配的单词 TYPE。

Here is a very simple solution, that works well with both deb and rpm packages:

install(FILES manfile.1 TYPE MAN)

Official documentation can be found here:
https://cmake.org/cmake/help/latest/command/install.html#install
Look for word TYPE with match case.

百合的盛世恋 2024-09-19 09:04:43

您可以深入研究 CMake 本身的源代码树,了解它如何安装自己的手册页。

它肯定是以下组合:

  • 使用 CMake 的 add_custom_command
  • 调用工具在这些自定义命令中生成/生成文档
  • 将结果安装在正确的位置

有关详细信息,请参阅 CMake 的 add_custom_command 和安装命令的文档:

You can delve into the source tree of CMake itself to see how it installs its own man pages.

It is sure to be a combination of:

  • using CMake's add_custom_command
  • calling tools to produce/generate documentation in those custom commands
  • installing the results in the correct location

See the documentation for CMake's add_custom_command and install commands for more information:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文