-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathCMakeLists.txt
371 lines (322 loc) · 11.6 KB
/
CMakeLists.txt
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
cmake_minimum_required(VERSION 2.8.12)
project(tarantool-doc)
# Set ldoc executable
set(LUA_EXECUTABLE /usr/bin/lua)
set(LDOC_PATH /usr/local/ldoc/ldoc.lua)
set(LDOC_EXECUTABLE "${LUA_EXECUTABLE} ${LDOC_PATH}")
set(PYTHON3_EXECUTABLE "python3")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_INCLUDE_PATH})
include(FindOptionalPackage)
include(FindPackageMessage)
include(cmake/FindSphinx.cmake)
find_package(Sphinx REQUIRED)
find_package(LATEX)
# Get version
set (PACKAGE_VERSION "")
set (TARANTOOL_VERSION "")
# Try to get version from VERSION file
set(VERSION_FILE_ORIG "${PROJECT_SOURCE_DIR}/VERSION")
set(VERSION_FILE "${PROJECT_BINARY_DIR}/VERSION")
if (EXISTS "${VERSION_FILE_ORIG}")
file (STRINGS "${VERSION_FILE_ORIG}" TARANTOOL_VERSION)
elseif (EXISTS "${VERSION_FILE}")
file (STRINGS "${VERSION_FILE}" TARANTOOL_VERSION)
endif()
if (NOT TARANTOOL_VERSION)
message (FATAL_ERROR "Unable to retrieve version from git or ${VERSION_FILE} file.")
endif()
# Split full version (git describe --long) to get components
string(REPLACE "-" "." TARANTOOL_VERSION_LIST ${TARANTOOL_VERSION})
string(REPLACE "." ";" TARANTOOL_VERSION_LIST ${TARANTOOL_VERSION_LIST})
LIST(GET TARANTOOL_VERSION_LIST 0 CPACK_PACKAGE_VERSION_MAJOR)
LIST(GET TARANTOOL_VERSION_LIST 1 CPACK_PACKAGE_VERSION_MINOR)
LIST(GET TARANTOOL_VERSION_LIST 2 CPACK_PACKAGE_VERSION_PATCH)
set(PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}")
set(PACKAGE_VERSION "${PACKAGE_VERSION}.${CPACK_PACKAGE_VERSION_MINOR}")
set(PACKAGE_VERSION "${PACKAGE_VERSION}.${CPACK_PACKAGE_VERSION_PATCH}")
find_package_message(TARANTOOL_VERSION
"Tarantool version is ${TARANTOOL_VERSION} (${PACKAGE_VERSION})"
"${PACKAGE_VERSION}")
set(SPHINX_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/output")
set(SPHINX_BUILD_LOCALE_DIR "${SPHINX_OUTPUT_DIR}/_locale_build/")
set(SPHINX_BUILD_SINGLEHTML_DIR "${SPHINX_OUTPUT_DIR}/doctrees/single/en/")
set(SPHINX_BUILD_SINGLEHTML_RU_DIR "${SPHINX_OUTPUT_DIR}/doctrees/single/ru/")
set(SPHINX_BUILD_HTML_DIR "${SPHINX_OUTPUT_DIR}/_html_en/")
set(SPHINX_BUILD_HTML_RU_DIR "${SPHINX_OUTPUT_DIR}/_html_ru/")
set(SPHINX_BUILD_HTML_OLD_DIR "${SPHINX_OUTPUT_DIR}/_html_old_en/")
set(SPHINX_BUILD_HTML_RU_OLD_DIR "${SPHINX_OUTPUT_DIR}/_html_old_ru/")
set(SPHINX_BUILD_LATEX_DIR "${SPHINX_OUTPUT_DIR}/_latex_en/")
set(SPHINX_BUILD_LATEX_RU_DIR "${SPHINX_OUTPUT_DIR}/_latex_ru/")
set(SPHINX_BUILD_JSON_EN_DIR "${SPHINX_OUTPUT_DIR}/doctrees/json/en/")
set(SPHINX_BUILD_JSON_RU_DIR "${SPHINX_OUTPUT_DIR}/doctrees/json/ru")
set(SPHINX_EN_HTML_DIR "${SPHINX_OUTPUT_DIR}/html/en/")
set(SPHINX_EN_SINGLEHTML_DIR "${SPHINX_OUTPUT_DIR}/singlehtml/en/")
set(SPHINX_EN_AUTOBUILD_DIR "${SPHINX_OUTPUT_DIR}/html_auto/en/")
set(SPHINX_RU_AUTOBUILD_DIR "${SPHINX_OUTPUT_DIR}/html_auto/ru/")
set(SPHINX_RU_HTML_DIR "${SPHINX_OUTPUT_DIR}/html/ru/")
set(SPHINX_RU_SINGLEHTML_DIR "${SPHINX_OUTPUT_DIR}/singlehtml/ru/")
set(SPHINX_EN_HTML_OLD_DIR "${SPHINX_OUTPUT_DIR}/html_old/en/")
set(SPHINX_RU_HTML_OLD_DIR "${SPHINX_OUTPUT_DIR}/html_old/ru/")
set(SPHINX_EN_JSON_DIR "${SPHINX_OUTPUT_DIR}/json/_build_en/json")
set(SPHINX_RU_JSON_DIR "${SPHINX_OUTPUT_DIR}/json/_build_ru/json")
set(SPHINX_BUILD_EPUB_DIR ${SPHINX_OUTPUT_DIR}/_epub_en/)
set(SPHINX_BUILD_EPUB_RU_DIR ${SPHINX_OUTPUT_DIR}/_epub_ru/)
set(SPHINX_EN_EPUB_DIR ${SPHINX_OUTPUT_DIR}/epub/en/)
set(SPHINX_RU_EPUB_DIR ${SPHINX_OUTPUT_DIR}/epub/ru/)
set(LDOC_CARTRIDGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/modules/cartridge")
set(LDOC_CARTRIDGE_DEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/doc/book/cartridge/cartridge_api")
set(LDOC_CARTRIDGE_CLI_DEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/doc/book/cartridge/cartridge_cli")
add_custom_target(html ALL
COMMAND "${SPHINX_EXECUTABLE}"
-b html
-d "${SPHINX_BUILD_HTML_DIR}"
-c html/
-q
"${CMAKE_CURRENT_SOURCE_DIR}/doc"
"${SPHINX_EN_HTML_DIR}"
COMMENT "Building HTML documentation with Sphinx"
)
add_custom_target(json ALL
COMMAND "${SPHINX_EXECUTABLE}"
-b json
-d "${SPHINX_BUILD_JSON_EN_DIR}"
-c html/
-q
"${CMAKE_CURRENT_SOURCE_DIR}/doc"
"${SPHINX_EN_JSON_DIR}"
-D language=en
COMMENT "Building English JSON documentation with Sphinx"
)
add_custom_target(singlehtml ALL
COMMAND "${SPHINX_EXECUTABLE}"
-b singlehtml
-d "${SPHINX_BUILD_SINGLEHTML_DIR}"
-c singlehtml/
-q
"${CMAKE_CURRENT_SOURCE_DIR}/doc"
"${SPHINX_EN_SINGLEHTML_DIR}"
COMMENT "Building HTML single-page documentation with Sphinx"
)
add_custom_target(singlehtml-website
COMMAND "${SPHINX_EXECUTABLE}"
-b singlehtml
-d "${SPHINX_BUILD_SINGLEHTML_DIR}"
-c singlehtml/
-A rel_path=true
"${CMAKE_CURRENT_SOURCE_DIR}/doc"
"${SPHINX_EN_SINGLEHTML_DIR}"
COMMENT "Building HTML single-page documentation with Sphinx"
)
add_custom_target(singlehtml-ru ALL
COMMAND "${SPHINX_EXECUTABLE}"
-b singlehtml
-d "${SPHINX_BUILD_SINGLEHTML_RU_DIR}"
-c singlehtml/
-D language=ru
"${CMAKE_CURRENT_SOURCE_DIR}/doc"
"${SPHINX_RU_SINGLEHTML_DIR}"
COMMENT "Building Russian HTML single-page documentation with Sphinx"
)
add_custom_target(singlehtml-ru-website
COMMAND "${SPHINX_EXECUTABLE}"
-b singlehtml
-d "${SPHINX_BUILD_SINGLEHTML_RU_DIR}"
-c singlehtml/
-D language=ru
-A rel_path=true
"${CMAKE_CURRENT_SOURCE_DIR}/doc"
"${SPHINX_RU_HTML_DIR}"
COMMENT "Building Russian HTML single-page documentation with Sphinx"
)
add_custom_target(autobuild
COMMAND sphinx-autobuild
-b html
-d "${SPHINX_BUILD_HTML_DIR}"
-c html/
--host 0.0.0.0
--port 8000
-A nolang_path=true
"${CMAKE_CURRENT_SOURCE_DIR}/doc"
"${SPHINX_EN_AUTOBUILD_DIR}"
COMMENT "Build & Live-reload on http://127.0.0.1:8000"
)
add_custom_target(autobuild-ru
COMMAND sphinx-autobuild
-b html
-d "${SPHINX_BUILD_HTML_DIR}"
-c html/
--host 0.0.0.0
--port 8000
-D language=ru
-A nolang_path=true
"${CMAKE_CURRENT_SOURCE_DIR}/doc"
"${SPHINX_RU_AUTOBUILD_DIR}"
COMMENT "Build & Live-reload on http://127.0.0.1:8000"
)
add_custom_target(html-ru ALL
COMMAND "${SPHINX_EXECUTABLE}"
-b html
-d "${SPHINX_BUILD_HTML_RU_DIR}"
-c html/
-q
"${CMAKE_CURRENT_SOURCE_DIR}/doc"
"${SPHINX_RU_HTML_DIR}"
-D language=ru
COMMENT "Building Russian HTML documentation with Sphinx"
)
add_custom_target(html-old-ru ALL
COMMAND "${SPHINX_EXECUTABLE}"
-b html
-d "${SPHINX_BUILD_HTML_RU_OLD_DIR}"
-c html/
"${CMAKE_CURRENT_SOURCE_DIR}/doc"
"${SPHINX_RU_HTML_OLD_DIR}"
-D language=ru -D master_doc=singlehtml
COMMENT "Building Russian HTML documentation with Sphinx"
)
add_custom_target(html-old ALL
COMMAND "${SPHINX_EXECUTABLE}"
-b html
-d "${SPHINX_BUILD_HTML_OLD_DIR}"
-c html/
"${CMAKE_CURRENT_SOURCE_DIR}/doc"
"${SPHINX_EN_HTML_OLD_DIR}"
-D language=en -D master_doc=singlehtml
COMMENT "Building English HTML documentation with Sphinx"
)
add_custom_target(json-ru ALL
COMMAND "${SPHINX_EXECUTABLE}"
-b json
-d "${SPHINX_BUILD_JSON_RU_DIR}"
-c html/
-q
"${CMAKE_CURRENT_SOURCE_DIR}/doc"
"${SPHINX_RU_JSON_DIR}"
-D language=ru
COMMENT "Building Russian JSON documentation with Sphinx"
)
add_custom_target(update-pot
COMMAND "${SPHINX_EXECUTABLE}"
-b gettext
-d "${SPHINX_BUILD_LOCALE_DIR}"
-c locale/
-q
"${CMAKE_CURRENT_SOURCE_DIR}/doc"
"${CMAKE_CURRENT_SOURCE_DIR}/locale/en/"
COMMENT "Update translation sources"
)
add_custom_target(update-po-raw
COMMAND "${SPHINX_INTL_EXECUTABLE}"
update
-p "${CMAKE_CURRENT_SOURCE_DIR}/locale/en/"
-d "${CMAKE_CURRENT_SOURCE_DIR}/locale/"
-l "ru"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/locale
COMMENT "Regenerate localization files from templates"
DEPENDS update-pot
)
add_custom_target(update-po
COMMAND make
update-po-raw
cleanup-po
)
add_custom_target(cleanup-po
COMMAND "${PYTHON3_EXECUTABLE}"
cleanup.py
po
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/locale
COMMENT "Cleanup and rearrange PO files"
)
add_custom_target(cleanup-pot
COMMAND "${PYTHON3_EXECUTABLE}"
cleanup.py
pot
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/locale
COMMENT "Cleanup and rearrange POT files"
)
add_custom_target(linkcheck
COMMAND "${SPHINX_EXECUTABLE}"
-b linkcheck
-d "${SPHINX_BUILD_HTML_DIR}"
-c html
-q
"${CMAKE_CURRENT_SOURCE_DIR}/doc"
"${SPHINX_BUILD_HTML_DIR}"
COMMENT "Linkcheck filter"
)
add_custom_target(submodules
COMMAND cd modules/cartridge-cli && lua /usr/local/ldoc/ldoc.lua
--dir=${LDOC_CARTRIDGE_CLI_DEST_DIR}
--ext=rst
README.md
COMMENT "Generate cartridge-cli rst from lua sources"
)
add_custom_target(epub ALL
COMMAND "${SPHINX_EXECUTABLE}"
-b epub
-d "${SPHINX_BUILD_EPUB_DIR}"
-c epub/
-q
"${CMAKE_CURRENT_SOURCE_DIR}/doc"
"${SPHINX_EN_EPUB_DIR}"
COMMENT "Building English epub with Sphinx"
)
add_custom_target(epub-ru ALL
COMMAND "${SPHINX_EXECUTABLE}"
-b epub
-d "${SPHINX_BUILD_EPUB_RU_DIR}"
-c epub/
-q
-D language=ru
"${CMAKE_CURRENT_SOURCE_DIR}/doc"
"${SPHINX_RU_EPUB_DIR}"
COMMENT "Building Russian epub with Sphinx"
)
add_custom_target(pull-modules ALL
COMMAND /usr/bin/env python3
./pull_submodules.py
COMMENT "Update submodules to their latest commits"
)
add_custom_target(build-modules ALL
COMMAND /usr/bin/env bash
./build_submodules.sh
COMMENT "Rebuild and copy content from submodules"
)
if (LATEX_FOUND)
add_custom_target(pdf-ru ALL COMMENT "PDF generation")
add_custom_command(TARGET pdf-ru
COMMAND "${SPHINX_EXECUTABLE}"
-b latex
-d "${SPHINX_BUILD_LATEX_RU_DIR}"
-c pdf
"${CMAKE_CURRENT_SOURCE_DIR}/doc"
"${SPHINX_BUILD_LATEX_RU_DIR}"
-D language=ru
)
add_custom_command(TARGET pdf-ru
COMMAND "${PDFLATEX_COMPILER}" -interaction nonstopmode Tarantool.tex || true
WORKING_DIRECTORY ${SPHINX_BUILD_LATEX_RU_DIR}
)
add_custom_command(TARGET pdf-ru
COMMAND "${PDFLATEX_COMPILER}" -interaction nonstopmode Tarantool.tex || true
WORKING_DIRECTORY ${SPHINX_BUILD_LATEX_RU_DIR}
)
add_custom_target(pdf ALL COMMENT "PDF generation")
add_custom_command(TARGET pdf
COMMAND "${SPHINX_EXECUTABLE}"
-b latex
-d "${SPHINX_BUILD_LATEX_DIR}"
-c pdf
"${CMAKE_CURRENT_SOURCE_DIR}/doc"
"${SPHINX_BUILD_LATEX_DIR}"
)
add_custom_command(TARGET pdf
COMMAND "${PDFLATEX_COMPILER}" -interaction nonstopmode Tarantool.tex || true
WORKING_DIRECTORY ${SPHINX_BUILD_LATEX_DIR}
)
add_custom_command(TARGET pdf
COMMAND "${PDFLATEX_COMPILER}" -interaction nonstopmode Tarantool.tex || true
WORKING_DIRECTORY ${SPHINX_BUILD_LATEX_DIR}
)
endif()