I am looking for some good examples / tutorials on how to generate, package, and install man pages in projects using CMake.
Asked
Active
Viewed 4,048 times
3 Answers
7
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.

Joachim W
- 7,290
- 5
- 31
- 59
-
4I realise this answer is +1yr old, but because it pops on Google search results, I feel compelled to share that this method issues warnings on CMake >=3.2.2 due to policy CMP0050. The CMake mailing list suggests a way to do what the asker wants: http://www.cmake.org/pipermail/cmake/2010-September/039781.html – silverclaw Jun 22 '15 at 14:07
3
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")

Nickolay Olshevsky
- 13,706
- 1
- 34
- 48
0
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:

DLRdave
- 13,876
- 4
- 53
- 70