xref: /aosp_15_r20/external/libgav1/cmake/toolchains/android.cmake (revision 095378508e87ed692bf8dfeb34008b65b3735891)
1# Copyright 2019 The libgav1 Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15if(LIBGAV1_CMAKE_TOOLCHAINS_ANDROID_CMAKE_)
16  return()
17endif() # LIBGAV1_CMAKE_TOOLCHAINS_ANDROID_CMAKE_
18
19# Additional ANDROID_* settings are available, see:
20# https://developer.android.com/ndk/guides/cmake#variables
21
22if(NOT ANDROID_PLATFORM)
23  set(ANDROID_PLATFORM android-21)
24endif()
25
26# Choose target architecture with:
27#
28# -DANDROID_ABI={armeabi-v7a,armeabi-v7a with NEON,arm64-v8a,x86,x86_64}
29if(NOT ANDROID_ABI)
30  set(ANDROID_ABI arm64-v8a)
31endif()
32
33# Force arm mode for 32-bit arm targets (instead of the default thumb) to
34# improve performance.
35if(ANDROID_ABI MATCHES "^armeabi" AND NOT ANDROID_ARM_MODE)
36  set(ANDROID_ARM_MODE arm)
37endif()
38
39# Toolchain files don't have access to cached variables:
40# https://gitlab.kitware.com/cmake/cmake/issues/16170. Set an intermediate
41# environment variable when loaded the first time.
42if(LIBGAV1_ANDROID_NDK_PATH)
43  set(ENV{LIBGAV1_ANDROID_NDK_PATH} "${LIBGAV1_ANDROID_NDK_PATH}")
44else()
45  set(LIBGAV1_ANDROID_NDK_PATH "$ENV{LIBGAV1_ANDROID_NDK_PATH}")
46endif()
47
48if(NOT LIBGAV1_ANDROID_NDK_PATH)
49  message(FATAL_ERROR "LIBGAV1_ANDROID_NDK_PATH not set.")
50  return()
51endif()
52
53include("${LIBGAV1_ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake")
54