开发者

man page generation/packaging/installation with cmake

I am looking 开发者_如何学Cfor some good examples / tutorials on how to generate, package, and install man pages in projects using CMake.

Thanks.


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.


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")


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:

  • http://cmake.org/cmake/help/cmake-2-8-docs.html#command:add_custom_command
  • http://cmake.org/cmake/help/cmake-2-8-docs.html#command:install
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