summaryrefslogtreecommitdiff
path: root/doc/man/CMakeLists.txt
blob: add68d62ea999d161937631d971883b20016e9e5 (plain)
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
set(MAN_NAMES
  # Add man page sources here
  flow_accept.3
  flow_alloc.3
  flow_dealloc.3
  flow_read.3
  flow_write.3
  fccntl.3
  fqueue.3
  fqueue_create.3
  fqueue_destroy.3
  fqueue_next.3
  fevent.3
  fset.3
  fset_create.3
  fset_destroy.3
  fset_zero.3
  fset_add.3
  fset_del.3
  fset_has.3
  ouroboros-glossary.7
  ouroboros-tutorial.7
  ouroboros.8
  irmd.8
  irm.8
  )

macro(INSTALL_MAN __mans)
  foreach (_man ${ARGV})
    string(REGEX REPLACE "^.+[.]([1-9]).gz" "\\1" _mansect ${_man})
    install(FILES ${_man} DESTINATION "${CMAKE_INSTALL_MANDIR}/man${_mansect}")
  endforeach (_man)
endmacro(INSTALL_MAN __mans)

find_program(GZIP_EXECUTABLE
  NAMES gzip
  DOC "Will gzip the man pages")

mark_as_advanced(GZIP_EXECUTABLE)

if (GZIP_EXECUTABLE)
  foreach (m ${MAN_NAMES})
    set(md ${CMAKE_CURRENT_BINARY_DIR}/${m}.gz)

    add_custom_command(
      OUTPUT ${md}
      COMMAND ${GZIP_EXECUTABLE}
      ARGS -c ${CMAKE_CURRENT_SOURCE_DIR}/${m} > ${md}
      COMMENT "Compressing manpage ${m}"
      VERBATIM)

    set(MAN_FILES ${MAN_FILES} ${md})
  endforeach ()

  add_custom_target(man ALL DEPENDS ${MAN_FILES})

  INSTALL_MAN(${MAN_FILES})
endif ()