2 ## Copyright (c) 2016, 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 cmake_minimum_required(VERSION 3.5)
14 if (NOT CMAKE_BUILD_TYPE)
15 set(CMAKE_BUILD_TYPE "Release" CACHE
16 "Build type: Debug, Release, RelWithDebInfo or MinSizeRel" STRING FORCE)
20 option(ENABLE_CCACHE "Enable ccache support." OFF)
21 option(ENABLE_DISTCC "Enable distcc support." OFF)
22 option(ENABLE_DOCS "Enable documentation generation (doxygen required)." ON)
23 option(ENABLE_EXAMPLES "Enables build of example code." ON)
24 option(ENABLE_GOMA "Enable goma support." OFF)
25 option(ENABLE_IDE_TEST_HOSTING
26 "Enables running tests within IDEs like Visual Studio and Xcode." OFF)
27 option(ENABLE_NASM "Use nasm instead of yasm for x86 assembly." OFF)
28 option(ENABLE_TOOLS "Enable applications in tools sub directory." ON)
29 option(ENABLE_WERROR "Converts warnings to errors at compile time." OFF)
31 # ARM assembly/intrinsics flags.
32 option(ENABLE_NEON "Enables NEON optimizations on ARM targets." ON)
33 option(ENABLE_NEON_ASM "Enables NEON ASM optimizations on ARM targets." ON)
35 # MIPS assembly/intrinsics flags.
36 option(ENABLE_DSPR2 "Enables DSPR2 optimizations on MIPS targets." OFF)
37 option(ENABLE_MSA "Enables MSA optimizations on MIPS targets." OFF)
39 # x86/x86_64 assembly/intrinsics flags.
40 option(ENABLE_MMX "Enables MMX optimizations on x86/x86_64 targets." ON)
41 option(ENABLE_SSE "Enables SSE optimizations on x86/x86_64 targets." ON)
42 option(ENABLE_SSE2 "Enables SSE2 optimizations on x86/x86_64 targets." ON)
43 option(ENABLE_SSE3 "Enables SSE3 optimizations on x86/x86_64 targets." ON)
44 option(ENABLE_SSSE3 "Enables SSSE3 optimizations on x86/x86_64 targets." ON)
45 option(ENABLE_SSE4_1 "Enables SSE4_1 optimizations on x86/x86_64 targets." ON)
46 option(ENABLE_SSE4_2 "Enables SSE4_2 optimizations on x86/x86_64 targets." ON)
47 option(ENABLE_AVX "Enables AVX optimizations on x86/x86_64 targets." ON)
48 option(ENABLE_AVX2 "Enables AVX2 optimizations on x86/x86_64 targets." ON)
50 # $BUILD_SHARED_LIBS is a CMake built-in-- it's listed here for visibility.
51 option(BUILD_SHARED_LIBS "CMake should generate a shared library build." OFF)
55 set(AOM_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
56 set(AOM_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}")
57 set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH
58 "Installation path of includes")
59 set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH
60 "Installation path of libraries")
62 if ("${AOM_ROOT}" STREQUAL "${AOM_CONFIG_DIR}")
64 "Building from within the aom source tree is not supported.\n"
65 "Hint: Run these commands\n"
66 "$ rm -rf CMakeCache.txt CMakeFiles\n"
67 "$ mkdir -p ../aom_build\n"
69 "And re-run CMake from the aom_build directory.")
72 include("${AOM_ROOT}/build/cmake/aom_configure.cmake")
73 include("${AOM_ROOT}/aom_dsp/aom_dsp.cmake")
74 include("${AOM_ROOT}/aom_mem/aom_mem.cmake")
75 include("${AOM_ROOT}/aom_ports/aom_ports.cmake")
76 include("${AOM_ROOT}/aom_scale/aom_scale.cmake")
77 include("${AOM_ROOT}/aom_util/aom_util.cmake")
78 include("${AOM_ROOT}/av1/av1.cmake")
79 include("${AOM_ROOT}/test/test.cmake")
80 include("${AOM_ROOT}/build/cmake/sanitizers.cmake")
81 include("${AOM_ROOT}/build/cmake/util.cmake")
84 "${AOM_CONFIG_DIR}/aom_dsp_rtcd.h"
85 "${AOM_CONFIG_DIR}/aom_scale_rtcd.h"
86 "${AOM_CONFIG_DIR}/av1_rtcd.h"
87 "${AOM_ROOT}/aom_dsp/aom_dsp_rtcd_defs.pl"
88 "${AOM_ROOT}/aom_dsp/aom_dsp_rtcd.c"
89 "${AOM_ROOT}/aom_scale/aom_scale_rtcd.pl"
90 "${AOM_ROOT}/aom_scale/aom_scale_rtcd.c"
91 "${AOM_ROOT}/av1/common/av1_rtcd_defs.pl"
92 "${AOM_ROOT}/av1/common/av1_rtcd.c"
93 "${AOM_ROOT}/build/make/rtcd.pl")
95 # TODO(tomfinegan): Use libwebm's cmake support directly.
96 set(AOM_LIBWEBM_SOURCES
97 "${AOM_ROOT}/third_party/libwebm/common/hdr_util.cc"
98 "${AOM_ROOT}/third_party/libwebm/common/hdr_util.h"
99 "${AOM_ROOT}/third_party/libwebm/common/webmids.h"
100 "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvmuxer.cc"
101 "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvmuxer.h"
102 "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvmuxertypes.h"
103 "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvmuxerutil.cc"
104 "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvmuxerutil.h"
105 "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvwriter.cc"
106 "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvwriter.h"
107 "${AOM_ROOT}/third_party/libwebm/mkvparser/mkvparser.cc"
108 "${AOM_ROOT}/third_party/libwebm/mkvparser/mkvparser.h"
109 "${AOM_ROOT}/third_party/libwebm/mkvparser/mkvreader.cc"
110 "${AOM_ROOT}/third_party/libwebm/mkvparser/mkvreader.h")
112 set(AOM_LIBYUV_SOURCES
113 "${AOM_ROOT}/third_party/libyuv/include/libyuv/basic_types.h"
114 "${AOM_ROOT}/third_party/libyuv/include/libyuv/convert.h"
115 "${AOM_ROOT}/third_party/libyuv/include/libyuv/convert_argb.h"
116 "${AOM_ROOT}/third_party/libyuv/include/libyuv/convert_from.h"
117 "${AOM_ROOT}/third_party/libyuv/include/libyuv/cpu_id.h"
118 "${AOM_ROOT}/third_party/libyuv/include/libyuv/planar_functions.h"
119 "${AOM_ROOT}/third_party/libyuv/include/libyuv/rotate.h"
120 "${AOM_ROOT}/third_party/libyuv/include/libyuv/row.h"
121 "${AOM_ROOT}/third_party/libyuv/include/libyuv/scale.h"
122 "${AOM_ROOT}/third_party/libyuv/include/libyuv/scale_row.h"
123 "${AOM_ROOT}/third_party/libyuv/source/cpu_id.cc"
124 "${AOM_ROOT}/third_party/libyuv/source/planar_functions.cc"
125 "${AOM_ROOT}/third_party/libyuv/source/row_any.cc"
126 "${AOM_ROOT}/third_party/libyuv/source/row_common.cc"
127 "${AOM_ROOT}/third_party/libyuv/source/row_gcc.cc"
128 "${AOM_ROOT}/third_party/libyuv/source/row_mips.cc"
129 "${AOM_ROOT}/third_party/libyuv/source/row_neon.cc"
130 "${AOM_ROOT}/third_party/libyuv/source/row_neon64.cc"
131 "${AOM_ROOT}/third_party/libyuv/source/row_win.cc"
132 "${AOM_ROOT}/third_party/libyuv/source/scale.cc"
133 "${AOM_ROOT}/third_party/libyuv/source/scale_any.cc"
134 "${AOM_ROOT}/third_party/libyuv/source/scale_common.cc"
135 "${AOM_ROOT}/third_party/libyuv/source/scale_gcc.cc"
136 "${AOM_ROOT}/third_party/libyuv/source/scale_mips.cc"
137 "${AOM_ROOT}/third_party/libyuv/source/scale_neon.cc"
138 "${AOM_ROOT}/third_party/libyuv/source/scale_neon64.cc"
139 "${AOM_ROOT}/third_party/libyuv/source/scale_win.cc")
142 "${AOM_CONFIG_DIR}/aom_config.c"
143 "${AOM_CONFIG_DIR}/aom_config.h"
144 "${AOM_ROOT}/aom/aom.h"
145 "${AOM_ROOT}/aom/aom_codec.h"
146 "${AOM_ROOT}/aom/aom_decoder.h"
147 "${AOM_ROOT}/aom/aom_encoder.h"
148 "${AOM_ROOT}/aom/aom_frame_buffer.h"
149 "${AOM_ROOT}/aom/aom_image.h"
150 "${AOM_ROOT}/aom/aom_integer.h"
151 "${AOM_ROOT}/aom/aomcx.h"
152 "${AOM_ROOT}/aom/aomdx.h"
153 "${AOM_ROOT}/aom/internal/aom_codec_internal.h"
154 "${AOM_ROOT}/aom/src/aom_codec.c"
155 "${AOM_ROOT}/aom/src/aom_decoder.c"
156 "${AOM_ROOT}/aom/src/aom_encoder.c"
157 "${AOM_ROOT}/aom/src/aom_image.c"
158 "${AOM_ROOT}/aom/src/aom_integer.c")
160 set(AOM_COMMON_APP_UTIL_SOURCES
163 "${AOM_ROOT}/md5_utils.c"
164 "${AOM_ROOT}/md5_utils.h"
165 "${AOM_ROOT}/tools_common.c"
166 "${AOM_ROOT}/tools_common.h"
167 "${AOM_ROOT}/video_common.h"
168 "${AOM_ROOT}/y4menc.c"
169 "${AOM_ROOT}/y4menc.h")
171 set(AOM_DECODER_APP_UTIL_SOURCES
172 "${AOM_ROOT}/ivfdec.c"
173 "${AOM_ROOT}/ivfdec.h"
174 "${AOM_ROOT}/video_reader.c"
175 "${AOM_ROOT}/video_reader.h")
177 if (CONFIG_OBU_NO_IVF)
178 list(APPEND AOM_DECODER_APP_UTIL_SOURCES "${AOM_ROOT}/obudec.c" "${AOM_ROOT}/obudec.h")
181 set(AOM_ENCODER_APP_UTIL_SOURCES
182 "${AOM_ROOT}/ivfenc.c"
183 "${AOM_ROOT}/ivfenc.h"
184 "${AOM_ROOT}/video_writer.c"
185 "${AOM_ROOT}/video_writer.h"
186 "${AOM_ROOT}/warnings.c"
187 "${AOM_ROOT}/warnings.h"
188 "${AOM_ROOT}/y4minput.c"
189 "${AOM_ROOT}/y4minput.h"
190 "${AOM_ROOT}/examples/encoder_util.h"
191 "${AOM_ROOT}/examples/encoder_util.c")
193 set(AOM_ENCODER_STATS_SOURCES
194 "${AOM_ROOT}/aomstats.c"
195 "${AOM_ROOT}/aomstats.h"
196 "${AOM_ROOT}/rate_hist.c"
197 "${AOM_ROOT}/rate_hist.h")
199 set(AOM_PKG_CONFIG_SOURCES "${AOM_CONFIG_DIR}/aom.pc")
201 set(AOM_VERSION_SOURCES "${AOM_CONFIG_DIR}/aom_version.h")
203 set(AOM_WEBM_DECODER_SOURCES
204 "${AOM_ROOT}/webmdec.cc"
205 "${AOM_ROOT}/webmdec.h")
207 set(AOM_WEBM_ENCODER_SOURCES
208 "${AOM_ROOT}/webmenc.cc"
209 "${AOM_ROOT}/webmenc.h")
211 include_directories(${AOM_ROOT} ${AOM_CONFIG_DIR})
214 add_library(aom_version ${AOM_VERSION_SOURCES})
215 add_dummy_source_file_to_target(aom_version c)
217 OUTPUT "${AOM_CONFIG_DIR}/aom_version.h"
218 COMMAND ${CMAKE_COMMAND}
219 ARGS -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
220 -DAOM_ROOT=${AOM_ROOT}
221 -DGIT_EXECUTABLE=${GIT_EXECUTABLE}
222 -DPERL_EXECUTABLE=${PERL_EXECUTABLE}
223 -P "${AOM_ROOT}/build/cmake/version.cmake"
224 COMMENT "Writing aom_version.h"
227 add_custom_target(aom_version_check
228 COMMAND ${CMAKE_COMMAND}
229 -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
230 -DAOM_ROOT=${AOM_ROOT}
231 -DGIT_EXECUTABLE=${GIT_EXECUTABLE}
232 -DPERL_EXECUTABLE=${PERL_EXECUTABLE}
233 -P "${AOM_ROOT}/build/cmake/version.cmake"
234 COMMENT "Updating version info if necessary."
236 add_dependencies(aom_version aom_version_check)
239 add_library(aom_pc ${AOM_PKG_CONFIG_SOURCES})
240 add_dummy_source_file_to_target(aom_pc c)
242 OUTPUT "${AOM_CONFIG_DIR}/aom.pc"
243 COMMAND ${CMAKE_COMMAND}
244 ARGS -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
245 -DAOM_ROOT=${AOM_ROOT}
246 -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
247 -DCMAKE_PROJECT_NAME=${CMAKE_PROJECT_NAME}
248 -DCONFIG_MULTITHREAD=${CONFIG_MULTITHREAD}
249 -DHAVE_PTHREAD_H=${HAVE_PTHREAD_H}
250 -P "${AOM_ROOT}/build/cmake/pkg_config.cmake"
251 COMMENT "Writing aom.pc"
253 add_dependencies(aom_pc aom_version)
256 # TODO(tomfinegan): Move rtcd target setup where it belongs for each rtcd
258 add_rtcd_build_step("${AOM_ROOT}/aom_dsp/aom_dsp_rtcd_defs.pl"
259 "${AOM_CONFIG_DIR}/aom_dsp_rtcd.h"
260 "${AOM_ROOT}/aom_dsp/aom_dsp_rtcd.c"
262 add_rtcd_build_step("${AOM_ROOT}/aom_scale/aom_scale_rtcd.pl"
263 "${AOM_CONFIG_DIR}/aom_scale_rtcd.h"
264 "${AOM_ROOT}/aom_scale/aom_scale_rtcd.c"
266 add_rtcd_build_step("${AOM_ROOT}/av1/common/av1_rtcd_defs.pl"
267 "${AOM_CONFIG_DIR}/av1_rtcd.h"
268 "${AOM_ROOT}/av1/common/av1_rtcd.c"
271 add_library(aom_rtcd OBJECT ${AOM_RTCD_SOURCES})
272 add_dependencies(aom_rtcd aom_version)
274 add_library(aom_encoder_stats OBJECT ${AOM_ENCODER_STATS_SOURCES})
275 add_library(aom ${AOM_SOURCES} $<TARGET_OBJECTS:aom_rtcd>)
277 if (NOT MSVC AND NOT APPLE)
278 target_link_libraries(aom ${AOM_LIB_LINK_TYPE} m)
281 # List of object and static library targets.
282 set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_rtcd aom_encoder_stats aom_mem
285 # Setup dependencies.
286 setup_aom_dsp_targets()
287 setup_aom_mem_targets()
288 setup_aom_ports_targets()
289 setup_aom_util_targets()
290 setup_aom_scale_targets()
293 # Make all library targets depend on aom_rtcd to make sure it builds first.
294 foreach (aom_lib ${AOM_LIB_TARGETS})
295 if (NOT "${aom_lib}" STREQUAL "aom_rtcd")
296 add_dependencies(${aom_lib} aom_rtcd)
300 # Generate C/C++ stub files containing the function usage_exit(). Users of the
301 # aom_common_app_util library must define this function. This is a convenience
302 # to allow omission of the function from applications that might want to use
303 # other pieces of the util support without defining usage_exit().
304 file(WRITE "${AOM_CONFIG_DIR}/usage_exit.c" "void usage_exit(void) {}")
305 file(WRITE "${AOM_CONFIG_DIR}/usage_exit.cc"
306 "extern \"C\" void usage_exit(void) {}")
309 # Application and application support targets.
311 if (CONFIG_UNIT_TESTS OR ENABLE_EXAMPLES OR ENABLE_TOOLS)
312 add_library(aom_common_app_util OBJECT ${AOM_COMMON_APP_UTIL_SOURCES})
313 if (CONFIG_AV1_DECODER)
314 add_library(aom_decoder_app_util OBJECT ${AOM_DECODER_APP_UTIL_SOURCES})
315 # obudec depends on internal headers that require *rtcd.h
316 if (CONFIG_OBU_NO_IVF)
317 add_dependencies(aom_decoder_app_util aom_rtcd)
320 if (CONFIG_AV1_ENCODER)
321 add_library(aom_encoder_app_util OBJECT ${AOM_ENCODER_APP_UTIL_SOURCES})
325 if (CONFIG_AV1_DECODER AND ENABLE_EXAMPLES)
326 add_executable(aomdec
327 "${AOM_ROOT}/aomdec.c"
328 $<TARGET_OBJECTS:aom_common_app_util>
329 $<TARGET_OBJECTS:aom_decoder_app_util>)
330 add_executable(decode_to_md5
331 "${AOM_ROOT}/examples/decode_to_md5.c"
332 $<TARGET_OBJECTS:aom_common_app_util>
333 $<TARGET_OBJECTS:aom_decoder_app_util>)
334 add_executable(decode_with_drops
335 "${AOM_ROOT}/examples/decode_with_drops.c"
336 $<TARGET_OBJECTS:aom_common_app_util>
337 $<TARGET_OBJECTS:aom_decoder_app_util>)
338 add_executable(simple_decoder
339 "${AOM_ROOT}/examples/simple_decoder.c"
340 $<TARGET_OBJECTS:aom_common_app_util>
341 $<TARGET_OBJECTS:aom_decoder_app_util>)
342 if (CONFIG_SCALABILITY)
343 add_executable(scalable_decoder
344 "${AOM_ROOT}/examples/scalable_decoder.c"
345 $<TARGET_OBJECTS:aom_common_app_util>
346 $<TARGET_OBJECTS:aom_decoder_app_util>)
350 add_executable(analyzer
351 "${AOM_ROOT}/examples/analyzer.cc"
352 $<TARGET_OBJECTS:aom_common_app_util>
353 $<TARGET_OBJECTS:aom_decoder_app_util>)
354 target_link_libraries(analyzer
355 ${AOM_LIB_LINK_TYPE} ${wxWidgets_LIBRARIES})
356 set(AOM_APP_TARGETS ${AOM_APP_TARGETS} analyzer)
357 set(AOM_DECODER_EXAMPLE_TARGETS ${AOM_DECODER_EXAMPLE_TARGETS} analyzer)
360 if (CONFIG_INSPECTION)
361 add_executable(inspect
362 "${AOM_ROOT}/examples/inspect.c"
363 $<TARGET_OBJECTS:aom_common_app_util>
364 $<TARGET_OBJECTS:aom_decoder_app_util>)
365 set(AOM_DECODER_EXAMPLE_TARGETS ${AOM_DECODER_EXAMPLE_TARGETS} inspect)
368 add_preproc_definition(_POSIX_SOURCE)
369 append_link_flag_to_target("inspect" "-s TOTAL_MEMORY=402653184")
370 append_link_flag_to_target("inspect" "-s MODULARIZE=1")
371 append_link_flag_to_target("inspect"
372 "-s EXPORT_NAME=\"\'DecoderModule\'\"")
373 append_link_flag_to_target("inspect" "--memory-init-file 0")
375 if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
376 # Default to -O3 when no build type specified.
377 append_compiler_flag("-O3")
380 em_link_post_js(inspect "${AOM_ROOT}/tools/inspect-post.js")
384 # Maintain a list of decoder example targets.
385 set(AOM_DECODER_EXAMPLE_TARGETS ${AOM_DECODER_EXAMPLE_TARGETS}
386 aomdec decode_to_md5 decode_with_drops simple_decoder)
388 if (CONFIG_SCALABILITY)
389 set(AOM_DECODER_EXAMPLE_TARGETS ${AOM_DECODER_EXAMPLE_TARGETS}
393 # Add decoder examples to the app targets list.
394 set(AOM_APP_TARGETS ${AOM_APP_TARGETS} ${AOM_DECODER_EXAMPLE_TARGETS})
397 if (CONFIG_AV1_ENCODER)
399 add_executable(aomenc
400 "${AOM_ROOT}/aomenc.c"
401 $<TARGET_OBJECTS:aom_common_app_util>
402 $<TARGET_OBJECTS:aom_encoder_app_util>
403 $<TARGET_OBJECTS:aom_encoder_stats>)
404 add_executable(lossless_encoder
405 "${AOM_ROOT}/examples/lossless_encoder.c"
406 $<TARGET_OBJECTS:aom_common_app_util>
407 $<TARGET_OBJECTS:aom_encoder_app_util>)
408 add_executable(set_maps
409 "${AOM_ROOT}/examples/set_maps.c"
410 $<TARGET_OBJECTS:aom_common_app_util>
411 $<TARGET_OBJECTS:aom_encoder_app_util>)
412 add_executable(simple_encoder
413 "${AOM_ROOT}/examples/simple_encoder.c"
414 $<TARGET_OBJECTS:aom_common_app_util>
415 $<TARGET_OBJECTS:aom_encoder_app_util>)
416 add_executable(twopass_encoder
417 "${AOM_ROOT}/examples/twopass_encoder.c"
418 $<TARGET_OBJECTS:aom_common_app_util>
419 $<TARGET_OBJECTS:aom_encoder_app_util>)
420 if (CONFIG_SCALABILITY)
421 add_executable(scalable_encoder
422 "${AOM_ROOT}/examples/scalable_encoder.c"
423 $<TARGET_OBJECTS:aom_common_app_util>
424 $<TARGET_OBJECTS:aom_encoder_app_util>)
427 # Maintain a list of encoder example targets.
428 set(AOM_ENCODER_EXAMPLE_TARGETS
429 aomenc lossless_encoder set_maps simple_encoder twopass_encoder)
431 if (CONFIG_SCALABILITY)
432 set(AOM_ENCODER_EXAMPLE_TARGETS ${AOM_ENCODER_EXAMPLE_TARGETS}
439 if (CONFIG_ENTROPY_STATS AND NOT BUILD_SHARED_LIBS)
440 # TODO(tomfinegan): Sort out why a simple link command with
441 # aom_entropy_optimizer.c won't work on macos, but dragging in all the
442 # helper machinery allows the link to succeed.
443 add_executable(aom_entropy_optimizer
444 "${AOM_CONFIG_DIR}/usage_exit.c"
445 "${AOM_ROOT}/tools/aom_entropy_optimizer.c"
446 $<TARGET_OBJECTS:aom_common_app_util>
447 $<TARGET_OBJECTS:aom_encoder_app_util>)
449 # Maintain a list of encoder tool targets.
450 set(AOM_ENCODER_TOOL_TARGETS
451 ${AOM_ENCODER_TOOL_TARGETS} aom_entropy_optimizer)
455 # Add encoder examples and tools to the targets list.
456 set(AOM_APP_TARGETS ${AOM_APP_TARGETS}
457 ${AOM_ENCODER_EXAMPLE_TARGETS} ${AOM_ENCODER_TOOL_TARGETS})
461 # Maintain a separate variable listing only the examples to facilitate
462 # installation of example programs into an examples sub directory of
463 # $AOM_DIST_DIR/bin when building the dist target.
464 set(AOM_EXAMPLE_TARGETS
465 ${AOM_DECODER_EXAMPLE_TARGETS} ${AOM_ENCODER_EXAMPLE_TARGETS})
469 if (CONFIG_AV1_DECODER)
470 require_cxx_flag_nomsvc("-std=c++11" NO)
471 add_executable(dump_obu
472 "${AOM_CONFIG_DIR}/usage_exit.cc"
473 "${AOM_ROOT}/tools/dump_obu.cc"
474 "${AOM_ROOT}/tools/obu_parser.cc"
475 "${AOM_ROOT}/tools/obu_parser.h"
476 $<TARGET_OBJECTS:aom_common_app_util>
477 $<TARGET_OBJECTS:aom_decoder_app_util>)
479 list(APPEND AOM_TOOL_TARGETS dump_obu)
480 list(APPEND AOM_APP_TARGETS dump_obu)
483 target_compile_options(dump_obu PUBLIC -std=c++11)
484 # TODO(tomfinegan): This can go once the GCC pragma in libwebm is updated
485 # to silence the auto_ptr warnings for GCC >= v4.
486 target_compile_options(dump_obu PUBLIC -Wno-deprecated-declarations)
489 # Maintain a separate variable listing only the examples to facilitate
490 # installation of example programs into an tools sub directory of
491 # $AOM_DIST_DIR/bin when building the dist target.
492 list(APPEND AOM_TOOL_TARGETS
493 ${AOM_DECODER_TOOL_TARGETS} ${AOM_ENCODER_TOOL_TARGETS})
497 if (ENABLE_EXAMPLES AND CONFIG_AV1_DECODER AND CONFIG_AV1_ENCODER)
498 add_executable(aom_cx_set_ref
499 "${AOM_ROOT}/examples/aom_cx_set_ref.c"
500 $<TARGET_OBJECTS:aom_common_app_util>
501 $<TARGET_OBJECTS:aom_encoder_app_util>)
502 set(AOM_EXAMPLE_TARGETS ${AOM_EXAMPLE_TARGETS} aom_cx_set_ref)
503 set(AOM_APP_TARGETS ${AOM_APP_TARGETS} aom_cx_set_ref)
506 foreach (aom_app ${AOM_APP_TARGETS})
507 target_link_libraries(${aom_app} ${AOM_LIB_LINK_TYPE} aom)
510 if (CONFIG_UNIT_TESTS OR ENABLE_EXAMPLES OR ENABLE_TOOLS)
512 add_library(yuv OBJECT ${AOM_LIBYUV_SOURCES})
514 target_compile_options(yuv PRIVATE -Wno-unused-parameter)
516 include_directories("${AOM_ROOT}/third_party/libyuv/include")
518 # Add to existing targets.
519 foreach (aom_app ${AOM_APP_TARGETS})
520 target_sources(${aom_app} PRIVATE $<TARGET_OBJECTS:yuv>)
521 set_property(TARGET ${aom_app} PROPERTY LINKER_LANGUAGE CXX)
526 add_library(webm OBJECT ${AOM_LIBWEBM_SOURCES})
527 include_directories("${AOM_ROOT}/third_party/libwebm")
528 target_compile_definitions(webm PRIVATE __STDC_CONSTANT_MACROS)
529 target_compile_definitions(webm PRIVATE __STDC_LIMIT_MACROS)
532 target_compile_options(webm PRIVATE -Wno-shadow)
535 # Add to existing targets.
536 if (CONFIG_AV1_DECODER)
537 target_sources(aom_decoder_app_util PRIVATE ${AOM_WEBM_DECODER_SOURCES})
540 if (CONFIG_AV1_ENCODER)
541 target_sources(aom_encoder_app_util PRIVATE ${AOM_WEBM_ENCODER_SOURCES})
544 foreach (aom_app ${AOM_APP_TARGETS})
545 target_sources(${aom_app} PRIVATE $<TARGET_OBJECTS:webm>)
546 set_property(TARGET ${aom_app} PROPERTY LINKER_LANGUAGE CXX)
551 if (CONFIG_UNIT_TESTS)
552 # Create test_libaom target and the targets it depends on.
553 setup_aom_test_targets()
556 if (HAVE_PTHREAD_H AND CONFIG_MULTITHREAD)
557 find_package(Threads)
558 foreach (app_target ${AOM_APP_TARGETS})
559 target_link_libraries(${app_target} ${AOM_LIB_LINK_TYPE} Threads::Threads)
564 # TODO(tomfinegan): Make sure target has no C++ files before doing this as
565 # it's not necessary in that case.
566 if (CONFIG_LIBYUV OR CONFIG_WEBM_IO)
567 # The Xcode generator does not obey LINKER_LANGUAGE. Because of the issue
568 # what looks like a C++ file needs to be in any target that Xcode will link
569 # when the target contains a C++ dependency.
570 # Without this Xcode will try to link with the C linker, which always ends
571 # badly when a dependency actually includes C++.
572 # Note: LINKER_LANGUAGE is explicitly set to C++ for all targets touched
573 # here, it really is the Xcode generator's fault, or just a deficiency in
575 foreach (aom_app ${AOM_APP_TARGETS})
576 add_dummy_source_file_to_target("${aom_app}" "cc")
581 if (ENABLE_EXAMPLES AND "${CMAKE_GENERATOR}" MATCHES "Makefiles$")
582 # For historical purposes place the example binaries in the example directory.
583 file(MAKE_DIRECTORY "${AOM_CONFIG_DIR}/examples")
585 foreach (target ${AOM_EXAMPLE_TARGETS})
586 if (NOT "${target}" MATCHES "aomdec\|aomenc")
587 set_target_properties(${target} PROPERTIES
588 RUNTIME_OUTPUT_DIRECTORY
589 "${AOM_CONFIG_DIR}/examples")
593 if (ENABLE_TOOLS AND AOM_TOOL_TARGETS)
594 # The same expectation is true for tool targets.
595 file(MAKE_DIRECTORY "${AOM_CONFIG_DIR}/tools")
596 set_target_properties(${AOM_TOOL_TARGETS} PROPERTIES
597 RUNTIME_OUTPUT_DIRECTORY "${AOM_CONFIG_DIR}/tools")
601 if (BUILD_SHARED_LIBS)
602 include("${AOM_ROOT}/build/cmake/exports.cmake")
603 setup_exports_target()
604 set_target_properties(aom PROPERTIES SOVERSION 0)
607 # Handle user supplied compile and link flags last to ensure they're obeyed.
610 # Aomedia documentation rule.
614 include("${AOM_ROOT}/docs.cmake")
615 setup_documentation_targets()
617 message("--- Cannot find doxygen, ENABLE_DOCS turned off.")
622 # Aomedia install rule.
624 "${AOM_ROOT}/aom/aom.h"
625 "${AOM_ROOT}/aom/aom_codec.h"
626 "${AOM_ROOT}/aom/aom_frame_buffer.h"
627 "${AOM_ROOT}/aom/aom_image.h"
628 "${AOM_ROOT}/aom/aom_integer.h"
629 "${AOM_ROOT}/aom/aom.h")
631 if (CONFIG_AV1_DECODER)
633 set(AOM_INSTALL_BINS ${AOM_INSTALL_BINS} aomdec)
638 "${AOM_ROOT}/aom/aom_decoder.h"
639 "${AOM_ROOT}/aom/aomdx.h")
642 if (CONFIG_AV1_ENCODER)
644 set(AOM_INSTALL_BINS ${AOM_INSTALL_BINS} aomenc)
649 "${AOM_ROOT}/aom/aomcx.h"
650 "${AOM_ROOT}/aom/aom_encoder.h")
653 set(AOM_INSTALL_LIBS aom)
655 install(FILES ${AOM_INSTALL_INCS}
656 DESTINATION "${INCLUDE_INSTALL_DIR}/aom")
657 install(FILES "${AOM_CONFIG_DIR}/aom.pc"
658 DESTINATION "${LIB_INSTALL_DIR}/pkgconfig")
659 install(TARGETS ${AOM_INSTALL_LIBS} DESTINATION "${LIB_INSTALL_DIR}")
662 install(TARGETS ${AOM_INSTALL_BINS} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
666 if (CONFIG_AV1_DECODER AND ENABLE_EXAMPLES)
667 set(AOM_DIST_APPS ${AOM_DIST_APPS} $<TARGET_FILE:aomdec>)
669 if (CONFIG_AV1_ENCODER AND ENABLE_EXAMPLES)
670 set(AOM_DIST_APPS ${AOM_DIST_APPS} $<TARGET_FILE:aomenc>)
674 foreach (example ${AOM_EXAMPLE_TARGETS})
675 list(APPEND AOM_DIST_EXAMPLES $<TARGET_FILE:${example}>)
680 foreach (tool ${AOM_TOOL_TARGETS})
681 list(APPEND AOM_DIST_TOOLS $<TARGET_FILE:${tool}>)
685 if (NOT AOM_DIST_DIR)
686 set(AOM_DIST_DIR "${AOM_CONFIG_DIR}/dist")
689 add_custom_target(dist
690 COMMAND ${CMAKE_COMMAND}
691 -DAOM_ROOT=${AOM_ROOT}
692 -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
693 -DAOM_DIST_DIR=${AOM_DIST_DIR}
694 -DAOM_DIST_APPS="${AOM_DIST_APPS}"
695 -DAOM_DIST_EXAMPLES="${AOM_DIST_EXAMPLES}"
696 -DAOM_DIST_TOOLS="${AOM_DIST_TOOLS}"
697 -DAOM_DIST_INCLUDES="${AOM_INSTALL_INCS}"
698 -DAOM_DIST_LIBS=$<TARGET_FILE:aom>
699 -DENABLE_DOCS=${ENABLE_DOCS}
700 -P "${AOM_ROOT}/build/cmake/dist.cmake"
701 DEPENDS ${AOM_INSTALL_BINS} ${AOM_INSTALL_LIBS}
702 ${AOM_INSTALL_INCS} ${AOM_EXAMPLE_TARGETS}
706 add_dependencies(dist docs)
709 # Collect all variables containing libaom source files.
710 get_cmake_property(all_cmake_vars VARIABLES)
711 foreach (var ${all_cmake_vars})
712 if ("${var}" MATCHES "SOURCES$\|_INTRIN_\|_ASM_" AND NOT
713 "${var}" MATCHES "_APP_\|DOXYGEN\|LIBWEBM\|LIBYUV\|_PKG_\|TEST")
714 list(APPEND aom_source_vars ${var})
718 # Libaom_srcs.txt generation.
719 set(libaom_srcs_txt_file "${AOM_CONFIG_DIR}/libaom_srcs.txt")
720 file(WRITE "${libaom_srcs_txt_file}" "# This file is generated. DO NOT EDIT.\n")
722 # Static source file list first.
723 foreach (aom_source_var ${aom_source_vars})
724 foreach (file ${${aom_source_var}})
725 if (NOT "${file}" MATCHES "${AOM_CONFIG_DIR}")
726 string(REPLACE "${AOM_ROOT}/" "" file "${file}")
727 file(APPEND "${libaom_srcs_txt_file}" "${file}\n")
732 file(APPEND "${libaom_srcs_txt_file}"
733 "# Files below this line are generated by the libaom build system.\n")
734 foreach (aom_source_var ${aom_source_vars})
735 foreach (file ${${aom_source_var}})
736 if ("${file}" MATCHES "${AOM_CONFIG_DIR}")
737 string(REPLACE "${AOM_CONFIG_DIR}/" "" file "${file}")
738 file(APPEND "${libaom_srcs_txt_file}" "${file}\n")
743 # Libaom_srcs.gni generation.
744 set(libaom_srcs_gni_file "${AOM_CONFIG_DIR}/libaom_srcs.gni")
745 file(WRITE "${libaom_srcs_gni_file}" "# This file is generated. DO NOT EDIT.\n")
747 foreach (aom_source_var ${aom_source_vars})
748 if ("${${aom_source_var}}" MATCHES "${AOM_ROOT}")
749 string(TOLOWER ${aom_source_var} aom_source_var_lowercase)
750 file(APPEND "${libaom_srcs_gni_file}" "\n${aom_source_var_lowercase} = [\n")
753 foreach (file ${${aom_source_var}})
754 if (NOT "${file}" MATCHES "${AOM_CONFIG_DIR}")
755 string(REPLACE "${AOM_ROOT}" "//third_party/aom/src" file "${file}")
756 file(APPEND "${libaom_srcs_gni_file}" " \"${file}\",\n")
760 if ("${${aom_source_var}}" MATCHES "${AOM_ROOT}")
761 file(APPEND "${libaom_srcs_gni_file}" "]\n")
765 file(APPEND "${libaom_srcs_gni_file}"
766 "\n# Files below this line are generated by the libaom build system.\n")
768 foreach (aom_source_var ${aom_source_vars})
769 if ("${${aom_source_var}}" MATCHES "${AOM_CONFIG_DIR}")
770 string(TOLOWER ${aom_source_var} aom_source_var_lowercase)
771 file(APPEND "${libaom_srcs_gni_file}"
772 "\n${aom_source_var_lowercase}_gen = [\n")
774 foreach (file ${${aom_source_var}})
775 if (NOT "${file}" MATCHES "${AOM_ROOT}")
776 string(REPLACE "${AOM_CONFIG_DIR}" "//third_party/aom/src" file "${file}")
777 file(APPEND "${libaom_srcs_gni_file}" " \"${file}\",\n")
781 if ("${${aom_source_var}}" MATCHES "${AOM_CONFIG_DIR}")
782 file(APPEND "${libaom_srcs_gni_file}" "]\n")