File: UseAsciidoc.cmake

package info (click to toggle)
owncloud-client 2.2.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 23,144 kB
  • ctags: 5,433
  • sloc: cpp: 35,894; ansic: 7,917; perl: 1,474; python: 217; ruby: 174; makefile: 38; sh: 23
file content (58 lines) | stat: -rw-r--r-- 1,669 bytes parent folder | download | duplicates (4)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#  - macro_asciidoc2man(inputfile outputfile)
#
#  Create a manpage with asciidoc.
#  Example: macro_asciidoc2man(foo.txt foo.1)
#
# Copyright (c) 2006, Andreas Schneider, <asn@cryptomilk.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

include(MacroCopyFile)

macro(MACRO_ASCIIDOC2MAN _a2m_input _a2m_output)
  find_program(A2X
    NAMES
      a2x
  )
  #message("+++ A2X: ${A2X}")

  if (A2X)

    #message("+++ ${A2X} --doctype=manpage --format=manpage --destination-dir=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${_a2m_input}")
    macro_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/${_a2m_input} ${CMAKE_CURRENT_BINARY_DIR}/${_a2m_input})

    execute_process(
      COMMAND
        ${A2X} --doctype=manpage --format=manpage ${_a2m_input}
      WORKING_DIRECTORY
        ${CMAKE_CURRENT_BINARY_DIR}
      RESULT_VARIABLE
        A2M_MAN_GENERATED
      ERROR_QUIET
    )

    #message("+++ A2M_MAN_GENERATED: ${A2M_MAN_GENERATED}")
    if (A2M_MAN_GENERATED EQUAL 0)
      find_file(A2M_MAN_FILE
        NAME
          ${_a2m_output}
        PATHS
          ${CMAKE_CURRENT_BINARY_DIR}
        NO_DEFAULT_PATH
      )

      if (A2M_MAN_FILE)
        get_filename_component(A2M_MAN_CATEGORY ${A2M_MAN_FILE} EXT)
        string(SUBSTRING ${A2M_MAN_CATEGORY} 1 1 A2M_MAN_CATEGORY)
        install(
          FILES
            ${A2M_MAN_FILE}
          DESTINATION
            ${MAN_INSTALL_DIR}/man${A2M_MAN_CATEGORY}
        )
      endif (A2M_MAN_FILE)
    endif (A2M_MAN_GENERATED EQUAL 0)

  endif (A2X)
endmacro(MACRO_ASCIIDOC2MAN _a2m_input _a2m_file)