Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

man page generation/packaging/installation with cmake

Tags:

manpage

cmake

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

Thanks.

like image 595
Noah Watkins Avatar asked Jul 30 '10 21:07

Noah Watkins


People also ask

What is Cmake_install CMake file?

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.

How does CMake install work?

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.

What is CMake in Linux?

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.


2 Answers

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.

like image 128
Joachim W Avatar answered Sep 28 '22 08:09

Joachim W


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")
like image 37
Nickolay Olshevsky Avatar answered Sep 28 '22 08:09

Nickolay Olshevsky