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