Move aom source to a sub-directory under media/libaom

There is no damned reason to treat this differently than any other media lib given its license and there never was.
This commit is contained in:
Matt A. Tobin 2020-04-07 23:30:51 -04:00 • committed by Roy Tam
commit b746a4196a
1002 changed files with 517 additions and 517 deletions

View file

@ -0,0 +1,13 @@
/*
* 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}";
const char *aom_codec_build_config(void) {return cfg;}

View file

@ -0,0 +1,196 @@
#
# 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_ROOT}/build/cmake/util.cmake")
# This file sets default values for libaom configuration variables. All libaom
# config variables are added to the CMake variable cache via the macros provided
# in util.cmake.
#
# The variables in this section of the file are detected at configuration time,
# but can be overridden via the use of CONFIG_* and ENABLE_* values also defined
# in this file.
#
set_aom_detect_var(INLINE "" STRING "Sets INLINE value for current target.")
# CPUs.
set_aom_detect_var(ARCH_ARM 0 NUMBER "Enables ARM architecture.")
set_aom_detect_var(ARCH_MIPS 0 NUMBER "Enables MIPS architecture.")
set_aom_detect_var(ARCH_PPC 0 NUMBER "Enables PPC architecture.")
set_aom_detect_var(ARCH_X86 0 NUMBER "Enables X86 architecture.")
set_aom_detect_var(ARCH_X86_64 0 NUMBER "Enables X86_64 architecture.")
# ARM feature flags.
set_aom_detect_var(HAVE_NEON 0 NUMBER "Enables NEON intrinsics optimizations.")
# MIPS feature flags.
set_aom_detect_var(HAVE_DSPR2 0 NUMBER "Enables DSPR2 optimizations.")
set_aom_detect_var(HAVE_MIPS32 0 NUMBER "Enables MIPS32 optimizations.")
set_aom_detect_var(HAVE_MIPS64 0 NUMBER "Enables MIPS64 optimizations. ")
set_aom_detect_var(HAVE_MSA 0 NUMBER "Enables MSA optimizations.")
# PPC feature flags.
set_aom_detect_var(HAVE_VSX 0 NUMBER "Enables VSX optimizations.")
# x86/x86_64 feature flags.
set_aom_detect_var(HAVE_AVX 0 NUMBER "Enables AVX optimizations.")
set_aom_detect_var(HAVE_AVX2 0 NUMBER "Enables AVX2 optimizations.")
set_aom_detect_var(HAVE_MMX 0 NUMBER "Enables MMX optimizations. ")
set_aom_detect_var(HAVE_SSE 0 NUMBER "Enables SSE optimizations.")
set_aom_detect_var(HAVE_SSE2 0 NUMBER "Enables SSE2 optimizations.")
set_aom_detect_var(HAVE_SSE3 0 NUMBER "Enables SSE3 optimizations.")
set_aom_detect_var(HAVE_SSE4_1 0 NUMBER "Enables SSE 4.1 optimizations.")
set_aom_detect_var(HAVE_SSE4_2 0 NUMBER "Enables SSE 4.2 optimizations.")
set_aom_detect_var(HAVE_SSSE3 0 NUMBER "Enables SSSE3 optimizations.")
# Flags describing the build environment.
set_aom_detect_var(HAVE_FEXCEPT 0 NUMBER
"Internal flag, GNU fenv.h present for target.")
set_aom_detect_var(HAVE_PTHREAD_H 0 NUMBER
"Internal flag, target pthread support.")
set_aom_detect_var(HAVE_UNISTD_H 0 NUMBER
"Internal flag, unistd.h present for target.")
set_aom_detect_var(HAVE_WXWIDGETS 0 NUMBER "WxWidgets present.")
#
# Variables in this section can be set from the CMake command line or from
# within the CMake GUI. The variables control libaom features.
#
# Build configuration flags.
set_aom_config_var(AOM_RTCD_FLAGS "" STRING
"Arguments to pass to rtcd.pl. Separate with ';'")
set_aom_config_var(CONFIG_AV1_DECODER 1 NUMBER "Enable AV1 decoder.")
set_aom_config_var(CONFIG_AV1_ENCODER 1 NUMBER "Enable AV1 encoder.")
set_aom_config_var(CONFIG_BIG_ENDIAN 0 NUMBER "Internal flag.")
set_aom_config_var(CONFIG_GCC 0 NUMBER "Building with GCC (detect).")
set_aom_config_var(CONFIG_GCOV 0 NUMBER "Enable gcov support.")
set_aom_config_var(CONFIG_GPROF 0 NUMBER "Enable gprof support.")
set_aom_config_var(CONFIG_LIBYUV 1 NUMBER
"Enables libyuv scaling/conversion support.")
set_aom_config_var(CONFIG_MULTITHREAD 1 NUMBER "Multithread support.")
set_aom_config_var(CONFIG_OS_SUPPORT 0 NUMBER "Internal flag.")
set_aom_config_var(CONFIG_PIC 0 NUMBER "Build with PIC enabled.")
set_aom_config_var(CONFIG_RUNTIME_CPU_DETECT 1 NUMBER
"Runtime CPU detection support.")
set_aom_config_var(CONFIG_SHARED 0 NUMBER "Build shared libs.")
set_aom_config_var(CONFIG_STATIC 1 NUMBER "Build static libs.")
set_aom_config_var(CONFIG_WEBM_IO 1 NUMBER "Enables WebM support.")
# Debugging flags.
set_aom_config_var(CONFIG_BITSTREAM_DEBUG 0 NUMBER "Bitstream debugging flag.")
set_aom_config_var(CONFIG_DEBUG 0 NUMBER "Debug build flag.")
set_aom_config_var(CONFIG_MISMATCH_DEBUG 0 NUMBER "Mismatch debugging flag.")
# AV1 feature flags.
set_aom_config_var(CONFIG_ACCOUNTING 0 NUMBER "Enables bit accounting.")
set_aom_config_var(CONFIG_ANALYZER 0 NUMBER "Enables bit stream analyzer.")
set_aom_config_var(CONFIG_COEFFICIENT_RANGE_CHECKING 0 NUMBER
"Coefficient range check.")
set_aom_config_var(CONFIG_DENOISE 1 NUMBER
"Denoise/noise modeling support in encoder.")
set_aom_config_var(CONFIG_FILEOPTIONS 1 NUMBER
"Enables encoder config file support.")
set_aom_config_var(CONFIG_FIX_GF_LENGTH 1 NUMBER
"Fix the GF length if possible")
set_aom_config_var(CONFIG_INSPECTION 0 NUMBER "Enables bitstream inspection.")
set_aom_config_var(CONFIG_INTERNAL_STATS 0 NUMBER
"Enables internal encoder stats.")
set_aom_config_var(CONFIG_LOWBITDEPTH 0 NUMBER
"Enables 8-bit optimized pipeline.")
set_aom_config_var(CONFIG_MAX_DECODE_PROFILE 2 NUMBER
"Max profile to support decoding.")
set_aom_config_var(CONFIG_NORMAL_TILE_MODE 0 NUMBER
"Only enables normal tile mode.")
set_aom_config_var(
CONFIG_REDUCED_ENCODER_BORDER 0 NUMBER
"Enable reduced border extention for encoder. \
Disables superres and resize support."
)
set_aom_config_var(CONFIG_SIZE_LIMIT 0 NUMBER "Limit max decode width/height.")
set_aom_config_var(CONFIG_SPATIAL_RESAMPLING 1 NUMBER "Spatial resampling.")
set_aom_config_var(DECODE_HEIGHT_LIMIT 0 NUMBER "Set limit for decode height.")
set_aom_config_var(DECODE_WIDTH_LIMIT 0 NUMBER "Set limit for decode width.")
set_aom_config_var(CONFIG_GLOBAL_MOTION_SEARCH 1 NUMBER
"Global motion search flag.")
# AV1 experiment flags.
set_aom_config_var(CONFIG_COLLECT_INTER_MODE_RD_STATS 1 NUMBER
"AV1 experiment flag.")
set_aom_config_var(CONFIG_COLLECT_RD_STATS 0 NUMBER "AV1 experiment flag.")
set_aom_config_var(CONFIG_DIST_8X8 0 NUMBER "AV1 experiment flag.")
set_aom_config_var(CONFIG_ENTROPY_STATS 0 NUMBER "AV1 experiment flag.")
set_aom_config_var(CONFIG_FP_MB_STATS 0 NUMBER "AV1 experiment flag.")
set_aom_config_var(CONFIG_INTER_STATS_ONLY 0 NUMBER "AV1 experiment flag.")
set_aom_config_var(CONFIG_RD_DEBUG 0 NUMBER "AV1 experiment flag.")
set_aom_config_var(CONFIG_2PASS_PARTITION_SEARCH_LVL 1 NUMBER
"AV1 experiment flag.")
set_aom_config_var(CONFIG_SHARP_SETTINGS 0 NUMBER
"Use sharper encoding settings")
#
# Variables in this section control optional features of the build system.
#
set_aom_option_var(ENABLE_CCACHE "Enable ccache support." OFF)
set_aom_option_var(ENABLE_DECODE_PERF_TESTS "Enables decoder performance tests"
OFF)
set_aom_option_var(ENABLE_DISTCC "Enable distcc support." OFF)
set_aom_option_var(ENABLE_DOCS
"Enable documentation generation (doxygen required)." ON)
set_aom_option_var(ENABLE_ENCODE_PERF_TESTS "Enables encoder performance tests"
OFF)
set_aom_option_var(ENABLE_EXAMPLES "Enables build of example code." ON)
set_aom_option_var(ENABLE_GOMA "Enable goma support." OFF)
set_aom_option_var(
ENABLE_IDE_TEST_HOSTING
"Enables running tests within IDEs like Visual Studio and Xcode." OFF)
set_aom_option_var(ENABLE_NASM "Use nasm instead of yasm for x86 assembly." OFF)
set_aom_option_var(ENABLE_TESTDATA "Enables unit test data download targets."
ON)
set_aom_option_var(ENABLE_TESTS "Enables unit tests." ON)
set_aom_option_var(ENABLE_TOOLS "Enable applications in tools sub directory."
ON)
set_aom_option_var(ENABLE_WERROR "Converts warnings to errors at compile time."
OFF)
# ARM assembly/intrinsics flags.
set_aom_option_var(ENABLE_NEON "Enables NEON optimizations on ARM targets." ON)
# MIPS assembly/intrinsics flags.
set_aom_option_var(ENABLE_DSPR2 "Enables DSPR2 optimizations on MIPS targets."
OFF)
set_aom_option_var(ENABLE_MSA "Enables MSA optimizations on MIPS targets." OFF)
# VSX intrinsics flags.
set_aom_option_var(ENABLE_VSX "Enables VSX optimizations on PowerPC targets."
ON)
# x86/x86_64 assembly/intrinsics flags.
set_aom_option_var(ENABLE_MMX
"Enables MMX optimizations on x86/x86_64 targets." ON)
set_aom_option_var(ENABLE_SSE
"Enables SSE optimizations on x86/x86_64 targets." ON)
set_aom_option_var(ENABLE_SSE2
"Enables SSE2 optimizations on x86/x86_64 targets." ON)
set_aom_option_var(ENABLE_SSE3
"Enables SSE3 optimizations on x86/x86_64 targets." ON)
set_aom_option_var(ENABLE_SSSE3
"Enables SSSE3 optimizations on x86/x86_64 targets." ON)
set_aom_option_var(ENABLE_SSE4_1
"Enables SSE4_1 optimizations on x86/x86_64 targets." ON)
set_aom_option_var(ENABLE_SSE4_2
"Enables SSE4_2 optimizations on x86/x86_64 targets." ON)
set_aom_option_var(ENABLE_AVX
"Enables AVX optimizations on x86/x86_64 targets." ON)
set_aom_option_var(ENABLE_AVX2
"Enables AVX2 optimizations on x86/x86_64 targets." ON)

View file

@ -0,0 +1,377 @@
#
# 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.
#
if(AOM_BUILD_CMAKE_AOM_CONFIGURE_CMAKE_)
return()
endif() # AOM_BUILD_CMAKE_AOM_CONFIGURE_CMAKE_
set(AOM_BUILD_CMAKE_AOM_CONFIGURE_CMAKE_ 1)
include(FindGit)
include(FindPerl)
include(FindThreads)
set(AOM_SUPPORTED_CPU_TARGETS
"arm64 armv7 armv7s generic mips32 mips64 ppc x86 x86_64")
include("${AOM_ROOT}/build/cmake/aom_config_defaults.cmake")
include("${AOM_ROOT}/build/cmake/aom_experiment_deps.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")
include("${AOM_ROOT}/build/cmake/util.cmake")
# Generate the user config settings.
list(APPEND aom_build_vars ${AOM_CONFIG_VARS} ${AOM_OPTION_VARS})
foreach(cache_var ${aom_build_vars})
get_property(cache_var_helpstring CACHE ${cache_var} PROPERTY HELPSTRING)
if("${cache_var_helpstring}" STREQUAL "${cmake_cmdline_helpstring}")
set(AOM_CMAKE_CONFIG "${AOM_CMAKE_CONFIG} -D${cache_var}=${${cache_var}}")
endif()
endforeach()
string(STRIP "${AOM_CMAKE_CONFIG}" AOM_CMAKE_CONFIG)
# 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}")
elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64")
set(AOM_TARGET_CPU "arm64")
elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "^ppc")
set(AOM_TARGET_CPU "ppc")
else()
message(WARNING "The architecture ${CMAKE_SYSTEM_PROCESSOR} is not "
"supported, falling back to the generic target")
set(AOM_TARGET_CPU "generic")
endif()
endif()
if(CMAKE_TOOLCHAIN_FILE) # Add toolchain file to config string.
file(RELATIVE_PATH toolchain_path "${AOM_CONFIG_DIR}"
"${CMAKE_TOOLCHAIN_FILE}")
set(toolchain_string "-DCMAKE_TOOLCHAIN_FILE=\\\"${toolchain_path}\\\"")
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}")
file(RELATIVE_PATH source_path "${AOM_CONFIG_DIR}" "${AOM_ROOT}")
set(AOM_CMAKE_CONFIG "cmake ${source_path} ${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("${CMAKE_BUILD_TYPE}" MATCHES "Deb")
set(CONFIG_DEBUG 1)
endif()
if(BUILD_SHARED_LIBS)
set(CONFIG_PIC 1)
set(CONFIG_SHARED 1)
set(CONFIG_STATIC 0)
endif()
if(NOT MSVC)
if(CONFIG_PIC)
# TODO(tomfinegan): clang needs -pie in CMAKE_EXE_LINKER_FLAGS for this to
# work.
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if("${AOM_TARGET_SYSTEM}" STREQUAL "Linux" AND "${AOM_TARGET_CPU}" MATCHES
"^armv7")
set(AOM_AS_FLAGS ${AOM_AS_FLAGS} --defsym PIC=1)
else()
set(AOM_AS_FLAGS ${AOM_AS_FLAGS} -DPIC)
endif()
endif()
endif()
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")
find_program(AS_EXECUTABLE yasm $ENV{YASM_PATH})
if(NOT AS_EXECUTABLE OR ENABLE_NASM)
unset(AS_EXECUTABLE CACHE)
find_program(AS_EXECUTABLE nasm $ENV{NASM_PATH})
if(AS_EXECUTABLE)
test_nasm()
endif()
endif()
if(NOT AS_EXECUTABLE)
message(FATAL_ERROR
"Unable to find assembler. Install 'yasm' or 'nasm.' "
"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")
if(NOT AS_EXECUTABLE)
set(AS_EXECUTABLE as)
endif()
elseif("${AOM_TARGET_SYSTEM}" STREQUAL "Windows")
if(NOT AS_EXECUTABLE)
set(AS_EXECUTABLE ${CMAKE_C_COMPILER} -c -mimplicit-it=always)
endif()
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()
if(CONFIG_ANALYZER)
include(FindwxWidgets)
find_package(wxWidgets REQUIRED adv base core)
include(${wxWidgets_USE_FILE})
endif()
if(NOT MSVC AND CMAKE_C_COMPILER_ID MATCHES "GNU\|Clang")
set(CONFIG_GCC 1)
endif()
if(CONFIG_GCOV)
message("--- Testing for CONFIG_GCOV support.")
require_linker_flag("-fprofile-arcs -ftest-coverage")
require_compiler_flag("-fprofile-arcs -ftest-coverage" YES)
endif()
if(CONFIG_GPROF)
message("--- Testing for CONFIG_GPROF support.")
require_compiler_flag("-pg" YES)
endif()
if("${AOM_TARGET_SYSTEM}" MATCHES "Darwin\|Linux\|Windows")
set(CONFIG_OS_SUPPORT 1)
endif()
#
# Fix CONFIG_* dependencies. This must be done before including cpu.cmake to
# ensure RTCD_CONFIG_* are properly set.
fix_experiment_configs()
# Test compiler support.
aom_get_inline("INLINE")
# Don't just check for pthread.h, but use the result of the full pthreads
# including a linking check in FindThreads above.
set(HAVE_PTHREAD_H ${CMAKE_USE_PTHREADS_INIT})
aom_check_source_compiles("unistd_check" "#include <unistd.h>" HAVE_UNISTD_H)
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)unused;
(void)feenableexcept(FE_DIVBYZERO | FE_INVALID);
}"
HAVE_FEXCEPT)
aom_pop_var(CMAKE_REQUIRED_LIBRARIES)
endif()
include("${AOM_ROOT}/build/cmake/cpu.cmake")
if(ENABLE_CCACHE)
set_compiler_launcher(ENABLE_CCACHE ccache)
endif()
if(ENABLE_DISTCC)
set_compiler_launcher(ENABLE_DISTCC distcc)
endif()
if(ENABLE_GOMA)
set_compiler_launcher(ENABLE_GOMA gomacc)
endif()
if(NOT CONFIG_AV1_DECODER AND NOT CONFIG_AV1_ENCODER)
message(FATAL_ERROR "Decoder and encoder disabled, nothing to build.")
endif()
if(DECODE_HEIGHT_LIMIT OR DECODE_WIDTH_LIMIT)
change_config_and_warn(CONFIG_SIZE_LIMIT 1
"DECODE_HEIGHT_LIMIT and DECODE_WIDTH_LIMIT")
endif()
if(CONFIG_SIZE_LIMIT)
if(NOT DECODE_HEIGHT_LIMIT OR NOT DECODE_WIDTH_LIMIT)
message(FATAL_ERROR "When setting CONFIG_SIZE_LIMIT, DECODE_HEIGHT_LIMIT "
"and DECODE_WIDTH_LIMIT must be set.")
endif()
endif()
# 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("-Wlogical-op")
add_compiler_flag_if_supported("-Wpointer-arith")
add_compiler_flag_if_supported("-Wsign-compare")
add_compiler_flag_if_supported("-Wstring-conversion")
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")
add_c_flag_if_supported("-Wstack-usage=100000")
add_cxx_flag_if_supported("-Wstack-usage=360000")
# 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")
# Quiet gcc 6 vs 7 abi warnings:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77728
if("${AOM_TARGET_CPU}" MATCHES "arm")
add_cxx_flag_if_supported("-Wno-psabi")
endif()
if(ENABLE_WERROR)
add_compiler_flag_if_supported("-Werror")
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()
set(AOM_LIB_LINK_TYPE PUBLIC)
if(EMSCRIPTEN)
# Avoid CMake generation time errors resulting from collisions with the form
# of target_link_libraries() used by Emscripten.cmake.
unset(AOM_LIB_LINK_TYPE)
endif()
# Generate aom_config templates.
set(aom_config_asm_template "${AOM_CONFIG_DIR}/config/aom_config.asm.cmake")
set(aom_config_h_template "${AOM_CONFIG_DIR}/config/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}/config/aom_config.asm")
configure_file("${aom_config_h_template}"
"${AOM_CONFIG_DIR}/config/aom_config.h")
# Read the current git hash.
find_package(Git)
if(NOT GIT_FOUND)
message("--- Git missing, version will be read from CHANGELOG.")
endif()
configure_file("${AOM_ROOT}/build/cmake/aom_config.c.template"
"${AOM_CONFIG_DIR}/config/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()
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}/config/aom_dsp_rtcd.h"
"${AOM_CONFIG_DIR}/config/aom_scale_rtcd.h"
"${AOM_CONFIG_DIR}/config/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/cmake/rtcd.pl"
--arch=${AOM_TARGET_CPU}
--sym=${AOM_RTCD_SYMBOL} ${AOM_RTCD_FLAGS}
--config=${AOM_CONFIG_DIR}/config/aom_config.h
${AOM_RTCD_CONFIG_FILE}
OUTPUT_FILE ${AOM_RTCD_HEADER_FILE})
endforeach()
# Generate aom_version.h.
execute_process(COMMAND ${CMAKE_COMMAND} -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
-DAOM_ROOT=${AOM_ROOT}
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
-DPERL_EXECUTABLE=${PERL_EXECUTABLE} -P
"${AOM_ROOT}/build/cmake/version.cmake")
if(NOT MSVC) # Generate aom.pc (pkg-config file).
execute_process(COMMAND ${CMAKE_COMMAND} -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
-DAOM_ROOT=${AOM_ROOT}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DCMAKE_PROJECT_NAME=${CMAKE_PROJECT_NAME}
-DCONFIG_MULTITHREAD=${CONFIG_MULTITHREAD}
-DHAVE_PTHREAD_H=${HAVE_PTHREAD_H} -P
"${AOM_ROOT}/build/cmake/pkg_config.cmake")
endif()

View file

@ -0,0 +1,32 @@
#
# 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_BUILD_CMAKE_AOM_EXPERIMENT_DEPS_CMAKE_)
return()
endif() # AOM_BUILD_CMAKE_AOM_EXPERIMENT_DEPS_CMAKE_
set(AOM_BUILD_CMAKE_AOM_EXPERIMENT_DEPS_CMAKE_ 1)
# Adjusts CONFIG_* CMake variables to address conflicts between active AV1
# experiments.
macro(fix_experiment_configs)
if(CONFIG_ANALYZER)
change_config_and_warn(CONFIG_INSPECTION 1 CONFIG_ANALYZER)
endif()
if(CONFIG_RD_DEBUG)
change_config_and_warn(CONFIG_RD_DEBUG 0 CONFIG_JNT_COMP)
endif()
if(CONFIG_DIST_8X8 AND CONFIG_MULTITHREAD)
change_config_and_warn(CONFIG_DIST_8X8 0 CONFIG_MULTITHREAD)
endif()
endmacro()

View file

@ -0,0 +1,212 @@
#
# 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_BUILD_CMAKE_AOM_OPTIMIZATION_CMAKE_)
return()
endif() # AOM_BUILD_CMAKE_AOM_OPTIMIZATION_CMAKE_
set(AOM_BUILD_CMAKE_AOM_OPTIMIZATION_CMAKE_ 1)
include("${AOM_ROOT}/build/cmake/util.cmake")
# 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
dependent_target)
if("${${sources}}" STREQUAL "")
return()
endif()
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)
separate_arguments(flag)
target_compile_options(${target_name} PUBLIC ${flag})
endif()
target_sources(${dependent_target} PRIVATE $<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} PRIVATE ${${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 "MSYS" OR "${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 "MSYS" OR "${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)
if("${${asm_sources}}" STREQUAL "")
return()
endif()
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(aom 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).
add_dummy_source_file_to_target("${lib_name}" "c")
# 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()
# Terminates generation if nasm found in PATH does not meet requirements.
# Currently checks only for presence of required object formats and support for
# the -Ox argument (multipass optimization).
function(test_nasm)
execute_process(COMMAND ${AS_EXECUTABLE} -hf OUTPUT_VARIABLE nasm_helptext)
if(NOT "${nasm_helptext}" MATCHES "-Ox")
message(FATAL_ERROR
"Unsupported nasm: multipass optimization not supported.")
endif()
if("${AOM_TARGET_CPU}" STREQUAL "x86")
if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
if(NOT "${nasm_helptext}" MATCHES "macho32")
message(FATAL_ERROR
"Unsupported nasm: macho32 object format not supported.")
endif()
elseif("${AOM_TARGET_SYSTEM}" STREQUAL "Linux")
if(NOT "${nasm_helptext}" MATCHES "elf32")
message(FATAL_ERROR
"Unsupported nasm: elf32 object format not supported.")
endif()
endif()
else()
if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
if(NOT "${nasm_helptext}" MATCHES "macho64")
message(FATAL_ERROR
"Unsupported nasm: macho64 object format not supported.")
endif()
elseif("${AOM_TARGET_SYSTEM}" STREQUAL "Linux")
if(NOT "${nasm_helptext}" MATCHES "elf64")
message(FATAL_ERROR
"Unsupported nasm: elf64 object format not supported.")
endif()
endif()
endif()
endfunction()
# Adds build command for generation of rtcd C source files using
# build/cmake/rtcd.pl. $config is the input perl file, $output is the output C
# include file, $source is the C source file, and $symbol is used for the symbol
# argument passed to rtcd.pl.
function(add_rtcd_build_step config output source symbol)
add_custom_command(OUTPUT ${output}
COMMAND ${PERL_EXECUTABLE} ARGS
"${AOM_ROOT}/build/cmake/rtcd.pl"
--arch=${AOM_TARGET_CPU}
--sym=${symbol} ${AOM_RTCD_FLAGS}
--config=${AOM_CONFIG_DIR}/config/aom_config.h
${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()

View file

@ -0,0 +1,373 @@
#
# 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.
#
if(AOM_BUILD_CMAKE_COMPILER_FLAGS_CMAKE_)
return()
endif() # AOM_BUILD_CMAKE_COMPILER_FLAGS_CMAKE_
set(AOM_BUILD_CMAKE_COMPILER_FLAGS_CMAKE_ 1)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include("${AOM_ROOT}/build/cmake/compiler_tests.cmake")
# Strings used to cache flags.
set(AOM_C_FLAGS)
set(AOM_CXX_FLAGS)
set(AOM_EXE_LINKER_FLAGS)
set(AOM_FAILED_C_FLAGS)
set(AOM_FAILED_CXX_FLAGS)
# Sets variable named by $out_is_present to YES in the caller's scope when $flag
# is found in the string variable named by $flag_cache. Sets the var to NO
# otherwise.
function(is_flag_present flag_cache flag out_is_present)
string(FIND "${${flag_cache}}" "${flag}" flag_pos)
if(${flag_pos} EQUAL -1)
set(${out_is_present} NO PARENT_SCOPE)
else()
set(${out_is_present} YES PARENT_SCOPE)
endif()
endfunction()
# Appends $flag to $flags. Ignores scope via use of FORCE with set() call.
function(append_flag flags flag)
string(FIND "${${flags}}" "${flag}" found)
if(${found} EQUAL -1)
set(${flags} "${${flags}} ${flag}" CACHE STRING "" FORCE)
endif()
endfunction()
# Checks C compiler for support of $c_flag. Adds $c_flag to all
# $CMAKE_C_FLAGS_<CONFIG>s stored in AOM_C_CONFIGS when the compile test passes.
# Caches $c_flag in $AOM_C_FLAGS or $AOM_FAILED_C_FLAGS depending on test
# outcome.
function(add_c_flag_if_supported c_flag)
if(DEBUG_CMAKE_DISABLE_COMPILER_TESTS)
return()
endif()
is_flag_present(AOM_C_FLAGS "${c_flag}" flag_ok)
is_flag_present(AOM_FAILED_C_FLAGS "${c_flag}" flag_failed)
if(${flag_ok} OR ${flag_failed})
return()
endif()
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})
append_flag(AOM_C_FLAGS "${c_flag}")
foreach(config ${AOM_C_CONFIGS})
unset(C_FLAG_FOUND)
append_flag("${config}" "${c_flag}")
endforeach()
else()
append_flag(AOM_FAILED_C_FLAGS "${c_flag}")
endif()
endfunction()
# Checks C++ compiler for support of $cxx_flag. Adds $cxx_flag to all
# $CMAKE_CXX_FLAGS_<CONFIG>s stored in AOM_CXX_CONFIGS when the compile test
# passes. Caches $cxx_flag in $AOM_CXX_FLAGS or $AOM_FAILED_CXX_FLAGS depending
# on test outcome.
function(add_cxx_flag_if_supported cxx_flag)
if(DEBUG_CMAKE_DISABLE_COMPILER_TESTS)
return()
endif()
is_flag_present(AOM_CXX_FLAGS "${cxx_flag}" flag_ok)
is_flag_present(AOM_FAILED_CXX_FLAGS "${cxx_flag}" flag_failed)
if(${flag_ok} OR ${flag_failed})
return()
endif()
unset(CXX_FLAG_SUPPORTED CACHE)
message("Checking C++ compiler flag support for: " ${cxx_flag})
check_cxx_compiler_flag("${cxx_flag}" CXX_FLAG_SUPPORTED)
if(${CXX_FLAG_SUPPORTED})
append_flag(AOM_CXX_FLAGS "${cxx_flag}")
foreach(config ${AOM_CXX_CONFIGS})
unset(CXX_FLAG_FOUND)
append_flag("${config}" "${cxx_flag}")
endforeach()
else()
append_flag(AOM_FAILED_CXX_FLAGS "${cxx_flag}")
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)
if(DEBUG_CMAKE_DISABLE_COMPILER_TESTS)
return()
endif()
is_flag_present(AOM_C_FLAGS "${c_flag}" flag_ok)
if(${flag_ok})
return()
endif()
if(NOT "${AOM_EXE_LINKER_FLAGS}" STREQUAL "")
aom_push_var(CMAKE_EXE_LINKER_FLAGS "${AOM_EXE_LINKER_FLAGS}")
endif()
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(NOT "${AOM_EXE_LINKER_FLAGS}" STREQUAL "")
aom_pop_var(CMAKE_EXE_LINKER_FLAGS)
endif()
append_flag(AOM_C_FLAGS "${c_flag}")
if(update_c_flags)
foreach(config ${AOM_C_CONFIGS})
set(${config} "${${config}} ${c_flag}" CACHE STRING "" FORCE)
endforeach()
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)
if(DEBUG_CMAKE_DISABLE_COMPILER_TESTS)
return()
endif()
is_flag_present(AOM_CXX_FLAGS "${cxx_flag}" flag_ok)
if(${flag_ok})
return()
endif()
if(NOT "${AOM_EXE_LINKER_FLAGS}" STREQUAL "")
aom_push_var(CMAKE_EXE_LINKER_FLAGS "${AOM_EXE_LINKER_FLAGS}")
endif()
unset(HAVE_CXX_FLAG CACHE)
message("Checking C 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 C flag: ${cxx_flag}.")
endif()
if(NOT "${AOM_EXE_LINKER_FLAGS}" STREQUAL "")
aom_pop_var(CMAKE_EXE_LINKER_FLAGS)
endif()
append_flag(AOM_CXX_FLAGS "${cxx_flag}")
if(update_cxx_flags)
foreach(config ${AOM_CXX_CONFIGS})
set(${config} "${${config}} ${cxx_flag}" CACHE STRING "" FORCE)
endforeach()
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_compiler_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_compiler_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)
set(preproc_def "-D${preproc_def}")
is_flag_present(AOM_C_FLAGS "${preproc_def}" flag_cached)
if(${flag_cached})
return()
endif()
foreach(config ${AOM_C_CONFIGS})
set(${config} "${${config}} ${preproc_def}" CACHE STRING "" FORCE)
endforeach()
endfunction()
# Adds $preproc_def to CXX compiler command line (as -D$preproc_def) if not
# already present.
function(add_cxx_preproc_definition preproc_def)
set(preproc_def "-D${preproc_def}")
is_flag_present(AOM_CXX_FLAGS "${preproc_def}" flag_cached)
if(${flag_cached})
return()
endif()
foreach(config ${AOM_CXX_CONFIGS})
set(${config} "${${config}} ${preproc_def}" CACHE STRING "" FORCE)
endforeach()
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)
is_flag_present(AOM_AS_FLAGS "${flag}" flag_cached)
if(${flag_cached})
return()
endif()
append_flag(AOM_AS_FLAGS "${flag}")
endfunction()
# Adds $flag to the C compiler command line.
function(append_c_flag flag)
is_flag_present(AOM_C_FLAGS "${flag}" flag_cached)
if(${flag_cached})
return()
endif()
foreach(config ${AOM_C_CONFIGS})
append_flag(${config} "${flag}")
endforeach()
endfunction()
# Adds $flag to the CXX compiler command line.
function(append_cxx_flag flag)
is_flag_present(AOM_CXX_FLAGS "${flag}" flag_cached)
if(${flag_cached})
return()
endif()
foreach(config ${AOM_CXX_CONFIGS})
append_flag(${config} "${flag}")
endforeach()
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 when not present.
function(append_exe_linker_flag flag)
is_flag_present(AOM_EXE_LINKER_FLAGS "${flag}" flag_cached)
if(${flag_cached})
return()
endif()
append_flag(AOM_EXE_LINKER_FLAGS "${flag}")
foreach(config ${AOM_EXE_LINKER_CONFIGS})
append_flag(${config} "${flag}")
endforeach()
endfunction()
# Adds $flag to the link flags for $target.
function(append_link_flag_to_target target flag)
unset(target_link_flags)
get_target_property(target_link_flags ${target} LINK_FLAGS)
if(target_link_flags)
is_flag_present(target_link_flags "${flag}" flag_found)
if(${flag_found})
return()
endif()
set(target_link_flags "${target_link_flags} ${flag}")
else()
set(target_link_flags "${flag}")
endif()
set_target_properties(${target} PROPERTIES LINK_FLAGS ${target_link_flags})
endfunction()
# Adds $flag to executable linker flags, and makes sure C/CXX builds still work.
function(require_linker_flag flag)
if(DEBUG_CMAKE_DISABLE_COMPILER_TESTS)
return()
endif()
append_exe_linker_flag(${flag})
unset(c_passed)
aom_check_c_compiles("LINKER_FLAG_C_TEST(${flag})" "" c_passed)
unset(cxx_passed)
aom_check_cxx_compiles("LINKER_FLAG_CXX_TEST(${flag})" "" cxx_passed)
if(NOT c_passed OR NOT cxx_passed)
message(FATAL_ERROR "Linker flag test for ${flag} failed.")
endif()
endfunction()
# Appends flags in $AOM_EXTRA_<TYPE>_FLAGS variables to the flags used at build
# time.
function(set_user_flags)
# Linker flags are handled first because some C/CXX flags require that a
# linker flag is present at link time.
if(AOM_EXTRA_EXE_LINKER_FLAGS)
is_flag_present(AOM_EXE_LINKER_FLAGS "${AOM_EXTRA_EXE_LINKER_FLAGS}"
extra_present)
if(NOT ${extra_present})
require_linker_flag("${AOM_EXTRA_EXE_LINKER_FLAGS}")
endif()
endif()
if(AOM_EXTRA_AS_FLAGS)
# TODO(tomfinegan): assembler flag testing would be a good thing to have.
is_flag_present(AOM_AS_FLAGS "${AOM_EXTRA_AS_FLAGS}" extra_present)
if(NOT ${extra_present})
append_flag(AOM_AS_FLAGS "${AOM_EXTRA_AS_FLAGS}")
endif()
endif()
if(AOM_EXTRA_C_FLAGS)
is_flag_present(AOM_C_FLAGS "${AOM_EXTRA_C_FLAGS}" extra_present)
if(NOT ${extra_present})
require_c_flag("${AOM_EXTRA_C_FLAGS}" YES)
endif()
endif()
if(AOM_EXTRA_CXX_FLAGS)
is_flag_present(AOM_CXX_FLAGS "${AOM_EXTRA_CXX_FLAGS}" extra_present)
if(NOT ${extra_present})
require_cxx_flag("${AOM_EXTRA_CXX_FLAGS}" YES)
endif()
endif()
endfunction()

View file

@ -0,0 +1,175 @@
#
# 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.
#
if(AOM_BUILD_CMAKE_COMPILER_TESTS_CMAKE_)
return()
endif() # AOM_BUILD_CMAKE_COMPILER_TESTS_CMAKE_
set(AOM_BUILD_CMAKE_COMPILER_TESTS_CMAKE_ 1)
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
# CMake passes command line flags like this:
#
# * $compiler $lang_flags $lang_flags_config ...
#
# To ensure the flags tested here and elsewhere are obeyed a list of active
# build configuration types is built, and flags are applied to the flag strings
# for each configuration currently active for C and CXX builds as determined by
# reading $CMAKE_CONFIGURATION_TYPES and $CMAKE_BUILD_TYPE. When
# $CMAKE_CONFIGURATION_TYPES is non-empty a multi- configuration generator is in
# use: currently this includes MSVC and Xcode. For other generators
# $CMAKE_BUILD_TYPE is used. For both cases AOM_<LANG>_CONFIGS is populated with
# CMake string variable names that contain flags for the currently available
# configuration(s).
unset(AOM_C_CONFIGS)
unset(AOM_CXX_CONFIGS)
list(LENGTH CMAKE_CONFIGURATION_TYPES num_configs)
if(${num_configs} GREATER 0)
foreach(config ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${config} config)
list(APPEND AOM_C_CONFIGS "CMAKE_C_FLAGS_${config}")
list(APPEND AOM_CXX_CONFIGS "CMAKE_CXX_FLAGS_${config}")
list(APPEND AOM_EXE_LINKER_CONFIGS "CMAKE_EXE_LINKER_FLAGS_${config}")
endforeach()
else()
string(TOUPPER ${CMAKE_BUILD_TYPE} config)
set(AOM_C_CONFIGS "CMAKE_C_FLAGS_${config}")
set(AOM_CXX_CONFIGS "CMAKE_CXX_FLAGS_${config}")
set(AOM_EXE_LINKER_CONFIGS "CMAKE_EXE_LINKER_FLAGS_${config}")
endif()
# 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} "${${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)
if(DEBUG_CMAKE_DISABLE_COMPILER_TESTS)
return()
endif()
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)
if(DEBUG_CMAKE_DISABLE_COMPILER_TESTS)
return()
endif()
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()

View file

@ -0,0 +1,93 @@
#
# 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(RTCD_ARCH_ARM "yes")
if(ENABLE_NEON)
set(HAVE_NEON 1)
set(RTCD_HAVE_NEON "yes")
else()
set(HAVE_NEON 0)
set(AOM_RTCD_FLAGS ${AOM_RTCD_FLAGS} --disable-neon)
endif()
elseif("${AOM_TARGET_CPU}" MATCHES "^armv7")
set(ARCH_ARM 1)
set(RTCD_ARCH_ARM "yes")
if(ENABLE_NEON)
set(HAVE_NEON 1)
set(RTCD_HAVE_NEON "yes")
else()
set(HAVE_NEON 0)
set(AOM_RTCD_FLAGS ${AOM_RTCD_FLAGS} --disable-neon)
endif()
elseif("${AOM_TARGET_CPU}" MATCHES "^mips")
set(ARCH_MIPS 1)
set(RTCD_ARCH_MIPS "yes")
if("${AOM_TARGET_CPU}" STREQUAL "mips32")
set(HAVE_MIPS32 1)
set(RTCD_HAVE_MIPS32 "yes")
elseif("${AOM_TARGET_CPU}" STREQUAL "mips64")
set(HAVE_MIPS64 1)
set(RTCD_HAVE_MIPS64 "yes")
endif()
# HAVE_DSPR2 is set by mips toolchain files.
if(ENABLE_DSPR2 AND HAVE_DSPR2)
set(RTCD_HAVE_DSPR2 "yes")
else()
set(HAVE_DSPR2 0)
set(AOM_RTCD_FLAGS ${AOM_RTCD_FLAGS} --disable-dspr2)
endif()
# HAVE_MSA is set by mips toolchain files.
if(ENABLE_MSA AND HAVE_MSA)
set(RTCD_HAVE_MSA "yes")
else()
set(HAVE_MSA 0)
set(AOM_RTCD_FLAGS ${AOM_RTCD_FLAGS} --disable-msa)
endif()
elseif("${AOM_TARGET_CPU}" MATCHES "ppc")
set(ARCH_PPC 1)
set(RTCD_ARCH_PPC "yes")
if(ENABLE_VSX)
set(HAVE_VSX 1)
set(RTCD_HAVE_VSX "yes")
else()
set(HAVE_VSX 0)
set(AOM_RTCD_FLAGS ${AOM_RTCD_FLAGS} --disable-vsx)
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(X86_FLAVORS "MMX;SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;AVX;AVX2")
foreach(flavor ${X86_FLAVORS})
if(ENABLE_${flavor} AND NOT disable_remaining_flavors)
set(HAVE_${flavor} 1)
set(RTCD_HAVE_${flavor} "yes")
else()
set(disable_remaining_flavors 1)
set(HAVE_${flavor} 0)
string(TOLOWER ${flavor} flavor)
set(AOM_RTCD_FLAGS ${AOM_RTCD_FLAGS} --disable-${flavor})
endif()
endforeach()
endif()

View file

@ -0,0 +1,64 @@
#
# 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)
# Converts spaces in $in_string to semicolons and writes the output to
# $out_string. In CMake's eyes this converts the input string to a list.
function(listify_string in_string out_string)
string(REPLACE " " ";" ${out_string} ${in_string})
set(${out_string} "${${out_string}}" PARENT_SCOPE)
endfunction()
set(REQUIRED_ARGS "AOM_ROOT" "AOM_CONFIG_DIR" "AOM_DIST_DIR"
"AOM_DIST_INCLUDES" "AOM_DIST_LIBS" "ENABLE_DOCS")
foreach(arg ${REQUIRED_ARGS})
if("${${arg}}" STREQUAL "")
message(FATAL_ERROR "${arg} must not be empty.")
endif()
endforeach()
if(ENABLE_DOCS)
file(INSTALL "${AOM_CONFIG_DIR}/docs" DESTINATION "${AOM_DIST_DIR}")
endif()
if(AOM_DIST_EXAMPLES)
listify_string("${AOM_DIST_EXAMPLES}" "AOM_DIST_EXAMPLES")
foreach(example ${AOM_DIST_EXAMPLES})
if(NOT "${example}" MATCHES "aomdec\|aomenc")
file(INSTALL "${example}" DESTINATION "${AOM_DIST_DIR}/bin/examples")
endif()
endforeach()
endif()
if(AOM_DIST_TOOLS)
listify_string("${AOM_DIST_TOOLS}" "AOM_DIST_TOOLS")
foreach(tool ${AOM_DIST_TOOLS})
file(INSTALL "${tool}" DESTINATION "${AOM_DIST_DIR}/bin/tools")
endforeach()
endif()
if(AOM_DIST_APPS)
listify_string("${AOM_DIST_APPS}" "AOM_DIST_APPS")
foreach(app ${AOM_DIST_APPS})
file(INSTALL "${app}" DESTINATION "${AOM_DIST_DIR}/bin")
endforeach()
endif()
listify_string("${AOM_DIST_INCLUDES}" "AOM_DIST_INCLUDES")
foreach(inc ${AOM_DIST_INCLUDES})
file(INSTALL "${inc}" DESTINATION "${AOM_DIST_DIR}/include/aom")
endforeach()
listify_string("${AOM_DIST_LIBS}" "AOM_DIST_LIBS")
foreach(lib ${AOM_DIST_LIBS})
file(INSTALL "${lib}" DESTINATION "${AOM_DIST_DIR}/lib")
endforeach()

View file

@ -0,0 +1,65 @@
#
# 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_BUILD_CMAKE_EXPORTS_CMAKE_)
return()
endif() # AOM_BUILD_CMAKE_EXPORTS_CMAKE_
set(AOM_BUILD_CMAKE_EXPORTS_CMAKE_ 1)
include("${AOM_ROOT}/build/cmake/exports_sources.cmake")
# Creates the custom target which handles generation of the symbol export lists.
function(setup_exports_target)
if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
set(symbol_file_ext "syms")
elseif("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS" AND MSVC)
set(symbol_file_ext "def")
else()
set(symbol_file_ext "ver")
endif()
set(aom_sym_file "${AOM_CONFIG_DIR}/libaom.${symbol_file_ext}")
add_custom_target(generate_exports
COMMAND ${CMAKE_COMMAND} -DAOM_ROOT="${AOM_ROOT}"
-DAOM_CONFIG_DIR="${AOM_CONFIG_DIR}"
-DAOM_TARGET_SYSTEM=${AOM_TARGET_SYSTEM}
-DAOM_SYM_FILE="${aom_sym_file}" -DAOM_MSVC=${MSVC}
-DAOM_XCODE=${XCODE} -DCONFIG_NAME=$<CONFIG>
-DCONFIG_AV1_DECODER=${CONFIG_AV1_DECODER}
-DCONFIG_AV1_ENCODER=${CONFIG_AV1_ENCODER}
-DENABLE_TESTS=${ENABLE_TESTS} -P
"${AOM_ROOT}/build/cmake/generate_exports.cmake"
SOURCES ${AOM_EXPORTS_SOURCES}
DEPENDS ${AOM_EXPORTS_SOURCES})
# Make libaom depend on the exports file, and set flags to pick it up when
# creating the dylib.
add_dependencies(aom generate_exports)
if(APPLE)
set_property(TARGET aom APPEND_STRING
PROPERTY LINK_FLAGS "-exported_symbols_list ${aom_sym_file}")
elseif(WIN32)
if(NOT MSVC)
set_property(TARGET aom APPEND_STRING
PROPERTY LINK_FLAGS "-Wl,--version-script ${aom_sym_file}")
else()
set_property(TARGET aom APPEND_STRING
PROPERTY LINK_FLAGS "/DEF:${aom_sym_file}")
endif()
# TODO(tomfinegan): Sort out the import lib situation and flags for MSVC.
else()
set_property(TARGET aom APPEND_STRING
PROPERTY LINK_FLAGS "-Wl,--version-script,${aom_sym_file}")
endif()
endfunction()

View file

@ -0,0 +1,32 @@
#
# 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_BUILD_CMAKE_EXPORTS_SOURCES_CMAKE_)
return()
endif() # AOM_BUILD_CMAKE_EXPORTS_SOURCES_CMAKE_
set(AOM_BUILD_CMAKE_EXPORTS_SOURCES_CMAKE_ 1)
list(APPEND AOM_EXPORTS_SOURCES "${AOM_ROOT}/aom/exports_com"
"${AOM_ROOT}/av1/exports_com")
if(CONFIG_AV1_DECODER)
list(APPEND AOM_EXPORTS_SOURCES "${AOM_ROOT}/aom/exports_dec"
"${AOM_ROOT}/av1/exports_dec")
endif()
if(CONFIG_AV1_ENCODER)
list(APPEND AOM_EXPORTS_SOURCES "${AOM_ROOT}/aom/exports_enc"
"${AOM_ROOT}/av1/exports_enc")
endif()
if(ENABLE_TESTS)
list(APPEND AOM_EXPORTS_SOURCES "${AOM_ROOT}/aom/exports_test"
"${AOM_ROOT}/av1/exports_test")
endif()

View file

@ -0,0 +1,101 @@
#
# 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_
"
)
set(
cmake_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.
##
"
)
# 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")
list(APPEND aom_build_vars ${AOM_DETECT_VARS} ${AOM_CONFIG_VARS})
list(SORT aom_build_vars)
set(aom_config_h_template "${AOM_CONFIG_DIR}/config/aom_config.h.cmake")
file(WRITE "${aom_config_h_template}" ${h_file_header_block})
foreach(aom_var ${aom_build_vars})
if(NOT "${aom_var}" STREQUAL "AOM_RTCD_FLAGS")
file(APPEND "${aom_config_h_template}"
"\#define ${aom_var} \${${aom_var}}\n")
endif()
endforeach()
file(APPEND "${aom_config_h_template}" "\#endif // AOM_CONFIG_H_")
set(aom_asm_config_template "${AOM_CONFIG_DIR}/config/aom_config.asm.cmake")
file(WRITE "${aom_asm_config_template}" ${asm_file_header_block})
foreach(aom_var ${aom_build_vars})
if(NOT "${aom_var}" STREQUAL "INLINE" AND NOT "${aom_var}" STREQUAL
"AOM_RTCD_FLAGS")
file(APPEND "${aom_asm_config_template}" "${aom_var} equ \${${aom_var}}\n")
endif()
endforeach()

View file

@ -0,0 +1,66 @@
#
# 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)
set(REQUIRED_ARGS "AOM_ROOT" "AOM_CONFIG_DIR" "AOM_TARGET_SYSTEM"
"AOM_SYM_FILE" "CONFIG_AV1_DECODER" "CONFIG_AV1_ENCODER")
foreach(arg ${REQUIRED_ARGS})
if("${${arg}}" STREQUAL "")
message(FATAL_ERROR "${arg} must not be empty.")
endif()
endforeach()
include("${AOM_ROOT}/build/cmake/exports_sources.cmake")
if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
set(symbol_prefix "_")
elseif("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS" AND AOM_MSVC)
file(WRITE "${AOM_SYM_FILE}" "LIBRARY aom\n" "EXPORTS\n")
else()
set(symbol_suffix ";")
endif()
set(aom_sym_file "${AOM_SYM_FILE}")
if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
file(REMOVE "${aom_sym_file}")
elseif("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS" AND AOM_MSVC)
file(WRITE "${aom_sym_file}" "LIBRARY aom\n" "EXPORTS\n")
else()
file(WRITE "${aom_sym_file}" "{\nglobal:\n")
endif()
foreach(export_file ${AOM_EXPORTS_SOURCES})
file(STRINGS "${export_file}" exported_file_data)
set(exported_symbols "${exported_symbols} ${exported_file_data};")
string(STRIP "${exported_symbols}" exported_symbols)
endforeach()
foreach(exported_symbol ${exported_symbols})
string(STRIP "${exported_symbol}" exported_symbol)
if("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS" AND AOM_MSVC)
string(SUBSTRING ${exported_symbol} 0 4 export_type)
string(COMPARE EQUAL "${export_type}" "data" is_data)
if(is_data)
set(symbol_suffix " DATA")
else()
set(symbol_suffix "")
endif()
endif()
string(REGEX REPLACE "text \|data " "" "exported_symbol" "${exported_symbol}")
set(exported_symbol " ${symbol_prefix}${exported_symbol}${symbol_suffix}")
file(APPEND "${aom_sym_file}" "${exported_symbol}\n")
endforeach()
if("${aom_sym_file}" MATCHES "ver$")
file(APPEND "${aom_sym_file}" " \nlocal:\n *;\n};")
endif()

View file

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>AOM</string>
<key>CFBundleIdentifier</key>
<string>org.webmproject.AOM</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>AOM</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>${VERSION}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>iPhoneOS</string>
</array>
<key>CFBundleVersion</key>
<string>${VERSION}</string>
<key>MinimumOSVersion</key>
<string>${IOS_VERSION_MIN}</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>AOMFullVersion</key>
<string>${FULLVERSION}</string>
</dict>
</plist>

View file

@ -0,0 +1,384 @@
#!/bin/sh
## 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.
##
## This script generates 'AOM.framework'. An iOS app can encode and decode AVx
## video by including 'AOM.framework'.
##
## Run iosbuild.sh to create 'AOM.framework' in the current directory.
##
set -e
devnull='> /dev/null 2>&1'
BUILD_ROOT="_iosbuild"
CONFIGURE_ARGS="--disable-docs
--disable-examples
--disable-libyuv
--disable-unit-tests"
DIST_DIR="_dist"
FRAMEWORK_DIR="AOM.framework"
FRAMEWORK_LIB="AOM.framework/AOM"
HEADER_DIR="${FRAMEWORK_DIR}/Headers/aom"
SCRIPT_DIR=$(dirname "$0")
LIBAOM_SOURCE_DIR=$(cd ${SCRIPT_DIR}/../..; pwd)
LIPO=$(xcrun -sdk iphoneos${SDK} -find lipo)
ORIG_PWD="$(pwd)"
ARM_TARGETS="arm64-darwin-gcc
armv7-darwin-gcc
armv7s-darwin-gcc"
SIM_TARGETS="x86-iphonesimulator-gcc
x86_64-iphonesimulator-gcc"
OSX_TARGETS="x86-darwin16-gcc
x86_64-darwin16-gcc"
TARGETS="${ARM_TARGETS} ${SIM_TARGETS}"
# Configures for the target specified by $1, and invokes make with the dist
# target using $ as the distribution output directory.
build_target() {
local target="$1"
local old_pwd="$(pwd)"
local target_specific_flags=""
vlog "***Building target: ${target}***"
case "${target}" in
x86-*)
target_specific_flags="--enable-pic"
vlog "Enabled PIC for ${target}"
;;
esac
mkdir "${target}"
cd "${target}"
# TODO(tomfinegan@google.com): switch to cmake.
eval "${LIBAOM_SOURCE_DIR}/configure" --target="${target}" \
${CONFIGURE_ARGS} ${EXTRA_CONFIGURE_ARGS} ${target_specific_flags} \
${devnull}
export DIST_DIR
eval make dist ${devnull}
cd "${old_pwd}"
vlog "***Done building target: ${target}***"
}
# Returns the preprocessor symbol for the target specified by $1.
target_to_preproc_symbol() {
target="$1"
case "${target}" in
arm64-*)
echo "__aarch64__"
;;
armv7-*)
echo "__ARM_ARCH_7A__"
;;
armv7s-*)
echo "__ARM_ARCH_7S__"
;;
x86-*)
echo "__i386__"
;;
x86_64-*)
echo "__x86_64__"
;;
*)
echo "#error ${target} unknown/unsupported"
return 1
;;
esac
}
# Create a aom_config.h shim that, based on preprocessor settings for the
# current target CPU, includes the real aom_config.h for the current target.
# $1 is the list of targets.
create_aom_framework_config_shim() {
local targets="$1"
local config_file="${HEADER_DIR}/aom_config.h"
local preproc_symbol=""
local target=""
local include_guard="AOM_FRAMEWORK_HEADERS_AOM_AOM_CONFIG_H_"
local file_header="/*
* Copyright (c) $(date +%Y), 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.
*/
/* GENERATED FILE: DO NOT EDIT! */
#ifndef ${include_guard}
#define ${include_guard}
#if defined"
printf "%s" "${file_header}" > "${config_file}"
for target in ${targets}; do
preproc_symbol=$(target_to_preproc_symbol "${target}")
printf " ${preproc_symbol}\n" >> "${config_file}"
printf "#define AOM_FRAMEWORK_TARGET \"${target}\"\n" >> "${config_file}"
printf "#include \"AOM/aom/${target}/aom_config.h\"\n" >> "${config_file}"
printf "#elif defined" >> "${config_file}"
mkdir "${HEADER_DIR}/${target}"
cp -p "${BUILD_ROOT}/${target}/aom_config.h" "${HEADER_DIR}/${target}"
done
# Consume the last line of output from the loop: We don't want it.
sed -i '' -e '$d' "${config_file}"
printf "#endif\n\n" >> "${config_file}"
printf "#endif // ${include_guard}" >> "${config_file}"
}
# Verifies that $FRAMEWORK_LIB fat library contains requested builds.
verify_framework_targets() {
local requested_cpus=""
local cpu=""
# Extract CPU from full target name.
for target; do
cpu="${target%%-*}"
if [ "${cpu}" = "x86" ]; then
# lipo -info outputs i386 for libaom x86 targets.
cpu="i386"
fi
requested_cpus="${requested_cpus}${cpu} "
done
# Get target CPUs present in framework library.
local targets_built=$(${LIPO} -info ${FRAMEWORK_LIB})
# $LIPO -info outputs a string like the following:
# Architectures in the fat file: $FRAMEWORK_LIB <architectures>
# Capture only the architecture strings.
targets_built=${targets_built##*: }
# Sort CPU strings to make the next step a simple string compare.
local actual=$(echo ${targets_built} | tr " " "\n" | sort | tr "\n" " ")
local requested=$(echo ${requested_cpus} | tr " " "\n" | sort | tr "\n" " ")
vlog "Requested ${FRAMEWORK_LIB} CPUs: ${requested}"
vlog "Actual ${FRAMEWORK_LIB} CPUs: ${actual}"
if [ "${requested}" != "${actual}" ]; then
elog "Actual ${FRAMEWORK_LIB} targets do not match requested target list."
elog " Requested target CPUs: ${requested}"
elog " Actual target CPUs: ${actual}"
return 1
fi
}
# Configures and builds each target specified by $1, and then builds
# AOM.framework.
build_framework() {
local lib_list=""
local targets="$1"
local target=""
local target_dist_dir=""
# Clean up from previous build(s).
rm -rf "${BUILD_ROOT}" "${FRAMEWORK_DIR}"
# Create output dirs.
mkdir -p "${BUILD_ROOT}"
mkdir -p "${HEADER_DIR}"
cd "${BUILD_ROOT}"
for target in ${targets}; do
build_target "${target}"
target_dist_dir="${BUILD_ROOT}/${target}/${DIST_DIR}"
if [ "${ENABLE_SHARED}" = "yes" ]; then
local suffix="dylib"
else
local suffix="a"
fi
lib_list="${lib_list} ${target_dist_dir}/lib/libaom.${suffix}"
done
cd "${ORIG_PWD}"
# The basic libaom API includes are all the same; just grab the most recent
# set.
cp -p "${target_dist_dir}"/include/aom/* "${HEADER_DIR}"
# Build the fat library.
${LIPO} -create ${lib_list} -output ${FRAMEWORK_DIR}/AOM
# Create the aom_config.h shim that allows usage of aom_config.h from
# within AOM.framework.
create_aom_framework_config_shim "${targets}"
# Copy in aom_version.h.
cp -p "${BUILD_ROOT}/${target}/aom_version.h" "${HEADER_DIR}"
if [ "${ENABLE_SHARED}" = "yes" ]; then
# Adjust the dylib's name so dynamic linking in apps works as expected.
install_name_tool -id '@rpath/AOM.framework/AOM' ${FRAMEWORK_DIR}/AOM
# Copy in Info.plist.
cat "${SCRIPT_DIR}/ios-Info.plist" \
| sed "s/\${FULLVERSION}/${FULLVERSION}/g" \
| sed "s/\${VERSION}/${VERSION}/g" \
| sed "s/\${IOS_VERSION_MIN}/${IOS_VERSION_MIN}/g" \
> "${FRAMEWORK_DIR}/Info.plist"
fi
# Confirm AOM.framework/AOM contains the targets requested.
verify_framework_targets ${targets}
vlog "Created fat library ${FRAMEWORK_LIB} containing:"
for lib in ${lib_list}; do
vlog " $(echo ${lib} | awk -F / '{print $2, $NF}')"
done
}
# Trap function. Cleans up the subtree used to build all targets contained in
# $TARGETS.
cleanup() {
local res=$?
cd "${ORIG_PWD}"
if [ $res -ne 0 ]; then
elog "build exited with error ($res)"
fi
if [ "${PRESERVE_BUILD_OUTPUT}" != "yes" ]; then
rm -rf "${BUILD_ROOT}"
fi
}
print_list() {
local indent="$1"
shift
local list="$@"
for entry in ${list}; do
echo "${indent}${entry}"
done
}
iosbuild_usage() {
cat << EOF
Usage: ${0##*/} [arguments]
--help: Display this message and exit.
--enable-shared: Build a dynamic framework for use on iOS 8 or later.
--extra-configure-args <args>: Extra args to pass when configuring libaom.
--macosx: Uses darwin16 targets instead of iphonesimulator targets for x86
and x86_64. Allows linking to framework when builds target MacOSX
instead of iOS.
--preserve-build-output: Do not delete the build directory.
--show-build-output: Show output from each library build.
--targets <targets>: Override default target list. Defaults:
$(print_list " " ${TARGETS})
--test-link: Confirms all targets can be linked. Functionally identical to
passing --enable-examples via --extra-configure-args.
--verbose: Output information about the environment and each stage of the
build.
EOF
}
elog() {
echo "${0##*/} failed because: $@" 1>&2
}
vlog() {
if [ "${VERBOSE}" = "yes" ]; then
echo "$@"
fi
}
trap cleanup EXIT
# Parse the command line.
while [ -n "$1" ]; do
case "$1" in
--extra-configure-args)
EXTRA_CONFIGURE_ARGS="$2"
shift
;;
--help)
iosbuild_usage
exit
;;
--enable-shared)
ENABLE_SHARED=yes
;;
--preserve-build-output)
PRESERVE_BUILD_OUTPUT=yes
;;
--show-build-output)
devnull=
;;
--test-link)
EXTRA_CONFIGURE_ARGS="${EXTRA_CONFIGURE_ARGS} --enable-examples"
;;
--targets)
TARGETS="$2"
shift
;;
--macosx)
TARGETS="${ARM_TARGETS} ${OSX_TARGETS}"
;;
--verbose)
VERBOSE=yes
;;
*)
iosbuild_usage
exit 1
;;
esac
shift
done
if [ "${ENABLE_SHARED}" = "yes" ]; then
CONFIGURE_ARGS="--enable-shared ${CONFIGURE_ARGS}"
fi
FULLVERSION=$("${SCRIPT_DIR}"/version.sh --bare "${LIBAOM_SOURCE_DIR}")
VERSION=$(echo "${FULLVERSION}" | sed -E 's/^v([0-9]+\.[0-9]+\.[0-9]+).*$/\1/')
if [ "$ENABLE_SHARED" = "yes" ]; then
IOS_VERSION_OPTIONS="--enable-shared"
IOS_VERSION_MIN="8.0"
else
IOS_VERSION_OPTIONS=""
IOS_VERSION_MIN="6.0"
fi
if [ "${VERBOSE}" = "yes" ]; then
cat << EOF
BUILD_ROOT=${BUILD_ROOT}
DIST_DIR=${DIST_DIR}
CONFIGURE_ARGS=${CONFIGURE_ARGS}
EXTRA_CONFIGURE_ARGS=${EXTRA_CONFIGURE_ARGS}
FRAMEWORK_DIR=${FRAMEWORK_DIR}
FRAMEWORK_LIB=${FRAMEWORK_LIB}
HEADER_DIR=${HEADER_DIR}
LIBAOM_SOURCE_DIR=${LIBAOM_SOURCE_DIR}
LIPO=${LIPO}
MAKEFLAGS=${MAKEFLAGS}
ORIG_PWD=${ORIG_PWD}
PRESERVE_BUILD_OUTPUT=${PRESERVE_BUILD_OUTPUT}
TARGETS="$(print_list "" ${TARGETS})"
ENABLE_SHARED=${ENABLE_SHARED}
OSX_TARGETS="${OSX_TARGETS}"
SIM_TARGETS="${SIM_TARGETS}"
SCRIPT_DIR="${SCRIPT_DIR}"
FULLVERSION="${FULLVERSION}"
VERSION="${VERSION}"
IOS_VERSION_MIN="${IOS_VERSION_MIN}"
EOF
fi
build_framework "${TARGETS}"
echo "Successfully built '${FRAMEWORK_DIR}' for:"
print_list "" ${TARGETS}

