android.cmake (1704B)
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 # 11 if(AOM_BUILD_CMAKE_TOOLCHAINS_ANDROID_CMAKE_) 12 return() 13 endif() # AOM_BUILD_CMAKE_TOOLCHAINS_ANDROID_CMAKE_ 14 set(AOM_BUILD_CMAKE_TOOLCHAINS_ANDROID_CMAKE_ 1) 15 16 if(NOT ANDROID_PLATFORM) 17 set(ANDROID_PLATFORM android-24) 18 endif() 19 20 # Choose target architecture with: 21 # 22 # -DANDROID_ABI={armeabi-v7a,armeabi-v7a with NEON,arm64-v8a,x86,x86_64} 23 if(NOT ANDROID_ABI) 24 set(ANDROID_ABI arm64-v8a) 25 endif() 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. 30 if(AOM_ANDROID_NDK_PATH) 31 set(ENV{_AOM_ANDROID_NDK_PATH} "${AOM_ANDROID_NDK_PATH}") 32 else() 33 set(AOM_ANDROID_NDK_PATH "$ENV{_AOM_ANDROID_NDK_PATH}") 34 endif() 35 36 if("${AOM_ANDROID_NDK_PATH}" STREQUAL "") 37 message(FATAL_ERROR "AOM_ANDROID_NDK_PATH not set.") 38 return() 39 endif() 40 41 include("${AOM_ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake") 42 43 if(ANDROID_ABI MATCHES "^armeabi") 44 set(AOM_NEON_INTRIN_FLAG "-mfpu=neon") 45 endif() 46 47 if(ANDROID_ABI MATCHES "^arm") 48 set(CMAKE_ASM_COMPILER as) 49 elseif(ANDROID_ABI MATCHES "^x86") 50 set(CMAKE_ASM_NASM_COMPILER yasm) 51 endif() 52 53 set(CMAKE_SYSTEM_NAME "Android")