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