View file

@ -0,0 +1,37 @@
#
# 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_BUILD_CMAKE_MSVC_RUNTIME_CMAKE_)
return()
endif() # AOM_BUILD_CMAKE_MSVC_RUNTIME_CMAKE_
set(AOM_BUILD_CMAKE_MSVC_RUNTIME_CMAKE_ 1)
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()

View file

@ -0,0 +1,58 @@
#
# 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)
set(REQUIRED_ARGS "AOM_ROOT" "AOM_CONFIG_DIR" "CMAKE_INSTALL_PREFIX"
"CMAKE_PROJECT_NAME" "CONFIG_MULTITHREAD" "HAVE_PTHREAD_H")
foreach(arg ${REQUIRED_ARGS})
if("${${arg}}" STREQUAL "")
message(FATAL_ERROR "${arg} must not be empty.")
endif()
endforeach()
include("${AOM_ROOT}/build/cmake/util.cmake")
extract_version_string("${AOM_CONFIG_DIR}/config/aom_version.h" aom_version)
# Create a version string suitable for comparison using the RPM version compare
# algorithm: strip out everything after the number.
string(FIND "${aom_version}" "-" dash_pos)
if(${dash_pos} EQUAL -1)
set(package_version "${aom_version}")
else()
string(SUBSTRING "${aom_version}" 0 ${dash_pos} package_version)
endif()
# Write pkg-config info.
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(pkgconfig_file "${AOM_CONFIG_DIR}/aom.pc")
string(TOLOWER ${CMAKE_PROJECT_NAME} pkg_name)
file(WRITE "${pkgconfig_file}" "# libaom pkg-config.\n")
file(APPEND "${pkgconfig_file}" "prefix=${prefix}\n")
file(APPEND "${pkgconfig_file}" "exec_prefix=\${prefix}/bin\n")
file(APPEND "${pkgconfig_file}" "libdir=\${prefix}/lib\n")
file(APPEND "${pkgconfig_file}" "includedir=\${prefix}/include\n\n")
file(APPEND "${pkgconfig_file}" "Name: ${pkg_name}\n")
file(APPEND "${pkgconfig_file}"
"Description: AV1 codec library v${aom_version}.\n")
file(APPEND "${pkgconfig_file}" "Version: ${package_version}\n")
file(APPEND "${pkgconfig_file}" "Requires:\n")
file(APPEND "${pkgconfig_file}" "Conflicts:\n")
if(CONFIG_MULTITHREAD AND HAVE_PTHREAD_H)
file(APPEND "${pkgconfig_file}"
"Libs: -L\${prefix}/lib -l${pkg_name} -lm -lpthread\n")
file(APPEND "${pkgconfig_file}" "Libs.private: -lm -lpthread\n")
else()
file(APPEND "${pkgconfig_file}" "Libs: -L\${prefix}/lib -l${pkg_name} -lm\n")
file(APPEND "${pkgconfig_file}" "Libs.private: -lm\n")
endif()
file(APPEND "${pkgconfig_file}" "Cflags: -I\${prefix}/include\n")

