Commit 973d4d56 authored by Tom Finegan's avatar Tom Finegan Committed by Yaowu Xu

cmake: Add partial configure.

- Add minimal compiler flag testing.
- Generate aom_config.c and aom_config.h. Note: hard coded
  to generic-gnu values for now.
- Still a work in progress. This will not build anything.

BUG=https://bugs.chromium.org/p/aomedia/issues/detail?id=76

Change-Id: Id65b42ea9f4c4f744d788660e2de7234886ce039
parent 9b3974ef
......@@ -12,8 +12,12 @@ cmake_minimum_required(VERSION 3.2)
project(AOM C CXX)
set(AOM_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
set(AOM_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}")
include("${AOM_ROOT}/build/cmake/aom_configure.cmake")
set(AOM_SRCS
"${AOM_CONFIG_DIR}/aom_config.c"
"${AOM_CONFIG_DIR}/aom_config.h"
"${AOM_ROOT}/aom/aom.h"
"${AOM_ROOT}/aom/aom_codec.h"
"${AOM_ROOT}/aom/aom_decoder.h"
......@@ -242,8 +246,10 @@ set(AOM_AV1_ENCODER_SRCS
# Targets
add_library(aom_dsp ${AOM_DSP_SRCS})
include_directories(${AOM_ROOT} ${AOM_CONFIG_DIR})
add_library(aom_mem ${AOM_MEM_SRCS})
add_library(aom_scale ${AOM_SCALE_SRCS})
include_directories(${AOM_ROOT} ${AOM_CONFIG_DIR})
add_library(aom_util ${AOM_UTIL_SRCS})
add_library(aom_av1_decoder ${AOM_AV1_DECODER_SRCS})
add_library(aom_av1_encoder ${AOM_AV1_ENCODER_SRCS})
......
/*
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
*
* This source code is subject to the terms of the BSD 2 Clause License and
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
* was not distributed with this source code in the LICENSE file, you can
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
* Media Patent License 1.0 was not distributed with this source code in the
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
#include "aom/aom_codec.h"
static const char* const cfg = "${AOM_CMAKE_CONFIG}";
static const char* const aom_git_hash = "${AOM_GIT_HASH}";
const char *aom_codec_build_config(void) {return cfg;}
const char *aom_codec_git_hash(void) {return aom_git_hash;}
/*
* 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 file is processed by cmake and used to produce aom_config.h in the
* directory where cmake was executed. */
#ifndef AOM_CONFIG_H
#define AOM_CONFIG_H
#define RESTRICT ${RESTRICT}
#define INLINE ${INLINE}
#define ARCH_ARM ${ARCH_ARM}
#define ARCH_MIPS ${ARCH_MIPS}
#define ARCH_X86 ${ARCH_X86}
#define ARCH_X86_64 ${ARCH_X86_64}
#define HAVE_EDSP ${HAVE_EDSP}
#define HAVE_MEDIA ${HAVE_MEDIA}
#define HAVE_NEON ${HAVE_NEON}
#define HAVE_NEON_ASM ${HAVE_NEON_ASM}
#define HAVE_MIPS32 ${HAVE_MIPS32}
#define HAVE_DSPR2 ${HAVE_DSPR2}
#define HAVE_MSA ${HAVE_MSA}
#define HAVE_MIPS64 ${HAVE_MIPS64}
#define HAVE_MMX ${HAVE_MMX}
#define HAVE_SSE ${HAVE_SSE}
#define HAVE_SSE2 ${HAVE_SSE2}
#define HAVE_SSE3 ${HAVE_SSE3}
#define HAVE_SSSE3 ${HAVE_SSSE3}
#define HAVE_SSE4_1 ${HAVE_SSE4_1}
#define HAVE_AVX ${HAVE_AVX}
#define HAVE_AVX2 ${HAVE_AVX2}
#define HAVE_AOM_PORTS ${HAVE_AOM_PORTS}
#define HAVE_PTHREAD_H ${HAVE_PTHREAD_H}
#define HAVE_UNISTD_H ${HAVE_UNISTD_H}
#define CONFIG_DEPENDENCY_TRACKING ${CONFIG_DEPENDENCY_TRACKING}
#define CONFIG_EXTERNAL_BUILD ${CONFIG_EXTERNAL_BUILD}
#define CONFIG_INSTALL_DOCS ${CONFIG_INSTALL_DOCS}
#define CONFIG_INSTALL_BINS ${CONFIG_INSTALL_BINS}
#define CONFIG_INSTALL_LIBS ${CONFIG_INSTALL_LIBS}
#define CONFIG_INSTALL_SRCS ${CONFIG_INSTALL_SRCS}
#define CONFIG_USE_X86INC ${CONFIG_USE_X86INC}
#define CONFIG_DEBUG ${CONFIG_DEBUG}
#define CONFIG_GPROF ${CONFIG_GPROF}
#define CONFIG_GCOV ${CONFIG_GCOV}
#define CONFIG_RVCT ${CONFIG_RVCT}
#define CONFIG_GCC ${CONFIG_GCC}
#define CONFIG_MSVS ${CONFIG_MSVS}
#define CONFIG_PIC ${CONFIG_PIC}
#define CONFIG_BIG_ENDIAN ${CONFIG_BIG_ENDIAN}
#define CONFIG_CODEC_SRCS ${CONFIG_CODEC_SRCS}
#define CONFIG_DEBUG_LIBS ${CONFIG_DEBUG_LIBS}
#define CONFIG_DEQUANT_TOKENS ${CONFIG_DEQUANT_TOKENS}
#define CONFIG_DC_RECON ${CONFIG_DC_RECON}
#define CONFIG_RUNTIME_CPU_DETECT ${CONFIG_RUNTIME_CPU_DETECT}
#define CONFIG_MULTITHREAD ${CONFIG_MULTITHREAD}
#define CONFIG_INTERNAL_STATS ${CONFIG_INTERNAL_STATS}
#define CONFIG_AV1_ENCODER ${CONFIG_AV1_ENCODER}
#define CONFIG_AV1_DECODER ${CONFIG_AV1_DECODER}
#define CONFIG_AV1 ${CONFIG_AV1}
#define CONFIG_ENCODERS ${CONFIG_ENCODERS}
#define CONFIG_DECODERS ${CONFIG_DECODERS}
#define CONFIG_STATIC_MSVCRT ${CONFIG_STATIC_MSVCRT}
#define CONFIG_SPATIAL_RESAMPLING ${CONFIG_SPATIAL_RESAMPLING}
#define CONFIG_REALTIME_ONLY ${CONFIG_REALTIME_ONLY}
#define CONFIG_ONTHEFLY_BITPACKING ${CONFIG_ONTHEFLY_BITPACKING}
#define CONFIG_ERROR_CONCEALMENT ${CONFIG_ERROR_CONCEALMENT}
#define CONFIG_SHARED ${CONFIG_SHARED}
#define CONFIG_STATIC ${CONFIG_STATIC}
#define CONFIG_SMALL ${CONFIG_SMALL}
#define CONFIG_OS_SUPPORT ${CONFIG_OS_SUPPORT}
#define CONFIG_UNIT_TESTS ${CONFIG_UNIT_TESTS}
#define CONFIG_WEBM_IO ${CONFIG_WEBM_IO}
#define CONFIG_LIBYUV ${CONFIG_LIBYUV}
#define CONFIG_ACCOUNTING ${CONFIG_ACCOUNTING}
#define CONFIG_DECODE_PERF_TESTS ${CONFIG_DECODE_PERF_TESTS}
#define CONFIG_ENCODE_PERF_TESTS ${CONFIG_ENCODE_PERF_TESTS}
#define CONFIG_MULTI_RES_ENCODING ${CONFIG_MULTI_RES_ENCODING}
#define CONFIG_TEMPORAL_DENOISING ${CONFIG_TEMPORAL_DENOISING}
#define CONFIG_COEFFICIENT_RANGE_CHECKING ${CONFIG_COEFFICIENT_RANGE_CHECKING}
#define CONFIG_AOM_HIGHBITDEPTH ${CONFIG_AOM_HIGHBITDEPTH}
#define CONFIG_EXPERIMENTAL ${CONFIG_EXPERIMENTAL}
#define CONFIG_SIZE_LIMIT ${CONFIG_SIZE_LIMIT}
#define CONFIG_AOM_QM ${CONFIG_AOM_QM}
#define CONFIG_SPATIAL_SVC ${CONFIG_SPATIAL_SVC}
#define CONFIG_FP_MB_STATS ${CONFIG_FP_MB_STATS}
#define CONFIG_EMULATE_HARDWARE ${CONFIG_EMULATE_HARDWARE}
#define CONFIG_CLPF ${CONFIG_CLPF}
#define CONFIG_DERING ${CONFIG_DERING}
#define CONFIG_REF_MV ${CONFIG_REF_MV}
#define CONFIG_SUB8X8_MC ${CONFIG_SUB8X8_MC}
#define CONFIG_EXT_INTRA ${CONFIG_EXT_INTRA}
#define CONFIG_EXT_INTERP ${CONFIG_EXT_INTERP}
#define CONFIG_EXT_TX ${CONFIG_EXT_TX}
#define CONFIG_MOTION_VAR ${CONFIG_MOTION_VAR}
#define CONFIG_EXT_REFS ${CONFIG_EXT_REFS}
#define CONFIG_EXT_COMPOUND ${CONFIG_EXT_COMPOUND}
#define CONFIG_SUPERTX ${CONFIG_SUPERTX}
#define CONFIG_ANS ${CONFIG_ANS}
#define CONFIG_EC_MULTISYMBOL ${CONFIG_EC_MULTISYMBOL}
#define CONFIG_DAALA_EC ${CONFIG_DAALA_EC}
#define CONFIG_PARALLEL_DEBLOCKING ${CONFIG_PARALLEL_DEBLOCKING}
#define CONFIG_CB4X4 ${CONFIG_CB4X4}
#define CONFIG_PALETTE ${CONFIG_PALETTE}
#define CONFIG_FRAME_SIZE ${CONFIG_FRAME_SIZE}
#define CONFIG_FILTER_7BIT ${CONFIG_FILTER_7BIT}
#define CONFIG_DELTA_Q ${CONFIG_DELTA_Q}
#define CONFIG_ADAPT_SCAN ${CONFIG_ADAPT_SCAN}
#define CONFIG_BITSTREAM_DEBUG ${CONFIG_BITSTREAM_DEBUG}
#define CONFIG_TILE_GROUPS ${CONFIG_TILE_GROUPS}
#define CONFIG_EC_ADAPT ${CONFIG_EC_ADAPT}
#endif /* AOM_CONFIG_H */
##
## 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.
##
cmake_minimum_required(VERSION 3.2)
include("${AOM_ROOT}/build/cmake/compiler_flags.cmake")
include(FindGit)
# Defaults for every libaom configuration variable.
set(RESTRICT)
set(INLINE)
set(ARCH_ARM 0)
set(ARCH_MIPS 0)
set(ARCH_X86 0)
set(ARCH_X86_64 0)
set(HAVE_EDSP 0)
set(HAVE_MEDIA 0)
set(HAVE_NEON 0)
set(HAVE_NEON_ASM 0)
set(HAVE_MIPS32 0)
set(HAVE_DSPR2 0)
set(HAVE_MSA 0)
set(HAVE_MIPS64 0)
set(HAVE_MMX 0)
set(HAVE_SSE 0)
set(HAVE_SSE2 0)
set(HAVE_SSE3 0)
set(HAVE_SSSE3 0)
set(HAVE_SSE4_1 0)
set(HAVE_AVX 0)
set(HAVE_AVX2 0)
set(HAVE_AOM_PORTS 0)
set(HAVE_PTHREAD_H 0)
set(HAVE_UNISTD_H 0)
set(CONFIG_DEPENDENCY_TRACKING 1)
set(CONFIG_EXTERNAL_BUILD 0)
set(CONFIG_INSTALL_DOCS 0)
set(CONFIG_INSTALL_BINS 0)
set(CONFIG_INSTALL_LIBS 0)
set(CONFIG_INSTALL_SRCS 0)
set(CONFIG_USE_X86INC 0)
set(CONFIG_DEBUG 0)
set(CONFIG_GPROF 0)
set(CONFIG_GCOV 0)
set(CONFIG_RVCT 0)
set(CONFIG_GCC 0)
set(CONFIG_MSVS 0)
set(CONFIG_PIC 0)
set(CONFIG_BIG_ENDIAN 0)
set(CONFIG_CODEC_SRCS 0)
set(CONFIG_DEBUG_LIBS 0)
set(CONFIG_DEQUANT_TOKENS 0)
set(CONFIG_DC_RECON 0)
set(CONFIG_RUNTIME_CPU_DETECT 0)
set(CONFIG_MULTITHREAD 0)
set(CONFIG_INTERNAL_STATS 0)
set(CONFIG_AV1_ENCODER 1)
set(CONFIG_AV1_DECODER 1)
set(CONFIG_AV1 1)
set(CONFIG_ENCODERS 1)
set(CONFIG_DECODERS 1)
set(CONFIG_STATIC_MSVCRT 0)
set(CONFIG_SPATIAL_RESAMPLING 1)
set(CONFIG_REALTIME_ONLY 0)
set(CONFIG_ONTHEFLY_BITPACKING 0)
set(CONFIG_ERROR_CONCEALMENT 0)
set(CONFIG_SHARED 0)
set(CONFIG_STATIC 1)
set(CONFIG_SMALL 0)
set(CONFIG_OS_SUPPORT 0)
set(CONFIG_UNIT_TESTS 0)
set(CONFIG_WEBM_IO 0)
set(CONFIG_LIBYUV 0)
set(CONFIG_ACCOUNTING 0)
set(CONFIG_DECODE_PERF_TESTS 0)
set(CONFIG_ENCODE_PERF_TESTS 0)
set(CONFIG_MULTI_RES_ENCODING 0)
set(CONFIG_TEMPORAL_DENOISING 1)
set(CONFIG_COEFFICIENT_RANGE_CHECKING 0)
set(CONFIG_AOM_HIGHBITDEPTH 0)
set(CONFIG_EXPERIMENTAL 0)
set(CONFIG_SIZE_LIMIT 0)
set(CONFIG_AOM_QM 0)
set(CONFIG_SPATIAL_SVC 0)
set(CONFIG_FP_MB_STATS 0)
set(CONFIG_EMULATE_HARDWARE 0)
set(CONFIG_CLPF 0)
set(CONFIG_DERING 0)
set(CONFIG_REF_MV 0)
set(CONFIG_SUB8X8_MC 0)
set(CONFIG_EXT_INTRA 0)
set(CONFIG_EXT_INTERP 0)
set(CONFIG_EXT_TX 0)
set(CONFIG_MOTION_VAR 0)
set(CONFIG_EXT_REFS 0)
set(CONFIG_EXT_COMPOUND 0)
set(CONFIG_SUPERTX 0)
set(CONFIG_ANS 0)
set(CONFIG_EC_MULTISYMBOL 0)
set(CONFIG_DAALA_EC 0)
set(CONFIG_PARALLEL_DEBLOCKING 0)
set(CONFIG_CB4X4 0)
set(CONFIG_PALETTE 0)
set(CONFIG_FRAME_SIZE 0)
set(CONFIG_FILTER_7BIT 0)
set(CONFIG_DELTA_Q 0)
set(CONFIG_ADAPT_SCAN 0)
set(CONFIG_BITSTREAM_DEBUG 0)
set(CONFIG_TILE_GROUPS 0)
set(CONFIG_EC_ADAPT 0)
# TODO(tomfinegan): consume trailing whitespace after configure_file().
configure_file("${AOM_ROOT}/build/cmake/aom_config.h.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/aom_config.h")
# Read the current git hash.
find_package(Git)
if (GIT_FOUND)
# TODO(tomfinegan): Make this smart enough to write a proper version string
# when in a repo that is on a label and clean.
# TODO(tomfinegan): In addition to the one above, also make this a custom
# build rule so users don't have to re-run cmake to create accurately
# versioned cmake builds.
execute_process(COMMAND ${GIT_EXECUTABLE}
--git-dir=${AOM_ROOT}/.git rev-parse HEAD
OUTPUT_VARIABLE AOM_GIT_HASH)
# Consume the newline at the end of the git output.
string(STRIP ${AOM_GIT_HASH} AOM_GIT_HASH)
else ()
set(AOM_GIT_HASH)
endIf ()
# TODO(tomfinegan): An alternative to dumping the configure command line to
# aom_config.c is needed in cmake. Normal cmake generation runs do not make the
# command line available in the cmake script. For now, we just set the variable
# to the following. The configure_file() command will expand the message in
# aom_config.c.
# Note: This message isn't strictly true. When cmake is run in script mode (with
# the -P argument), CMAKE_ARGC and CMAKE_ARGVn are defined (n = 0 through
# n = CMAKE_ARGC become valid). Normal cmake generation runs do not make the
# information available.
set(AOM_CMAKE_CONFIG "cmake")
configure_file("${AOM_ROOT}/build/cmake/aom_config.c.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/aom_config.c")
##
## 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.
##
cmake_minimum_required(VERSION 3.2)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
function (add_c_flag_if_supported c_flag)
unset(C_FLAG_SUPPORTED CACHE)
message("Checking C compiler flag support for: " ${c_flag})
check_c_compiler_flag("${c_flag}" C_FLAG_SUPPORTED)
if (C_FLAG_SUPPORTED)
set(CMAKE_C_FLAGS "${c_flag} ${CMAKE_C_FLAGS}" CACHE STRING "" FORCE)
endif ()
endfunction ()
function (add_cxx_flag_if_supported cxx_flag)
unset(CXX_FLAG_SUPPORTED CACHE)
message("Checking CXX compiler flag support for: " ${cxx_flag})
check_cxx_compiler_flag("${cxx_flag}" CXX_FLAG_SUPPORTED)
if (CXX_FLAG_SUPPORTED)
set(CMAKE_CXX_FLAGS "${cxx_flag} ${CMAKE_CXX_FLAGS}" CACHE STRING "" FORCE)
endif ()
endfunction ()
function (add_compiler_flag_if_supported flag)
add_c_flag_if_supported(${flag})
add_cxx_flag_if_supported(${flag})
endfunction ()
# Set warning levels.
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 ()
add_compiler_flag_if_supported("-Wall")
add_compiler_flag_if_supported("-Wextra")
add_compiler_flag_if_supported("-Wno-deprecated")
add_compiler_flag_if_supported("-Wshorten-64-to-32")
add_compiler_flag_if_supported("-Wnarrowing")
if (ENABLE_WERROR)
add_compiler_flag_if_supported("-Werror")
endif ()
endif ()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment