blob: 78281f27b573c1db39225029ca8a241204c4918c [file] [log] [blame]
Tom Finegan0d066ce2017-05-30 11:07:05 -07001##
2## Copyright (c) 2017, Alliance for Open Media. All rights reserved
3##
4## This source code is subject to the terms of the BSD 2 Clause License and
5## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6## was not distributed with this source code in the LICENSE file, you can
7## obtain it at www.aomedia.org/license/software. If the Alliance for Open
8## Media Patent License 1.0 was not distributed with this source code in the
9## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10##
11if (NOT AOM_DOCS_CMAKE_)
12set(AOM_DOCS_CMAKE_ 1)
13
14cmake_minimum_required(VERSION 3.5)
15
16set(AOM_DOXYFILE "${AOM_CONFIG_DIR}/doxyfile")
17set(AOM_DOXYGEN_CONFIG_TEMPLATE "libs.doxy_template")
18set(AOM_DOXYGEN_OUTPUT_DIR "${AOM_CONFIG_DIR}/dox")
19set(AOM_DOXYGEN_SECTIONS "av1")
20
21set(AOM_DOXYGEN_SOURCES
22 "${AOM_ROOT}/aom/aom.h"
23 "${AOM_ROOT}/aom/aom_codec.h"
24 "${AOM_ROOT}/aom/aom_frame_buffer.h"
25 "${AOM_ROOT}/aom/aom_image.h"
26 "${AOM_ROOT}/aom/aom_integer.h"
27 "${AOM_ROOT}/keywords.dox"
28 "${AOM_ROOT}/mainpage.dox"
29 "${AOM_ROOT}/usage.dox")
30
31if (CONFIG_AV1_DECODER)
32 set(AOM_DOXYGEN_EXAMPLE_SOURCES
33 ${AOM_DOXYGEN_EXAMPLE_SOURCES}
34 "${AOM_ROOT}/aomdec.c"
35 "${AOM_ROOT}/examples/decode_to_md5.c"
36 "${AOM_ROOT}/examples/decode_with_drops.c"
37 "${AOM_ROOT}/examples/simple_decoder.c")
38
39 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS
40 ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
41 "Full featured decoder."
42 "Frame by frame MD5 checksum."
43 "Drops frames while decoding."
44 "Simplified decoder loop.")
45
46 set(AOM_DOXYGEN_SECTIONS ${AOM_DOXYGEN_SECTIONS} "av1_decoder decoder")
47
48 set(AOM_DOXYGEN_SOURCES
49 ${AOM_DOXYGEN_SOURCES}
50 "${AOM_ROOT}/aom/aom_decoder.h"
51 "${AOM_ROOT}/aom/aomdx.h"
52 "${AOM_ROOT}/usage_dx.dox")
53
54 if (CONFIG_ANALYZER)
55 set(AOM_DOXYGEN_EXAMPLE_SOURCES
56 ${AOM_DOXYGEN_EXAMPLE_SOURCES}
Tom Finegan614bf342017-06-29 09:18:17 -070057 "${AOM_ROOT}/examples/analyzer.cc")
Tom Finegan0d066ce2017-05-30 11:07:05 -070058
59 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS
60 ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
61 "Bitstream analyzer.")
62 endif ()
63
64 if (CONFIG_INSPECTION)
65 set(AOM_DOXYGEN_EXAMPLE_SOURCES
66 ${AOM_DOXYGEN_EXAMPLE_SOURCES}
67 "${AOM_ROOT}/examples/inspect.c")
68
69 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS
70 ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
71 "Bitstream inspector.")
72 endif ()
73endif ()
74
75if (CONFIG_AV1_ENCODER)
76 set(AOM_DOXYGEN_EXAMPLE_SOURCES
77 ${AOM_DOXYGEN_EXAMPLE_SOURCES}
78 "${AOM_ROOT}/aomenc.c"
79 "${AOM_ROOT}/examples/lossless_encoder.c"
80 "${AOM_ROOT}/examples/set_maps.c"
81 "${AOM_ROOT}/examples/simple_encoder.c"
82 "${AOM_ROOT}/examples/twopass_encoder.c")
83
84 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS
85 ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
86 "Full featured encoder."
87 "Simplified lossless encoder."
88 "Set active and ROI maps."
89 "Simplified encoder loop."
90 "Two-pass encoder loop.")
91
Soo-Chul Hanf8589862018-01-24 03:13:14 +000092 set(AOM_DOXYGEN_EXAMPLE_SOURCES
93 ${AOM_DOXYGEN_EXAMPLE_SOURCES}
94 "${AOM_ROOT}/examples/scalable_encoder.c")
95
96 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS
97 ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
98 "Scalable encoder loop.")
Soo-Chul Hanf8589862018-01-24 03:13:14 +000099
Tom Finegan0d066ce2017-05-30 11:07:05 -0700100 set(AOM_DOXYGEN_SECTIONS ${AOM_DOXYGEN_SECTIONS} "av1_encoder encoder")
101
102 set(AOM_DOXYGEN_SOURCES
103 ${AOM_DOXYGEN_SOURCES}
104 "${AOM_ROOT}/aom/aomcx.h"
105 "${AOM_ROOT}/aom/aom_encoder.h"
106 "${AOM_ROOT}/usage_cx.dox")
107endif ()
108
109if (CONFIG_AV1_DECODER AND CONFIG_AV1_ENCODER)
110 set(AOM_DOXYGEN_EXAMPLE_SOURCES
111 ${AOM_DOXYGEN_EXAMPLE_SOURCES}
112 "${AOM_ROOT}/examples/aom_cx_set_ref.c")
113
114 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS
115 ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
116 "Set encoder reference frame.")
117endif ()
118
119# Iterates over list named by $list_name and appends each item to $AOM_DOXYFILE
120# as values assigned to $var_name with no line breaks between list items.
121# Appends a new line after the entire config variable is expanded.
122function (write_cmake_list_to_doxygen_config_var var_name list_name)
123 unset(output_string)
124 foreach (list_item ${${list_name}})
125 set(output_string "${output_string} ${list_item} ")
126 endforeach ()
127 string(STRIP "${output_string}" output_string)
128 file(APPEND "${AOM_DOXYFILE}" "${var_name} += ${output_string}\n")
129endfunction ()
130
131function (get_name file_path name_var)
132 get_filename_component(file_basename ${file_path} NAME)
133 get_filename_component(${name_var} ${file_basename} NAME_WE)
134 set(${name_var} ${${name_var}} PARENT_SCOPE)
135endfunction ()
136
137function (setup_documentation_targets)
138 # Sanity check: the lengths of these lists must match.
139 list(LENGTH AOM_DOXYGEN_EXAMPLE_SOURCES num_sources)
140 list(LENGTH AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS num_descs)
141 if (NOT ${num_sources} EQUAL ${num_descs})
142 message(FATAL_ERROR "Unqeual example and description totals.")
143 endif ()
144
145 # Take the list of examples and produce example_basename.dox for each file in
146 # the list.
147 file(MAKE_DIRECTORY "${AOM_DOXYGEN_OUTPUT_DIR}")
148 foreach (example_file ${AOM_DOXYGEN_EXAMPLE_SOURCES})
149 unset(example_basename)
150 get_name("${example_file}" "example_name")
151 set(example_dox "${AOM_DOXYGEN_OUTPUT_DIR}/${example_name}.dox")
152 set(dox_string "/*!\\page example_${example_name} ${example_name}\n")
153 set(dox_string "${dox_string} \\includelineno ${example_file}\n*/\n")
154 file(WRITE "${example_dox}" ${dox_string})
155 set(AOM_DOXYGEN_SOURCES ${AOM_DOXYGEN_SOURCES} "${example_dox}")
156 endforeach ()
157
158 # Generate samples.dox, an index page that refers to the example_basename.dox
159 # files that were just created.
160 set(samples_header
161"
162/*!\\page samples Sample Code
163This SDK includes a number of sample applications. Each sample documents a
164feature of the SDK in both prose and the associated C code. The following
165samples are included:
166")
167
168 set(utils_desc
169"
170In addition, the SDK contains a number of utilities. Since these utilities are
171built upon the concepts described in the sample code listed above, they are not
172documented in pieces like the samples are. Their source is included here for
173reference. The following utilities are included:
174")
175
176 # Write the description for the samples section.
177 set(samples_dox "${AOM_CONFIG_DIR}/samples.dox")
178 file(WRITE "${samples_dox}" "${samples_header}\n")
179
180 # Iterate over $AOM_DOXYGEN_EXAMPLE_SOURCES and
181 # $AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS and massage example names as required by
182 # AV1's doxygen setup.
183 math(EXPR max_example_index "${num_sources} - 1")
184 foreach (NUM RANGE ${max_example_index})
185 list(GET AOM_DOXYGEN_EXAMPLE_SOURCES ${NUM} ex_name)
186 get_name("${ex_name}" "ex_name")
187
188 # AV1's doxygen lists aomdec and aomenc as utils apart from the examples.
189 # Save the indexes for another pass.
190 if ("${ex_name}" MATCHES "aomdec\|aomenc")
191 set(util_indexes "${util_indexes}" "${NUM}")
192 continue()
193 endif ()
194 list(GET AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${NUM} ex_desc)
195 file(APPEND "${samples_dox}" " - \\subpage example_${ex_name} ${ex_desc}\n")
196 endforeach ()
197
198 # Write the description and index for the utils.
199 file(APPEND "${samples_dox}" "${utils_desc}\n")
200 foreach (util_index ${util_indexes})
201 list(GET AOM_DOXYGEN_EXAMPLE_SOURCES ${util_index} ex_name)
202 get_name("${ex_name}" "ex_name")
203 list(GET AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${util_index} ex_desc)
204 file(APPEND "${samples_dox}" " - \\subpage example_${ex_name} ${ex_desc}\n")
205 endforeach ()
206 file(APPEND "${samples_dox}" "*/")
207
208 # Add $samples_dox to the doxygen inputs.
209 get_filename_component(samples_dox ${samples_dox} NAME)
210 set(AOM_DOXYGEN_SOURCES ${AOM_DOXYGEN_SOURCES} ${samples_dox})
211
212 # Generate libaom's doxyfile.
Tom Finegan746a7852017-06-02 11:29:48 -0700213 file(WRITE "${AOM_DOXYFILE}" "##\n## GENERATED FILE. DO NOT EDIT\n##\n")
214 file(READ "${AOM_ROOT}/${AOM_DOXYGEN_CONFIG_TEMPLATE}" doxygen_template_data)
215 file(APPEND "${AOM_DOXYFILE}" ${doxygen_template_data})
Tom Finegan0d066ce2017-05-30 11:07:05 -0700216 file(APPEND "${AOM_DOXYFILE}"
217 "EXAMPLE_PATH += ${AOM_ROOT} ${AOM_ROOT}/examples\n")
218 file(APPEND
219 "${AOM_DOXYFILE}" "INCLUDE_PATH += ${AOM_CONFIG_DIR} ${AOM_ROOT}\n")
220 file(APPEND "${AOM_DOXYFILE}"
221 "STRIP_FROM_PATH += ${AOM_ROOT} ${AOM_CONFIG_DIR}\n")
222 write_cmake_list_to_doxygen_config_var("INPUT" "AOM_DOXYGEN_SOURCES")
223 write_cmake_list_to_doxygen_config_var("ENABLED_SECTIONS"
224 "AOM_DOXYGEN_SECTIONS")
225
226 # Add the doxygen generation rule.
227 add_custom_target(docs ALL
228 COMMAND "${DOXYGEN_EXECUTABLE}" "${AOM_DOXYFILE}"
229 DEPENDS "${AOM_DOXYFILE}" ${AOM_DOXYGEN_SOURCES}
230 ${AOM_DOXYGEN_EXAMPLE_SOURCES}
Tom Finegan746a7852017-06-02 11:29:48 -0700231 "${AOM_DOXYGEN_CONFIG_TEMPLATE}"
Tom Finegan0d066ce2017-05-30 11:07:05 -0700232 SOURCES "${AOM_DOXYFILE}" ${AOM_DOXYGEN_SOURCES}
Tom Finegan746a7852017-06-02 11:29:48 -0700233 ${AOM_DOXYGEN_EXAMPLE_SOURCES}
234 "${AOM_DOXYGEN_CONFIG_TEMPLATE}")
Tom Finegan0d066ce2017-05-30 11:07:05 -0700235endfunction ()
236
237endif () # AOM_DOCS_CMAKE_