Debian Codegraph @

doc/CMakeLists.txt

raw
1 # Copyright(C) 2023 Sutou Kouhei <[email protected]>
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17 include(GroongaSphinx)
18 include(${CMAKE_CURRENT_SOURCE_DIR}/files.cmake)
19
20 set(GRN_DOC_PRE_BUILD_STAMP "${CMAKE_CURRENT_SOURCE_DIR}/build-stamp")
21 set(GRN_DOC_LOCALES en ja)
22 foreach(LOCALE ${GRN_DOC_LOCALES})
23 set(GRN_DOC_HTML_FILES_LOCALE)
24 foreach(file ${GRN_DOC_HTML_FILES})
25 list(APPEND GRN_DOC_HTML_FILES_LOCALE
26 ${CMAKE_CURRENT_BINARY_DIR}/${LOCALE}/html/${file})
27 endforeach()
28 if(EXISTS "${GRN_DOC_PRE_BUILD_STAMP}")
29 install(
30 DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/locale/${LOCALE}/html/
31 COMPONENT Document
32 DESTINATION ${CMAKE_INSTALL_DOCDIR}/${LOCALE}
33 PATTERN ".buildinfo" EXCLUDE)
34 else()
35 grn_sphinx(${CMAKE_CURRENT_SOURCE_DIR}/source ${LOCALE}
36 "${GRN_DOC_SOURCES}" "${GRN_DOC_HTML_FILES_LOCALE}")
37 install(
38 DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${LOCALE}/html/
39 COMPONENT Document
40 DESTINATION ${CMAKE_INSTALL_DOCDIR}/${LOCALE}
41 PATTERN ".buildinfo" EXCLUDE)
42 endif()
43 endforeach()
44
45 # TODO: When building packages in `packages/`, the documentation generated by Doxygen should be included.
46 if(NOT EXISTS "${GRN_DOC_PRE_BUILD_STAMP}")
47 find_program(DOXYGEN doxygen REQUIRED)
48 find_path(DOXYGEN_AWESOME_CSS_DIR doxygen-awesome.css
49 HINTS /usr/share/doxygen-awesome-css)
50 if(DOXYGEN_AWESOME_CSS_DIR)
51 message(STATUS "Found doxygen-awesome-css: ${DOXYGEN_AWESOME_CSS_DIR}")
52 set(DOXYGEN_HTML_HEADER "doc/header.html")
53 set(DOXYGEN_HTML_EXTRA_STYLESHEET
54 "${DOXYGEN_AWESOME_CSS_DIR}/doxygen-awesome.css")
55 set(DOXYGEN_HTML_EXTRA_FILES
56 "${DOXYGEN_AWESOME_CSS_DIR}/doxygen-awesome-darkmode-toggle.js \
57 ${DOXYGEN_AWESOME_CSS_DIR}/doxygen-awesome-fragment-copy-button.js \
58 ${DOXYGEN_AWESOME_CSS_DIR}/doxygen-awesome-interactive-toc.js \
59 ${DOXYGEN_AWESOME_CSS_DIR}/doxygen-awesome-paragraph-link.js")
60 else()
61 message(STATUS "doxygen-awesome-css not found, using default Doxygen theme")
62 set(DOXYGEN_HTML_HEADER "")
63 set(DOXYGEN_HTML_EXTRA_STYLESHEET "")
64 set(DOXYGEN_HTML_EXTRA_FILES "")
65 endif()
66 set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/en/html/reference)
67 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
68 ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
69 # Since `${DOXYGEN_OUTPUT_DIRECTORY}` is created by `doc_en_html`,
70 # this target is executed after that.
71 add_custom_target(
72 doc_c_api ALL
73 COMMAND ${DOXYGEN} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
74 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..
75 DEPENDS doc_en_html
76 VERBATIM)
77 endif()
78
79 add_custom_target(
80 doc_update_files
81 COMMAND ${RUBY} ${CMAKE_CURRENT_SOURCE_DIR}/update-files.rb
82 DEPENDS doc_en_html)
83
84 add_custom_target(
85 doc_update_examples
86 COMMAND
87 ${CMAKE_COMMAND} -E env
88 GRN_PLUGINS_DIR=${CMAKE_CURRENT_SOURCE_DIR}/../plugins
89 GRN_PLUGINS_PATH=${CMAKE_CURRENT_BINARY_DIR}/../plugins
90 GRN_RUBY_SCRIPTS_DIR=${CMAKE_CURRENT_SOURCE_DIR}/../lib/mrb/scripts
91 LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}/../lib:$ENV{LD_LIBRARY_PATH}
92 PATH=${CMAKE_CURRENT_BINARY_DIR}/../src:${CMAKE_CURRENT_BINARY_DIR}/../src/suggest:$ENV{PATH}
93 ${RUBY} ${CMAKE_CURRENT_SOURCE_DIR}/update-execution-example.rb
94 DEPENDS groonga groonga-suggest-create-dataset groonga-suggest-httpd
95 groonga-suggest-learner
96 VERBATIM)
97
98 set(GRN_DOC_DEPLOY_DEPENDS)
99 foreach(LOCALE ${GRN_DOC_LOCALES})
100 list(APPEND GRN_DOC_DEPLOY_DEPENDS doc_${LOCALE}_html)
101 endforeach()
102 add_custom_target(
103 doc_deploy
104 COMMAND ${RUBY} ${CMAKE_CURRENT_SOURCE_DIR}/deploy.rb
105 DEPENDS ${GRN_DOC_DEPLOY_DEPENDS}
106 VERBATIM)