forked from KhronosGroup/KTX-Software
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocs.cmake
248 lines (226 loc) · 8.55 KB
/
docs.cmake
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
# Copyright 2015-2020 The Khronos Group Inc.
# SPDX-License-Identifier: Apache-2.0
find_package(Doxygen REQUIRED)
set(docdest "${CMAKE_CURRENT_BINARY_DIR}/docs")
# The torturous Doxygen output settings are a hack
# to workaround a doxygen limitation where it will
# only create the trailing directory of the path
# given in, e.g DOXYGEN_HTML_OUTPUT while enabling
# us to put each sub-document in its own directory of
# the html output.
# Global
set( DOXYGEN_PROJECT_LOGO icons/ktx_logo_200.png )
set( DOXYGEN_OUTPUT_DIRECTORY ${docdest}/html)
set( DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES )
set( DOXYGEN_EXTRACT_LOCAL_CLASSES NO )
set( DOXYGEN_HIDE_UNDOC_MEMBERS YES )
set( DOXYGEN_CASE_SENSE_NAMES YES )
set( DOXYGEN_SHOW_USED_FILES NO )
set( DOXYGEN_VERBATIM_HEADERS NO )
set( DOXYGEN_CLANG_ASSISTED_PARSING NO )
set( DOXYGEN_ALPHABETICAL_INDEX NO )
set( DOXYGEN_DISABLE_INDEX YES )
set( DOXYGEN_DISABLE_INDEX NO )
set( DOXYGEN_GENERATE_TREEVIEW YES )
set( DOXYGEN_GENERATE_LATEX NO )
set( DOXYGEN_GENERATE_HTML YES )
set( DOXYGEN_GENERATE_MAN YES )
set( DOXYGEN_MAN_OUTPUT ../man )
# This is to get timestamps with older versions of doxygen.
# older
set( DOXYGEN_HTML_TIMESTAMP YES )
set( DOXYGEN_TIMESTAMP YES )
function( add_sources target sources )
# Make ${sources} show up in IDE/project
get_target_property( doc_sources ${target} SOURCES )
if( NOT doc_sources )
set( doc_sources "" ) # Clear doc_sources-NOTFOUND value.
endif()
set_target_properties(
${target}
PROPERTIES
SOURCES "${doc_sources};${sources}"
)
endfunction()
function( add_docs_cmake target )
# Make `docs.cmake` show up in IDE/project
add_sources( ${target} "cmake/docs.cmake" )
endfunction()
function( add_docs_cmake_plus target sources )
# Make `docs.cmake` plus ${sources} show up in IDE/project
add_sources( ${target} "cmake/docs.cmake;${sources}" )
endfunction()
# Note very well
#
# These projects and accompanying DOXYGEN_LAYOUT_FILES are carefully crafted
# to provide the illusion of a consistent GUI across all the projects.
# Likely this will be fragile in the face of Doxygen changes.
# ktx.doc
function( CreateDocLibKTX )
set( DOXYGEN_PROJECT_NAME "libktx Reference" )
set( DOXYGEN_ALIASES error=\"\\par Errors\\n\" )
set( DOXYGEN_LAYOUT_FILE pkgdoc/libktxDoxyLayout.xml )
set( DOXYGEN_TYPEDEF_HIDES_STRUCT NO )
set( DOXYGEN_EXCLUDE lib/uthash.h )
set( DOXYGEN_EXCLUDE_PATTERNS ktxint.h )
set( DOXYGEN_EXAMPLE_PATH examples lib )
# This does not hide the scope (class) names in the Modules list
# in the ToC. See https://github.com/doxygen/doxygen/issues/9921.
set( DOXYGEN_HIDE_SCOPE_NAMES YES )
set( DOXYGEN_HTML_OUTPUT libktx )
# Order is important here. '_' suffixed prefices must come first
# otherwise the non-suffixed is stripped first leaving just '_'.
set( DOXYGEN_IGNORE_PREFIX KTX_;ktx_;KTX;ktx )
set( DOXYGEN_MAN_LINKS YES )
set( DOXYGEN_MACRO_EXPANSION YES )
set( DOXYGEN_EXPAND_ONLY_PREDEF YES )
set( DOXYGEN_PREDEFINED
"KTXTEXTURECLASSDEFN=class_id classId\; \\
struct ktxTexture_vtbl* vtbl\; \\
struct ktxTexture_vvtbl* vvtbl\; \\
struct ktxTexture_protected* _protected\; \\
ktx_bool_t isArray\; \\
ktx_bool_t isCubemap\; \\
ktx_bool_t isCompressed\; \\
ktx_bool_t generateMipmaps\; \\
ktx_uint32_t baseWidth\; \\
ktx_uint32_t baseHeight\; \\
ktx_uint32_t baseDepth\; \\
ktx_uint32_t numDimensions\; \\
ktx_uint32_t numLevels\; \\
ktx_uint32_t numLayers\; \\
ktx_uint32_t numFaces\; \\
struct { \\
ktxOrientationX x\; \\
ktxOrientationY y\; \\
ktxOrientationZ z\; \\
} orientation\; \\
ktxHashList kvDataHead\; \\
ktx_uint32_t kvDataLen\; \\
ktx_uint8_t* kvData\; \\
ktx_size_t dataSize\; \\
ktx_uint8_t* pData\;"
)
#set( DOXYGEN_GENERATE_TAGFILE ${docdest}/libktx.tag )
doxygen_add_docs(
libktx.doc
lib/libktx_mainpage.md
include
lib/astc_encode.cpp
lib/basis_encode.cpp
lib/basis_transcode.cpp
lib/miniz_wrapper.cpp
lib/strings.c
lib/glloader.c
lib/hashlist.c
lib/filestream.c
lib/memstream.c
lib/texture.c
lib/texture1.c
lib/texture2.c
lib/vkloader.c
lib/writer1.c
lib/writer2.c
)
add_docs_cmake_plus( libktx.doc pkgdoc/libktxDoxyLayout.xml )
endfunction()
# ktxtools.doc
function( CreateDocTools )
set( DOXYGEN_PROJECT_NAME "KTX Tools Reference" )
set( DOXYGEN_FULL_PATH_NAMES NO )
set( DOXYGEN_ALIASES author=\"\\section AUTHOR\\n\" )
set( DOXYGEN_LAYOUT_FILE pkgdoc/toolsDoxyLayout.xml )
set( DOXYGEN_SHOW_FILES NO )
set( DOXYGEN_FILE_PATTERNS *.cpp )
set( DOXYGEN_RECURSIVE YES )
set( DOXYGEN_EXAMPLE_PATH utils tools )
set( DOXYGEN_HTML_OUTPUT ktxtools )
set( DOXYGEN_MAN_EXTENSION .1 )
#set( DOXYGEN_GENERATE_TAGFILE ${docdest}/ktxtools.tag )
set( DOXYGEN_TAGFILES ${docdest}/ktxpkg.tag=.. )
doxygen_add_docs(
tools.doc
tools/ktx/ktx_main.cpp
tools/ktx/command_create.cpp
tools/ktx/command_encode.cpp
tools/ktx/command_extract.cpp
tools/ktx/command_help.cpp
tools/ktx/command_info.cpp
tools/ktx/command_transcode.cpp
tools/ktx/command_validate.cpp
tools/ktx2check/ktx2check.cpp
tools/ktx2ktx2/ktx2ktx2.cpp
tools/ktxinfo/ktxinfo.cpp
tools/ktxsc/ktxsc.cpp
tools/ktxtools_mainpage.md
tools/toktx/toktx.cc
)
add_docs_cmake_plus( tools.doc pkgdoc/toolsDoxyLayout.xml )
endfunction()
# ktxjswrappers.doc
function( CreateDocJSWrappers )
set( DOXYGEN_PROJECT_NAME "KTX Javascript Wrappers Reference" )
set( DOXYGEN_FULL_PATH_NAMES NO )
set( DOXYGEN_ALIASES author=\"\\section AUTHOR\\n\" )
set( DOXYGEN_LAYOUT_FILE pkgdoc/jswrappersDoxyLayout.xml )
set( DOXYGEN_SHOW_FILES NO )
set( DOXYGEN_HTML_OUTPUT ktxjswrappers )
#set( DOXYGEN_GENERATE_TAGFILE ${docdest}/ktxjswrappers.tag )
set( DOXYGEN_TAGFILES ${docdest}/ktxpkg.tag=.. )
doxygen_add_docs(
jswrappers.doc
interface/js_binding
)
add_docs_cmake_plus( jswrappers.doc pkgdoc/jswrappersDoxyLayout.xml )
endfunction()
# ktxpkg.doc
function( CreateDocKTX )
set( DOXYGEN_PROJECT_NAME "Khronos Texture Software" )
set( DOXYGEN_ALIASES pversion=\"\\par Package Version\\n\" )
set( DOXYGEN_LAYOUT_FILE pkgdoc/packageDoxyLayout.xml )
set( DOXYGEN_EXCLUDE lib/uthash.h )
set( DOXYGEN_EXCLUDE_PATTERNS ktxint.h )
set( DOXYGEN_EXAMPLE_PATH lib )
set( DOXYGEN_GENERATE_TAGFILE ${docdest}/ktxpkg.tag )
set( DOXYGEN_HTML_HEADER pkgdoc/header.html )
set( DOXYGEN_HTML_OUTPUT . )
set( DOXYGEN_MAN_LINKS YES )
#set( DOXYGEN_TAGFILES ${docdest}/libktx.tag=libktx ${docdest}/ktxtools.tag=ktxtools )
doxygen_add_docs(
ktxpkg.doc
pkgdoc/pages.md
LICENSE.md
#RELEASE_NOTES.md
)
add_docs_cmake_plus( ktxpkg.doc pkgdoc/packageDoxyLayout.xml )
endfunction()
CreateDocLibKTX()
CreateDocTools()
CreateDocJSWrappers()
CreateDocKTX()
add_dependencies( libktx.doc ktxpkg.doc ktx_version )
add_dependencies( jswrappers.doc ktxpkg.doc )
add_dependencies( tools.doc ktxpkg.doc )
# I want to add a dependency on the "package" built-in target.
# Unfortunately CMake does not support adding dependencies to
# built-in targets. See https://gitlab.kitware.com/cmake/cmake/-/issues/8438.
#
# There also seems to be no way to add a dependency for the install commands
# below. Presumably "install(TARGETS ...)" adds a dependency on each target
# but the rest of that command is simply not appropriate for this case.
add_custom_target( all.doc ALL
DEPENDS tools.doc libktx.doc jswrappers.doc
)
install(
DIRECTORY ${docdest}/html
DESTINATION "${CMAKE_INSTALL_DOCDIR}"
COMPONENT tools
)
install(
DIRECTORY ${docdest}/man/man1
## Omit those, since at the moment they contain a lot of undesired files generated by Doxygen
# ${docdest}/man/man3
# ${docdest}/man/ktx/man3
DESTINATION "${CMAKE_INSTALL_MANDIR}"
COMPONENT tools
)