blob: 6b5d47a723e8e2e1b6e194e133a2318dde3067c6 [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
James Zern70f85382019-05-24 20:31:20 -070023set(AOM_DOXYGEN_SOURCES "${AOM_ROOT}/aom/aom.h" "${AOM_ROOT}/aom/aom_codec.h"
24 "${AOM_ROOT}/aom/aom_decoder.h"
25 "${AOM_ROOT}/aom/aom_encoder.h"
26 "${AOM_ROOT}/aom/aom_frame_buffer.h"
27 "${AOM_ROOT}/aom/aom_image.h"
28 "${AOM_ROOT}/aom/aom_integer.h"
29 "${AOM_ROOT}/keywords.dox" "${AOM_ROOT}/mainpage.dox"
30 "${AOM_ROOT}/usage.dox")
Tom Finegan0d066ce2017-05-30 11:07:05 -070031
Johann589bae82018-04-27 10:57:44 -070032if(CONFIG_AV1_DECODER)
33 set(AOM_DOXYGEN_EXAMPLE_SOURCES ${AOM_DOXYGEN_EXAMPLE_SOURCES}
James Zern70f85382019-05-24 20:31:20 -070034 "${AOM_ROOT}/apps/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")
Tom Finegan0d066ce2017-05-30 11:07:05 -070038
Johann589bae82018-04-27 10:57:44 -070039 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
James Zern70f85382019-05-24 20:31:20 -070040 "Full featured decoder."
41 "Frame by frame MD5 checksum."
42 "Drops frames while decoding."
43 "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"
James Zern70f85382019-05-24 20:31:20 -070048 "${AOM_ROOT}/usage_dx.dox")
Tom Finegan0d066ce2017-05-30 11:07:05 -070049
Johann589bae82018-04-27 10:57:44 -070050 if(CONFIG_ANALYZER)
51 set(AOM_DOXYGEN_EXAMPLE_SOURCES ${AOM_DOXYGEN_EXAMPLE_SOURCES}
James Zern70f85382019-05-24 20:31:20 -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}
James Zern70f85382019-05-24 20:31:20 -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}
James Zern70f85382019-05-24 20:31:20 -070060 "${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}
James Zern70f85382019-05-24 20:31:20 -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}
James Zern70f85382019-05-24 20:31:20 -070069 "${AOM_ROOT}/apps/aomenc.c"
70 "${AOM_ROOT}/examples/lossless_encoder.c"
71 "${AOM_ROOT}/examples/set_maps.c"
72 "${AOM_ROOT}/examples/simple_encoder.c"
73 "${AOM_ROOT}/examples/twopass_encoder.c")
Tom Finegan0d066ce2017-05-30 11:07:05 -070074
Johann589bae82018-04-27 10:57:44 -070075 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
James Zern70f85382019-05-24 20:31:20 -070076 "Full featured encoder."
77 "Simplified lossless encoder."
78 "Set active and ROI maps."
79 "Simplified encoder loop."
80 "Two-pass encoder loop.")
Tom Finegan0d066ce2017-05-30 11:07:05 -070081
Johann589bae82018-04-27 10:57:44 -070082 set(AOM_DOXYGEN_EXAMPLE_SOURCES ${AOM_DOXYGEN_EXAMPLE_SOURCES}
James Zern70f85382019-05-24 20:31:20 -070083 "${AOM_ROOT}/examples/scalable_encoder.c")
Soo-Chul Hanf8589862018-01-24 03:13:14 +000084
Johann589bae82018-04-27 10:57:44 -070085 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
James Zern70f85382019-05-24 20:31:20 -070086 "Scalable encoder loop.")
Soo-Chul Hanf8589862018-01-24 03:13:14 +000087
Tom Finegan0d066ce2017-05-30 11:07:05 -070088 set(AOM_DOXYGEN_SECTIONS ${AOM_DOXYGEN_SECTIONS} "av1_encoder encoder")
89
Johann589bae82018-04-27 10:57:44 -070090 set(AOM_DOXYGEN_SOURCES ${AOM_DOXYGEN_SOURCES} "${AOM_ROOT}/aom/aomcx.h"
James Zern70f85382019-05-24 20:31:20 -070091 "${AOM_ROOT}/usage_cx.dox")
Johann589bae82018-04-27 10:57:44 -070092endif()
Tom Finegan0d066ce2017-05-30 11:07:05 -070093
Johann589bae82018-04-27 10:57:44 -070094if(CONFIG_AV1_DECODER AND CONFIG_AV1_ENCODER)
95 set(AOM_DOXYGEN_EXAMPLE_SOURCES ${AOM_DOXYGEN_EXAMPLE_SOURCES}
James Zern70f85382019-05-24 20:31:20 -070096 "${AOM_ROOT}/examples/aom_cx_set_ref.c")
Tom Finegan0d066ce2017-05-30 11:07:05 -070097
Johann589bae82018-04-27 10:57:44 -070098 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
James Zern70f85382019-05-24 20:31:20 -070099 "Set encoder reference frame.")
Johann589bae82018-04-27 10:57:44 -0700100endif()
Tom Finegan0d066ce2017-05-30 11:07:05 -0700101
Yunqing Wangb97cfae2018-05-11 14:19:05 -0700102if(CONFIG_AV1_ENCODER)
103 set(AOM_DOXYGEN_EXAMPLE_SOURCES ${AOM_DOXYGEN_EXAMPLE_SOURCES}
James Zern70f85382019-05-24 20:31:20 -0700104 "${AOM_ROOT}/examples/lightfield_encoder.c")
Yunqing Wangb97cfae2018-05-11 14:19:05 -0700105
106 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
James Zern70f85382019-05-24 20:31:20 -0700107 "Lightfield encoder example.")
Yunqing Wangb97cfae2018-05-11 14:19:05 -0700108endif()
109
110if(CONFIG_AV1_DECODER)
James Zern70f85382019-05-24 20:31:20 -0700111 set(AOM_DOXYGEN_EXAMPLE_SOURCES
112 ${AOM_DOXYGEN_EXAMPLE_SOURCES}
Yunqing Wangd417bb52018-06-03 14:13:38 -0700113 "${AOM_ROOT}/examples/lightfield_tile_list_decoder.c")
114
115 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
James Zern70f85382019-05-24 20:31:20 -0700116 "Lightfield tile list decoder example.")
Yunqing Wangd417bb52018-06-03 14:13:38 -0700117endif()
118
119if(CONFIG_AV1_DECODER)
120 set(AOM_DOXYGEN_EXAMPLE_SOURCES ${AOM_DOXYGEN_EXAMPLE_SOURCES}
James Zern70f85382019-05-24 20:31:20 -0700121 "${AOM_ROOT}/examples/lightfield_decoder.c")
Yunqing Wangb97cfae2018-05-11 14:19:05 -0700122
123 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
James Zern70f85382019-05-24 20:31:20 -0700124 "Lightfield decoder example.")
Yunqing Wangb97cfae2018-05-11 14:19:05 -0700125endif()
126
Yunqing Wang40bde4d2018-06-01 16:48:03 -0700127if(CONFIG_AV1_DECODER AND CONFIG_AV1_ENCODER)
James Zern70f85382019-05-24 20:31:20 -0700128 set(AOM_DOXYGEN_EXAMPLE_SOURCES
129 ${AOM_DOXYGEN_EXAMPLE_SOURCES}
Yunqing Wang40bde4d2018-06-01 16:48:03 -0700130 "${AOM_ROOT}/examples/lightfield_bitstream_parsing.c")
131
132 set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
James Zern70f85382019-05-24 20:31:20 -0700133 "Lightfield bitstream parsing example.")
Yunqing Wang40bde4d2018-06-01 16:48:03 -0700134endif()
135
Tom Finegan0d066ce2017-05-30 11:07:05 -0700136# Iterates over list named by $list_name and appends each item to $AOM_DOXYFILE
137# as values assigned to $var_name with no line breaks between list items.
138# Appends a new line after the entire config variable is expanded.
Johann589bae82018-04-27 10:57:44 -0700139function(write_cmake_list_to_doxygen_config_var var_name list_name)
Tom Finegan0d066ce2017-05-30 11:07:05 -0700140 unset(output_string)
Johann589bae82018-04-27 10:57:44 -0700141 foreach(list_item ${${list_name}})
Tom Finegan0d066ce2017-05-30 11:07:05 -0700142 set(output_string "${output_string} ${list_item} ")
Johann589bae82018-04-27 10:57:44 -0700143 endforeach()
Tom Finegan0d066ce2017-05-30 11:07:05 -0700144 string(STRIP "${output_string}" output_string)
145 file(APPEND "${AOM_DOXYFILE}" "${var_name} += ${output_string}\n")
Johann589bae82018-04-27 10:57:44 -0700146endfunction()
Tom Finegan0d066ce2017-05-30 11:07:05 -0700147
Johann589bae82018-04-27 10:57:44 -0700148function(get_name file_path name_var)
149 get_filename_component(file_basename ${file_path} NAME)
150 get_filename_component(${name_var} ${file_basename} NAME_WE)
151 set(${name_var} ${${name_var}} PARENT_SCOPE)
152endfunction()
Tom Finegan0d066ce2017-05-30 11:07:05 -0700153
Johann589bae82018-04-27 10:57:44 -0700154function(setup_documentation_targets)
155
Tom Finegan0d066ce2017-05-30 11:07:05 -0700156 # Sanity check: the lengths of these lists must match.
157 list(LENGTH AOM_DOXYGEN_EXAMPLE_SOURCES num_sources)
158 list(LENGTH AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS num_descs)
Johann589bae82018-04-27 10:57:44 -0700159 if(NOT ${num_sources} EQUAL ${num_descs})
Tom Finegan0d066ce2017-05-30 11:07:05 -0700160 message(FATAL_ERROR "Unqeual example and description totals.")
Johann589bae82018-04-27 10:57:44 -0700161 endif()
Tom Finegan0d066ce2017-05-30 11:07:05 -0700162
163 # Take the list of examples and produce example_basename.dox for each file in
164 # the list.
165 file(MAKE_DIRECTORY "${AOM_DOXYGEN_OUTPUT_DIR}")
Johann589bae82018-04-27 10:57:44 -0700166 foreach(example_file ${AOM_DOXYGEN_EXAMPLE_SOURCES})
Tom Finegan0d066ce2017-05-30 11:07:05 -0700167 unset(example_basename)
168 get_name("${example_file}" "example_name")
169 set(example_dox "${AOM_DOXYGEN_OUTPUT_DIR}/${example_name}.dox")
170 set(dox_string "/*!\\page example_${example_name} ${example_name}\n")
171 set(dox_string "${dox_string} \\includelineno ${example_file}\n*/\n")
172 file(WRITE "${example_dox}" ${dox_string})
173 set(AOM_DOXYGEN_SOURCES ${AOM_DOXYGEN_SOURCES} "${example_dox}")
Johann589bae82018-04-27 10:57:44 -0700174 endforeach()
Tom Finegan0d066ce2017-05-30 11:07:05 -0700175
176 # Generate samples.dox, an index page that refers to the example_basename.dox
177 # files that were just created.
James Zern70f85382019-05-24 20:31:20 -0700178 set(samples_header "
Tom Finegan0d066ce2017-05-30 11:07:05 -0700179/*!\\page samples Sample Code
180This SDK includes a number of sample applications. Each sample documents a
181feature of the SDK in both prose and the associated C code. The following
182samples are included:
James Zern70f85382019-05-24 20:31:20 -0700183")
Johann589bae82018-04-27 10:57:44 -0700184
James Zern70f85382019-05-24 20:31:20 -0700185 set(utils_desc "
Tom Finegan0d066ce2017-05-30 11:07:05 -0700186In addition, the SDK contains a number of utilities. Since these utilities are
187built upon the concepts described in the sample code listed above, they are not
188documented in pieces like the samples are. Their source is included here for
189reference. The following utilities are included:
James Zern70f85382019-05-24 20:31:20 -0700190")
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}"
James Zern70f85382019-05-24 20:31:20 -0700233 "EXAMPLE_PATH += ${AOM_ROOT} ${AOM_ROOT}/examples\n")
Tom Finegan0d066ce2017-05-30 11:07:05 -0700234 file(APPEND "${AOM_DOXYFILE}"
James Zern70f85382019-05-24 20:31:20 -0700235 "INCLUDE_PATH += ${AOM_CONFIG_DIR} ${AOM_ROOT}\n")
Johann589bae82018-04-27 10:57:44 -0700236 file(APPEND "${AOM_DOXYFILE}"
James Zern70f85382019-05-24 20:31:20 -0700237 "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()