2 ## Copyright (c) 2017, Alliance for Open Media. All rights reserved
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.
11 if (NOT AOM_DOCS_CMAKE_)
12 set(AOM_DOCS_CMAKE_ 1)
14 cmake_minimum_required(VERSION 3.5)
16 set(AOM_DOXYFILE "${AOM_CONFIG_DIR}/doxyfile")
17 set(AOM_DOXYGEN_CONFIG_TEMPLATE "libs.doxy_template")
18 set(AOM_DOXYGEN_OUTPUT_DIR "${AOM_CONFIG_DIR}/dox")
19 set(AOM_DOXYGEN_SECTIONS "av1")
21 set(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")
31 if (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")
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.")
46 set(AOM_DOXYGEN_SECTIONS ${AOM_DOXYGEN_SECTIONS} "av1_decoder decoder")
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")
55 set(AOM_DOXYGEN_EXAMPLE_SOURCES
56 ${AOM_DOXYGEN_EXAMPLE_SOURCES}
57 "${AOM_ROOT}/examples/analyzer.cc")
59 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS
60 ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
61 "Bitstream analyzer.")
64 if (CONFIG_INSPECTION)
65 set(AOM_DOXYGEN_EXAMPLE_SOURCES
66 ${AOM_DOXYGEN_EXAMPLE_SOURCES}
67 "${AOM_ROOT}/examples/inspect.c")
69 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS
70 ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
71 "Bitstream inspector.")
75 if (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")
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.")
92 set(AOM_DOXYGEN_EXAMPLE_SOURCES
93 ${AOM_DOXYGEN_EXAMPLE_SOURCES}
94 "${AOM_ROOT}/examples/scalable_encoder.c")
96 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS
97 ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
98 "Scalable encoder loop.")
100 set(AOM_DOXYGEN_SECTIONS ${AOM_DOXYGEN_SECTIONS} "av1_encoder encoder")
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")
109 if (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")
114 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS
115 ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
116 "Set encoder reference frame.")
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.
122 function (write_cmake_list_to_doxygen_config_var var_name list_name)
124 foreach (list_item ${${list_name}})
125 set(output_string "${output_string} ${list_item} ")
127 string(STRIP "${output_string}" output_string)
128 file(APPEND "${AOM_DOXYFILE}" "${var_name} += ${output_string}\n")
131 function (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)
137 function (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.")
145 # Take the list of examples and produce example_basename.dox for each file in
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}")
158 # Generate samples.dox, an index page that refers to the example_basename.dox
159 # files that were just created.
162 /*!\\page samples Sample Code
163 This SDK includes a number of sample applications. Each sample documents a
164 feature of the SDK in both prose and the associated C code. The following
165 samples are included:
170 In addition, the SDK contains a number of utilities. Since these utilities are
171 built upon the concepts described in the sample code listed above, they are not
172 documented in pieces like the samples are. Their source is included here for
173 reference. The following utilities are included:
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")
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")
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}")
194 list(GET AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${NUM} ex_desc)
195 file(APPEND "${samples_dox}" " - \\subpage example_${ex_name} ${ex_desc}\n")
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")
206 file(APPEND "${samples_dox}" "*/")
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})
212 # Generate libaom's doxyfile.
213 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})
216 file(APPEND "${AOM_DOXYFILE}"
217 "EXAMPLE_PATH += ${AOM_ROOT} ${AOM_ROOT}/examples\n")
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")
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}
231 "${AOM_DOXYGEN_CONFIG_TEMPLATE}"
232 SOURCES "${AOM_DOXYFILE}" ${AOM_DOXYGEN_SOURCES}
233 ${AOM_DOXYGEN_EXAMPLE_SOURCES}
234 "${AOM_DOXYGEN_CONFIG_TEMPLATE}")
237 endif () # AOM_DOCS_CMAKE_