blob: b5bfa9b5606ed841fc0c13583ca6f39357895580 [file] [log] [blame]
Johann589bae82018-04-27 10:57:44 -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 the
5# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
6# not distributed with this source code in the LICENSE file, you can obtain it
7# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
8# License 1.0 was not distributed with this source code in the PATENTS file, you
9# can obtain it at www.aomedia.org/license/patent.
10#
11if(AOM_DOCS_CMAKE_)
Johann29a59732018-04-27 10:51:00 -070012 return()
Johann589bae82018-04-27 10:57:44 -070013endif() # AOM_DOCS_CMAKE_
Tom Finegan0d066ce2017-05-30 11:07:05 -070014set(AOM_DOCS_CMAKE_ 1)
15
16cmake_minimum_required(VERSION 3.5)
17
18set(AOM_DOXYFILE "${AOM_CONFIG_DIR}/doxyfile")
19set(AOM_DOXYGEN_CONFIG_TEMPLATE "libs.doxy_template")
20set(AOM_DOXYGEN_OUTPUT_DIR "${AOM_CONFIG_DIR}/dox")
21set(AOM_DOXYGEN_SECTIONS "av1")
22
Johannb72d2e12018-09-11 12:41:38 -070023set(AOM_DOXYGEN_SOURCES
24 "${AOM_ROOT}/aom/aom.h"
25 "${AOM_ROOT}/aom/aom_codec.h"
26 "${AOM_ROOT}/aom/aom_decoder.h"
27 "${AOM_ROOT}/aom/aom_encoder.h"
28 "${AOM_ROOT}/aom/aom_frame_buffer.h"
29 "${AOM_ROOT}/aom/aom_image.h"
30 "${AOM_ROOT}/aom/aom_integer.h"
31 "${AOM_ROOT}/keywords.dox"
32 "${AOM_ROOT}/mainpage.dox"
33 "${AOM_ROOT}/usage.dox")
Tom Finegan0d066ce2017-05-30 11:07:05 -070034
Johann589bae82018-04-27 10:57:44 -070035if(CONFIG_AV1_DECODER)
36 set(AOM_DOXYGEN_EXAMPLE_SOURCES ${AOM_DOXYGEN_EXAMPLE_SOURCES}
Tom Finegan77902132018-05-21 10:19:15 -070037 "${AOM_ROOT}/apps/aomdec.c" "${AOM_ROOT}/examples/decode_to_md5.c"
Tom Finegan0d066ce2017-05-30 11:07:05 -070038 "${AOM_ROOT}/examples/decode_with_drops.c"
39 "${AOM_ROOT}/examples/simple_decoder.c")
40
Johann589bae82018-04-27 10:57:44 -070041 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
42 "Full featured decoder." "Frame by frame MD5 checksum."
43 "Drops frames while decoding." "Simplified decoder loop.")
Tom Finegan0d066ce2017-05-30 11:07:05 -070044
45 set(AOM_DOXYGEN_SECTIONS ${AOM_DOXYGEN_SECTIONS} "av1_decoder decoder")
46
Johannb72d2e12018-09-11 12:41:38 -070047 set(AOM_DOXYGEN_SOURCES ${AOM_DOXYGEN_SOURCES} "${AOM_ROOT}/aom/aomdx.h"
Tom Finegan0d066ce2017-05-30 11:07:05 -070048 "${AOM_ROOT}/usage_dx.dox")
49
Johann589bae82018-04-27 10:57:44 -070050 if(CONFIG_ANALYZER)
51 set(AOM_DOXYGEN_EXAMPLE_SOURCES ${AOM_DOXYGEN_EXAMPLE_SOURCES}
Tom Finegan614bf342017-06-29 09:18:17 -070052 "${AOM_ROOT}/examples/analyzer.cc")
Tom Finegan0d066ce2017-05-30 11:07:05 -070053
Johann589bae82018-04-27 10:57:44 -070054 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
Tom Finegan0d066ce2017-05-30 11:07:05 -070055 "Bitstream analyzer.")
Johann589bae82018-04-27 10:57:44 -070056 endif()
Tom Finegan0d066ce2017-05-30 11:07:05 -070057
Johann589bae82018-04-27 10:57:44 -070058 if(CONFIG_INSPECTION)
59 set(AOM_DOXYGEN_EXAMPLE_SOURCES ${AOM_DOXYGEN_EXAMPLE_SOURCES}
60 "${AOM_ROOT}/examples/inspect.c")
Tom Finegan0d066ce2017-05-30 11:07:05 -070061
Johann589bae82018-04-27 10:57:44 -070062 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
Tom Finegan0d066ce2017-05-30 11:07:05 -070063 "Bitstream inspector.")
Johann589bae82018-04-27 10:57:44 -070064 endif()
65endif()
Tom Finegan0d066ce2017-05-30 11:07:05 -070066
Johann589bae82018-04-27 10:57:44 -070067if(CONFIG_AV1_ENCODER)
68 set(AOM_DOXYGEN_EXAMPLE_SOURCES ${AOM_DOXYGEN_EXAMPLE_SOURCES}
Tom Finegan77902132018-05-21 10:19:15 -070069 "${AOM_ROOT}/apps/aomenc.c" "${AOM_ROOT}/examples/lossless_encoder.c"
Johann589bae82018-04-27 10:57:44 -070070 "${AOM_ROOT}/examples/set_maps.c" "${AOM_ROOT}/examples/simple_encoder.c"
Tom Finegan0d066ce2017-05-30 11:07:05 -070071 "${AOM_ROOT}/examples/twopass_encoder.c")
72
Johann589bae82018-04-27 10:57:44 -070073 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
74 "Full featured encoder." "Simplified lossless encoder."
75 "Set active and ROI maps." "Simplified encoder loop."
Tom Finegan0d066ce2017-05-30 11:07:05 -070076 "Two-pass encoder loop.")
77
Johann589bae82018-04-27 10:57:44 -070078 set(AOM_DOXYGEN_EXAMPLE_SOURCES ${AOM_DOXYGEN_EXAMPLE_SOURCES}
79 "${AOM_ROOT}/examples/scalable_encoder.c")
Soo-Chul Hanf8589862018-01-24 03:13:14 +000080
Johann589bae82018-04-27 10:57:44 -070081 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
82 "Scalable encoder loop.")
Soo-Chul Hanf8589862018-01-24 03:13:14 +000083
Tom Finegan0d066ce2017-05-30 11:07:05 -070084 set(AOM_DOXYGEN_SECTIONS ${AOM_DOXYGEN_SECTIONS} "av1_encoder encoder")
85
Johann589bae82018-04-27 10:57:44 -070086 set(AOM_DOXYGEN_SOURCES ${AOM_DOXYGEN_SOURCES} "${AOM_ROOT}/aom/aomcx.h"
Johannb72d2e12018-09-11 12:41:38 -070087 "${AOM_ROOT}/usage_cx.dox")
Johann589bae82018-04-27 10:57:44 -070088endif()
Tom Finegan0d066ce2017-05-30 11:07:05 -070089
Johann589bae82018-04-27 10:57:44 -070090if(CONFIG_AV1_DECODER AND CONFIG_AV1_ENCODER)
91 set(AOM_DOXYGEN_EXAMPLE_SOURCES ${AOM_DOXYGEN_EXAMPLE_SOURCES}
Tom Finegan0d066ce2017-05-30 11:07:05 -070092 "${AOM_ROOT}/examples/aom_cx_set_ref.c")
93
Johann589bae82018-04-27 10:57:44 -070094 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
Tom Finegan0d066ce2017-05-30 11:07:05 -070095 "Set encoder reference frame.")
Johann589bae82018-04-27 10:57:44 -070096endif()
Tom Finegan0d066ce2017-05-30 11:07:05 -070097
Yunqing Wangb97cfae2018-05-11 14:19:05 -070098if(CONFIG_AV1_ENCODER)
99 set(AOM_DOXYGEN_EXAMPLE_SOURCES ${AOM_DOXYGEN_EXAMPLE_SOURCES}
100 "${AOM_ROOT}/examples/lightfield_encoder.c")
101
102 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
103 "Lightfield encoder example.")
104endif()
105
106if(CONFIG_AV1_DECODER)
107 set(AOM_DOXYGEN_EXAMPLE_SOURCES ${AOM_DOXYGEN_EXAMPLE_SOURCES}
Yunqing Wangd417bb52018-06-03 14:13:38 -0700108 "${AOM_ROOT}/examples/lightfield_tile_list_decoder.c")
109
110 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
111 "Lightfield tile list decoder example.")
112endif()
113
114if(CONFIG_AV1_DECODER)
115 set(AOM_DOXYGEN_EXAMPLE_SOURCES ${AOM_DOXYGEN_EXAMPLE_SOURCES}
Yunqing Wangb97cfae2018-05-11 14:19:05 -0700116 "${AOM_ROOT}/examples/lightfield_decoder.c")
117
118 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
119 "Lightfield decoder example.")
120endif()
121
Yunqing Wang40bde4d2018-06-01 16:48:03 -0700122if(CONFIG_AV1_DECODER AND CONFIG_AV1_ENCODER)
123 set(AOM_DOXYGEN_EXAMPLE_SOURCES ${AOM_DOXYGEN_EXAMPLE_SOURCES}
124 "${AOM_ROOT}/examples/lightfield_bitstream_parsing.c")
125
126 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
127 "Lightfield bitstream parsing example.")
128endif()
129
Tom Finegan0d066ce2017-05-30 11:07:05 -0700130# Iterates over list named by $list_name and appends each item to $AOM_DOXYFILE
131# as values assigned to $var_name with no line breaks between list items.
132# Appends a new line after the entire config variable is expanded.
Johann589bae82018-04-27 10:57:44 -0700133function(write_cmake_list_to_doxygen_config_var var_name list_name)
Tom Finegan0d066ce2017-05-30 11:07:05 -0700134 unset(output_string)
Johann589bae82018-04-27 10:57:44 -0700135 foreach(list_item ${${list_name}})
Tom Finegan0d066ce2017-05-30 11:07:05 -0700136 set(output_string "${output_string} ${list_item} ")
Johann589bae82018-04-27 10:57:44 -0700137 endforeach()
Tom Finegan0d066ce2017-05-30 11:07:05 -0700138 string(STRIP "${output_string}" output_string)
139 file(APPEND "${AOM_DOXYFILE}" "${var_name} += ${output_string}\n")
Johann589bae82018-04-27 10:57:44 -0700140endfunction()
Tom Finegan0d066ce2017-05-30 11:07:05 -0700141
Johann589bae82018-04-27 10:57:44 -0700142function(get_name file_path name_var)
143 get_filename_component(file_basename ${file_path} NAME)
144 get_filename_component(${name_var} ${file_basename} NAME_WE)
145 set(${name_var} ${${name_var}} PARENT_SCOPE)
146endfunction()
Tom Finegan0d066ce2017-05-30 11:07:05 -0700147
Johann589bae82018-04-27 10:57:44 -0700148function(setup_documentation_targets)
149
Tom Finegan0d066ce2017-05-30 11:07:05 -0700150 # Sanity check: the lengths of these lists must match.
151 list(LENGTH AOM_DOXYGEN_EXAMPLE_SOURCES num_sources)
152 list(LENGTH AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS num_descs)
Johann589bae82018-04-27 10:57:44 -0700153 if(NOT ${num_sources} EQUAL ${num_descs})
Tom Finegan0d066ce2017-05-30 11:07:05 -0700154 message(FATAL_ERROR "Unqeual example and description totals.")
Johann589bae82018-04-27 10:57:44 -0700155 endif()
Tom Finegan0d066ce2017-05-30 11:07:05 -0700156
157 # Take the list of examples and produce example_basename.dox for each file in
158 # the list.
159 file(MAKE_DIRECTORY "${AOM_DOXYGEN_OUTPUT_DIR}")
Johann589bae82018-04-27 10:57:44 -0700160 foreach(example_file ${AOM_DOXYGEN_EXAMPLE_SOURCES})
Tom Finegan0d066ce2017-05-30 11:07:05 -0700161 unset(example_basename)
162 get_name("${example_file}" "example_name")
163 set(example_dox "${AOM_DOXYGEN_OUTPUT_DIR}/${example_name}.dox")
164 set(dox_string "/*!\\page example_${example_name} ${example_name}\n")
165 set(dox_string "${dox_string} \\includelineno ${example_file}\n*/\n")
166 file(WRITE "${example_dox}" ${dox_string})
167 set(AOM_DOXYGEN_SOURCES ${AOM_DOXYGEN_SOURCES} "${example_dox}")
Johann589bae82018-04-27 10:57:44 -0700168 endforeach()
Tom Finegan0d066ce2017-05-30 11:07:05 -0700169
170 # Generate samples.dox, an index page that refers to the example_basename.dox
171 # files that were just created.
Johann589bae82018-04-27 10:57:44 -0700172 set(
173 samples_header
174 "
Tom Finegan0d066ce2017-05-30 11:07:05 -0700175/*!\\page samples Sample Code
176This SDK includes a number of sample applications. Each sample documents a
177feature of the SDK in both prose and the associated C code. The following
178samples are included:
Tom Finegan0d066ce2017-05-30 11:07:05 -0700179"
Johann589bae82018-04-27 10:57:44 -0700180 )
181
182 set(
183 utils_desc
184 "
Tom Finegan0d066ce2017-05-30 11:07:05 -0700185In addition, the SDK contains a number of utilities. Since these utilities are
186built upon the concepts described in the sample code listed above, they are not
187documented in pieces like the samples are. Their source is included here for
188reference. The following utilities are included:
Johann589bae82018-04-27 10:57:44 -0700189"
190 )
Tom Finegan0d066ce2017-05-30 11:07:05 -0700191
192 # Write the description for the samples section.
193 set(samples_dox "${AOM_CONFIG_DIR}/samples.dox")
194 file(WRITE "${samples_dox}" "${samples_header}\n")
195
196 # Iterate over $AOM_DOXYGEN_EXAMPLE_SOURCES and
197 # $AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS and massage example names as required by
198 # AV1's doxygen setup.
199 math(EXPR max_example_index "${num_sources} - 1")
Johann589bae82018-04-27 10:57:44 -0700200 foreach(NUM RANGE ${max_example_index})
Tom Finegan0d066ce2017-05-30 11:07:05 -0700201 list(GET AOM_DOXYGEN_EXAMPLE_SOURCES ${NUM} ex_name)
202 get_name("${ex_name}" "ex_name")
203
204 # AV1's doxygen lists aomdec and aomenc as utils apart from the examples.
205 # Save the indexes for another pass.
Johann589bae82018-04-27 10:57:44 -0700206 if("${ex_name}" MATCHES "aomdec\|aomenc")
Tom Finegan0d066ce2017-05-30 11:07:05 -0700207 set(util_indexes "${util_indexes}" "${NUM}")
208 continue()
Johann589bae82018-04-27 10:57:44 -0700209 endif()
Tom Finegan0d066ce2017-05-30 11:07:05 -0700210 list(GET AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${NUM} ex_desc)
211 file(APPEND "${samples_dox}" " - \\subpage example_${ex_name} ${ex_desc}\n")
Johann589bae82018-04-27 10:57:44 -0700212 endforeach()
Tom Finegan0d066ce2017-05-30 11:07:05 -0700213
214 # Write the description and index for the utils.
215 file(APPEND "${samples_dox}" "${utils_desc}\n")
Johann589bae82018-04-27 10:57:44 -0700216 foreach(util_index ${util_indexes})
Tom Finegan0d066ce2017-05-30 11:07:05 -0700217 list(GET AOM_DOXYGEN_EXAMPLE_SOURCES ${util_index} ex_name)
218 get_name("${ex_name}" "ex_name")
219 list(GET AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${util_index} ex_desc)
220 file(APPEND "${samples_dox}" " - \\subpage example_${ex_name} ${ex_desc}\n")
Johann589bae82018-04-27 10:57:44 -0700221 endforeach()
Tom Finegan0d066ce2017-05-30 11:07:05 -0700222 file(APPEND "${samples_dox}" "*/")
223
224 # Add $samples_dox to the doxygen inputs.
225 get_filename_component(samples_dox ${samples_dox} NAME)
226 set(AOM_DOXYGEN_SOURCES ${AOM_DOXYGEN_SOURCES} ${samples_dox})
227
228 # Generate libaom's doxyfile.
Tom Finegan746a7852017-06-02 11:29:48 -0700229 file(WRITE "${AOM_DOXYFILE}" "##\n## GENERATED FILE. DO NOT EDIT\n##\n")
230 file(READ "${AOM_ROOT}/${AOM_DOXYGEN_CONFIG_TEMPLATE}" doxygen_template_data)
231 file(APPEND "${AOM_DOXYFILE}" ${doxygen_template_data})
Tom Finegan0d066ce2017-05-30 11:07:05 -0700232 file(APPEND "${AOM_DOXYFILE}"
Johann589bae82018-04-27 10:57:44 -0700233 "EXAMPLE_PATH += ${AOM_ROOT} ${AOM_ROOT}/examples\n")
Tom Finegan0d066ce2017-05-30 11:07:05 -0700234 file(APPEND "${AOM_DOXYFILE}"
Johann589bae82018-04-27 10:57:44 -0700235 "INCLUDE_PATH += ${AOM_CONFIG_DIR} ${AOM_ROOT}\n")
236 file(APPEND "${AOM_DOXYFILE}"
237 "STRIP_FROM_PATH += ${AOM_ROOT} ${AOM_CONFIG_DIR}\n")
Tom Finegan0d066ce2017-05-30 11:07:05 -0700238 write_cmake_list_to_doxygen_config_var("INPUT" "AOM_DOXYGEN_SOURCES")
239 write_cmake_list_to_doxygen_config_var("ENABLED_SECTIONS"
240 "AOM_DOXYGEN_SECTIONS")
241
242 # Add the doxygen generation rule.
243 add_custom_target(docs ALL
244 COMMAND "${DOXYGEN_EXECUTABLE}" "${AOM_DOXYFILE}"
245 DEPENDS "${AOM_DOXYFILE}" ${AOM_DOXYGEN_SOURCES}
Johann589bae82018-04-27 10:57:44 -0700246 ${AOM_DOXYGEN_EXAMPLE_SOURCES}
247 "${AOM_DOXYGEN_CONFIG_TEMPLATE}"
Tom Finegan0d066ce2017-05-30 11:07:05 -0700248 SOURCES "${AOM_DOXYFILE}" ${AOM_DOXYGEN_SOURCES}
Johann589bae82018-04-27 10:57:44 -0700249 ${AOM_DOXYGEN_EXAMPLE_SOURCES}
250 "${AOM_DOXYGEN_CONFIG_TEMPLATE}")
251endfunction()