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 if (CONFIG_SCALABILITY)
93 set(AOM_DOXYGEN_EXAMPLE_SOURCES
94 ${AOM_DOXYGEN_EXAMPLE_SOURCES}
95 "${AOM_ROOT}/examples/scalable_encoder.c")
97 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS
98 ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
99 "Scalable encoder loop.")
102 set(AOM_DOXYGEN_SECTIONS ${AOM_DOXYGEN_SECTIONS} "av1_encoder encoder")
104 set(AOM_DOXYGEN_SOURCES
105 ${AOM_DOXYGEN_SOURCES}
106 "${AOM_ROOT}/aom/aomcx.h"
107 "${AOM_ROOT}/aom/aom_encoder.h"
108 "${AOM_ROOT}/usage_cx.dox")
111 if (CONFIG_AV1_DECODER AND CONFIG_AV1_ENCODER)
112 set(AOM_DOXYGEN_EXAMPLE_SOURCES
113 ${AOM_DOXYGEN_EXAMPLE_SOURCES}
114 "${AOM_ROOT}/examples/aom_cx_set_ref.c")
116 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS
117 ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
118 "Set encoder reference frame.")
121 # Iterates over list named by $list_name and appends each item to $AOM_DOXYFILE
122 # as values assigned to $var_name with no line breaks between list items.
123 # Appends a new line after the entire config variable is expanded.
124 function (write_cmake_list_to_doxygen_config_var var_name list_name)
126 foreach (list_item ${${list_name}})
127 set(output_string "${output_string} ${list_item} ")
129 string(STRIP "${output_string}" output_string)
130 file(APPEND "${AOM_DOXYFILE}" "${var_name} += ${output_string}\n")
133 function (get_name file_path name_var)
134 get_filename_component(file_basename ${file_path} NAME)
135 get_filename_component(${name_var} ${file_basename} NAME_WE)
136 set(${name_var} ${${name_var}} PARENT_SCOPE)
139 function (setup_documentation_targets)
140 # Sanity check: the lengths of these lists must match.
141 list(LENGTH AOM_DOXYGEN_EXAMPLE_SOURCES num_sources)
142 list(LENGTH AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS num_descs)
143 if (NOT ${num_sources} EQUAL ${num_descs})
144 message(FATAL_ERROR "Unqeual example and description totals.")
147 # Take the list of examples and produce example_basename.dox for each file in
149 file(MAKE_DIRECTORY "${AOM_DOXYGEN_OUTPUT_DIR}")
150 foreach (example_file ${AOM_DOXYGEN_EXAMPLE_SOURCES})
151 unset(example_basename)
152 get_name("${example_file}" "example_name")
153 set(example_dox "${AOM_DOXYGEN_OUTPUT_DIR}/${example_name}.dox")
154 set(dox_string "/*!\\page example_${example_name} ${example_name}\n")
155 set(dox_string "${dox_string} \\includelineno ${example_file}\n*/\n")
156 file(WRITE "${example_dox}" ${dox_string})
157 set(AOM_DOXYGEN_SOURCES ${AOM_DOXYGEN_SOURCES} "${example_dox}")
160 # Generate samples.dox, an index page that refers to the example_basename.dox
161 # files that were just created.
164 /*!\\page samples Sample Code
165 This SDK includes a number of sample applications. Each sample documents a
166 feature of the SDK in both prose and the associated C code. The following
167 samples are included:
172 In addition, the SDK contains a number of utilities. Since these utilities are
173 built upon the concepts described in the sample code listed above, they are not
174 documented in pieces like the samples are. Their source is included here for
175 reference. The following utilities are included:
178 # Write the description for the samples section.
179 set(samples_dox "${AOM_CONFIG_DIR}/samples.dox")
180 file(WRITE "${samples_dox}" "${samples_header}\n")
182 # Iterate over $AOM_DOXYGEN_EXAMPLE_SOURCES and
183 # $AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS and massage example names as required by
184 # AV1's doxygen setup.
185 math(EXPR max_example_index "${num_sources} - 1")
186 foreach (NUM RANGE ${max_example_index})
187 list(GET AOM_DOXYGEN_EXAMPLE_SOURCES ${NUM} ex_name)
188 get_name("${ex_name}" "ex_name")
190 # AV1's doxygen lists aomdec and aomenc as utils apart from the examples.
191 # Save the indexes for another pass.
192 if ("${ex_name}" MATCHES "aomdec\|aomenc")
193 set(util_indexes "${util_indexes}" "${NUM}")
196 list(GET AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${NUM} ex_desc)
197 file(APPEND "${samples_dox}" " - \\subpage example_${ex_name} ${ex_desc}\n")
200 # Write the description and index for the utils.
201 file(APPEND "${samples_dox}" "${utils_desc}\n")
202 foreach (util_index ${util_indexes})
203 list(GET AOM_DOXYGEN_EXAMPLE_SOURCES ${util_index} ex_name)
204 get_name("${ex_name}" "ex_name")
205 list(GET AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${util_index} ex_desc)
206 file(APPEND "${samples_dox}" " - \\subpage example_${ex_name} ${ex_desc}\n")
208 file(APPEND "${samples_dox}" "*/")
210 # Add $samples_dox to the doxygen inputs.
211 get_filename_component(samples_dox ${samples_dox} NAME)
212 set(AOM_DOXYGEN_SOURCES ${AOM_DOXYGEN_SOURCES} ${samples_dox})
214 # Generate libaom's doxyfile.
215 file(WRITE "${AOM_DOXYFILE}" "##\n## GENERATED FILE. DO NOT EDIT\n##\n")
216 file(READ "${AOM_ROOT}/${AOM_DOXYGEN_CONFIG_TEMPLATE}" doxygen_template_data)
217 file(APPEND "${AOM_DOXYFILE}" ${doxygen_template_data})
218 file(APPEND "${AOM_DOXYFILE}"
219 "EXAMPLE_PATH += ${AOM_ROOT} ${AOM_ROOT}/examples\n")
221 "${AOM_DOXYFILE}" "INCLUDE_PATH += ${AOM_CONFIG_DIR} ${AOM_ROOT}\n")
222 file(APPEND "${AOM_DOXYFILE}"
223 "STRIP_FROM_PATH += ${AOM_ROOT} ${AOM_CONFIG_DIR}\n")
224 write_cmake_list_to_doxygen_config_var("INPUT" "AOM_DOXYGEN_SOURCES")
225 write_cmake_list_to_doxygen_config_var("ENABLED_SECTIONS"
226 "AOM_DOXYGEN_SECTIONS")
228 # Add the doxygen generation rule.
229 add_custom_target(docs ALL
230 COMMAND "${DOXYGEN_EXECUTABLE}" "${AOM_DOXYFILE}"
231 DEPENDS "${AOM_DOXYFILE}" ${AOM_DOXYGEN_SOURCES}
232 ${AOM_DOXYGEN_EXAMPLE_SOURCES}
233 "${AOM_DOXYGEN_CONFIG_TEMPLATE}"
234 SOURCES "${AOM_DOXYFILE}" ${AOM_DOXYGEN_SOURCES}
235 ${AOM_DOXYGEN_EXAMPLE_SOURCES}
236 "${AOM_DOXYGEN_CONFIG_TEMPLATE}")
239 endif () # AOM_DOCS_CMAKE_