summaryrefslogtreecommitdiff
path: root/doc/CMakeLists.txt
blob: 2837321d713e9d4fcddd5d80f050d23395079f10 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#
# Copyright (C) 2003-2022 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2009 Emmanuel Bouthenot <kolter@openics.org>
#
# This file is part of WeeChat, the extensible chat client.
#
# WeeChat is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# WeeChat is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with WeeChat.  If not, see <https://www.gnu.org/licenses/>.
#

if(ENABLE_MAN OR ENABLE_DOC)
  find_package(Asciidoctor)
  if(ASCIIDOCTOR_FOUND)
    # common asciidoctor arguments
    set(ASCIIDOCTOR_ARGS -a experimental -a reproducible -a "prewrap!" -a "webfonts!" -a icons=font -a revnumber="${VERSION}" -a sectanchors -a source-highlighter=pygments -a pygments-style=native)

    # sed arguments used to replace links in ChangeLog and release notes
    set(SED_LINKS_ARGS
      -e "'s/issue #\\([0-9][0-9]*\\)/https:\\/\\/github.com\\/weechat\\/weechat\\/issues\\/\\1[issue #\\1^]/g'"
      -e "'s/bug #\\([0-9][0-9]*\\)/https:\\/\\/savannah.nongnu.org\\/bugs\\/?\\1[bug #\\1^]/g'"
      -e "'s/task #\\([0-9][0-9]*\\)/https:\\/\\/savannah.nongnu.org\\/task\\/?\\1[task #\\1^]/g'"
      -e "'s/patch #\\([0-9][0-9]*\\)/https:\\/\\/savannah.nongnu.org\\/patch\\/?\\1[patch #\\1^]/g'"
      -e "'s/debian #\\([0-9][0-9]*\\)/http:\\/\\/bugs.debian.org\\/cgi-bin\\/bugreport.cgi?bug=\\1[debian bug #\\1^]/g'"
      -e "'s/\\(CVE-[0-9][0-9]*-[0-9][0-9]*\\)/https:\\/\\/cve.mitre.org\\/cgi-bin\\/cvename.cgi?name=\\1[\\1^]/g'"
    )

    # ChangeLog
    add_custom_command(
      OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ChangeLog-links.adoc
      COMMAND sed ARGS ${SED_LINKS_ARGS} ${CMAKE_CURRENT_SOURCE_DIR}/../ChangeLog.adoc > ${CMAKE_CURRENT_BINARY_DIR}/ChangeLog-links.adoc
      DEPENDS
      ${CMAKE_CURRENT_SOURCE_DIR}/../ChangeLog.adoc
      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    )
    add_custom_command(
      OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ChangeLog.html
      COMMAND ${ASCIIDOCTOR_EXECUTABLE} ARGS ${ASCIIDOCTOR_ARGS} -a docinfodir="${CMAKE_CURRENT_SOURCE_DIR}" -o ChangeLog.html ${CMAKE_CURRENT_BINARY_DIR}/ChangeLog-links.adoc
      DEPENDS
      ${CMAKE_CURRENT_SOURCE_DIR}/docinfo.html
      ${CMAKE_CURRENT_BINARY_DIR}/ChangeLog-links.adoc
      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
      COMMENT "Building ChangeLog.html"
    )
    add_custom_target(changelog DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ChangeLog.html)

    # Release notes
    add_custom_command(
      OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ReleaseNotes-links.adoc
      COMMAND sed ARGS ${SED_LINKS_ARGS} ${CMAKE_CURRENT_SOURCE_DIR}/../ReleaseNotes.adoc > ${CMAKE_CURRENT_BINARY_DIR}/ReleaseNotes-links.adoc
      DEPENDS
      ${CMAKE_CURRENT_SOURCE_DIR}/../ReleaseNotes.adoc
      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    )
    add_custom_command(
      OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ReleaseNotes.html
      COMMAND ${ASCIIDOCTOR_EXECUTABLE} ARGS ${ASCIIDOCTOR_ARGS} -a docinfodir="${CMAKE_CURRENT_SOURCE_DIR}" -o ReleaseNotes.html ${CMAKE_CURRENT_BINARY_DIR}/ReleaseNotes-links.adoc
      DEPENDS
      ${CMAKE_CURRENT_SOURCE_DIR}/docinfo.html
      ${CMAKE_CURRENT_BINARY_DIR}/ReleaseNotes-links.adoc
      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
      COMMENT "Building ReleaseNotes.html"
    )
    add_custom_target(rn DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ReleaseNotes.html)

    # man/doc in all languages
    add_subdirectory(cs)
    add_subdirectory(de)
    add_subdirectory(en)
    add_subdirectory(es)
    add_subdirectory(fr)
    add_subdirectory(it)
    add_subdirectory(ja)
    add_subdirectory(pl)
    add_subdirectory(ru)
    add_subdirectory(sr)
  else()
    message(SEND_ERROR "Asciidoctor not found")
  endif()
endif()