View file

@ -0,0 +1,467 @@
#!/usr/bin/env perl
##
## 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.
##
no strict 'refs';
use warnings;
use Getopt::Long;
Getopt::Long::Configure("auto_help") if $Getopt::Long::VERSION > 2.32;
my %ALL_FUNCS = ();
my @ALL_ARCHS;
my @ALL_FORWARD_DECLS;
my @REQUIRES;
my %opts = ();
my %disabled = ();
my %required = ();
my @argv;
foreach (@ARGV) {
$disabled{$1} = 1, next if /--disable-(.*)/;
$required{$1} = 1, next if /--require-(.*)/;
push @argv, $_;
}
# NB: use GetOptions() instead of GetOptionsFromArray() for compatibility.
@ARGV = @argv;
GetOptions(
\%opts,
'arch=s',
'sym=s',
'config=s',
);
foreach my $opt (qw/arch config/) {
if (!defined($opts{$opt})) {
warn "--$opt is required!\n";
Getopt::Long::HelpMessage('-exit' => 1);
}
}
foreach my $defs_file (@ARGV) {
if (!-f $defs_file) {
warn "$defs_file: $!\n";
Getopt::Long::HelpMessage('-exit' => 1);
}
}
open CONFIG_FILE, $opts{config} or
die "Error opening config file '$opts{config}': $!\n";
my %config = ();
while (<CONFIG_FILE>) {
next if !/^#define\s+(?:CONFIG_|HAVE_)/;
chomp;
my @line_components = split /\s/;
scalar @line_components > 2 or
die "Invalid input passed to rtcd.pl via $opts{config}.";
# $line_components[0] = #define
# $line_components[1] = flag name (CONFIG_SOMETHING or HAVE_SOMETHING)
# $line_components[2] = flag value (0 or 1)
$config{$line_components[1]} = "$line_components[2]" eq "1" ? "yes" : "";
}
close CONFIG_FILE;
#
# Routines for the RTCD DSL to call
#
sub aom_config($) {
return (defined $config{$_[0]}) ? $config{$_[0]} : "";
}
sub specialize {
if (@_ <= 1) {
die "'specialize' must be called with a function name and at least one ",
"architecture ('C' is implied): \n@_\n";
}
my $fn=$_[0];
shift;
foreach my $opt (@_) {
eval "\$${fn}_${opt}=${fn}_${opt}";
}
}
sub add_proto {
my $fn = splice(@_, -2, 1);
$ALL_FUNCS{$fn} = \@_;
specialize $fn, "c";
}
sub require {
foreach my $fn (keys %ALL_FUNCS) {
foreach my $opt (@_) {
my $ofn = eval "\$${fn}_${opt}";
next if !$ofn;
# if we already have a default, then we can disable it, as we know
# we can do better.
my $best = eval "\$${fn}_default";
if ($best) {
my $best_ofn = eval "\$${best}";
if ($best_ofn && "$best_ofn" ne "$ofn") {
eval "\$${best}_link = 'false'";
}
}
eval "\$${fn}_default=${fn}_${opt}";
eval "\$${fn}_${opt}_link='true'";
}
}
}
sub forward_decls {
push @ALL_FORWARD_DECLS, @_;
}
#
# Include the user's directives
#
foreach my $f (@ARGV) {
open FILE, "<", $f or die "cannot open $f: $!\n";
my $contents = join('', <FILE>);
close FILE;
eval $contents or warn "eval failed: $@\n";
}
#
# Process the directives according to the command line
#
sub process_forward_decls() {
foreach (@ALL_FORWARD_DECLS) {
$_->();
}
}
sub determine_indirection {
aom_config("CONFIG_RUNTIME_CPU_DETECT") eq "yes" or &require(@ALL_ARCHS);
foreach my $fn (keys %ALL_FUNCS) {
my $n = "";
my @val = @{$ALL_FUNCS{$fn}};
my $args = pop @val;
my $rtyp = "@val";
my $dfn = eval "\$${fn}_default";
$dfn = eval "\$${dfn}";
foreach my $opt (@_) {
my $ofn = eval "\$${fn}_${opt}";
next if !$ofn;
my $link = eval "\$${fn}_${opt}_link";
next if $link && $link eq "false";
$n .= "x";
}
if ($n eq "x") {
eval "\$${fn}_indirect = 'false'";
} else {
eval "\$${fn}_indirect = 'true'";
}
}
}
sub declare_function_pointers {
foreach my $fn (sort keys %ALL_FUNCS) {
my @val = @{$ALL_FUNCS{$fn}};
my $args = pop @val;
my $rtyp = "@val";
my $dfn = eval "\$${fn}_default";
$dfn = eval "\$${dfn}";
foreach my $opt (@_) {
my $ofn = eval "\$${fn}_${opt}";
next if !$ofn;
print "$rtyp ${ofn}($args);\n";
}
if (eval "\$${fn}_indirect" eq "false") {
print "#define ${fn} ${dfn}\n";
} else {
print "RTCD_EXTERN $rtyp (*${fn})($args);\n";
}
print "\n";
}
}
sub set_function_pointers {
foreach my $fn (sort keys %ALL_FUNCS) {
my @val = @{$ALL_FUNCS{$fn}};
my $args = pop @val;
my $rtyp = "@val";
my $dfn = eval "\$${fn}_default";
$dfn = eval "\$${dfn}";
if (eval "\$${fn}_indirect" eq "true") {
print " $fn = $dfn;\n";
foreach my $opt (@_) {
my $ofn = eval "\$${fn}_${opt}";
next if !$ofn;
next if "$ofn" eq "$dfn";
my $link = eval "\$${fn}_${opt}_link";
next if $link && $link eq "false";
my $cond = eval "\$have_${opt}";
print " if (${cond}) $fn = $ofn;\n"
}
}
}
}
sub filter {
my @filtered;
foreach (@_) { push @filtered, $_ unless $disabled{$_}; }
return @filtered;
}
#
# Helper functions for generating the arch specific RTCD files
#
sub common_top() {
my $include_guard = uc($opts{sym})."_H_";
print <<EOF;
// This file is generated. Do not edit.
#ifndef ${include_guard}
#define ${include_guard}
#ifdef RTCD_C
#define RTCD_EXTERN
#else
#define RTCD_EXTERN extern
#endif
EOF
process_forward_decls();
print <<EOF;
#ifdef __cplusplus
extern "C" {
#endif
EOF
declare_function_pointers("c", @ALL_ARCHS);
print <<EOF;
void $opts{sym}(void);
EOF
}
sub common_bottom() {
print <<EOF;
#ifdef __cplusplus
} // extern "C"
#endif
#endif
EOF
}
sub x86() {
determine_indirection("c", @ALL_ARCHS);
# Assign the helper variable for each enabled extension
foreach my $opt (@ALL_ARCHS) {
my $opt_uc = uc $opt;
eval "\$have_${opt}=\"flags & HAS_${opt_uc}\"";
}
common_top;
print <<EOF;
#ifdef RTCD_C
#include "aom_ports/x86.h"
static void setup_rtcd_internal(void)
{
int flags = x86_simd_caps();
(void)flags;
EOF
set_function_pointers("c", @ALL_ARCHS);
print <<EOF;
}
#endif
EOF
common_bottom;
}
sub arm() {
determine_indirection("c", @ALL_ARCHS);
# Assign the helper variable for each enabled extension
foreach my $opt (@ALL_ARCHS) {
my $opt_uc = uc $opt;
eval "\$have_${opt}=\"flags & HAS_${opt_uc}\"";
}
common_top;
print <<EOF;
#include "config/aom_config.h"
#ifdef RTCD_C
#include "aom_ports/arm.h"
static void setup_rtcd_internal(void)
{
int flags = aom_arm_cpu_caps();
(void)flags;
EOF
set_function_pointers("c", @ALL_ARCHS);
print <<EOF;
}
#endif
EOF
common_bottom;
}
sub mips() {
determine_indirection("c", @ALL_ARCHS);
# Assign the helper variable for each enabled extension
foreach my $opt (@ALL_ARCHS) {
my $opt_uc = uc $opt;
eval "\$have_${opt}=\"flags & HAS_${opt_uc}\"";
}
common_top;
print <<EOF;
#include "config/aom_config.h"
#ifdef RTCD_C
static void setup_rtcd_internal(void)
{
EOF
set_function_pointers("c", @ALL_ARCHS);
print <<EOF;
#if HAVE_DSPR2
void aom_dsputil_static_init();
aom_dsputil_static_init();
#endif
}
#endif
EOF
common_bottom;
}
sub ppc() {
determine_indirection("c", @ALL_ARCHS);
# Assign the helper variable for each enabled extension
foreach my $opt (@ALL_ARCHS) {
my $opt_uc = uc $opt;
eval "\$have_${opt}=\"flags & HAS_${opt_uc}\"";
}
common_top;
print <<EOF;
#include "config/aom_config.h"
#ifdef RTCD_C
#include "aom_ports/ppc.h"
static void setup_rtcd_internal(void)
{
int flags = ppc_simd_caps();
(void)flags;
EOF
set_function_pointers("c", @ALL_ARCHS);
print <<EOF;
}
#endif
EOF
common_bottom;
}
sub unoptimized() {
determine_indirection "c";
common_top;
print <<EOF;
#include "config/aom_config.h"
#ifdef RTCD_C
static void setup_rtcd_internal(void)
{
EOF
set_function_pointers "c";
print <<EOF;
}
#endif
EOF
common_bottom;
}
#
# Main Driver
#
&require("c");
&require(keys %required);
if ($opts{arch} eq 'x86') {
@ALL_ARCHS = filter(qw/mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 avx avx2/);
x86;
} elsif ($opts{arch} eq 'x86_64') {
@ALL_ARCHS = filter(qw/mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 avx avx2/);
@REQUIRES = filter(qw/mmx sse sse2/);
&require(@REQUIRES);
x86;
} elsif ($opts{arch} eq 'mips32' || $opts{arch} eq 'mips64') {
@ALL_ARCHS = filter("$opts{arch}");
if (aom_config("HAVE_DSPR2") eq "yes") {
@ALL_ARCHS = filter("$opts{arch}", qw/dspr2/);
} elsif (aom_config("HAVE_MSA") eq "yes") {
@ALL_ARCHS = filter("$opts{arch}", qw/msa/);
}
mips;
} elsif ($opts{arch} =~ /armv7\w?/) {
@ALL_ARCHS = filter(qw/neon/);
arm;
} elsif ($opts{arch} eq 'armv8' || $opts{arch} eq 'arm64' ) {
@ALL_ARCHS = filter(qw/neon/);
&require("neon");
arm;
} elsif ($opts{arch} eq 'ppc') {
@ALL_ARCHS = filter(qw/vsx/);
ppc;
} else {
unoptimized;
}
__END__
=head1 NAME
rtcd -
=head1 SYNOPSIS
Usage: rtcd.pl [options] FILE
See 'perldoc rtcd.pl' for more details.
=head1 DESCRIPTION
Reads the Run Time CPU Detections definitions from FILE and generates a
C header file on stdout.
=head1 OPTIONS
Options:
--arch=ARCH Architecture to generate defs for (required)
--disable-EXT Disable support for EXT extensions
--require-EXT Require support for EXT extensions
--sym=SYMBOL Unique symbol to use for RTCD initialization function
--config=FILE Path to file containing C preprocessor directives to parse

