-1

I'm trying to switch a Makefile-based build to using CMake. I'm ok with specifying the build of the app itself, but - there's also a man (manual) page, in TROFF format.

  • How do I tell CMake to process it into an installable form (e.g. processing if necessary, compression), alongside the building of the executable?
  • How do I get CMake to install it to an appropriate location?
starball
  • 20,030
  • 7
  • 43
  • 238
einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • 1
    what exactly does "installable form" mean? what needs to happen to do that processing? can you elaborate on what logic you want to happen for install location (I.e. elaborate on what "appropriate location" means?) Is there any particular reason why GNUInstallDir's `MANDIR`, `DOCDIR`, or `INFODIR` don't work for you? Or did you just not know about them? – starball Jun 25 '23 at 17:06
  • @starball: 1. See edit. 2. Ok, there's a `MANDIR`, but what command do I issue which uses it? – einpoklum Jun 25 '23 at 19:17
  • How to process troff into installable form? What command exactly do you want to execute? What is the appropriate location of that executable? /usr/bin? – KamilCuk Jun 25 '23 at 20:08
  • 1) so you don't know what processing you want to do with it? Is there a particular reason you think you might need compression? is compression of docs conventional for installation purposes? 2) https://cmake.org/cmake/help/latest/command/install.html#files – starball Jun 25 '23 at 20:08
  • @starball: 1. I've never installed man pages before, so, yes, I don't know. I specifically don't know what one does with TROFF files. Yes, there is a particular reason: On my system, most man pages are gzipped. 2. That page doesn't deal with man files. – einpoklum Jun 26 '23 at 07:07
  • @KamilCuk : "How to process" <- I don't know. I have a TROFF file, I've not handled those before. Maybe I only need to compress it. "What command exactly" <- Again, don't know. Whatever one usually does with TROFFs for man pages. "location of that executable" <- depends on the install prefix. If you like, let's assume it's `/opt/foo/bin`. – einpoklum Jun 26 '23 at 07:09

2 Answers2

1

If you want to compress something, use the file(ARCHIVE_CREATE ...) command.

To install something that's intended to be a manpage, use the install(FILES ...) command and use CMAKE_INSTALL_MANDIR in the DESTINATION argument.

starball
  • 20,030
  • 7
  • 43
  • 238
0

Elaborating on @starball's answer:

There is currently no "hand-holding" specialty mechanism for handling manual files, so you need to take care of archive compression. No preliminary processing of the TROFF file is necessary.

Suppose your program name is foo and the TROFF file's relative path in the repository is doc/foo.1.

First, increase your CMake version dependency to 3.18, to have access to the file(ARCHIVE_CREATE) command variant.

Now, in your CMakeLists.txt, add the following lines:

include(GNUInstallDirs)
file(ARCHIVE_CREATE OUTPUT foo.1.gz PATHS doc/foo.1 FORMAT raw COMPRESSION GZip)
install(FILES foo.1.gz DESTINATION "${CMAKE_INSTALL_MANDIR}")

(the GNUINstallDirs module is what defines the _MANDIR install path.)

einpoklum
  • 118,144
  • 57
  • 340
  • 684