File: pod2man.cmake

package info (click to toggle)
leatherman 1.4.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,944 kB
  • sloc: cpp: 14,555; python: 3,105; sh: 45; makefile: 9; ruby: 1
file content (36 lines) | stat: -rw-r--r-- 1,314 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Taken from https://github.com/tarantool/tarantool

# Generate man pages of the project by using the POD header
# written in the tool source code. To use it - include this
# file in CMakeLists.txt and invoke
# pod2man(<podfile> <manfile> <section> <center>)
find_program(POD2MAN pod2man)

if(NOT POD2MAN)
    message(STATUS "Could not find pod2man - man pages disabled")
endif(NOT POD2MAN)

macro(pod2man PODFILE MANFILE SECTION OUTPATH CENTER)
    if(NOT EXISTS ${PODFILE})
        message(FATAL ERROR "Could not find pod file ${PODFILE} to generate man page")
    endif(NOT EXISTS ${PODFILE})

    if(POD2MAN)
        set(OUTPATH_NEW "${PROJECT_BINARY_DIR}/${OUTPATH}")

        add_custom_command(
            OUTPUT ${OUTPATH_NEW}/${MANFILE}.${SECTION}
            COMMAND ${POD2MAN} --section ${SECTION} --center ${CENTER}
                --release "\"\"" --name ${MANFILE} ${PODFILE}
                ${OUTPATH_NEW}/${MANFILE}.${SECTION}
        )
        set(MANPAGE_TARGET "man-${MANFILE}")
        add_custom_target(${MANPAGE_TARGET} ALL
            DEPENDS ${OUTPATH_NEW}/${MANFILE}.${SECTION}
        )
        install(
            FILES ${OUTPATH_NEW}/${MANFILE}.${SECTION}
            DESTINATION ${OUTPATH}/man${SECTION}
        )
    endif()
endmacro(pod2man PODFILE MANFILE SECTION OUTPATH CENTER)