View file

@ -0,0 +1,38 @@
#
# 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_BUILD_CMAKE_SANITIZERS_CMAKE_)
return()
endif() # AOM_BUILD_CMAKE_SANITIZERS_CMAKE_
set(AOM_BUILD_CMAKE_SANITIZERS_CMAKE_ 1)
if(MSVC OR NOT SANITIZE)
return()
endif()
include("${AOM_ROOT}/build/cmake/compiler_flags.cmake")
string(TOLOWER ${SANITIZE} SANITIZE)
# Require the sanitizer requested.
require_linker_flag("-fsanitize=${SANITIZE}")
require_compiler_flag("-fsanitize=${SANITIZE}" YES)
# Make callstacks accurate.
require_compiler_flag("-fno-omit-frame-pointer -fno-optimize-sibling-calls" YES)
# Fix link errors due to missing rt compiler lib in 32-bit builds.
# http://llvm.org/bugs/show_bug.cgi?id=17693
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
if(${CMAKE_SIZEOF_VOID_P} EQUAL 4 AND "${SANITIZE}" MATCHES
"integer|undefined")
require_linker_flag("--rtlib=compiler-rt -lgcc_s")
endif()
endif()

View file

@ -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(AOM_BUILD_CMAKE_TOOLCHAINS_ARM_IOS_COMMON_CMAKE_)
return()
endif() # 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}")
# No runtime cpu detect for arm*-ios targets.
set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE NUMBER "")
# TODO(tomfinegan): Handle bit code embedding.

