forked from mydumper/mydumper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
156 lines (139 loc) · 4.31 KB
/
CMakeLists.txt
File metadata and controls
156 lines (139 loc) · 4.31 KB
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
# Generate documentation in HTML and PDF format using Sphinx.
set(GENERATE_DOC TRUE)
# We use the Sphinx documentation generator to render HTML and manual
# pages from the user and reference documentation in ReST format.
find_package(Sphinx QUIET)
if(NOT SPHINX_FOUND)
message(WARNING "Unable to find Sphinx documentation generator")
set(GENERATE_DOC FALSE)
endif(NOT SPHINX_FOUND)
if(SPHINX_MAJOR_VERSION LESS 1)
message(WARNING "Sphinx is older than v1.0, not building docs")
set(GENERATE_DOC FALSE)
endif(SPHINX_MAJOR_VERSION LESS 1)
if(GENERATE_DOC)
# documentation tools
set(SOURCE_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/_build")
# configured documentation tools and intermediate build results
set(BINARY_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/_build")
# static ReST documentation sources
set(SOURCES_DIR "${CMAKE_CURRENT_BINARY_DIR}/_sources")
# generated ReST documentation sources
set(REF_SOURCES_DIR "${SOURCES_DIR}/reference")
# master document with modules index
set(REF_MASTER_DOC "modules")
# substitute variables in configuration and scripts
foreach(file
conf.py
sources.cmake
)
configure_file(
"${SOURCE_BUILD_DIR}/${file}.in"
"${BINARY_BUILD_DIR}/${file}"
@ONLY
)
endforeach(file)
set(CLEAN_FILES
"${BINARY_BUILD_DIR}/html"
)
add_custom_target(ALL
DEPENDS "${REF_SOURCES_DIR}/${REF_MASTER_DOC}.rst"
)
# Sphinx requires all sources in the same directory tree. As we wish
# to include generated reference documention from the build tree, we
# copy static ReST documents to the build tree before calling Sphinx.
add_custom_target(doc_sources ALL
"${CMAKE_COMMAND}" -P "${BINARY_BUILD_DIR}/sources.cmake"
)
list(APPEND CLEAN_FILES
"${SOURCES_DIR}"
)
# note the trailing slash to exclude directory name
install(DIRECTORY "${SOURCES_DIR}/"
DESTINATION "share/doc/mydumper"
)
# Sphinx cache with pickled ReST documents
set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees")
# HTML output directory
set(SPHINX_HTML_DIR "${CMAKE_CURRENT_BINARY_DIR}/html")
# This target builds HTML documentation using Sphinx.
add_custom_target(doc_html ALL
${SPHINX_EXECUTABLE}
-q -b html
-c "${BINARY_BUILD_DIR}"
-d "${SPHINX_CACHE_DIR}"
"${SOURCES_DIR}"
"${SPHINX_HTML_DIR}"
COMMENT "Building HTML documentation with Sphinx"
)
list(APPEND CLEAN_FILES
"${SPHINX_CACHE_DIR}"
"${SPHINX_HTML_DIR}"
)
add_dependencies(doc_html
doc_sources
)
install(DIRECTORY "${SPHINX_HTML_DIR}"
DESTINATION "share/doc/mydumper"
)
# HTML output directory
set(SPHINX_MAN_DIR "${CMAKE_CURRENT_BINARY_DIR}/man")
# This target builds a manual page using Sphinx.
add_custom_target(doc_man ALL
${SPHINX_EXECUTABLE}
-q -b man
-c "${BINARY_BUILD_DIR}"
-d "${SPHINX_CACHE_DIR}"
"${SOURCES_DIR}"
"${SPHINX_MAN_DIR}"
COMMENT "Building manual page with Sphinx"
)
list(APPEND CLEAN_FILES
"${SPHINX_MAN_DIR}"
)
add_dependencies(doc_man
doc_sources
)
# serialize Sphinx targets to avoid cache conflicts in parallel builds
add_dependencies(doc_man
doc_html
)
install(FILES "${SPHINX_MAN_DIR}/mydumper.1" "${SPHINX_MAN_DIR}/myloader.1"
DESTINATION "share/man/man1"
)
# This target builds PDF documentation using Sphinx and LaTeX.
if(PDFLATEX_COMPILER)
# PDF output directory
set(SPHINX_PDF_DIR "${CMAKE_CURRENT_BINARY_DIR}/pdf")
add_custom_target(doc_pdf ALL
${SPHINX_EXECUTABLE}
-q -b latex
-c "${BINARY_BUILD_DIR}"
-d "${SPHINX_CACHE_DIR}"
"${SOURCES_DIR}"
"${SPHINX_PDF_DIR}"
COMMENT "Building PDF documentation with Sphinx"
)
add_custom_command(TARGET doc_pdf POST_BUILD
COMMAND ${CMAKE_MAKE_PROGRAM} LATEXOPTS=-interaction=batchmode
WORKING_DIRECTORY "${SPHINX_PDF_DIR}"
)
list(APPEND CLEAN_FILES
"${SPHINX_PDF_DIR}"
)
add_dependencies(doc_pdf
doc_sources
)
# serialize Sphinx targets to avoid cache conflicts in parallel builds
add_dependencies(doc_pdf
doc_man
)
install(FILES "${SPHINX_PDF_DIR}/mydumper.pdf"
DESTINATION "share/doc/mydumper"
)
endif(PDFLATEX_COMPILER)
# Add output directories to clean target.
set_directory_properties(PROPERTIES
ADDITIONAL_MAKE_CLEAN_FILES "${CLEAN_FILES}"
)
endif(GENERATE_DOC)