From 1264fde267a4d87e80d17c82e450efd21d00f0bc Mon Sep 17 00:00:00 2001 From: Tom Finegan Date: Wed, 15 Feb 2017 15:40:00 -0800 Subject: [PATCH] Add cmake toolchain for x86 support on linux. - Properly respond to detection of i386 and x86 as the CPU. - Restrict -Wshadow to C files: it silences a large number of warnings caused by test code. BUG=https://bugs.chromium.org/p/aomedia/issues/detail?id=76 Change-Id: Ia15ae8ed0fa90aec587818bda778a638c811168d --- build/cmake/aom_configure.cmake | 10 +++++++++- build/cmake/aom_optimization.cmake | 2 ++ build/cmake/toolchains/x86-linux.cmake | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 build/cmake/toolchains/x86-linux.cmake diff --git a/build/cmake/aom_configure.cmake b/build/cmake/aom_configure.cmake index 7aae928d3..f0f026a2a 100644 --- a/build/cmake/aom_configure.cmake +++ b/build/cmake/aom_configure.cmake @@ -29,10 +29,15 @@ if (NOT AOM_TARGET_CPU) " 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") endif () endif () +message("--- aom_configure: Detected CPU: ${AOM_TARGET_CPU}") set(AOM_TARGET_SYSTEM ${CMAKE_SYSTEM_NAME}) + if (NOT EXISTS "${AOM_ROOT}/build/cmake/targets/${AOM_TARGET_CPU}.cmake") message(FATAL_ERROR "No RTCD template for ${AOM_TARGET_CPU}. Create one, or " "add -DAOM_TARGET_CPU=generic to your cmake command line for a " @@ -68,12 +73,15 @@ else () add_compiler_flag_if_supported("-Wfloat-conversion") add_compiler_flag_if_supported("-Wimplicit-function-declaration") add_compiler_flag_if_supported("-Wpointer-arith") - add_compiler_flag_if_supported("-Wshadow") add_compiler_flag_if_supported("-Wsign-compare") add_compiler_flag_if_supported("-Wtype-limits") add_compiler_flag_if_supported("-Wuninitialized") add_compiler_flag_if_supported("-Wunused") add_compiler_flag_if_supported("-Wvla") + + # Add -Wshadow only for C files to avoid massive gtest warning spam. + add_c_flag_if_supported("-Wshadow") + if (ENABLE_WERROR) add_compiler_flag_if_supported("-Werror") endif () diff --git a/build/cmake/aom_optimization.cmake b/build/cmake/aom_optimization.cmake index dc304b379..701abff30 100644 --- a/build/cmake/aom_optimization.cmake +++ b/build/cmake/aom_optimization.cmake @@ -81,6 +81,8 @@ function (get_asm_obj_format out_format) elseif ("${AOM_TARGET_CPU}" STREQUAL "x86") if ("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin") set(objformat "macho32") + elseif ("${AOM_TARGET_SYSTEM}" STREQUAL "Linux") + set(objformat "elf32") elseif ("${AOM_TARGET_SYSTEM}" STREQUAL "Windows") set(objformat "win32") else () diff --git a/build/cmake/toolchains/x86-linux.cmake b/build/cmake/toolchains/x86-linux.cmake new file mode 100644 index 000000000..077c8f325 --- /dev/null +++ b/build/cmake/toolchains/x86-linux.cmake @@ -0,0 +1,14 @@ +## +## Copyright (c) 2017, Alliance for Open Media. All rights reserved +## +## This source code is subject to the terms of the BSD 2 Clause License and +## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License +## was not distributed with this source code in the LICENSE file, you can +## obtain it at www.aomedia.org/license/software. If the Alliance for Open +## Media Patent License 1.0 was not distributed with this source code in the +## PATENTS file, you can obtain it at www.aomedia.org/license/patent. +## +set(CMAKE_SYSTEM_PROCESSOR "x86") +set(CMAKE_SYSTEM_NAME "Linux") +set(CMAKE_C_COMPILER_ARG1 "-m32") +set(CMAKE_CXX_COMPILER_ARG1 "-m32") -- GitLab