View file

@ -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(AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_IOS_CMAKE_)
return()
endif() # 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")

View file

@ -0,0 +1,36 @@
#
# 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_BUILD_CMAKE_TOOLCHAINS_ARM64_LINUX_GCC_CMAKE_)
return()
endif() # 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 NUMBER "")

View file

@ -0,0 +1,32 @@
#
# Copyright (c) 2018, 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_BUILD_CMAKE_TOOLCHAINS_ARM64_MINGW_GCC_CMAKE_)
return()
endif() # AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_MINGW_GCC_CMAKE_
set(AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_MINGW_GCC_CMAKE_ 1)
set(CMAKE_SYSTEM_PROCESSOR "arm64")
set(CMAKE_SYSTEM_NAME "Windows")
if("${CROSS}" STREQUAL "")
set(CROSS aarch64-w64-mingw32-)
endif()
set(CMAKE_C_COMPILER ${CROSS}gcc)
set(CMAKE_CXX_COMPILER ${CROSS}g++)
set(CMAKE_AR ${CROSS}ar CACHE FILEPATH Archiver)
set(CMAKE_RANLIB ${CROSS}ranlib CACHE FILEPATH Indexer)
# No runtime cpu detect for arm64-mingw-gcc.
set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE NUMBER "")
# Disable the use of the gtest's CMake support.
set(AOM_DISABLE_GTEST_CMAKE 1)

View file

@ -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(AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7_IOS_CMAKE_)
return()
endif() # 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 NUMBER "")

View file

@ -0,0 +1,43 @@
#
# 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_BUILD_CMAKE_TOOLCHAINS_ARMV7_LINUX_GCC_CMAKE_)
return()
endif() # 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 "")
# No runtime cpu detect for armv7-linux-gcc.
set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE NUMBER "")

View file

@ -0,0 +1,32 @@
#
# Copyright (c) 2018, 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_BUILD_CMAKE_TOOLCHAINS_ARMV7_MINGW_GCC_CMAKE_)
return()
endif() # AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7_MINGW_GCC_CMAKE_
set(AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7_MINGW_GCC_CMAKE_ 1)
set(CMAKE_SYSTEM_PROCESSOR "armv7")
set(CMAKE_SYSTEM_NAME "Windows")
if("${CROSS}" STREQUAL "")
set(CROSS armv7-w64-mingw32-)
endif()
set(CMAKE_C_COMPILER ${CROSS}gcc)
set(CMAKE_CXX_COMPILER ${CROSS}g++)
set(CMAKE_AR ${CROSS}ar CACHE FILEPATH Archiver)
set(CMAKE_RANLIB ${CROSS}ranlib CACHE FILEPATH Indexer)
# No runtime cpu detect for armv7-mingw-gcc.
set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE NUMBER "")
# Disable the use of the gtest's CMake support.
set(AOM_DISABLE_GTEST_CMAKE 1)

