I am looking for some good examples / tutorials on how to generate, package, and install man pages in projects using CMake.
Thanks.
cmake contains the commands generated by install command from your CMakeLists. txt . You can execute it by cmake -P cmake_install. cmake and it performs the installation of your project even on windows.
CMake provides the install command to specify how a project is to be installed. This command is invoked by a project in the CMakeLists file and tells CMake how to generate installation scripts. The scripts are executed at install time to perform the actual installation of files.
CMake is an open-source, cross-platform tool that uses compiler and platform independent configuration files to generate native build tool files specific to your compiler and platform. The CMake Tools extension integrates Visual Studio Code and CMake to make it easy to configure, build, and debug your C++ project.
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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With