summaryrefslogtreecommitdiffstats
path: root/third_party/aom/build/cmake/toolchains/android.cmake
blob: fb086856a7fccf36478c697895ba97f7db9b244d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#
# Copyright (c) 2019, 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_ANDROID_CMAKE_)
  return()
endif() # AOM_BUILD_CMAKE_TOOLCHAINS_ANDROID_CMAKE_
set(AOM_BUILD_CMAKE_TOOLCHAINS_ANDROID_CMAKE_ 1)

if(NOT ANDROID_PLATFORM)
  set(ANDROID_PLATFORM android-24)
endif()

# Choose target architecture with:
#
# -DANDROID_ABI={armeabi-v7a,armeabi-v7a with NEON,arm64-v8a,x86,x86_64}
if(NOT ANDROID_ABI)
  set(ANDROID_ABI arm64-v8a)
endif()

# Toolchain files don't have access to cached variables:
# https://gitlab.kitware.com/cmake/cmake/issues/16170. Set an intermediate
# environment variable when loaded the first time.
if(AOM_ANDROID_NDK_PATH)
  set(ENV{_AOM_ANDROID_NDK_PATH} "${AOM_ANDROID_NDK_PATH}")
else()
  set(AOM_ANDROID_NDK_PATH "$ENV{_AOM_ANDROID_NDK_PATH}")
endif()

if("${AOM_ANDROID_NDK_PATH}" STREQUAL "")
  message(FATAL_ERROR "AOM_ANDROID_NDK_PATH not set.")
  return()
endif()

include("${AOM_ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake")

if(ANDROID_ABI MATCHES "^armeabi")
  set(AOM_NEON_INTRIN_FLAG "-mfpu=neon")
endif()

if(ANDROID_ABI MATCHES "^arm")
  set(CMAKE_ASM_COMPILER as)
elseif(ANDROID_ABI MATCHES "^x86")
  set(CMAKE_ASM_NASM_COMPILER yasm)
endif()

set(CMAKE_SYSTEM_NAME "Android")