View file

@ -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(AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7S_IOS_CMAKE_)
return()
endif() # 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 NUMBER "")

View file

@ -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(AOM_BUILD_CMAKE_TOOLCHAINS_IOS_SIMULATOR_COMMON_CMAKE_)
return()
endif() # 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.

View file

@ -0,0 +1,77 @@
#
# 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_BUILD_CMAKE_TOOLCHAINS_MIPS32_LINUX_GCC_CMAKE_)
return()
endif() # 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.
if(CONFIG_RUNTIME_CPU_DETECT)
message("--- CONFIG_RUNTIME_CPU_DETECT not supported for mips32 targets.")
endif()
set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE NUMBER "" FORCE)

View file

@ -0,0 +1,54 @@
#
# 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_BUILD_CMAKE_TOOLCHAINS_MIPS64_LINUX_GCC_CMAKE_)
return()
endif() # 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.
if(CONFIG_RUNTIME_CPU_DETECT)
message("--- CONFIG_RUNTIME_CPU_DETECT not supported for mips64 targets.")
endif()
set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE NUMBER "" FORCE)

View file

@ -0,0 +1,29 @@
#
# Copyright (c) 2018, 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_BUILD_CMAKE_TOOLCHAINS_PPC_LINUX_GCC_CMAKE_)
return()
endif() # AOM_BUILD_CMAKE_TOOLCHAINS_PPC_LINUX_GCC_CMAKE_
set(AOM_BUILD_CMAKE_TOOLCHAINS_PPC_LINUX_GCC_CMAKE_ 1)
set(CMAKE_SYSTEM_NAME "Linux")
if("${CROSS}" STREQUAL "")
# Default the cross compiler prefix to something known to work.
set(CROSS powerpc64le-unknown-linux-gnu-)
endif()
set(CMAKE_C_COMPILER ${CROSS}gcc)
set(CMAKE_CXX_COMPILER ${CROSS}g++)
set(AS_EXECUTABLE ${CROSS}as)
set(CMAKE_SYSTEM_PROCESSOR "ppc")
set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE NUMBER "")

View file

@ -0,0 +1,28 @@
#
# 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_BUILD_CMAKE_TOOLCHAINS_X86_IOS_SIMULATOR_CMAKE_)
return()
endif() # 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 NUMBER "")
include("${CMAKE_CURRENT_LIST_DIR}/ios-simulator-common.cmake")

