xref: /aosp_15_r20/external/libaom/build/cmake/toolchains/android.cmake (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1#
2# Copyright (c) 2019, Alliance for Open Media. All rights reserved.
3#
4# This source code is subject to the terms of the BSD 2 Clause License and the
5# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
6# not distributed with this source code in the LICENSE file, you can obtain it
7# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
8# License 1.0 was not distributed with this source code in the PATENTS file, you
9# can obtain it at www.aomedia.org/license/patent.
10#
11if(AOM_BUILD_CMAKE_TOOLCHAINS_ANDROID_CMAKE_)
12  return()
13endif() # AOM_BUILD_CMAKE_TOOLCHAINS_ANDROID_CMAKE_
14set(AOM_BUILD_CMAKE_TOOLCHAINS_ANDROID_CMAKE_ 1)
15
16if(NOT ANDROID_PLATFORM)
17  set(ANDROID_PLATFORM android-24)
18endif()
19
20# Choose target architecture with:
21#
22# -DANDROID_ABI={armeabi-v7a,armeabi-v7a with NEON,arm64-v8a,x86,x86_64}
23if(NOT ANDROID_ABI)
24  set(ANDROID_ABI arm64-v8a)
25endif()
26
27# Toolchain files don't have access to cached variables:
28# https://gitlab.kitware.com/cmake/cmake/issues/16170. Set an intermediate
29# environment variable when loaded the first time.
30if(AOM_ANDROID_NDK_PATH)
31  set(ENV{_AOM_ANDROID_NDK_PATH} "${AOM_ANDROID_NDK_PATH}")
32else()
33  set(AOM_ANDROID_NDK_PATH "$ENV{_AOM_ANDROID_NDK_PATH}")
34endif()
35
36if("${AOM_ANDROID_NDK_PATH}" STREQUAL "")
37  message(FATAL_ERROR "AOM_ANDROID_NDK_PATH not set.")
38  return()
39endif()
40
41include("${AOM_ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake")
42
43if(ANDROID_ABI MATCHES "^armeabi")
44  set(AOM_NEON_INTRIN_FLAG "-mfpu=neon")
45endif()
46
47if(ANDROID_ABI MATCHES "^arm")
48  set(CMAKE_ASM_COMPILER as)
49elseif(ANDROID_ABI MATCHES "^x86")
50  set(CMAKE_ASM_NASM_COMPILER yasm)
51endif()
52
53set(CMAKE_SYSTEM_NAME "Android")
54