summaryrefslogtreecommitdiffstats
path: root/third_party/aom/build/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/aom/build/cmake')
-rw-r--r--third_party/aom/build/cmake/aom_config.c.cmake15
-rw-r--r--third_party/aom/build/cmake/aom_config_defaults.cmake167
-rw-r--r--third_party/aom/build/cmake/aom_configure.cmake306
-rw-r--r--third_party/aom/build/cmake/aom_optimization.cmake204
-rwxr-xr-xthird_party/aom/build/cmake/aom_version.pl93
-rw-r--r--third_party/aom/build/cmake/compiler_flags.cmake218
-rw-r--r--third_party/aom/build/cmake/compiler_tests.cmake133
-rw-r--r--third_party/aom/build/cmake/cpu.cmake72
-rw-r--r--third_party/aom/build/cmake/generate_aom_config_templates.cmake84
-rw-r--r--third_party/aom/build/cmake/msvc_runtime.cmake26
-rw-r--r--third_party/aom/build/cmake/rtcd_config.cmake137
-rw-r--r--third_party/aom/build/cmake/toolchains/arm-ios-common.cmake31
-rw-r--r--third_party/aom/build/cmake/toolchains/arm64-ios.cmake24
-rw-r--r--third_party/aom/build/cmake/toolchains/arm64-linux-gcc.cmake35
-rw-r--r--third_party/aom/build/cmake/toolchains/armv7-ios.cmake34
-rw-r--r--third_party/aom/build/cmake/toolchains/armv7-linux-gcc.cmake48
-rw-r--r--third_party/aom/build/cmake/toolchains/armv7s-ios.cmake34
-rw-r--r--third_party/aom/build/cmake/toolchains/ios-simulator-common.cmake23
-rw-r--r--third_party/aom/build/cmake/toolchains/mips32-linux-gcc.cmake71
-rw-r--r--third_party/aom/build/cmake/toolchains/mips64-linux-gcc.cmake48
-rw-r--r--third_party/aom/build/cmake/toolchains/x86-ios-simulator.cmake27
-rw-r--r--third_party/aom/build/cmake/toolchains/x86-linux.cmake14
-rw-r--r--third_party/aom/build/cmake/toolchains/x86-macos.cmake18
-rw-r--r--third_party/aom/build/cmake/toolchains/x86_64-ios-simulator.cmake24
24 files changed, 1886 insertions, 0 deletions
diff --git a/third_party/aom/build/cmake/aom_config.c.cmake b/third_party/aom/build/cmake/aom_config.c.cmake
new file mode 100644
index 000000000..70bf95037
--- /dev/null
+++ b/third_party/aom/build/cmake/aom_config.c.cmake
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2016, Alliance for Open Media. All rights reserved
+ *
+ * This source code is subject to the terms of the BSD 2 Clause License and
+ * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+ * was not distributed with this source code in the LICENSE file, you can
+ * obtain it at www.aomedia.org/license/software. If the Alliance for Open
+ * Media Patent License 1.0 was not distributed with this source code in the
+ * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+ */
+#include "aom/aom_codec.h"
+static const char* const cfg = "${AOM_CMAKE_CONFIG}";
+static const char* const aom_git_hash = "${AOM_GIT_HASH}";
+const char *aom_codec_build_config(void) {return cfg;}
+const char *aom_codec_git_hash(void) {return aom_git_hash;}
diff --git a/third_party/aom/build/cmake/aom_config_defaults.cmake b/third_party/aom/build/cmake/aom_config_defaults.cmake
new file mode 100644
index 000000000..5c2bc5801
--- /dev/null
+++ b/third_party/aom/build/cmake/aom_config_defaults.cmake
@@ -0,0 +1,167 @@
+##
+## Copyright (c) 2016, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+
+# Defaults for every libaom configuration variable. Here we add all libaom
+# config variables to the cmake variable cache, but omit the FORCE parameter to
+# allow users to specify values when executing cmake to generate build files.
+# Values here are used only if not set by the user.
+set(RESTRICT "" CACHE STRING "Sets RESTRICT value for current target.")
+set(INLINE "" CACHE STRING "Sets INLINE value for current target.")
+set(ARCH_ARM 0 CACHE BOOL "Enables ARM architecture.")
+set(ARCH_MIPS 0 CACHE BOOL "Enables MIPS architecture.")
+set(ARCH_X86 0 CACHE BOOL "Enables X86 architecture.")
+set(ARCH_X86_64 0 CACHE BOOL "Enables X86_64 architecture.")
+set(HAVE_EDSP 0 CACHE BOOL "Enables EDSP optimizations.")
+set(HAVE_MEDIA 0 CACHE BOOL "Enables MEDIA optimizations.")
+set(HAVE_NEON 0 CACHE BOOL "Enables NEON intrinsics optimizations.")
+set(HAVE_NEON_ASM 0 CACHE BOOL "Enables NEON assembly optimizations.")
+set(HAVE_MIPS32 0 CACHE BOOL "Enables MIPS32 optimizations.")
+set(HAVE_DSPR2 0 CACHE BOOL "Enables DSPR2 optimizations.")
+set(HAVE_MSA 0 CACHE BOOL "Enables MSA optimizations.")
+set(HAVE_MIPS64 0 CACHE BOOL "Enables MIPS64 optimizations. ")
+set(HAVE_MMX 0 CACHE BOOL "Enables MMX optimizations. ")
+set(HAVE_SSE 0 CACHE BOOL "Enables SSE optimizations.")
+set(HAVE_SSE2 0 CACHE BOOL "Enables SSE2 optimizations.")
+set(HAVE_SSE3 0 CACHE BOOL "Enables SSE3 optimizations.")
+set(HAVE_SSSE3 0 CACHE BOOL "Enables SSSE3 optimizations.")
+set(HAVE_SSE4_1 0 CACHE BOOL "Enables SSE 4.1 optimizations.")
+set(HAVE_AVX 0 CACHE BOOL "Enables AVX optimizations.")
+set(HAVE_AVX2 0 CACHE BOOL "Enables AVX2 optimizations.")
+set(HAVE_AOM_PORTS 0 CACHE BOOL "Internal flag, deprecated.")
+set(HAVE_FEXCEPT 0 CACHE BOOL "Internal flag, GNU fenv.h present for target.")
+set(HAVE_PTHREAD_H 0 CACHE BOOL "Internal flag, target pthread support.")
+set(HAVE_UNISTD_H 0 CACHE BOOL "Internal flag, unistd.h present for target.")
+set(HAVE_WXWIDGETS 0 CACHE BOOL "WxWidgets present.")
+set(CONFIG_DEPENDENCY_TRACKING 1 CACHE BOOL "Internal flag.")
+set(CONFIG_EXTERNAL_BUILD 0 CACHE BOOL "Internal flag.")
+set(CONFIG_INSTALL_DOCS 0 CACHE BOOL "Internal flag.")
+set(CONFIG_INSTALL_BINS 0 CACHE BOOL "Internal flag.")
+set(CONFIG_INSTALL_LIBS 0 CACHE BOOL "Internal flag.")
+set(CONFIG_INSTALL_SRCS 0 CACHE BOOL "Internal flag.")
+set(CONFIG_DEBUG 0 CACHE BOOL "Internal flag.")
+set(CONFIG_GPROF 0 CACHE BOOL "Internal flag.")
+set(CONFIG_GCOV 0 CACHE BOOL "Internal flag.")
+set(CONFIG_RVCT 0 CACHE BOOL "Internal flag.")
+set(CONFIG_GCC 0 CACHE BOOL "Internal flag.")
+set(CONFIG_MSVS 0 CACHE BOOL "Internal flag.")
+set(CONFIG_PIC 0 CACHE BOOL "Internal flag.")
+set(CONFIG_BIG_ENDIAN 0 CACHE BOOL "Internal flag.")
+set(CONFIG_CODEC_SRCS 0 CACHE BOOL "Internal flag.")
+set(CONFIG_DEBUG_LIBS 0 CACHE BOOL "Internal flag.")
+set(CONFIG_RUNTIME_CPU_DETECT 1 CACHE BOOL "Internal flag.")
+set(CONFIG_POSTPROC 1 CACHE BOOL "Internal flag.")
+set(CONFIG_MULTITHREAD 1 CACHE BOOL "Internal flag.")
+set(CONFIG_INTERNAL_STATS 0 CACHE BOOL "Internal flag.")
+set(CONFIG_AV1_ENCODER 1 CACHE BOOL "Enable AV1 encoder.")
+set(CONFIG_AV1_DECODER 1 CACHE BOOL "Enable AV1 decoder.")
+set(CONFIG_AV1 1 CACHE BOOL "Internal flag.")
+set(CONFIG_ENCODERS 1 CACHE BOOL "Enable encoding.")
+set(CONFIG_DECODERS 1 CACHE BOOL "Enable decoding.")
+set(CONFIG_STATIC_MSVCRT 0 CACHE BOOL "Internal flag.")
+set(CONFIG_SPATIAL_RESAMPLING 1 CACHE BOOL "Internal flag.")
+set(CONFIG_REALTIME_ONLY 0 CACHE BOOL "Internal flag.")
+set(CONFIG_ONTHEFLY_BITPACKING 0 CACHE BOOL "Internal flag.")
+set(CONFIG_ERROR_CONCEALMENT 0 CACHE BOOL "Internal flag.")
+set(CONFIG_SHARED 0 CACHE BOOL "Internal flag.")
+set(CONFIG_STATIC 1 CACHE BOOL "Internal flag.")
+set(CONFIG_SMALL 0 CACHE BOOL "Internal flag.")
+set(CONFIG_POSTPROC_VISUALIZER 0 CACHE BOOL "Internal flag.")
+set(CONFIG_OS_SUPPORT 0 CACHE BOOL "Internal flag.")
+set(CONFIG_UNIT_TESTS 1 CACHE BOOL "Internal flag.")
+set(CONFIG_WEBM_IO 1 CACHE BOOL "Enables WebM support.")
+set(CONFIG_LIBYUV 1 CACHE BOOL "Enables libyuv scaling and conversion support.")
+set(CONFIG_ACCOUNTING 0 CACHE BOOL "Enables bit accounting.")
+set(CONFIG_INSPECTION 0 CACHE BOOL "Enables bitstream inspection.")
+set(CONFIG_DECODE_PERF_TESTS 0 CACHE BOOL "Internal flag.")
+set(CONFIG_ENCODE_PERF_TESTS 0 CACHE BOOL "Internal flag.")
+set(CONFIG_COEFFICIENT_RANGE_CHECKING 0 CACHE BOOL "Internal flag.")
+set(CONFIG_LOWBITDEPTH 1 CACHE BOOL "Internal flag.")
+set(CONFIG_HIGHBITDEPTH 0 CACHE BOOL "Internal flag.")
+set(CONFIG_EXPERIMENTAL 0 CACHE BOOL "Internal flag.")
+set(CONFIG_SIZE_LIMIT 0 CACHE BOOL "Internal flag.")
+set(CONFIG_AOM_QM 0 CACHE BOOL "Internal flag.")
+set(CONFIG_FP_MB_STATS 0 CACHE BOOL "Internal flag.")
+set(CONFIG_CDEF 1 CACHE BOOL "Internal flag.")
+set(CONFIG_VAR_TX 0 CACHE BOOL "Internal flag.")
+set(CONFIG_RECT_TX 1 CACHE BOOL "Internal flag.")
+set(CONFIG_REF_MV 1 CACHE BOOL "Internal flag.")
+set(CONFIG_TPL_MV 0 CACHE BOOL "Internal flag.")
+set(CONFIG_DUAL_FILTER 1 CACHE BOOL "Internal flag.")
+set(CONFIG_CONVOLVE_ROUND 0 CACHE BOOL "Internal flag.")
+set(CONFIG_COMPOUND_ROUND 0 CACHE BOOL "Internal flag.")
+set(CONFIG_EXT_TX 0 CACHE BOOL "Internal flag.")
+set(CONFIG_TX64X64 0 CACHE BOOL "Internal flag.")
+set(CONFIG_SUB8X8_MC 0 CACHE BOOL "Internal flag.")
+set(CONFIG_EXT_INTRA 1 CACHE BOOL "Internal flag.")
+set(CONFIG_INTRA_INTERP 0 CACHE BOOL "Internal flag.")
+set(CONFIG_FILTER_INTRA 0 CACHE BOOL "Internal flag.")
+set(CONFIG_INTRABC 0 CACHE BOOL "Internal flag.")
+set(CONFIG_EXT_INTER 0 CACHE BOOL "Internal flag.")
+set(CONFIG_INTERINTRA 0 CACHE BOOL "Internal flag.")
+set(CONFIG_WEDGE 0 CACHE BOOL "Internal flag.")
+set(CONFIG_COMPOUND_SEGMENT 0 CACHE BOOL "Internal flag.")
+set(CONFIG_EXT_REFS 1 CACHE BOOL "Internal flag.")
+set(CONFIG_GLOBAL_MOTION 0 CACHE BOOL "Internal flag.")
+set(CONFIG_NEW_QUANT 0 CACHE BOOL "Internal flag.")
+set(CONFIG_SUPERTX 0 CACHE BOOL "Internal flag.")
+set(CONFIG_ANS 0 CACHE BOOL "Internal flag.")
+set(CONFIG_EC_MULTISYMBOL 1 CACHE BOOL "Internal flag.")
+set(CONFIG_NEW_TOKENSET 1 CACHE BOOL "Internal flag.")
+set(CONFIG_LOOP_RESTORATION 0 CACHE BOOL "Internal flag.")
+set(CONFIG_EXT_PARTITION 0 CACHE BOOL "Internal flag.")
+set(CONFIG_EXT_PARTITION_TYPES 0 CACHE BOOL "Internal flag.")
+set(CONFIG_UNPOISON_PARTITION_CTX 0 CACHE BOOL "Internal flag.")
+set(CONFIG_EXT_TILE 0 CACHE BOOL "Internal flag.")
+set(CONFIG_MOTION_VAR 0 CACHE BOOL "Internal flag.")
+set(CONFIG_NCOBMC 0 CACHE BOOL "Internal flag.")
+set(CONFIG_WARPED_MOTION 0 CACHE BOOL "Internal flag.")
+set(CONFIG_Q_ADAPT_PROBS 0 CACHE BOOL "Internal flag.")
+set(CONFIG_SUBFRAME_PROB_UPDATE 0 CACHE BOOL "Internal flag.")
+set(CONFIG_BITSTREAM_DEBUG 0 CACHE BOOL "Internal flag.")
+set(CONFIG_ALT_INTRA 1 CACHE BOOL "Internal flag.")
+set(CONFIG_PALETTE 1 CACHE BOOL "Internal flag.")
+set(CONFIG_PALETTE_DELTA_ENCODING 0 CACHE BOOL "Internal flag.")
+set(CONFIG_DAALA_EC 1 CACHE BOOL "Internal flag.")
+set(CONFIG_RAWBITS 0 CACHE BOOL "Internal flag.")
+set(CONFIG_EC_SMALLMUL 0 CACHE BOOL "Internal flag.")
+set(CONFIG_PVQ 0 CACHE BOOL "Internal flag.")
+set(CONFIG_CFL 0 CACHE BOOL "Internal flag.")
+set(CONFIG_XIPHRC 0 CACHE BOOL "Internal flag.")
+set(CONFIG_CB4X4 1 CACHE BOOL "Internal flag.")
+set(CONFIG_CHROMA_2X2 0 CACHE BOOL "Internal flag.")
+set(CONFIG_FRAME_SIZE 0 CACHE BOOL "Internal flag.")
+set(CONFIG_DELTA_Q 1 CACHE BOOL "Internal flag.")
+set(CONFIG_EXT_DELTA_Q 0 CACHE BOOL "Internal flag.")
+set(CONFIG_ADAPT_SCAN 0 CACHE BOOL "Internal flag.")
+set(CONFIG_FILTER_7BIT 1 CACHE BOOL "Internal flag.")
+set(CONFIG_PARALLEL_DEBLOCKING 0 CACHE BOOL "Internal flag.")
+set(CONFIG_PARALLEL_DEBLOCKING_15TAP 0 CACHE BOOL "Internal flag.")
+set(CONFIG_LOOPFILTERING_ACROSS_TILES 0 CACHE BOOL "Internal flag.")
+set(CONFIG_TILE_GROUPS 1 CACHE BOOL "Internal flag.")
+set(CONFIG_EC_ADAPT 1 CACHE BOOL "Internal flag.")
+set(CONFIG_TEMPMV_SIGNALING 0 CACHE BOOL "Internal flag.")
+set(CONFIG_RD_DEBUG 0 CACHE BOOL "Internal flag.")
+set(CONFIG_REFERENCE_BUFFER 1 CACHE BOOL "Internal flag.")
+set(CONFIG_COEF_INTERLEAVE 0 CACHE BOOL "Internal flag.")
+set(CONFIG_ENTROPY_STATS 0 CACHE BOOL "Internal flag.")
+set(CONFIG_MASKED_TX 0 CACHE BOOL "Internal flag.")
+set(CONFIG_DEPENDENT_HORZTILES 0 CACHE BOOL "Internal flag.")
+set(CONFIG_DAALA_DIST 0 CACHE BOOL "Internal flag.")
+set(CONFIG_TRIPRED 0 CACHE BOOL "Internal flag.")
+set(CONFIG_PALETTE_THROUGHPUT 1 CACHE BOOL "Internal flag.")
+set(CONFIG_REF_ADAPT 0 CACHE BOOL "Internal flag.")
+set(CONFIG_LV_MAP 0 CACHE BOOL "Internal flag.")
+set(CONFIG_TXK_SEL 0 CACHE BOOL "Internal flag.")
+set(CONFIG_MV_COMPRESS 1 CACHE BOOL "Internal flag.")
+set(CONFIG_FRAME_SUPERRES 0 CACHE BOOL "Internal flag.")
+set(CONFIG_NEW_MULTISYMBOL 0 CACHE BOOL "Internal flag.")
+set(CONFIG_COMPOUND_SINGLEREF 0 CACHE BOOL "Internal flag.")
+set(CONFIG_ANALYZER 0 CACHE BOOL "Internal flag.")
diff --git a/third_party/aom/build/cmake/aom_configure.cmake b/third_party/aom/build/cmake/aom_configure.cmake
new file mode 100644
index 000000000..3c9402d0b
--- /dev/null
+++ b/third_party/aom/build/cmake/aom_configure.cmake
@@ -0,0 +1,306 @@
+##
+## Copyright (c) 2016, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+include(FindGit)
+include(FindPerl)
+include(FindThreads)
+include(FindwxWidgets)
+
+set(AOM_SUPPORTED_CPU_TARGETS
+ "arm64 armv7 armv7s generic mips32 mips64 x86 x86_64")
+
+# Generate the user config settings. This must occur before include of
+# aom_config_defaults.cmake (because it turns every config variable into a cache
+# variable with its own help string).
+get_cmake_property(cmake_cache_vars CACHE_VARIABLES)
+foreach(cache_var ${cmake_cache_vars})
+ get_property(cache_var_helpstring CACHE ${cache_var} PROPERTY HELPSTRING)
+ set(cmdline_helpstring "No help, variable specified on the command line.")
+ if("${cache_var_helpstring}" STREQUAL "${cmdline_helpstring}")
+ set(AOM_CMAKE_CONFIG "${AOM_CMAKE_CONFIG} -D${cache_var}=${${cache_var}}")
+ endif ()
+endforeach()
+string(STRIP "${AOM_CMAKE_CONFIG}" AOM_CMAKE_CONFIG)
+
+include("${AOM_ROOT}/build/cmake/aom_config_defaults.cmake")
+include("${AOM_ROOT}/build/cmake/aom_optimization.cmake")
+include("${AOM_ROOT}/build/cmake/compiler_flags.cmake")
+include("${AOM_ROOT}/build/cmake/compiler_tests.cmake")
+
+# Build a list of all configurable variables.
+get_cmake_property(cmake_cache_vars CACHE_VARIABLES)
+foreach (var ${cmake_cache_vars})
+ if ("${var}" MATCHES "^CONFIG_")
+ list(APPEND AOM_CONFIG_VARS ${var})
+ endif ()
+endforeach ()
+
+# Detect target CPU.
+if (NOT AOM_TARGET_CPU)
+ if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64" OR
+ "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
+ if (${CMAKE_SIZEOF_VOID_P} EQUAL 4)
+ set(AOM_TARGET_CPU "x86")
+ elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
+ set(AOM_TARGET_CPU "x86_64")
+ else ()
+ message(FATAL_ERROR
+ "--- Unexpected pointer size (${CMAKE_SIZEOF_VOID_P}) for\n"
+ " CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}\n"
+ " CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}\n"
+ " CMAKE_GENERATOR=${CMAKE_GENERATOR}\n")
+ endif ()
+ elseif ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i386" OR
+ "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86")
+ set(AOM_TARGET_CPU "x86")
+ elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "^arm" OR
+ "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "^mips")
+ set(AOM_TARGET_CPU "${CMAKE_SYSTEM_PROCESSOR}")
+ endif ()
+endif ()
+
+if (CMAKE_TOOLCHAIN_FILE)
+ # Add toolchain file to config string.
+ set(toolchain_string "-DCMAKE_TOOLCHAIN_FILE=\\\"${CMAKE_TOOLCHAIN_FILE}\\\"")
+ set(AOM_CMAKE_CONFIG "${toolchain_string} ${AOM_CMAKE_CONFIG}")
+else ()
+ # Add detected CPU to the config string.
+ set(AOM_CMAKE_CONFIG "-DAOM_TARGET_CPU=${AOM_TARGET_CPU} ${AOM_CMAKE_CONFIG}")
+endif ()
+set(AOM_CMAKE_CONFIG "-G \\\"${CMAKE_GENERATOR}\\\" ${AOM_CMAKE_CONFIG}")
+string(STRIP "${AOM_CMAKE_CONFIG}" AOM_CMAKE_CONFIG)
+
+message("--- aom_configure: Detected CPU: ${AOM_TARGET_CPU}")
+set(AOM_TARGET_SYSTEM ${CMAKE_SYSTEM_NAME})
+
+if (NOT "${AOM_SUPPORTED_CPU_TARGETS}" MATCHES "${AOM_TARGET_CPU}")
+ message(FATAL_ERROR "No RTCD support for ${AOM_TARGET_CPU}. Create it, or "
+ "add -DAOM_TARGET_CPU=generic to your cmake command line for a "
+ "generic build of libaom and tools.")
+endif ()
+
+if ("${AOM_TARGET_CPU}" STREQUAL "x86" OR "${AOM_TARGET_CPU}" STREQUAL "x86_64")
+ # TODO(tomfinegan): Support nasm at least as well as the existing build
+ # system.
+ find_program(AS_EXECUTABLE yasm $ENV{YASM_PATH})
+ if (NOT AS_EXECUTABLE)
+ message(FATAL_ERROR "Unable to find yasm. To build without optimizations, "
+ "add -DAOM_TARGET_CPU=generic to your cmake command line.")
+ endif ()
+ get_asm_obj_format("objformat")
+ set(AOM_AS_FLAGS -f ${objformat} ${AOM_AS_FLAGS})
+ string(STRIP "${AOM_AS_FLAGS}" AOM_AS_FLAGS)
+elseif ("${AOM_TARGET_CPU}" MATCHES "arm")
+ if ("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
+ set(AS_EXECUTABLE as)
+ set(AOM_AS_FLAGS -arch ${AOM_TARGET_CPU} -isysroot ${CMAKE_OSX_SYSROOT})
+ elseif ("${AOM_TARGET_SYSTEM}" STREQUAL "Linux")
+ # arm linux assembler settings controlled by
+ # build/cmake/toolchains/arm*-linux*.cmake
+ endif ()
+ if (NOT AS_EXECUTABLE)
+ message(FATAL_ERROR
+ "Unknown assembler for: ${AOM_TARGET_CPU}-${AOM_TARGET_SYSTEM}")
+ endif ()
+
+ string(STRIP "${AOM_AS_FLAGS}" AOM_AS_FLAGS)
+endif ()
+
+include("${AOM_ROOT}/build/cmake/cpu.cmake")
+
+# Test compiler flags.
+if (MSVC)
+ add_compiler_flag_if_supported("/W3")
+ # Disable MSVC warnings that suggest making code non-portable.
+ add_compiler_flag_if_supported("/wd4996")
+ if (ENABLE_WERROR)
+ add_compiler_flag_if_supported("/WX")
+ endif ()
+else ()
+ require_c_flag("-std=c99" YES)
+ add_compiler_flag_if_supported("-Wall")
+ add_compiler_flag_if_supported("-Wdisabled-optimization")
+ add_compiler_flag_if_supported("-Wextra")
+ add_compiler_flag_if_supported("-Wfloat-conversion")
+ add_compiler_flag_if_supported("-Wimplicit-function-declaration")
+ add_compiler_flag_if_supported("-Wpointer-arith")
+ add_compiler_flag_if_supported("-Wsign-compare")
+ add_compiler_flag_if_supported("-Wtype-limits")
+ add_compiler_flag_if_supported("-Wuninitialized")
+ add_compiler_flag_if_supported("-Wunused")
+ add_compiler_flag_if_supported("-Wvla")
+ # TODO(jzern): this could be added as a cxx flags for test/*.cc only,
+ # avoiding third_party.
+ add_c_flag_if_supported("-Wshorten-64-to-32")
+
+ # Add -Wshadow only for C files to avoid massive gtest warning spam.
+ add_c_flag_if_supported("-Wshadow")
+
+ # Add -Wundef only for C files to avoid massive gtest warning spam.
+ add_c_flag_if_supported("-Wundef")
+
+ if (ENABLE_WERROR)
+ add_compiler_flag_if_supported("-Werror")
+ endif ()
+ # Flag(s) added here negate CMake defaults and produce build output similar
+ # to the existing configure/make build system.
+ add_compiler_flag_if_supported("-Wno-unused-function")
+
+ if (CMAKE_C_COMPILER_ID MATCHES "GNU\|Clang")
+ set(CONFIG_GCC 1)
+ endif ()
+
+ if ("${CMAKE_BUILD_TYPE}" MATCHES "Rel")
+ add_compiler_flag_if_supported("-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0")
+ endif ()
+ add_compiler_flag_if_supported("-D_LARGEFILE_SOURCE")
+ add_compiler_flag_if_supported("-D_FILE_OFFSET_BITS=64")
+endif ()
+
+if ("${AOM_TARGET_SYSTEM}" MATCHES "Darwin\|Linux\|Windows")
+ set(CONFIG_OS_SUPPORT 1)
+endif ()
+
+# Test compiler support.
+aom_get_inline("INLINE")
+
+# TODO(tomfinegan): aom_ports_check is legacy; HAVE_AOM_PORTS is not used
+# anywhere in the aom sources. To be removed after parity with the legacy
+# build system stops being important.
+aom_check_source_compiles("aom_ports_check"
+ "#include \"${AOM_ROOT}/aom/aom_integer.h\""
+ HAVE_AOM_PORTS)
+aom_check_source_compiles("pthread_check" "#include <pthread.h>" HAVE_PTHREAD_H)
+aom_check_source_compiles("unistd_check" "#include <unistd.h>" HAVE_UNISTD_H)
+
+if (CONFIG_ANALYZER)
+ find_package(wxWidgets REQUIRED adv base core)
+ include(${wxWidgets_USE_FILE})
+
+ if (NOT CONFIG_INSPECTION)
+ set(CONFIG_INSPECTION 1)
+ message(WARNING
+ "--- Enabled CONFIG_INSPECTION, required for CONFIG_ANALYZER.")
+ endif ()
+endif ()
+
+if (CONFIG_ANS AND CONFIG_DAALA_EC)
+ message(FATAL_ERROR
+ "CONFIG_ANS and CONFIG_DAALA_EC cannot be enabled together.")
+endif ()
+
+if (NOT MSVC)
+ aom_push_var(CMAKE_REQUIRED_LIBRARIES "m")
+ aom_check_c_compiles("fenv_check"
+ "#define _GNU_SOURCE
+ #include <fenv.h>
+ void unused(void) {
+ (void)feenableexcept(FE_DIVBYZERO | FE_INVALID);
+ }" HAVE_FEXCEPT)
+ aom_pop_var(CMAKE_REQUIRED_LIBRARIES)
+endif()
+
+# Generate aom_config templates.
+set(aom_config_asm_template "${AOM_CONFIG_DIR}/aom_config.asm.cmake")
+set(aom_config_h_template "${AOM_CONFIG_DIR}/aom_config.h.cmake")
+execute_process(COMMAND ${CMAKE_COMMAND}
+ -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
+ -DAOM_ROOT=${AOM_ROOT}
+ -P "${AOM_ROOT}/build/cmake/generate_aom_config_templates.cmake")
+
+# Generate aom_config.{asm,h}.
+configure_file("${aom_config_asm_template}" "${AOM_CONFIG_DIR}/aom_config.asm")
+configure_file("${aom_config_h_template}" "${AOM_CONFIG_DIR}/aom_config.h")
+
+# Read the current git hash.
+find_package(Git)
+set(AOM_GIT_DESCRIPTION)
+set(AOM_GIT_HASH)
+if (GIT_FOUND)
+ # TODO(tomfinegan): Add build rule so users don't have to re-run cmake to
+ # create accurately versioned cmake builds.
+ execute_process(COMMAND ${GIT_EXECUTABLE}
+ --git-dir=${AOM_ROOT}/.git rev-parse HEAD
+ OUTPUT_VARIABLE AOM_GIT_HASH)
+ execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=${AOM_ROOT}/.git describe
+ OUTPUT_VARIABLE AOM_GIT_DESCRIPTION ERROR_QUIET)
+ # Consume the newline at the end of the git output.
+ string(STRIP "${AOM_GIT_HASH}" AOM_GIT_HASH)
+ string(STRIP "${AOM_GIT_DESCRIPTION}" AOM_GIT_DESCRIPTION)
+endif ()
+
+configure_file("${AOM_ROOT}/build/cmake/aom_config.c.cmake"
+ "${AOM_CONFIG_DIR}/aom_config.c")
+
+# Find Perl and generate the RTCD sources.
+find_package(Perl)
+if (NOT PERL_FOUND)
+ message(FATAL_ERROR "Perl is required to build libaom.")
+endif ()
+configure_file(
+ "${AOM_ROOT}/build/cmake/rtcd_config.cmake"
+ "${AOM_CONFIG_DIR}/${AOM_TARGET_CPU}_rtcd_config.rtcd")
+
+set(AOM_RTCD_CONFIG_FILE_LIST
+ "${AOM_ROOT}/aom_dsp/aom_dsp_rtcd_defs.pl"
+ "${AOM_ROOT}/aom_scale/aom_scale_rtcd.pl"
+ "${AOM_ROOT}/av1/common/av1_rtcd_defs.pl")
+set(AOM_RTCD_HEADER_FILE_LIST
+ "${AOM_CONFIG_DIR}/aom_dsp_rtcd.h"
+ "${AOM_CONFIG_DIR}/aom_scale_rtcd.h"
+ "${AOM_CONFIG_DIR}/av1_rtcd.h")
+set(AOM_RTCD_SOURCE_FILE_LIST
+ "${AOM_ROOT}/aom_dsp/aom_dsp_rtcd.c"
+ "${AOM_ROOT}/aom_scale/aom_scale_rtcd.c"
+ "${AOM_ROOT}/av1/common/av1_rtcd.c")
+set(AOM_RTCD_SYMBOL_LIST aom_dsp_rtcd aom_scale_rtcd av1_rtcd)
+list(LENGTH AOM_RTCD_SYMBOL_LIST AOM_RTCD_CUSTOM_COMMAND_COUNT)
+math(EXPR AOM_RTCD_CUSTOM_COMMAND_COUNT "${AOM_RTCD_CUSTOM_COMMAND_COUNT} - 1")
+
+foreach(NUM RANGE ${AOM_RTCD_CUSTOM_COMMAND_COUNT})
+ list(GET AOM_RTCD_CONFIG_FILE_LIST ${NUM} AOM_RTCD_CONFIG_FILE)
+ list(GET AOM_RTCD_HEADER_FILE_LIST ${NUM} AOM_RTCD_HEADER_FILE)
+ list(GET AOM_RTCD_SOURCE_FILE_LIST ${NUM} AOM_RTCD_SOURCE_FILE)
+ list(GET AOM_RTCD_SYMBOL_LIST ${NUM} AOM_RTCD_SYMBOL)
+ execute_process(
+ COMMAND ${PERL_EXECUTABLE} "${AOM_ROOT}/build/make/rtcd.pl"
+ --arch=${AOM_TARGET_CPU} --sym=${AOM_RTCD_SYMBOL} ${AOM_RTCD_FLAGS}
+ --config=${AOM_CONFIG_DIR}/${AOM_TARGET_CPU}_rtcd_config.rtcd
+ ${AOM_RTCD_CONFIG_FILE}
+ OUTPUT_FILE ${AOM_RTCD_HEADER_FILE})
+endforeach()
+
+function (add_rtcd_build_step config output source symbol)
+ add_custom_command(
+ OUTPUT ${output}
+ COMMAND ${PERL_EXECUTABLE}
+ ARGS "${AOM_ROOT}/build/make/rtcd.pl"
+ --arch=${AOM_TARGET_CPU}
+ --sym=${symbol}
+ ${AOM_RTCD_FLAGS}
+ --config=${AOM_CONFIG_DIR}/${AOM_TARGET_CPU}_rtcd_config.rtcd
+ ${config}
+ > ${output}
+ DEPENDS ${config}
+ COMMENT "Generating ${output}"
+ WORKING_DIRECTORY ${AOM_CONFIG_DIR}
+ VERBATIM)
+ set_property(SOURCE ${source} PROPERTY OBJECT_DEPENDS ${output})
+ set_property(SOURCE ${output} PROPERTY GENERATED)
+endfunction ()
+
+# Generate aom_version.h.
+if ("${AOM_GIT_DESCRIPTION}" STREQUAL "")
+ set(AOM_GIT_DESCRIPTION "${AOM_ROOT}/CHANGELOG")
+endif ()
+execute_process(
+ COMMAND ${PERL_EXECUTABLE} "${AOM_ROOT}/build/cmake/aom_version.pl"
+ --version_data=${AOM_GIT_DESCRIPTION}
+ --version_filename=${AOM_CONFIG_DIR}/aom_version.h)
diff --git a/third_party/aom/build/cmake/aom_optimization.cmake b/third_party/aom/build/cmake/aom_optimization.cmake
new file mode 100644
index 000000000..e2b0ba07e
--- /dev/null
+++ b/third_party/aom/build/cmake/aom_optimization.cmake
@@ -0,0 +1,204 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+if (NOT AOM_BUILD_CMAKE_AOM_OPTIMIZATION_CMAKE_)
+set(AOM_BUILD_CMAKE_AOM_OPTIMIZATION_CMAKE_ 1)
+
+# Translate $flag to one which MSVC understands, and write the new flag to the
+# variable named by $translated_flag (or unset it, when MSVC needs no flag).
+function (get_msvc_intrinsic_flag flag translated_flag)
+ if ("${flag}" STREQUAL "-mavx")
+ set(${translated_flag} "/arch:AVX" PARENT_SCOPE)
+ elseif ("${flag}" STREQUAL "-mavx2")
+ set(${translated_flag} "/arch:AVX2" PARENT_SCOPE)
+ else ()
+ # MSVC does not need flags for intrinsics flavors other than AVX/AVX2.
+ unset(${translated_flag} PARENT_SCOPE)
+ endif ()
+endfunction ()
+
+# Adds an object library target. Terminates generation if $flag is not supported
+# by the current compiler. $flag is the intrinsics flag required by the current
+# compiler, and is added to the compile flags for all sources in $sources.
+# $opt_name is used to name the target. $target_to_update is made
+# dependent upon the created target.
+#
+# Note: the libaom target is always updated because OBJECT libraries have rules
+# that disallow the direct addition of .o files to them as dependencies. Static
+# libraries do not have this limitation.
+function (add_intrinsics_object_library flag opt_name target_to_update sources)
+ set(target_name ${target_to_update}_${opt_name}_intrinsics)
+ add_library(${target_name} OBJECT ${${sources}})
+
+ if (MSVC)
+ get_msvc_intrinsic_flag(${flag} "flag")
+ endif ()
+
+ if (flag)
+ target_compile_options(${target_name} PUBLIC ${flag})
+ endif ()
+
+ target_sources(aom PUBLIC $<TARGET_OBJECTS:${target_name}>)
+
+ # Add the new lib target to the global list of aom library targets.
+ list(APPEND AOM_LIB_TARGETS ${target_name})
+ set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE)
+endfunction ()
+
+# Adds sources in list named by $sources to $target and adds $flag to the
+# compile flags for each source file.
+function (add_intrinsics_source_to_target flag target sources)
+ target_sources(${target} PUBLIC ${${sources}})
+ if (MSVC)
+ get_msvc_intrinsic_flag(${flag} "flag")
+ endif ()
+ if (flag)
+ foreach (source ${${sources}})
+ set_property(SOURCE ${source} APPEND PROPERTY COMPILE_FLAGS ${flag})
+ endforeach ()
+ endif ()
+endfunction ()
+
+# Writes object format for the current target to the var named by $out_format,
+# or terminates the build when the object format for the current target is
+# unknown.
+function (get_asm_obj_format out_format)
+ if ("${AOM_TARGET_CPU}" STREQUAL "x86_64")
+ if ("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
+ set(objformat "macho64")
+ elseif ("${AOM_TARGET_SYSTEM}" STREQUAL "Linux")
+ set(objformat "elf64")
+ elseif ("${AOM_TARGET_SYSTEM}" STREQUAL "Windows")
+ set(objformat "win64")
+ else ()
+ message(FATAL_ERROR "Unknown obj format: ${AOM_TARGET_SYSTEM}")
+ endif ()
+ elseif ("${AOM_TARGET_CPU}" STREQUAL "x86")
+ if ("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
+ set(objformat "macho32")
+ elseif ("${AOM_TARGET_SYSTEM}" STREQUAL "Linux")
+ set(objformat "elf32")
+ elseif ("${AOM_TARGET_SYSTEM}" STREQUAL "Windows")
+ set(objformat "win32")
+ else ()
+ message(FATAL_ERROR "Unknown obj format: ${AOM_TARGET_SYSTEM}")
+ endif ()
+ else ()
+ message(FATAL_ERROR
+ "Unknown obj format: ${AOM_TARGET_CPU}-${AOM_TARGET_SYSTEM}")
+ endif ()
+
+ set(${out_format} ${objformat} PARENT_SCOPE)
+endfunction ()
+
+# Adds library target named $lib_name for ASM files in variable named by
+# $asm_sources. Builds an output directory path from $lib_name. Links $lib_name
+# into $dependent_target. Generates a dummy C file with a dummy function to
+# ensure that all cmake generators can determine the linker language, and that
+# build tools don't complain that an object exposes no symbols.
+function (add_asm_library lib_name asm_sources dependent_target)
+ set(asm_lib_obj_dir "${AOM_CONFIG_DIR}/asm_objects/${lib_name}")
+ if (NOT EXISTS "${asm_lib_obj_dir}")
+ file(MAKE_DIRECTORY "${asm_lib_obj_dir}")
+ endif ()
+
+ # TODO(tomfinegan): If cmake ever allows addition of .o files to OBJECT lib
+ # targets, make this OBJECT instead of STATIC to hide the target from
+ # consumers of the AOM cmake build.
+ add_library(${lib_name} STATIC ${${asm_sources}})
+
+ foreach (asm_source ${${asm_sources}})
+ get_filename_component(asm_source_name "${asm_source}" NAME)
+ set(asm_object "${asm_lib_obj_dir}/${asm_source_name}.o")
+ add_custom_command(OUTPUT "${asm_object}"
+ COMMAND ${AS_EXECUTABLE}
+ ARGS ${AOM_AS_FLAGS}
+ -I${AOM_ROOT} -I${AOM_CONFIG_DIR}
+ -o "${asm_object}" "${asm_source}"
+ DEPENDS "${asm_source}"
+ COMMENT "Building ASM object ${asm_object}"
+ WORKING_DIRECTORY "${AOM_CONFIG_DIR}"
+ VERBATIM)
+ target_sources(${lib_name} PRIVATE "${asm_object}")
+ endforeach ()
+
+ # The above created a target containing only ASM sources. Cmake needs help
+ # here to determine the linker language. Add a dummy C file to force the
+ # linker language to C. We don't bother with setting the LINKER_LANGUAGE
+ # property on the library target because not all generators obey it (looking
+ # at you, xcode generator).
+ set(dummy_c_file "${AOM_CONFIG_DIR}/${lib_name}_dummy.c")
+ file(WRITE "${dummy_c_file}"
+ "// Generated file. DO NOT EDIT!\n"
+ "// ${lib_name} needs C file to force link language, ignore me.\n"
+ "void ${lib_name}_dummy_function(void) {}\n")
+ target_sources(${lib_name} PUBLIC ${dummy_c_file})
+
+ target_link_libraries(${dependent_target} PRIVATE ${lib_name})
+
+ # Add the new lib target to the global list of aom library targets.
+ list(APPEND AOM_LIB_TARGETS ${lib_name})
+ set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE)
+endfunction ()
+
+# Converts asm sources in $asm_sources using $AOM_ADS2GAS and calls
+# add_asm_library() to create a library from the converted sources. At
+# generation time the converted sources are created, and a custom rule is added
+# to ensure the sources are reconverted when the original asm source is updated.
+# See add_asm_library() for more information.
+function (add_gas_asm_library lib_name asm_sources dependent_target)
+ set(asm_converted_source_dir "${AOM_CONFIG_DIR}/asm_gas/${lib_name}")
+ if (NOT EXISTS "${asm_converted_source_dir}")
+ file(MAKE_DIRECTORY "${asm_converted_source_dir}")
+ endif ()
+
+ # Create the converted version of each assembly source at generation time.
+ unset(gas_target_sources)
+ foreach (neon_asm_source ${${asm_sources}})
+ get_filename_component(output_asm_source "${neon_asm_source}" NAME)
+ set(output_asm_source "${asm_converted_source_dir}/${output_asm_source}")
+ set(output_asm_source "${output_asm_source}.${AOM_GAS_EXT}")
+ execute_process(COMMAND "${PERL_EXECUTABLE}" "${AOM_ADS2GAS}"
+ INPUT_FILE "${neon_asm_source}"
+ OUTPUT_FILE "${output_asm_source}")
+ list(APPEND gas_target_sources "${output_asm_source}")
+ endforeach ()
+
+ add_asm_library("${lib_name}" "gas_target_sources" "${dependent_target}")
+
+ # For each of the converted sources, create a custom rule that will regenerate
+ # the converted source when its input is touched.
+ list(LENGTH gas_target_sources num_asm_files)
+ math(EXPR num_asm_files "${num_asm_files} - 1")
+ foreach(NUM RANGE ${num_asm_files})
+ list(GET ${asm_sources} ${NUM} neon_asm_source)
+ list(GET gas_target_sources ${NUM} gas_asm_source)
+
+ # Grab only the filename for the custom command output to keep build output
+ # reasonably sane.
+ get_filename_component(neon_name "${neon_asm_source}" NAME)
+ get_filename_component(gas_name "${gas_asm_source}" NAME)
+
+ add_custom_command(
+ OUTPUT "${gas_asm_source}"
+ COMMAND ${PERL_EXECUTABLE}
+ ARGS "${AOM_ADS2GAS}" < "${neon_asm_source}" > "${gas_asm_source}"
+ DEPENDS "${neon_asm_source}"
+ COMMENT "ads2gas conversion ${neon_name} -> ${gas_name}"
+ WORKING_DIRECTORY "${AOM_CONFIG_DIR}"
+ VERBATIM)
+ endforeach ()
+
+ # Update the sources list passed in to include the converted asm source files.
+ list(APPEND asm_sources ${gas_target_sources})
+ set(${asm_sources} ${${asm_sources}} PARENT_SCOPE)
+endfunction ()
+
+endif () # AOM_BUILD_CMAKE_AOM_OPTIMIZATION_CMAKE_
diff --git a/third_party/aom/build/cmake/aom_version.pl b/third_party/aom/build/cmake/aom_version.pl
new file mode 100755
index 000000000..3412feebd
--- /dev/null
+++ b/third_party/aom/build/cmake/aom_version.pl
@@ -0,0 +1,93 @@
+#!/usr/bin/env perl
+##
+## Copyright (c) 2016, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+use strict;
+use warnings;
+use 5.010;
+use Getopt::Long;
+
+my $version_data;
+my $version_filename;
+GetOptions('version_data=s' => \$version_data,
+ 'version_filename=s' => \$version_filename) or
+ die("Invalid arg(s): $!");
+
+if (!defined $version_data || length($version_data) == 0 ||
+ !defined $version_filename || length($version_filename) == 0) {
+ die("--version_data and --version_filename are required.");
+}
+
+# Determine if $version_data is a filename or a git tag/description.
+my $version_string;
+if (-r $version_data) {
+ # $version_data is the path to the CHANGELOG. Parse the most recent version.
+ my $changelog_filename = $version_data;
+ open(my $changelog_file, '<', $changelog_filename) or
+ die("Unable to open CHANGELOG @ $changelog_filename: $!.");
+
+ while (my $line = <$changelog_file>) {
+ my @split_line = split(" ", $line, 3);
+ next if @split_line < 2;
+ $version_string = $split_line[1];
+ last if substr($version_string, 0, 1) eq "v";
+ }
+ close($changelog_file);
+} else {
+ # $version_data is either a tag name or a full git description, one of:
+ # tagName OR tagName-commitsSinceTag-shortCommitHash
+ # In either case we want the first element of the array returned by split.
+ $version_string = (split("-", $version_data))[0];
+}
+
+if (substr($version_string, 0, 1) eq "v") {
+ $version_string = substr($version_string, 1);
+}
+
+my @version_components = split('\.', $version_string, 4);
+my $version_major = $version_components[0];
+my $version_minor = $version_components[1];
+my $version_patch = $version_components[2];
+
+my $version_extra = "";
+if (@version_components > 3) {
+ $version_extra = $version_components[3];
+}
+
+open(my $version_file, '>', $version_filename) or
+ die("Cannot open $version_filename: $!");
+
+my $version_packed = "((VERSION_MAJOR<<16)|(VERSION_MINOR<<8)|(VERSION_PATCH))";
+my $year = (localtime)[5] + 1900;
+my $lic_block = << "EOF";
+/*
+ * Copyright (c) $year, Alliance for Open Media. All rights reserved
+ *
+ * This source code is subject to the terms of the BSD 2 Clause License and
+ * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+ * was not distributed with this source code in the LICENSE file, you can
+ * obtain it at www.aomedia.org/license/software. If the Alliance for Open
+ * Media Patent License 1.0 was not distributed with this source code in the
+ * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+ */
+EOF
+
+select $version_file;
+print << "EOF";
+$lic_block
+#define VERSION_MAJOR $version_major
+#define VERSION_MINOR $version_minor
+#define VERSION_PATCH $version_patch
+#define VERSION_EXTRA \"$version_extra\"
+#define VERSION_PACKED $version_packed
+#define VERSION_STRING_NOSP \"v$version_string\"
+#define VERSION_STRING \" v$version_string\"
+EOF
+close($version_file);
diff --git a/third_party/aom/build/cmake/compiler_flags.cmake b/third_party/aom/build/cmake/compiler_flags.cmake
new file mode 100644
index 000000000..beb217abc
--- /dev/null
+++ b/third_party/aom/build/cmake/compiler_flags.cmake
@@ -0,0 +1,218 @@
+##
+## Copyright (c) 2016, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+include(CheckCCompilerFlag)
+include(CheckCXXCompilerFlag)
+
+# Strings used to cache failed C/CXX flags.
+set(AOM_FAILED_C_FLAGS)
+set(AOM_FAILED_CXX_FLAGS)
+
+# Checks C compiler for support of $c_flag. Adds $c_flag to $CMAKE_C_FLAGS when
+# the compile test passes. Caches $c_flag in $AOM_FAILED_C_FLAGS when the test
+# fails.
+function (add_c_flag_if_supported c_flag)
+ unset(C_FLAG_FOUND CACHE)
+ string(FIND "${CMAKE_C_FLAGS}" "${c_flag}" C_FLAG_FOUND)
+ unset(C_FLAG_FAILED CACHE)
+ string(FIND "${AOM_FAILED_C_FLAGS}" "${c_flag}" C_FLAG_FAILED)
+
+ if (${C_FLAG_FOUND} EQUAL -1 AND ${C_FLAG_FAILED} EQUAL -1)
+ unset(C_FLAG_SUPPORTED CACHE)
+ message("Checking C compiler flag support for: " ${c_flag})
+ check_c_compiler_flag("${c_flag}" C_FLAG_SUPPORTED)
+ if (C_FLAG_SUPPORTED)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${c_flag}" CACHE STRING "" FORCE)
+ else ()
+ set(AOM_FAILED_C_FLAGS "${AOM_FAILED_C_FLAGS} ${c_flag}" CACHE STRING ""
+ FORCE)
+ endif ()
+ endif ()
+endfunction ()
+
+# Checks C++ compiler for support of $cxx_flag. Adds $cxx_flag to
+# $CMAKE_CXX_FLAGS when the compile test passes. Caches $c_flag in
+# $AOM_FAILED_CXX_FLAGS when the test fails.
+function (add_cxx_flag_if_supported cxx_flag)
+ unset(CXX_FLAG_FOUND CACHE)
+ string(FIND "${CMAKE_CXX_FLAGS}" "${cxx_flag}" CXX_FLAG_FOUND)
+ unset(CXX_FLAG_FAILED CACHE)
+ string(FIND "${AOM_FAILED_CXX_FLAGS}" "${cxx_flag}" CXX_FLAG_FAILED)
+
+ if (${CXX_FLAG_FOUND} EQUAL -1 AND ${CXX_FLAG_FAILED} EQUAL -1)
+ unset(CXX_FLAG_SUPPORTED CACHE)
+ message("Checking CXX compiler flag support for: " ${cxx_flag})
+ check_cxx_compiler_flag("${cxx_flag}" CXX_FLAG_SUPPORTED)
+ if (CXX_FLAG_SUPPORTED)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cxx_flag}" CACHE STRING ""
+ FORCE)
+ else()
+ set(AOM_FAILED_CXX_FLAGS "${AOM_FAILED_CXX_FLAGS} ${cxx_flag}" CACHE
+ STRING "" FORCE)
+ endif ()
+ endif ()
+endfunction ()
+
+# Convenience method for adding a flag to both the C and C++ compiler command
+# lines.
+function (add_compiler_flag_if_supported flag)
+ add_c_flag_if_supported(${flag})
+ add_cxx_flag_if_supported(${flag})
+endfunction ()
+
+# Checks C compiler for support of $c_flag and terminates generation when
+# support is not present.
+function (require_c_flag c_flag update_c_flags)
+ unset(C_FLAG_FOUND CACHE)
+ string(FIND "${CMAKE_C_FLAGS}" "${c_flag}" C_FLAG_FOUND)
+
+ if (${C_FLAG_FOUND} EQUAL -1)
+ unset(HAVE_C_FLAG CACHE)
+ message("Checking C compiler flag support for: " ${c_flag})
+ check_c_compiler_flag("${c_flag}" HAVE_C_FLAG)
+ if (NOT HAVE_C_FLAG)
+ message(FATAL_ERROR
+ "${PROJECT_NAME} requires support for C flag: ${c_flag}.")
+ endif ()
+ if (update_c_flags)
+ set(CMAKE_C_FLAGS "${c_flag} ${CMAKE_C_FLAGS}" CACHE STRING "" FORCE)
+ endif ()
+ endif ()
+endfunction ()
+
+# Checks CXX compiler for support of $cxx_flag and terminates generation when
+# support is not present.
+function (require_cxx_flag cxx_flag update_cxx_flags)
+ unset(CXX_FLAG_FOUND CACHE)
+ string(FIND "${CMAKE_CXX_FLAGS}" "${cxx_flag}" CXX_FLAG_FOUND)
+
+ if (${CXX_FLAG_FOUND} EQUAL -1)
+ unset(HAVE_CXX_FLAG CACHE)
+ message("Checking CXX compiler flag support for: " ${cxx_flag})
+ check_cxx_compiler_flag("${cxx_flag}" HAVE_CXX_FLAG)
+ if (NOT HAVE_CXX_FLAG)
+ message(FATAL_ERROR
+ "${PROJECT_NAME} requires support for CXX flag: ${cxx_flag}.")
+ endif ()
+ if (update_cxx_flags)
+ set(CMAKE_CXX_FLAGS "${cxx_flag} ${CMAKE_CXX_FLAGS}" CACHE STRING ""
+ FORCE)
+ endif ()
+ endif ()
+endfunction ()
+
+# Checks for support of $flag by both the C and CXX compilers. Terminates
+# generation when support is not present in both compilers.
+function (require_flag flag update_cmake_flags)
+ require_c_flag(${flag} ${update_cmake_flags})
+ require_cxx_flag(${flag} ${update_cmake_flags})
+endfunction ()
+
+# Checks only non-MSVC targets for support of $c_flag and terminates generation
+# when support is not present.
+function (require_c_flag_nomsvc c_flag update_c_flags)
+ if (NOT MSVC)
+ require_c_flag(${c_flag} ${update_c_flags})
+ endif ()
+endfunction ()
+
+# Checks only non-MSVC targets for support of $cxx_flag and terminates
+# generation when support is not present.
+function (require_cxx_flag_nomsvc cxx_flag update_cxx_flags)
+ if (NOT MSVC)
+ require_cxx_flag(${cxx_flag} ${update_cxx_flags})
+ endif ()
+endfunction ()
+
+# Checks only non-MSVC targets for support of $flag by both the C and CXX
+# compilers. Terminates generation when support is not present in both
+# compilers.
+function (require_flag_nomsvc flag update_cmake_flags)
+ require_c_flag_nomsvc(${flag} ${update_cmake_flags})
+ require_cxx_flag_nomsvc(${flag} ${update_cmake_flags})
+endfunction ()
+
+# Adds $preproc_def to C compiler command line (as -D$preproc_def) if not
+# already present.
+function (add_c_preproc_definition preproc_def)
+ unset(PREPROC_DEF_FOUND CACHE)
+ string(FIND "${CMAKE_C_FLAGS}" "${preproc_def}" PREPROC_DEF_FOUND)
+
+ if (${PREPROC_DEF_FOUND} EQUAL -1)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D${preproc_def}" CACHE STRING ""
+ FORCE)
+ endif ()
+endfunction ()
+
+# Adds $preproc_def to CXX compiler command line (as -D$preproc_def) if not
+# already present.
+function (add_cxx_preproc_definition preproc_def)
+ unset(PREPROC_DEF_FOUND CACHE)
+ string(FIND "${CMAKE_CXX_FLAGS}" "${preproc_def}" PREPROC_DEF_FOUND)
+
+ if (${PREPROC_DEF_FOUND} EQUAL -1)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D${preproc_def}" CACHE STRING ""
+ FORCE)
+ endif ()
+endfunction ()
+
+# Adds $preproc_def to C and CXX compiler command line (as -D$preproc_def) if
+# not already present.
+function (add_preproc_definition preproc_def)
+ add_c_preproc_definition(${preproc_def})
+ add_cxx_preproc_definition(${preproc_def})
+endfunction ()
+
+# Adds $flag to assembler command line.
+function (append_as_flag flag)
+ unset(AS_FLAG_FOUND CACHE)
+ string(FIND "${AOM_AS_FLAGS}" "${flag}" AS_FLAG_FOUND)
+
+ if (${AS_FLAG_FOUND} EQUAL -1)
+ set(AOM_AS_FLAGS "${AOM_AS_FLAGS} ${flag}" CACHE STRING "" FORCE)
+ endif ()
+endfunction ()
+
+# Adds $flag to the C compiler command line.
+function (append_c_flag flag)
+ unset(C_FLAG_FOUND CACHE)
+ string(FIND "${CMAKE_C_FLAGS}" "${flag}" C_FLAG_FOUND)
+
+ if (${C_FLAG_FOUND} EQUAL -1)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" CACHE STRING "" FORCE)
+ endif ()
+endfunction ()
+
+# Adds $flag to the CXX compiler command line.
+function (append_cxx_flag flag)
+ unset(CXX_FLAG_FOUND CACHE)
+ string(FIND "${CMAKE_CXX_FLAGS}" "${flag}" CXX_FLAG_FOUND)
+
+ if (${CXX_FLAG_FOUND} EQUAL -1)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" CACHE STRING "" FORCE)
+ endif ()
+endfunction ()
+
+# Adds $flag to the C and CXX compiler command lines.
+function (append_compiler_flag flag)
+ append_c_flag(${flag})
+ append_cxx_flag(${flag})
+endfunction ()
+
+# Adds $flag to the executable linker command line.
+function (append_exe_linker_flag flag)
+ unset(LINKER_FLAG_FOUND CACHE)
+ string(FIND "${CMAKE_EXE_LINKER_FLAGS}" "${flag}" LINKER_FLAG_FOUND)
+
+ if (${LINKER_FLAG_FOUND} EQUAL -1)
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}" CACHE STRING
+ "" FORCE)
+ endif ()
+endfunction ()
diff --git a/third_party/aom/build/cmake/compiler_tests.cmake b/third_party/aom/build/cmake/compiler_tests.cmake
new file mode 100644
index 000000000..e763597a2
--- /dev/null
+++ b/third_party/aom/build/cmake/compiler_tests.cmake
@@ -0,0 +1,133 @@
+##
+## Copyright (c) 2016, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+include(CheckCSourceCompiles)
+include(CheckCXXSourceCompiles)
+
+# The basic main() function used in all compile tests.
+set(AOM_C_MAIN "\nint main(void) { return 0; }")
+set(AOM_CXX_MAIN "\nint main() { return 0; }")
+
+# Strings containing the names of passed and failed tests.
+set(AOM_C_PASSED_TESTS)
+set(AOM_C_FAILED_TESTS)
+set(AOM_CXX_PASSED_TESTS)
+set(AOM_CXX_FAILED_TESTS)
+
+function(aom_push_var var new_value)
+ set(SAVED_${var} ${var} PARENT_SCOPE)
+ set(${var} ${new_value} PARENT_SCOPE)
+endfunction ()
+
+function(aom_pop_var var)
+ set(var ${SAVED_${var}} PARENT_SCOPE)
+ unset(SAVED_${var} PARENT_SCOPE)
+endfunction ()
+
+# Confirms $test_source compiles and stores $test_name in one of
+# $AOM_C_PASSED_TESTS or $AOM_C_FAILED_TESTS depending on out come. When the
+# test passes $result_var is set to 1. When it fails $result_var is unset.
+# The test is not run if the test name is found in either of the passed or
+# failed test variables.
+function(aom_check_c_compiles test_name test_source result_var)
+ unset(C_TEST_PASSED CACHE)
+ unset(C_TEST_FAILED CACHE)
+ string(FIND "${AOM_C_PASSED_TESTS}" "${test_name}" C_TEST_PASSED)
+ string(FIND "${AOM_C_FAILED_TESTS}" "${test_name}" C_TEST_FAILED)
+ if (${C_TEST_PASSED} EQUAL -1 AND ${C_TEST_FAILED} EQUAL -1)
+ unset(C_TEST_COMPILED CACHE)
+ message("Running C compiler test: ${test_name}")
+ check_c_source_compiles("${test_source} ${AOM_C_MAIN}" C_TEST_COMPILED)
+ set(${result_var} ${C_TEST_COMPILED} PARENT_SCOPE)
+
+ if (C_TEST_COMPILED)
+ set(AOM_C_PASSED_TESTS "${AOM_C_PASSED_TESTS} ${test_name}" CACHE STRING
+ "" FORCE)
+ else ()
+ set(AOM_C_FAILED_TESTS "${AOM_C_FAILED_TESTS} ${test_name}" CACHE STRING
+ "" FORCE)
+ message("C Compiler test ${test_name} failed.")
+ endif ()
+ elseif (NOT ${C_TEST_PASSED} EQUAL -1)
+ set(${result_var} 1 PARENT_SCOPE)
+ else () # ${C_TEST_FAILED} NOT EQUAL -1
+ unset(${result_var} PARENT_SCOPE)
+ endif ()
+endfunction ()
+
+# Confirms $test_source compiles and stores $test_name in one of
+# $AOM_CXX_PASSED_TESTS or $AOM_CXX_FAILED_TESTS depending on out come. When the
+# test passes $result_var is set to 1. When it fails $result_var is unset.
+# The test is not run if the test name is found in either of the passed or
+# failed test variables.
+function(aom_check_cxx_compiles test_name test_source result_var)
+ unset(CXX_TEST_PASSED CACHE)
+ unset(CXX_TEST_FAILED CACHE)
+ string(FIND "${AOM_CXX_PASSED_TESTS}" "${test_name}" CXX_TEST_PASSED)
+ string(FIND "${AOM_CXX_FAILED_TESTS}" "${test_name}" CXX_TEST_FAILED)
+ if (${CXX_TEST_PASSED} EQUAL -1 AND ${CXX_TEST_FAILED} EQUAL -1)
+ unset(CXX_TEST_COMPILED CACHE)
+ message("Running CXX compiler test: ${test_name}")
+ check_cxx_source_compiles("${test_source} ${AOM_CXX_MAIN}"
+ CXX_TEST_COMPILED)
+ set(${result_var} ${CXX_TEST_COMPILED} PARENT_SCOPE)
+
+ if (CXX_TEST_COMPILED)
+ set(AOM_CXX_PASSED_TESTS "${AOM_CXX_PASSED_TESTS} ${test_name}" CACHE
+ STRING "" FORCE)
+ else ()
+ set(AOM_CXX_FAILED_TESTS "${AOM_CXX_FAILED_TESTS} ${test_name}" CACHE
+ STRING "" FORCE)
+ message("CXX Compiler test ${test_name} failed.")
+ endif ()
+ elseif (NOT ${CXX_TEST_PASSED} EQUAL -1)
+ set(${result_var} 1 PARENT_SCOPE)
+ else () # ${CXX_TEST_FAILED} NOT EQUAL -1
+ unset(${result_var} PARENT_SCOPE)
+ endif ()
+endfunction ()
+
+# Convenience function that confirms $test_source compiles as C and C++.
+# $result_var is set to 1 when both tests are successful, and 0 when one or both
+# tests fail.
+# Note: This function is intended to be used to write to result variables that are
+# expanded via configure_file(). $result_var is set to 1 or 0 to allow direct
+# usage of the value in generated source files.
+function(aom_check_source_compiles test_name test_source result_var)
+ unset(C_PASSED)
+ unset(CXX_PASSED)
+ aom_check_c_compiles(${test_name} ${test_source} C_PASSED)
+ aom_check_cxx_compiles(${test_name} ${test_source} CXX_PASSED)
+ if (C_PASSED AND CXX_PASSED)
+ set(${result_var} 1 PARENT_SCOPE)
+ else ()
+ set(${result_var} 0 PARENT_SCOPE)
+ endif ()
+endfunction ()
+
+# When inline support is detected for the current compiler the supported
+# inlining keyword is written to $result in caller scope.
+function (aom_get_inline result)
+ aom_check_source_compiles("inline_check_1"
+ "static inline void function(void) {}"
+ HAVE_INLINE_1)
+ if (HAVE_INLINE_1 EQUAL 1)
+ set(${result} "inline" PARENT_SCOPE)
+ return()
+ endif ()
+
+ # Check __inline.
+ aom_check_source_compiles("inline_check_2"
+ "static __inline void function(void) {}"
+ HAVE_INLINE_2)
+ if (HAVE_INLINE_2 EQUAL 1)
+ set(${result} "__inline" PARENT_SCOPE)
+ endif ()
+endfunction ()
diff --git a/third_party/aom/build/cmake/cpu.cmake b/third_party/aom/build/cmake/cpu.cmake
new file mode 100644
index 000000000..5d0b1a6e8
--- /dev/null
+++ b/third_party/aom/build/cmake/cpu.cmake
@@ -0,0 +1,72 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+if ("${AOM_TARGET_CPU}" STREQUAL "arm64")
+ set(ARCH_ARM 1)
+ set(HAVE_NEON 1)
+ set(RTCD_ARCH_ARM "yes")
+ set(RTCD_HAVE_NEON "yes")
+elseif ("${AOM_TARGET_CPU}" MATCHES "^armv7")
+ set(ARCH_ARM 1)
+ set(HAVE_NEON 1)
+ set(HAVE_NEON_ASM 1)
+ set(RTCD_ARCH_ARM "yes")
+ set(RTCD_HAVE_NEON "yes")
+ set(RTCD_HAVE_NEON_ASM "yes")
+elseif ("${AOM_TARGET_CPU}" MATCHES "^mips")
+ set(ARCH_MIPS 1)
+
+ if ("${AOM_TARGET_CPU}" STREQUAL "mips32")
+ set(HAVE_MIPS32 1)
+ elseif ("${AOM_TARGET_CPU}" STREQUAL "mips64")
+ set(HAVE_MIPS64 1)
+ endif ()
+
+ set(RTCD_ARCH_MIPS "yes")
+
+ if (HAVE_DSPR2)
+ set(RTCD_HAVE_DSPR2 "yes")
+ endif ()
+
+ if (HAVE_MSA)
+ set(RTCD_HAVE_MSA "yes")
+ endif ()
+elseif ("${AOM_TARGET_CPU}" MATCHES "^x86")
+ if ("${AOM_TARGET_CPU}" STREQUAL "x86")
+ set(ARCH_X86 1)
+ set(RTCD_ARCH_X86 "yes")
+ elseif ("${AOM_TARGET_CPU}" STREQUAL "x86_64")
+ set(ARCH_X86_64 1)
+ set(RTCD_ARCH_X86_64 "yes")
+ endif ()
+
+ set(HAVE_MMX 1)
+ set(HAVE_SSE 1)
+ set(HAVE_SSE2 1)
+ set(HAVE_SSE3 1)
+ set(HAVE_SSSE3 1)
+ set(HAVE_SSE4_1 1)
+ set(HAVE_AVX 1)
+ set(HAVE_AVX2 1)
+ set(RTCD_HAVE_MMX "yes")
+ set(RTCD_HAVE_SSE "yes")
+ set(RTCD_HAVE_SSE2 "yes")
+ set(RTCD_HAVE_SSE3 "yes")
+ set(RTCD_HAVE_SSSE3 "yes")
+ set(RTCD_HAVE_SSE4_1 "yes")
+ set(RTCD_HAVE_AVX "yes")
+ set(RTCD_HAVE_AVX2 "yes")
+endif ()
+
+foreach (config_var ${AOM_CONFIG_VARS})
+ if (${${config_var}})
+ set(RTCD_${config_var} yes)
+ endif ()
+endforeach ()
diff --git a/third_party/aom/build/cmake/generate_aom_config_templates.cmake b/third_party/aom/build/cmake/generate_aom_config_templates.cmake
new file mode 100644
index 000000000..aea4253bb
--- /dev/null
+++ b/third_party/aom/build/cmake/generate_aom_config_templates.cmake
@@ -0,0 +1,84 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+cmake_minimum_required(VERSION 3.5)
+
+string(TIMESTAMP year "%Y")
+set(asm_file_header_block
+"\;
+\; Copyright (c) ${year}, Alliance for Open Media. All rights reserved
+\;
+\; This source code is subject to the terms of the BSD 2 Clause License and
+\; the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+\; was not distributed with this source code in the LICENSE file, you can
+\; obtain it at www.aomedia.org/license/software. If the Alliance for Open
+\; Media Patent License 1.0 was not distributed with this source code in the
+\; PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+\;
+")
+set(h_file_header_block
+"/*
+ * Copyright (c) ${year}, Alliance for Open Media. All rights reserved
+ *
+ * This source code is subject to the terms of the BSD 2 Clause License and
+ * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+ * was not distributed with this source code in the LICENSE file, you can
+ * obtain it at www.aomedia.org/license/software. If the Alliance for Open
+ * Media Patent License 1.0 was not distributed with this source code in the
+ * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+ */
+\#ifndef AOM_CONFIG_H_
+\#define AOM_CONFIG_H_
+")
+
+# Terminates cmake execution when $var_name is an empty string, or the variable
+# name it contains does not expand to an existing directory.
+function (check_directory_var var_name)
+ if ("${var_name}" STREQUAL "")
+ message(FATAL_ERROR "The CMake variable ${var_name} must be defined.")
+ endif ()
+
+ if (NOT EXISTS "${${var_name}}")
+ message(FATAL_ERROR "${${var_name}} (${var_name}) missing.")
+ endif ()
+endfunction ()
+
+check_directory_var(AOM_CONFIG_DIR)
+check_directory_var(AOM_ROOT)
+
+set(AOM_DEFAULTS "${AOM_ROOT}/build/cmake/aom_config_defaults.cmake")
+if (NOT EXISTS "${AOM_DEFAULTS}")
+ message(FATAL_ERROR
+ "Configuration default values file (${AOM_DEFAULTS}) missing.")
+endif ()
+
+include("${AOM_ROOT}/build/cmake/aom_config_defaults.cmake")
+get_cmake_property(cmake_cache_vars CACHE_VARIABLES)
+
+set(aom_config_h_template "${AOM_CONFIG_DIR}/aom_config.h.cmake")
+file(WRITE "${aom_config_h_template}" ${h_file_header_block})
+foreach(cache_var ${cmake_cache_vars})
+ if (NOT "${cache_var}" MATCHES "AOM_CONFIG_DIR\|AOM_ROOT\|^CMAKE_")
+ file(APPEND
+ "${aom_config_h_template}" "\#define ${cache_var} \${${cache_var}}\n")
+ endif ()
+endforeach()
+file(APPEND "${aom_config_h_template}" "\#endif /* AOM_CONFIG_H_ */")
+
+set(aom_asm_config_template "${AOM_CONFIG_DIR}/aom_config.asm.cmake")
+file(WRITE "${aom_asm_config_template}" ${asm_file_header_block})
+foreach(cache_var ${cmake_cache_vars})
+ if (NOT "${cache_var}" MATCHES
+ "AOM_CONFIG_DIR\|AOM_ROOT\|^CMAKE_\|INLINE\|RESTRICT")
+ file(APPEND "${aom_asm_config_template}"
+ "${cache_var} equ \${${cache_var}}\n")
+ endif ()
+endforeach ()
+
diff --git a/third_party/aom/build/cmake/msvc_runtime.cmake b/third_party/aom/build/cmake/msvc_runtime.cmake
new file mode 100644
index 000000000..0327217b4
--- /dev/null
+++ b/third_party/aom/build/cmake/msvc_runtime.cmake
@@ -0,0 +1,26 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+
+if (MSVC)
+ # CMake defaults to producing code linked to the DLL MSVC runtime. That will
+ # not work with googletest, and isn't what we want anyway.
+ if (NOT "${MSVC_RUNTIME}" STREQUAL "dll")
+ foreach (flag_var
+ CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
+ CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
+ CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+ if (${flag_var} MATCHES "/MD")
+ string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
+ endif (${flag_var} MATCHES "/MD")
+ endforeach (flag_var)
+ endif ()
+endif ()
diff --git a/third_party/aom/build/cmake/rtcd_config.cmake b/third_party/aom/build/cmake/rtcd_config.cmake
new file mode 100644
index 000000000..cdea3452a
--- /dev/null
+++ b/third_party/aom/build/cmake/rtcd_config.cmake
@@ -0,0 +1,137 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+ARCH_ARM=${RTCD_ARCH_ARM}
+ARCH_MIPS=${RTCD_ARCH_MIPS}
+ARCH_X86=${RTCD_ARCH_X86}
+ARCH_X86_64=${RTCD_ARCH_X86_64}
+HAVE_NEON=${RTCD_HAVE_NEON}
+HAVE_NEON_ASM=${RTCD_HAVE_NEON_ASM}
+HAVE_MIPS32=${RTCD_HAVE_MIPS32}
+HAVE_DSPR2=${RTCD_HAVE_DSPR2}
+HAVE_MSA=${RTCD_HAVE_MSA}
+HAVE_MIPS64=${RTCD_HAVE_MIPS64}
+HAVE_MMX=${RTCD_HAVE_MMX}
+HAVE_SSE=${RTCD_HAVE_SSE}
+HAVE_SSE2=${RTCD_HAVE_SSE2}
+HAVE_SSE3=${RTCD_HAVE_SSE3}
+HAVE_SSSE3=${RTCD_HAVE_SSSE3}
+HAVE_SSE4_1=${RTCD_HAVE_SSE4_1}
+HAVE_AVX=${RTCD_HAVE_AVX}
+HAVE_AVX2=${RTCD_HAVE_AVX2}
+CONFIG_ACCOUNTING=${RTCD_CONFIG_ACCOUNTING}
+CONFIG_INSPECTION=${RTCD_CONFIG_INSPECTION}
+CONFIG_ADAPT_SCAN=${RTCD_CONFIG_ADAPT_SCAN}
+CONFIG_ALT_INTRA=${RTCD_CONFIG_ALT_INTRA}
+CONFIG_ANS=${RTCD_CONFIG_ANS}
+CONFIG_HIGHBITDEPTH=${RTCD_CONFIG_HIGHBITDEPTH}
+CONFIG_AOM_QM=${RTCD_CONFIG_AOM_QM}
+CONFIG_AV1=${RTCD_CONFIG_AV1}
+CONFIG_AV1_DECODER=${RTCD_CONFIG_AV1_DECODER}
+CONFIG_AV1_ENCODER=${RTCD_CONFIG_AV1_ENCODER}
+CONFIG_BIG_ENDIAN=${RTCD_CONFIG_BIG_ENDIAN}
+CONFIG_BITSTREAM_DEBUG=${RTCD_CONFIG_BITSTREAM_DEBUG}
+CONFIG_CB4X4=${RTCD_CONFIG_CB4X4}
+CONFIG_CDEF=${RTCD_CONFIG_CDEF}
+CONFIG_CHROMA_2X2=${RTCD_CONFIG_CHROMA_2X2}
+CONFIG_CODEC_SRCS=${RTCD_CONFIG_CODEC_SRCS}
+CONFIG_COEFFICIENT_RANGE_CHECKING=${RTCD_CONFIG_COEFFICIENT_RANGE_CHECKING}
+CONFIG_COEF_INTERLEAVE=${RTCD_CONFIG_COEF_INTERLEAVE}
+CONFIG_COMPOUND_SEGMENT=${RTCD_CONFIG_COMPOUND_SEGMENT}
+CONFIG_CONVOLVE_ROUND=${RTCD_CONFIG_CONVOLVE_ROUND}
+CONFIG_DAALA_DIST=${RTCD_CONFIG_DAALA_DIST}
+CONFIG_DAALA_EC=${RTCD_CONFIG_DAALA_EC}
+CONFIG_DEBUG=${RTCD_CONFIG_DEBUG}
+CONFIG_DEBUG_LIBS=${RTCD_CONFIG_DEBUG_LIBS}
+CONFIG_DECODERS=${RTCD_CONFIG_DECODERS}
+CONFIG_DECODE_PERF_TESTS=${RTCD_CONFIG_DECODE_PERF_TESTS}
+CONFIG_DELTA_Q=${RTCD_CONFIG_DELTA_Q}
+CONFIG_DEPENDENCY_TRACKING=${RTCD_CONFIG_DEPENDENCY_TRACKING}
+CONFIG_DEPENDENT_HORZTILES=${RTCD_CONFIG_DEPENDENT_HORZTILES}
+CONFIG_DUAL_FILTER=${RTCD_CONFIG_DUAL_FILTER}
+CONFIG_EC_ADAPT=${RTCD_CONFIG_EC_ADAPT}
+CONFIG_EC_MULTISYMBOL=${RTCD_CONFIG_EC_MULTISYMBOL}
+CONFIG_ENCODERS=${RTCD_CONFIG_ENCODERS}
+CONFIG_ENCODE_PERF_TESTS=${RTCD_CONFIG_ENCODE_PERF_TESTS}
+CONFIG_ENTROPY_STATS=${RTCD_CONFIG_ENTROPY_STATS}
+CONFIG_ERROR_CONCEALMENT=${RTCD_CONFIG_ERROR_CONCEALMENT}
+CONFIG_EXPERIMENTAL=${RTCD_CONFIG_EXPERIMENTAL}
+CONFIG_EXTERNAL_BUILD=${RTCD_CONFIG_EXTERNAL_BUILD}
+CONFIG_EXT_INTER=${RTCD_CONFIG_EXT_INTER}
+CONFIG_EXT_INTRA=${RTCD_CONFIG_EXT_INTRA}
+CONFIG_EXT_PARTITION=${RTCD_CONFIG_EXT_PARTITION}
+CONFIG_EXT_PARTITION_TYPES=${RTCD_CONFIG_EXT_PARTITION_TYPES}
+CONFIG_EXT_REFS=${RTCD_CONFIG_EXT_REFS}
+CONFIG_EXT_TILE=${RTCD_CONFIG_EXT_TILE}
+CONFIG_EXT_TX=${RTCD_CONFIG_EXT_TX}
+CONFIG_FILTER_7BIT=${RTCD_CONFIG_FILTER_7BIT}
+CONFIG_FILTER_INTRA=${RTCD_CONFIG_FILTER_INTRA}
+CONFIG_FP_MB_STATS=${RTCD_CONFIG_FP_MB_STATS}
+CONFIG_FRAME_SIZE=${RTCD_CONFIG_FRAME_SIZE}
+CONFIG_GCC=${RTCD_CONFIG_GCC}
+CONFIG_GCOV=${RTCD_CONFIG_GCOV}
+CONFIG_GLOBAL_MOTION=${RTCD_CONFIG_GLOBAL_MOTION}
+CONFIG_GPROF=${RTCD_CONFIG_GPROF}
+CONFIG_INSTALL_BINS=${RTCD_CONFIG_INSTALL_BINS}
+CONFIG_INSTALL_DOCS=${RTCD_CONFIG_INSTALL_DOCS}
+CONFIG_INSTALL_LIBS=${RTCD_CONFIG_INSTALL_LIBS}
+CONFIG_INSTALL_SRCS=${RTCD_CONFIG_INSTALL_SRCS}
+CONFIG_INTERNAL_STATS=${RTCD_CONFIG_INTERNAL_STATS}
+CONFIG_INTRA_INTERP=${RTCD_CONFIG_INTRA_INTERP}
+CONFIG_LIBYUV=${RTCD_CONFIG_LIBYUV}
+CONFIG_LOOPFILTERING_ACROSS_TILES=${RTCD_CONFIG_LOOPFILTERING_ACROSS_TILES}
+CONFIG_LOOP_RESTORATION=${RTCD_CONFIG_LOOP_RESTORATION}
+CONFIG_LOWBITDEPTH=${RTCD_CONFIG_LOWBITDEPTH}
+CONFIG_LV_MAP=${RTCD_CONFIG_LV_MAP}
+CONFIG_MASKED_TX=${RTCD_CONFIG_MASKED_TX}
+CONFIG_MOTION_VAR=${RTCD_CONFIG_MOTION_VAR}
+CONFIG_MSVS=${RTCD_CONFIG_MSVS}
+CONFIG_MULTITHREAD=${RTCD_CONFIG_MULTITHREAD}
+CONFIG_MV_COMPRESS=${RTCD_CONFIG_MV_COMPRESS}
+CONFIG_NCOBMC=${RTCD_CONFIG_NCOBMC}
+CONFIG_NEW_QUANT=${RTCD_CONFIG_NEW_QUANT}
+CONFIG_NEW_TOKENSET=${RTCD_CONFIG_NEW_TOKENSET}
+CONFIG_ONTHEFLY_BITPACKING=${RTCD_CONFIG_ONTHEFLY_BITPACKING}
+CONFIG_OS_SUPPORT=${RTCD_CONFIG_OS_SUPPORT}
+CONFIG_PALETTE=${RTCD_CONFIG_PALETTE}
+CONFIG_PALETTE_THROUGHPUT=${RTCD_CONFIG_PALETTE_THROUGHPUT}
+CONFIG_PARALLEL_DEBLOCKING=${RTCD_CONFIG_PARALLEL_DEBLOCKING}
+CONFIG_PIC=${RTCD_CONFIG_PIC}
+CONFIG_POSTPROC=${RTCD_CONFIG_POSTPROC}
+CONFIG_POSTPROC_VISUALIZER=${RTCD_CONFIG_POSTPROC_VISUALIZER}
+CONFIG_PVQ=${RTCD_CONFIG_PVQ}
+CONFIG_RAWBITS=${RTCD_CONFIG_RAWBITS}
+CONFIG_RD_DEBUG=${RTCD_CONFIG_RD_DEBUG}
+CONFIG_REALTIME_ONLY=${RTCD_CONFIG_REALTIME_ONLY}
+CONFIG_RECT_TX=${RTCD_CONFIG_RECT_TX}
+CONFIG_REFERENCE_BUFFER=${RTCD_CONFIG_REFERENCE_BUFFER}
+CONFIG_REF_ADAPT=${RTCD_CONFIG_REF_ADAPT}
+CONFIG_REF_MV=${RTCD_CONFIG_REF_MV}
+CONFIG_RUNTIME_CPU_DETECT=${RTCD_CONFIG_RUNTIME_CPU_DETECT}
+CONFIG_RVCT=${RTCD_CONFIG_RVCT}
+CONFIG_SHARED=${RTCD_CONFIG_SHARED}
+CONFIG_SIZE_LIMIT=${RTCD_CONFIG_SIZE_LIMIT}
+CONFIG_SMALL=${RTCD_CONFIG_SMALL}
+CONFIG_SPATIAL_RESAMPLING=${RTCD_CONFIG_SPATIAL_RESAMPLING}
+CONFIG_STATIC=${RTCD_CONFIG_STATIC}
+CONFIG_STATIC_MSVCRT=${RTCD_CONFIG_STATIC_MSVCRT}
+CONFIG_SUB8X8_MC=${RTCD_CONFIG_SUB8X8_MC}
+CONFIG_SUPERTX=${RTCD_CONFIG_SUPERTX}
+CONFIG_TEMPMV_SIGNALING=${RTCD_CONFIG_TEMPMV_SIGNALING}
+CONFIG_TILE_GROUPS=${RTCD_CONFIG_TILE_GROUPS}
+CONFIG_TPL_MV=${RTCD_CONFIG_TPL_MV}
+CONFIG_TRIPRED=${RTCD_CONFIG_TRIPRED}
+CONFIG_TX64X64=${RTCD_CONFIG_TX64X64}
+CONFIG_UNIT_TESTS=${RTCD_CONFIG_UNIT_TESTS}
+CONFIG_UNPOISON_PARTITION_CTX=${RTCD_CONFIG_UNPOISON_PARTITION_CTX}
+CONFIG_VAR_TX=${RTCD_CONFIG_VAR_TX}
+CONFIG_WARPED_MOTION=${RTCD_CONFIG_WARPED_MOTION}
+CONFIG_WEBM_IO=${RTCD_CONFIG_WEBM_IO}
+CONFIG_XIPHRC=${RTCD_CONFIG_XIPHRC}
diff --git a/third_party/aom/build/cmake/toolchains/arm-ios-common.cmake b/third_party/aom/build/cmake/toolchains/arm-ios-common.cmake
new file mode 100644
index 000000000..8317ae272
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/arm-ios-common.cmake
@@ -0,0 +1,31 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+if (NOT AOM_BUILD_CMAKE_TOOLCHAINS_ARM_IOS_COMMON_CMAKE_)
+set(AOM_BUILD_CMAKE_ARM_IOS_COMMON_CMAKE_ 1)
+
+set(CMAKE_SYSTEM_NAME "Darwin")
+set(CMAKE_OSX_SYSROOT iphoneos)
+set(CMAKE_C_COMPILER clang)
+set(CMAKE_C_COMPILER_ARG1 "-arch ${CMAKE_SYSTEM_PROCESSOR}")
+set(CMAKE_CXX_COMPILER clang++)
+set(CMAKE_CXX_COMPILER_ARG1 "-arch ${CMAKE_SYSTEM_PROCESSOR}")
+
+# Assembler sources must be converted for ARM iOS targets.
+set(AOM_ADS2GAS_REQUIRED 1)
+set(AOM_ADS2GAS "${CMAKE_CURRENT_SOURCE_DIR}/build/make/ads2gas_apple.pl")
+set(AOM_GAS_EXT "S")
+
+# No runtime cpu detect for arm*-ios targets.
+set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE BOOL "")
+
+# TODO(tomfinegan): Handle bit code embedding.
+
+endif () # AOM_BUILD_CMAKE_TOOLCHAINS_ARM_IOS_COMMON_CMAKE_
diff --git a/third_party/aom/build/cmake/toolchains/arm64-ios.cmake b/third_party/aom/build/cmake/toolchains/arm64-ios.cmake
new file mode 100644
index 000000000..434809db9
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/arm64-ios.cmake
@@ -0,0 +1,24 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+if (NOT AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_IOS_CMAKE_)
+set(AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_IOS_CMAKE_ 1)
+
+if (XCODE)
+ # TODO(tomfinegan): Handle arm builds in Xcode.
+ message(FATAL_ERROR "This toolchain does not support Xcode.")
+endif ()
+
+set(CMAKE_SYSTEM_PROCESSOR "arm64")
+set(CMAKE_OSX_ARCHITECTURES "arm64")
+
+include("${CMAKE_CURRENT_LIST_DIR}/arm-ios-common.cmake")
+
+endif () # AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_IOS_CMAKE_
diff --git a/third_party/aom/build/cmake/toolchains/arm64-linux-gcc.cmake b/third_party/aom/build/cmake/toolchains/arm64-linux-gcc.cmake
new file mode 100644
index 000000000..b8efe6be6
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/arm64-linux-gcc.cmake
@@ -0,0 +1,35 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+if (NOT AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_LINUX_GCC_CMAKE_)
+set(AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_LINUX_GCC_CMAKE_ 1)
+
+set(CMAKE_SYSTEM_NAME "Linux")
+
+if ("${CROSS}" STREQUAL "")
+ # Default the cross compiler prefix to something known to work.
+ set(CROSS aarch64-linux-gnu-)
+endif ()
+
+set(CMAKE_C_COMPILER ${CROSS}gcc)
+set(CMAKE_CXX_COMPILER ${CROSS}g++)
+set(AS_EXECUTABLE ${CROSS}as)
+set(CMAKE_C_COMPILER_ARG1 "-march=armv8-a")
+set(CMAKE_CXX_COMPILER_ARG1 "-march=armv8-a")
+set(AOM_AS_FLAGS "-march=armv8-a")
+set(CMAKE_SYSTEM_PROCESSOR "arm64")
+
+# No intrinsics flag required for arm64-linux-gcc.
+set(AOM_NEON_INTRIN_FLAG "")
+
+# No runtime cpu detect for arm64-linux-gcc.
+set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE BOOL "")
+
+endif () # AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_LINUX_GCC_CMAKE_
diff --git a/third_party/aom/build/cmake/toolchains/armv7-ios.cmake b/third_party/aom/build/cmake/toolchains/armv7-ios.cmake
new file mode 100644
index 000000000..bcd37a06d
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/armv7-ios.cmake
@@ -0,0 +1,34 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+if (NOT AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7_IOS_CMAKE_)
+set(AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7_IOS_CMAKE_ 1)
+
+if (XCODE)
+ # TODO(tomfinegan): Handle arm builds in Xcode.
+ message(FATAL_ERROR "This toolchain does not support Xcode.")
+endif ()
+
+set(CMAKE_SYSTEM_PROCESSOR "armv7")
+set(CMAKE_OSX_ARCHITECTURES "armv7")
+
+include("${CMAKE_CURRENT_LIST_DIR}/arm-ios-common.cmake")
+
+# No intrinsics flag required for armv7s-ios.
+set(AOM_NEON_INTRIN_FLAG "")
+
+# No runtime cpu detect for armv7s-ios.
+set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE BOOL "")
+
+# RTCD generation requires --disable-media for armv7s-ios.
+set(AOM_RTCD_FLAGS ${AOM_RTCD_FLAGS} --disable-media)
+string(STRIP AOM_RTCD_FLAGS ${AOM_RTCD_FLAGS})
+
+endif () # AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7_IOS_CMAKE_
diff --git a/third_party/aom/build/cmake/toolchains/armv7-linux-gcc.cmake b/third_party/aom/build/cmake/toolchains/armv7-linux-gcc.cmake
new file mode 100644
index 000000000..eedfda464
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/armv7-linux-gcc.cmake
@@ -0,0 +1,48 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+if (NOT AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7_LINUX_GCC_CMAKE_)
+set(AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7_LINUX_GCC_CMAKE_ 1)
+
+set(CMAKE_SYSTEM_NAME "Linux")
+
+if ("${CROSS}" STREQUAL "")
+ # Default the cross compiler prefix to something known to work.
+ set(CROSS arm-linux-gnueabihf-)
+endif ()
+
+if (NOT ${CROSS} MATCHES hf-$)
+ set(AOM_EXTRA_TOOLCHAIN_FLAGS "-mfloat-abi=softfp")
+endif ()
+
+set(CMAKE_C_COMPILER ${CROSS}gcc)
+set(CMAKE_CXX_COMPILER ${CROSS}g++)
+set(AS_EXECUTABLE ${CROSS}as)
+set(CMAKE_C_COMPILER_ARG1
+ "-march=armv7-a -mfpu=neon ${AOM_EXTRA_TOOLCHAIN_FLAGS}")
+set(CMAKE_CXX_COMPILER_ARG1
+ "-march=armv7-a -mfpu=neon ${AOM_EXTRA_TOOLCHAIN_FLAGS}")
+set(AOM_AS_FLAGS
+ --defsym ARCHITECTURE=7 -march=armv7-a -mfpu=neon
+ ${AOM_EXTRA_TOOLCHAIN_FLAGS})
+set(CMAKE_SYSTEM_PROCESSOR "armv7")
+
+# No intrinsics flag required for armv7-linux-gcc.
+set(AOM_NEON_INTRIN_FLAG "")
+
+# Assembler sources must be converted for armv7-linux-gcc targets.
+set(AOM_ADS2GAS_REQUIRED 1)
+set(AOM_ADS2GAS "${CMAKE_CURRENT_SOURCE_DIR}/build/make/ads2gas.pl")
+set(AOM_GAS_EXT "S")
+
+# No runtime cpu detect for armv7-linux-gcc.
+set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE BOOL "")
+
+endif () # AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7_LINUX_GCC_CMAKE_
diff --git a/third_party/aom/build/cmake/toolchains/armv7s-ios.cmake b/third_party/aom/build/cmake/toolchains/armv7s-ios.cmake
new file mode 100644
index 000000000..08a0a37ee
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/armv7s-ios.cmake
@@ -0,0 +1,34 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+if (NOT AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7S_IOS_CMAKE_)
+set(AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7S_IOS_CMAKE_ 1)
+
+if (XCODE)
+ # TODO(tomfinegan): Handle arm builds in Xcode.
+ message(FATAL_ERROR "This toolchain does not support Xcode.")
+endif ()
+
+set(CMAKE_SYSTEM_PROCESSOR "armv7s")
+set(CMAKE_OSX_ARCHITECTURES "armv7s")
+
+include("${CMAKE_CURRENT_LIST_DIR}/arm-ios-common.cmake")
+
+# No intrinsics flag required for armv7s-ios.
+set(AOM_NEON_INTRIN_FLAG "")
+
+# No runtime cpu detect for armv7s-ios.
+set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE BOOL "")
+
+# RTCD generation requires --disable-media for armv7s-ios.
+set(AOM_RTCD_FLAGS ${AOM_RTCD_FLAGS} --disable-media)
+string(STRIP AOM_RTCD_FLAGS ${AOM_RTCD_FLAGS})
+
+endif () # AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7S_IOS_CMAKE_
diff --git a/third_party/aom/build/cmake/toolchains/ios-simulator-common.cmake b/third_party/aom/build/cmake/toolchains/ios-simulator-common.cmake
new file mode 100644
index 000000000..7a28e329c
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/ios-simulator-common.cmake
@@ -0,0 +1,23 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+if (NOT AOM_BUILD_CMAKE_TOOLCHAINS_IOS_SIMULATOR_COMMON_CMAKE_)
+set(AOM_BUILD_CMAKE_IOS_SIMULATOR_COMMON_CMAKE_ 1)
+
+set(CMAKE_SYSTEM_NAME "Darwin")
+set(CMAKE_OSX_SYSROOT iphonesimulator)
+set(CMAKE_C_COMPILER clang)
+set(CMAKE_C_COMPILER_ARG1 "-arch ${CMAKE_SYSTEM_PROCESSOR}")
+set(CMAKE_CXX_COMPILER clang++)
+set(CMAKE_CXX_COMPILER_ARG1 "-arch ${CMAKE_SYSTEM_PROCESSOR}")
+
+# TODO(tomfinegan): Handle bit code embedding.
+
+endif () # AOM_BUILD_CMAKE_TOOLCHAINS_IOS_SIMULATOR_COMMON_CMAKE_
diff --git a/third_party/aom/build/cmake/toolchains/mips32-linux-gcc.cmake b/third_party/aom/build/cmake/toolchains/mips32-linux-gcc.cmake
new file mode 100644
index 000000000..a55c41115
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/mips32-linux-gcc.cmake
@@ -0,0 +1,71 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+if (NOT AOM_BUILD_CMAKE_TOOLCHAINS_MIPS32_LINUX_GCC_CMAKE_)
+set(AOM_BUILD_CMAKE_TOOLCHAINS_MIPS32_LINUX_GCC_CMAKE_ 1)
+
+set(CMAKE_SYSTEM_NAME "Linux")
+
+if (ENABLE_DSPR2 AND ENABLE_MSA)
+ message(FATAL_ERROR "ENABLE_DSPR2 and ENABLE_MSA cannot be combined.")
+endif ()
+
+if (ENABLE_DSPR2)
+ set(HAVE_DSPR2 1 CACHE BOOL "" FORCE)
+
+ if ("${CROSS}" STREQUAL "")
+ # Default the cross compiler prefix to something known to work.
+ set(CROSS mips-linux-gnu-)
+ endif ()
+
+ set(MIPS_CFLAGS "-mdspr2")
+ set(MIPS_CXXFLAGS "-mdspr2")
+elseif (ENABLE_MSA)
+ set(HAVE_MSA 1 CACHE BOOL "" FORCE)
+
+ if ("${CROSS}" STREQUAL "")
+ # Default the cross compiler prefix to something known to work.
+ set(CROSS mips-mti-linux-gnu-)
+ endif ()
+
+ set(MIPS_CFLAGS "-mmsa")
+ set(MIPS_CXXFLAGS "-mmsa")
+endif ()
+
+if ("${CROSS}" STREQUAL "")
+ # TODO(tomfinegan): Make it possible to turn this off. The $CROSS prefix
+ # won't be desired on a mips host.
+ # Default cross compiler prefix to something that might work for an
+ # unoptimized build.
+ set(CROSS mips-linux-gnu-)
+endif ()
+
+if ("${MIPS_CPU}" STREQUAL "")
+ set(MIPS_CFLAGS "${MIPS_CFLAGS} -mips32r2")
+ set(MIPS_CXXFLAGS "${MIPS_CXXFLAGS} -mips32r2")
+elseif ("${MIPS_CPU}" STREQUAL "p5600")
+ set(P56_FLAGS
+ "-mips32r5 -mload-store-pairs -msched-weight -mhard-float -mfp64")
+ set(MIPS_CFLAGS "${MIPS_CFLAGS} ${P56_FLAGS}")
+ set(MIPS_CXXFLAGS "${MIPS_CXXFLAGS} ${P56_FLAGS}")
+ set(CMAKE_EXE_LINKER_FLAGS "-mfp64 ${CMAKE_EXE_LINKER_FLAGS}")
+endif ()
+
+set(CMAKE_C_COMPILER ${CROSS}gcc)
+set(CMAKE_CXX_COMPILER ${CROSS}g++)
+set(AS_EXECUTABLE ${CROSS}as)
+set(CMAKE_C_COMPILER_ARG1 "-EL ${MIPS_CFLAGS}")
+set(CMAKE_CXX_COMPILER_ARG1 "-EL ${MIPS_CXXFLAGS}")
+set(CMAKE_SYSTEM_PROCESSOR "mips32")
+
+# No runtime cpu detect for mips32-linux-gcc.
+set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE BOOL "")
+
+endif () # AOM_BUILD_CMAKE_TOOLCHAINS_MIPS32_LINUX_GCC_CMAKE_
diff --git a/third_party/aom/build/cmake/toolchains/mips64-linux-gcc.cmake b/third_party/aom/build/cmake/toolchains/mips64-linux-gcc.cmake
new file mode 100644
index 000000000..28b1582cc
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/mips64-linux-gcc.cmake
@@ -0,0 +1,48 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+if (NOT AOM_BUILD_CMAKE_TOOLCHAINS_MIPS64_LINUX_GCC_CMAKE_)
+set(AOM_BUILD_CMAKE_TOOLCHAINS_MIPS64_LINUX_GCC_CMAKE_ 1)
+
+set(CMAKE_SYSTEM_NAME "Linux")
+
+if ("${CROSS}" STREQUAL "")
+ # TODO(tomfinegan): Make it possible to turn this off. The $CROSS prefix
+ # won't be desired on a mips host.
+ # Default the cross compiler prefix to something known to work.
+ set(CROSS mips-img-linux-gnu-)
+endif ()
+
+if (ENABLE_MSA)
+ set(HAVE_MSA 1 CACHE BOOL "" FORCE)
+ set(MIPS_CFLAGS "-mmsa")
+ set(MIPS_CXXFLAGS "-mmsa")
+endif ()
+
+if ("${MIPS_CPU}" STREQUAL "i6400" OR "${MIPS_CPU}" STREQUAL "p6600")
+ set(MIPS_CPU_FLAGS "-mips64r6 -mabi=64 -mload-store-pairs -msched-weight")
+ set(MIPS_CPU_FLAGS "${MIPS_CPU_FLAGS} -mhard-float -mfp64")
+ set(MIPS_CFLAGS "${MIPS_CFLAGS} ${MIPS_CPU_FLAGS}")
+ set(MIPS_CXXFLAGS "${MIPS_CXXFLAGS} ${MIPS_CPU_FLAGS}")
+ set(CMAKE_EXE_LINKER_FLAGS
+ "-mips64r6 -mabi64 -mfp64 ${CMAKE_EXE_LINKER_FLAGS}")
+endif ()
+
+set(CMAKE_C_COMPILER ${CROSS}gcc)
+set(CMAKE_CXX_COMPILER ${CROSS}g++)
+set(AS_EXECUTABLE ${CROSS}as)
+set(CMAKE_C_COMPILER_ARG1 "-EL ${MIPS_CFLAGS}")
+set(CMAKE_CXX_COMPILER_ARG1 "-EL ${MIPS_CXXFLAGS}")
+set(CMAKE_SYSTEM_PROCESSOR "mips64")
+
+# No runtime cpu detect for mips64-linux-gcc.
+set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE BOOL "")
+
+endif () # AOM_BUILD_CMAKE_TOOLCHAINS_MIPS64_LINUX_GCC_CMAKE_
diff --git a/third_party/aom/build/cmake/toolchains/x86-ios-simulator.cmake b/third_party/aom/build/cmake/toolchains/x86-ios-simulator.cmake
new file mode 100644
index 000000000..4e4ebc034
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/x86-ios-simulator.cmake
@@ -0,0 +1,27 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+if (NOT AOM_BUILD_CMAKE_TOOLCHAINS_X86_IOS_SIMULATOR_CMAKE_)
+set(AOM_BUILD_CMAKE_TOOLCHAINS_X86_IOS_SIMULATOR_CMAKE_ 1)
+
+if (XCODE)
+ # TODO(tomfinegan): Handle ios sim builds in Xcode.
+ message(FATAL_ERROR "This toolchain does not support Xcode.")
+endif ()
+
+set(CMAKE_SYSTEM_PROCESSOR "i386")
+set(CMAKE_OSX_ARCHITECTURES "i386")
+
+# Avoid noisy PIC/PIE warnings.
+set(CONFIG_PIC 1 CACHE BOOL "")
+
+include("${CMAKE_CURRENT_LIST_DIR}/ios-simulator-common.cmake")
+
+endif () # AOM_BUILD_CMAKE_TOOLCHAINS_X86_IOS_SIMULATOR_CMAKE_
diff --git a/third_party/aom/build/cmake/toolchains/x86-linux.cmake b/third_party/aom/build/cmake/toolchains/x86-linux.cmake
new file mode 100644
index 000000000..077c8f325
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/x86-linux.cmake
@@ -0,0 +1,14 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+set(CMAKE_SYSTEM_PROCESSOR "x86")
+set(CMAKE_SYSTEM_NAME "Linux")
+set(CMAKE_C_COMPILER_ARG1 "-m32")
+set(CMAKE_CXX_COMPILER_ARG1 "-m32")
diff --git a/third_party/aom/build/cmake/toolchains/x86-macos.cmake b/third_party/aom/build/cmake/toolchains/x86-macos.cmake
new file mode 100644
index 000000000..22d0171a7
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/x86-macos.cmake
@@ -0,0 +1,18 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+set(CMAKE_SYSTEM_PROCESSOR "x86")
+set(CMAKE_SYSTEM_NAME "Darwin")
+set(CMAKE_OSX_ARCHITECTURES "i386")
+set(CMAKE_C_COMPILER_ARG1 "-arch i386")
+set(CMAKE_CXX_COMPILER_ARG1 "-arch i386")
+
+# Apple tools always complain in 32 bit mode without PIC.
+set(CONFIG_PIC 1 CACHE STRING "")
diff --git a/third_party/aom/build/cmake/toolchains/x86_64-ios-simulator.cmake b/third_party/aom/build/cmake/toolchains/x86_64-ios-simulator.cmake
new file mode 100644
index 000000000..884540a9d
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/x86_64-ios-simulator.cmake
@@ -0,0 +1,24 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+if (NOT AOM_BUILD_CMAKE_TOOLCHAINS_X86_64_IOS_SIMULATOR_CMAKE_)
+set(AOM_BUILD_CMAKE_TOOLCHAINS_X86_64_IOS_SIMULATOR_CMAKE_ 1)
+
+if (XCODE)
+ # TODO(tomfinegan): Handle ios sim builds in Xcode.
+ message(FATAL_ERROR "This toolchain does not support Xcode.")
+endif ()
+
+set(CMAKE_SYSTEM_PROCESSOR "x86_64")
+set(CMAKE_OSX_ARCHITECTURES "x86_64")
+
+include("${CMAKE_CURRENT_LIST_DIR}/ios-simulator-common.cmake")
+
+endif () # AOM_BUILD_CMAKE_TOOLCHAINS_X86_64_IOS_SIMULATOR_CMAKE_