View file

@ -0,0 +1,19 @@
#
# 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_BUILD_CMAKE_TOOLCHAINS_X86_LINUX_CMAKE_)
return()
endif() # AOM_BUILD_CMAKE_TOOLCHAINS_X86_LINUX_CMAKE_
set(AOM_BUILD_CMAKE_TOOLCHAINS_X86_LINUX_CMAKE_ 1)
set(CMAKE_SYSTEM_PROCESSOR "x86")
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_C_COMPILER_ARG1 "-m32")
set(CMAKE_CXX_COMPILER_ARG1 "-m32")

View file

@ -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 NUMBER "")

View file

@ -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(AOM_BUILD_CMAKE_TOOLCHAINS_X86_MINGW_GCC_CMAKE_)
return()
endif() # AOM_BUILD_CMAKE_TOOLCHAINS_X86_MINGW_GCC_CMAKE_
set(AOM_BUILD_CMAKE_TOOLCHAINS_X86_MINGW_GCC_CMAKE_ 1)
set(CMAKE_SYSTEM_PROCESSOR "x86")
set(CMAKE_SYSTEM_NAME "Windows")
set(CMAKE_C_COMPILER_ARG1 "-m32")
set(CMAKE_CXX_COMPILER_ARG1 "-m32")
if("${CROSS}" STREQUAL "")
set(CROSS i686-w64-mingw32-)
endif()
set(CMAKE_C_COMPILER ${CROSS}gcc)
set(CMAKE_CXX_COMPILER ${CROSS}g++)
set(CMAKE_AR ${CROSS}ar CACHE FILEPATH Archiver)
set(CMAKE_RANLIB ${CROSS}ranlib CACHE FILEPATH Indexer)
# Disable the use of the gtest's CMake support.
set(AOM_DISABLE_GTEST_CMAKE 1)

View file

@ -0,0 +1,25 @@
#
# 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_BUILD_CMAKE_TOOLCHAINS_X86_64_IOS_SIMULATOR_CMAKE_)
return()
endif() # 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")

View file

@ -0,0 +1,29 @@
#
# 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_BUILD_CMAKE_TOOLCHAINS_X86_64_MINGW_GCC_CMAKE_)
return()
endif() # AOM_BUILD_CMAKE_TOOLCHAINS_X86_64_MINGW_GCC_CMAKE_
set(AOM_BUILD_CMAKE_TOOLCHAINS_X86_64_MINGW_GCC_CMAKE_ 1)
set(CMAKE_SYSTEM_PROCESSOR "x86_64")
set(CMAKE_SYSTEM_NAME "Windows")
if("${CROSS}" STREQUAL "")
set(CROSS x86_64-w64-mingw32-)
endif()
set(CMAKE_C_COMPILER ${CROSS}gcc)
set(CMAKE_CXX_COMPILER ${CROSS}g++)
set(CMAKE_AR ${CROSS}ar CACHE FILEPATH Archiver)
set(CMAKE_RANLIB ${CROSS}ranlib CACHE FILEPATH Indexer)
# Disable the use of the gtest's CMake support.
set(AOM_DISABLE_GTEST_CMAKE 1)

View file

@ -0,0 +1,171 @@
#
# 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_BUILD_CMAKE_UTIL_CMAKE_)
return()
endif() # AOM_BUILD_CMAKE_UTIL_CMAKE_
set(AOM_BUILD_CMAKE_UTIL_CMAKE_ 1)
# Directory where generated sources will be written.
set(AOM_GEN_SRC_DIR "${AOM_CONFIG_DIR}/gen_src")
# Creates dummy source file in $AOM_CONFIG_DIR named $basename.$extension and
# returns the full path to the dummy source file via the $out_file_path
# parameter.
macro(create_dummy_source_file basename extension out_file_path)
set(dummy_source_file "${AOM_GEN_SRC_DIR}/${basename}_dummy.${extension}")
file(
WRITE
"${dummy_source_file}" "// Generated file. DO NOT EDIT!\n"
"// ${target_name} needs a ${extension} file to force link language, \n"
"// or to silence a harmless CMake warning: Ignore me.\n"
"void ${target_name}_dummy_function(void) {}\n")
endmacro()
# Convenience function for adding a dummy source file to $target_name using
# $extension as the file extension. Wraps create_dummy_source_file().
function(add_dummy_source_file_to_target target_name extension)
create_dummy_source_file("${target_name}" "${extension}" "dummy_source_file")
target_sources(${target_name} PRIVATE ${dummy_source_file})
endfunction()
# Sets the value of the variable referenced by $feature to $value, and reports
# the change to the user via call to message(WARNING ...). $cause is expected to
# be a configuration variable that conflicts with $feature in some way. This
# function is a noop if $feature is already set to $value.
function(change_config_and_warn feature value cause)
if(${feature} EQUAL ${value})
return()
endif()
set(${feature} ${value} PARENT_SCOPE)
if(${value} EQUAL 1)
set(verb "Enabled")
set(reason "required for")
else()
set(verb "Disabled")
set(reason "incompatible with")
endif()
set(warning_message "${verb} ${feature}, ${reason} ${cause}.")
message(WARNING "--- ${warning_message}")
endfunction()
# Extracts the version string from $version_file and returns it to the user via
# $version_string_out_var. To achieve this VERSION_STRING_NOSP is located in
# $version_file and then everything but the string literal assigned to the
# variable is removed. Quotes and the leading 'v' are stripped from the returned
# string.
function(extract_version_string version_file version_string_out_var)
file(STRINGS "${version_file}" aom_version REGEX "VERSION_STRING_NOSP")
string(REPLACE "#define VERSION_STRING_NOSP " "" aom_version "${aom_version}")
string(REPLACE "\"" "" aom_version "${aom_version}")
string(REPLACE " " "" aom_version "${aom_version}")
string(FIND "${aom_version}" "v" v_pos)
if(${v_pos} EQUAL 0)
string(SUBSTRING "${aom_version}" 1 -1 aom_version)
endif()
set("${version_string_out_var}" "${aom_version}" PARENT_SCOPE)
endfunction()
# Sets CMake compiler launcher to $launcher_name when $launcher_name is found in
# $PATH. Warns user about ignoring build flag $launcher_flag when $launcher_name
# is not found in $PATH.
function(set_compiler_launcher launcher_flag launcher_name)
find_program(launcher_path "${launcher_name}")
if(launcher_path)
set(CMAKE_C_COMPILER_LAUNCHER "${launcher_path}" PARENT_SCOPE)
set(CMAKE_CXX_COMPILER_LAUNCHER "${launcher_path}" PARENT_SCOPE)
message("--- Using ${launcher_name} as compiler launcher.")
else()
message(WARNING
"--- Cannot find ${launcher_name}, ${launcher_flag} ignored.")
endif()
endfunction()
# Sentinel value used to detect when a variable has been set via the -D argument
# passed to CMake on the command line.
set(cmake_cmdline_helpstring "No help, variable specified on the command line.")
# Wrapper macro for set() that does some book keeping to help with storage of
# build configuration information.
#
# Sets the default value for variable $name when the value of $name has not
# already been set via the CMake command line.
#
# The names of variables defaulted through this macro are added to
# $AOM_CONFIG_VARS to facilitate build logging and diagnostics.
macro(set_aom_detect_var name value type helpstring)
unset(list_index)
list(FIND AOM_DETECT_VARS ${name} list_index)
if(${list_index} EQUAL -1)
list(APPEND AOM_DETECT_VARS ${name})
endif()
# Update the variable only when it does not carry the CMake assigned help
# string for variables specified via the command line.
unset(cache_helpstring)
get_property(cache_helpstring CACHE ${name} PROPERTY HELPSTRING)
if(NOT "${cache_helpstring}" STREQUAL "${cmake_cmdline_helpstring}")
set(${name} ${value} CACHE ${type} "${helpstring}")
mark_as_advanced(${name})
else()
message(
WARNING
"${name} has been set by CMake, but it may be overridden by the build "
"system during environment detection")
endif()
endmacro()
# Wrapper macro for set() that does some book keeping to help with storage of
# build configuration information.
#
# Sets the default value for variable $name when the value of $name has not
# already been set via the CMake command line.
#
# The names of variables defaulted through this macro are added to
# $AOM_CONFIG_VARS to facilitate build logging and diagnostics.
macro(set_aom_config_var name value type helpstring)
unset(list_index)
list(FIND AOM_CONFIG_VARS ${name} list_index)
if(${list_index} EQUAL -1)
list(APPEND AOM_CONFIG_VARS ${name})
endif()
# Update the variable only when it does not carry the CMake assigned help
# string for variables specified via the command line.
unset(cache_helpstring)
get_property(cache_helpstring CACHE ${name} PROPERTY HELPSTRING)
if(NOT "${cache_helpstring}" STREQUAL "${cmake_cmdline_helpstring}")
set(${name} ${value} CACHE ${type} "${helpstring}")
endif()
endmacro()
# Wrapper macro for option() that does some book keeping to help with storage of
# build configuration information.
#
# Sets the default value for variable $name when the value of $name has not
# already been set via the CMake command line.
#
# The names of variables defaulted through this macro are added to
# $AOM_OPTION_VARS to facilitate build logging and diagnostics.
macro(set_aom_option_var name helpstring value)
unset(list_index)
list(FIND AOM_OPTION_VARS ${name} list_index)
if(${list_index} EQUAL -1)
list(APPEND AOM_OPTION_VARS ${name})
endif()
# Update the variable only when it does not carry the CMake assigned help
# string for variables specified via the command line.
unset(cache_helpstring)
get_property(cache_helpstring CACHE ${name} PROPERTY HELPSTRING)
if(NOT "${cache_helpstring}" STREQUAL "${cmake_cmdline_helpstring}")
option(${name} "${helpstring}" ${value})
endif()
endmacro()

View file

@ -0,0 +1,57 @@
#
# 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)
set(REQUIRED_ARGS "AOM_ROOT" "AOM_CONFIG_DIR" "GIT_EXECUTABLE"
"PERL_EXECUTABLE")
foreach(arg ${REQUIRED_ARGS})
if("${${arg}}" STREQUAL "")
message(FATAL_ERROR "${arg} must not be empty.")
endif()
endforeach()
include("${AOM_ROOT}/build/cmake/util.cmake")
# Generate the version string for this run.
unset(aom_version)
if(EXISTS "${GIT_EXECUTABLE}")
execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=${AOM_ROOT}/.git describe
OUTPUT_VARIABLE aom_version ERROR_QUIET)
string(STRIP "${aom_version}" aom_version)
# Remove the leading 'v' from the version string.
string(FIND "${aom_version}" "v" v_pos)
if(${v_pos} EQUAL 0)
string(SUBSTRING "${aom_version}" 1 -1 aom_version)
endif()
endif()
if("${aom_version}" STREQUAL "")
set(aom_version "${AOM_ROOT}/CHANGELOG")
endif()
unset(last_aom_version)
if(EXISTS "${AOM_CONFIG_DIR}/config/aom_version.h")
extract_version_string("${AOM_CONFIG_DIR}/config/aom_version.h"
last_aom_version)
endif()
if(NOT "${aom_version}" STREQUAL "${last_aom_version}")
# TODO(tomfinegan): Perl dependency is unnecessary. CMake can do everything
# that is done by version.pl on its own (if a bit more verbose...).
execute_process(COMMAND
${PERL_EXECUTABLE} "${AOM_ROOT}/build/cmake/version.pl"
--version_data=${aom_version}
--version_filename=${AOM_CONFIG_DIR}/config/aom_version.h
VERBATIM)
endif()

View file

@ -0,0 +1,112 @@
#!/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 $git_desc = '';
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;
chomp($version_data);
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];
$git_desc = $version_data;
}
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 (length($git_desc) > 0) {
my @git_desc_components = split('-', $git_desc, 2);
$version_extra = $git_desc_components[1];
}
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;
if (length($git_desc)) {
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 \"$git_desc\"
#define VERSION_STRING \" $git_desc\"
EOF
} else {
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);