summaryrefslogtreecommitdiff
path: root/share/cmake-3.18/Modules/Platform/Android-Determine.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'share/cmake-3.18/Modules/Platform/Android-Determine.cmake')
-rw-r--r--share/cmake-3.18/Modules/Platform/Android-Determine.cmake315
1 files changed, 203 insertions, 112 deletions
diff --git a/share/cmake-3.18/Modules/Platform/Android-Determine.cmake b/share/cmake-3.18/Modules/Platform/Android-Determine.cmake
index 2225897..4ba3601 100644
--- a/share/cmake-3.18/Modules/Platform/Android-Determine.cmake
+++ b/share/cmake-3.18/Modules/Platform/Android-Determine.cmake
@@ -5,6 +5,12 @@
# This module detects platform-wide information about the Android target
# in order to store it in "CMakeSystem.cmake".
+# Include the NDK hook.
+# It can be used by NDK to inject necessary fixes for an earlier cmake.
+if(CMAKE_ANDROID_NDK)
+ include(${CMAKE_ANDROID_NDK}/build/cmake/hooks/pre/Android-Determine.cmake OPTIONAL)
+endif()
+
# Support for NVIDIA Nsight Tegra Visual Studio Edition was previously
# implemented in the CMake VS IDE generators. Avoid interfering with
# that functionality for now. Later we may try to integrate this.
@@ -144,64 +150,23 @@ if(NOT CMAKE_ANDROID_NDK AND NOT CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
message(FATAL_ERROR "Android: Neither the NDK or a standalone toolchain was found.")
endif()
-# Select an API.
-if(CMAKE_SYSTEM_VERSION)
- set(_ANDROID_API_VAR CMAKE_SYSTEM_VERSION)
-elseif(CMAKE_ANDROID_API)
- set(CMAKE_SYSTEM_VERSION "${CMAKE_ANDROID_API}")
- set(_ANDROID_API_VAR CMAKE_ANDROID_API)
-elseif(_ANDROID_SYSROOT_API)
- set(CMAKE_SYSTEM_VERSION "${_ANDROID_SYSROOT_API}")
- set(_ANDROID_API_VAR CMAKE_SYSROOT)
-elseif(_ANDROID_STANDALONE_TOOLCHAIN_API)
- set(CMAKE_SYSTEM_VERSION "${_ANDROID_STANDALONE_TOOLCHAIN_API}")
-endif()
-if(CMAKE_SYSTEM_VERSION)
- if(CMAKE_ANDROID_API AND NOT "x${CMAKE_ANDROID_API}" STREQUAL "x${CMAKE_SYSTEM_VERSION}")
- message(FATAL_ERROR
- "Android: The API specified by CMAKE_ANDROID_API='${CMAKE_ANDROID_API}' is not consistent with CMAKE_SYSTEM_VERSION='${CMAKE_SYSTEM_VERSION}'."
- )
- endif()
- if(_ANDROID_SYSROOT_API)
- foreach(v CMAKE_ANDROID_API CMAKE_SYSTEM_VERSION)
- if(${v} AND NOT "x${_ANDROID_SYSROOT_API}" STREQUAL "x${${v}}")
- message(FATAL_ERROR
- "Android: The API specified by ${v}='${${v}}' is not consistent with CMAKE_SYSROOT:\n"
- " ${CMAKE_SYSROOT}"
- )
- endif()
- endforeach()
- endif()
- if(CMAKE_ANDROID_NDK AND NOT IS_DIRECTORY "${CMAKE_ANDROID_NDK}/platforms/android-${CMAKE_SYSTEM_VERSION}")
- message(FATAL_ERROR
- "Android: The API specified by ${_ANDROID_API_VAR}='${${_ANDROID_API_VAR}}' does not exist in the NDK. "
- "The directory:\n"
- " ${CMAKE_ANDROID_NDK}/platforms/android-${CMAKE_SYSTEM_VERSION}\n"
- "does not exist."
- )
- endif()
-elseif(CMAKE_ANDROID_NDK)
- file(GLOB _ANDROID_APIS_1 RELATIVE "${CMAKE_ANDROID_NDK}/platforms" "${CMAKE_ANDROID_NDK}/platforms/android-[0-9]")
- file(GLOB _ANDROID_APIS_2 RELATIVE "${CMAKE_ANDROID_NDK}/platforms" "${CMAKE_ANDROID_NDK}/platforms/android-[0-9][0-9]")
- list(SORT _ANDROID_APIS_1)
- list(SORT _ANDROID_APIS_2)
- set(_ANDROID_APIS ${_ANDROID_APIS_1} ${_ANDROID_APIS_2})
- unset(_ANDROID_APIS_1)
- unset(_ANDROID_APIS_2)
- if(_ANDROID_APIS STREQUAL "")
- message(FATAL_ERROR
- "Android: No APIs found in the NDK. No\n"
- " ${CMAKE_ANDROID_NDK}/platforms/android-*\n"
- "directories exist."
- )
- endif()
- string(REPLACE "android-" "" _ANDROID_APIS "${_ANDROID_APIS}")
- list(REVERSE _ANDROID_APIS)
- list(GET _ANDROID_APIS 0 CMAKE_SYSTEM_VERSION)
- unset(_ANDROID_APIS)
-endif()
-if(NOT CMAKE_SYSTEM_VERSION MATCHES "^[0-9]+$")
- message(FATAL_ERROR "Android: The API specified by CMAKE_SYSTEM_VERSION='${CMAKE_SYSTEM_VERSION}' is not an integer.")
+if(CMAKE_ANDROID_NDK)
+ # NDK >= 18 has platforms.cmake. It provides:
+ # NDK_MIN_PLATFORM_LEVEL
+ # NDK_MAX_PLATFORM_LEVEL
+ include("${CMAKE_ANDROID_NDK}/build/cmake/platforms.cmake" OPTIONAL RESULT_VARIABLE _INCLUDED_PLATFORMS)
+ # NDK >= 18 has abis.cmake. It provides:
+ # NDK_KNOWN_DEVICE_ABI32S
+ # NDK_KNOWN_DEVICE_ABI64S
+ # NDK >= 23 also provides:
+ # NDK_KNOWN_DEVICE_ABIS
+ # NDK_ABI_<abi>_PROC
+ # NDK_ABI_<abi>_ARCH
+ # NDK_ABI_<abi>_TRIPLE
+ # NDK_ABI_<abi>_LLVM_TRIPLE
+ # NDK_PROC_<processor>_ABI
+ # NDK_ARCH_<arch>_ABI
+ include("${CMAKE_ANDROID_NDK}/build/cmake/abis.cmake" OPTIONAL RESULT_VARIABLE _INCLUDED_ABIS)
endif()
if(CMAKE_ANDROID_NDK)
@@ -238,57 +203,76 @@ else()
set(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED "")
endif()
-# https://developer.android.com/ndk/guides/abis.html
-
-set(_ANDROID_ABI_arm64-v8a_PROC "aarch64")
-set(_ANDROID_ABI_arm64-v8a_ARCH "arm64")
-set(_ANDROID_ABI_arm64-v8a_TRIPLE "aarch64-linux-android")
-set(_ANDROID_ABI_armeabi-v7a_PROC "armv7-a")
-set(_ANDROID_ABI_armeabi-v7a_ARCH "arm")
-set(_ANDROID_ABI_armeabi-v7a_TRIPLE "arm-linux-androideabi")
-set(_ANDROID_ABI_armeabi-v6_PROC "armv6")
-set(_ANDROID_ABI_armeabi-v6_ARCH "arm")
-set(_ANDROID_ABI_armeabi-v6_TRIPLE "arm-linux-androideabi")
-set(_ANDROID_ABI_armeabi_PROC "armv5te")
-set(_ANDROID_ABI_armeabi_ARCH "arm")
-set(_ANDROID_ABI_armeabi_TRIPLE "arm-linux-androideabi")
-set(_ANDROID_ABI_mips_PROC "mips")
-set(_ANDROID_ABI_mips_ARCH "mips")
-set(_ANDROID_ABI_mips_TRIPLE "mipsel-linux-android")
-set(_ANDROID_ABI_mips64_PROC "mips64")
-set(_ANDROID_ABI_mips64_ARCH "mips64")
-set(_ANDROID_ABI_mips64_TRIPLE "mips64el-linux-android")
-set(_ANDROID_ABI_x86_PROC "i686")
-set(_ANDROID_ABI_x86_ARCH "x86")
-set(_ANDROID_ABI_x86_TRIPLE "i686-linux-android")
-set(_ANDROID_ABI_x86_64_PROC "x86_64")
-set(_ANDROID_ABI_x86_64_ARCH "x86_64")
-set(_ANDROID_ABI_x86_64_TRIPLE "x86_64-linux-android")
-
-set(_ANDROID_PROC_aarch64_ARCH_ABI "arm64-v8a")
-set(_ANDROID_PROC_armv7-a_ARCH_ABI "armeabi-v7a")
-set(_ANDROID_PROC_armv6_ARCH_ABI "armeabi-v6")
-set(_ANDROID_PROC_armv5te_ARCH_ABI "armeabi")
-set(_ANDROID_PROC_i686_ARCH_ABI "x86")
-set(_ANDROID_PROC_mips_ARCH_ABI "mips")
-set(_ANDROID_PROC_mips64_ARCH_ABI "mips64")
-set(_ANDROID_PROC_x86_64_ARCH_ABI "x86_64")
-
-set(_ANDROID_ARCH_arm64_ABI "arm64-v8a")
-set(_ANDROID_ARCH_arm_ABI "armeabi")
-set(_ANDROID_ARCH_mips_ABI "mips")
-set(_ANDROID_ARCH_mips64_ABI "mips64")
-set(_ANDROID_ARCH_x86_ABI "x86")
-set(_ANDROID_ARCH_x86_64_ABI "x86_64")
+if(_INCLUDED_ABIS)
+ if(NDK_KNOWN_DEVICE_ABIS)
+ set(_ANDROID_KNOWN_ABIS ${NDK_KNOWN_DEVICE_ABIS})
+ else()
+ set(_ANDROID_KNOWN_ABIS ${NDK_KNOWN_DEVICE_ABI32S} ${NDK_KNOWN_DEVICE_ABI64S})
+ endif()
+endif()
+
+if(NOT DEFINED NDK_KNOWN_DEVICE_ABIS)
+ # The NDK is not new enough to provide ABI information.
+ # https://developer.android.com/ndk/guides/abis.html
+
+ set(NDK_ABI_arm64-v8a_PROC "aarch64")
+ set(NDK_ABI_arm64-v8a_ARCH "arm64")
+ set(NDK_ABI_arm64-v8a_TRIPLE "aarch64-linux-android")
+ set(NDK_ABI_arm64-v8a_LLVM_TRIPLE "aarch64-none-linux-android")
+ set(NDK_ABI_armeabi-v7a_PROC "armv7-a")
+ set(NDK_ABI_armeabi-v7a_ARCH "arm")
+ set(NDK_ABI_armeabi-v7a_TRIPLE "arm-linux-androideabi")
+ set(NDK_ABI_armeabi-v7a_LLVM_TRIPLE "armv7-none-linux-androideabi")
+ set(NDK_ABI_armeabi-v6_PROC "armv6")
+ set(NDK_ABI_armeabi-v6_ARCH "arm")
+ set(NDK_ABI_armeabi-v6_TRIPLE "arm-linux-androideabi")
+ set(NDK_ABI_armeabi-v6_LLVM_TRIPLE "armv6-none-linux-androideabi")
+ set(NDK_ABI_armeabi_PROC "armv5te")
+ set(NDK_ABI_armeabi_ARCH "arm")
+ set(NDK_ABI_armeabi_TRIPLE "arm-linux-androideabi")
+ set(NDK_ABI_armeabi_LLVM_TRIPLE "armv5te-none-linux-androideabi")
+ set(NDK_ABI_mips_PROC "mips")
+ set(NDK_ABI_mips_ARCH "mips")
+ set(NDK_ABI_mips_TRIPLE "mipsel-linux-android")
+ set(NDK_ABI_mips_LLVM_TRIPLE "mipsel-none-linux-android")
+ set(NDK_ABI_mips64_PROC "mips64")
+ set(NDK_ABI_mips64_ARCH "mips64")
+ set(NDK_ABI_mips64_TRIPLE "mips64el-linux-android")
+ set(NDK_ABI_mips64_LLVM_TRIPLE "mips64el-none-linux-android")
+ set(NDK_ABI_x86_PROC "i686")
+ set(NDK_ABI_x86_ARCH "x86")
+ set(NDK_ABI_x86_TRIPLE "i686-linux-android")
+ set(NDK_ABI_x86_LLVM_TRIPLE "i686-none-linux-android")
+ set(NDK_ABI_x86_64_PROC "x86_64")
+ set(NDK_ABI_x86_64_ARCH "x86_64")
+ set(NDK_ABI_x86_64_TRIPLE "x86_64-linux-android")
+ set(NDK_ABI_x86_64_LLVM_TRIPLE "x86_64-none-linux-android")
+
+ set(NDK_PROC_aarch64_ABI "arm64-v8a")
+ set(NDK_PROC_armv7-a_ABI "armeabi-v7a")
+ set(NDK_PROC_armv6_ABI "armeabi-v6")
+ set(NDK_PROC_armv5te_ABI "armeabi")
+ set(NDK_PROC_i686_ABI "x86")
+ set(NDK_PROC_mips_ABI "mips")
+ set(NDK_PROC_mips64_ABI "mips64")
+ set(NDK_PROC_x86_64_ABI "x86_64")
+
+ set(NDK_ARCH_arm64_ABI "arm64-v8a")
+ set(NDK_ARCH_arm_ABI "armeabi")
+ set(NDK_ARCH_mips_ABI "mips")
+ set(NDK_ARCH_mips64_ABI "mips64")
+ set(NDK_ARCH_x86_ABI "x86")
+ set(NDK_ARCH_x86_64_ABI "x86_64")
+endif()
# Validate inputs.
-if(CMAKE_ANDROID_ARCH_ABI AND NOT DEFINED "_ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_PROC")
+if(CMAKE_ANDROID_ARCH_ABI AND NOT DEFINED "NDK_ABI_${CMAKE_ANDROID_ARCH_ABI}_PROC")
message(FATAL_ERROR "Android: Unknown ABI CMAKE_ANDROID_ARCH_ABI='${CMAKE_ANDROID_ARCH_ABI}'.")
endif()
-if(CMAKE_SYSTEM_PROCESSOR AND NOT DEFINED "_ANDROID_PROC_${CMAKE_SYSTEM_PROCESSOR}_ARCH_ABI")
+if(CMAKE_SYSTEM_PROCESSOR AND NOT DEFINED "NDK_PROC_${CMAKE_SYSTEM_PROCESSOR}_ABI")
message(FATAL_ERROR "Android: Unknown processor CMAKE_SYSTEM_PROCESSOR='${CMAKE_SYSTEM_PROCESSOR}'.")
endif()
-if(_ANDROID_SYSROOT_ARCH AND NOT DEFINED "_ANDROID_ARCH_${_ANDROID_SYSROOT_ARCH}_ABI")
+if(_ANDROID_SYSROOT_ARCH AND NOT DEFINED "NDK_ARCH_${_ANDROID_SYSROOT_ARCH}_ABI")
message(FATAL_ERROR
"Android: Unknown architecture '${_ANDROID_SYSROOT_ARCH}' specified in CMAKE_SYSROOT:\n"
" ${CMAKE_SYSROOT}"
@@ -298,9 +282,22 @@ endif()
# Select an ABI.
if(NOT CMAKE_ANDROID_ARCH_ABI)
if(CMAKE_SYSTEM_PROCESSOR)
- set(CMAKE_ANDROID_ARCH_ABI "${_ANDROID_PROC_${CMAKE_SYSTEM_PROCESSOR}_ARCH_ABI}")
+ set(CMAKE_ANDROID_ARCH_ABI "${NDK_PROC_${CMAKE_SYSTEM_PROCESSOR}_ABI}")
elseif(_ANDROID_SYSROOT_ARCH)
- set(CMAKE_ANDROID_ARCH_ABI "${_ANDROID_ARCH_${_ANDROID_SYSROOT_ARCH}_ABI}")
+ set(CMAKE_ANDROID_ARCH_ABI "${NDK_ARCH_${_ANDROID_SYSROOT_ARCH}_ABI}")
+ elseif(_INCLUDED_ABIS)
+ # Default to the oldest ARM ABI.
+ foreach(abi armeabi armeabi-v7a arm64-v8a)
+ if("${abi}" IN_LIST _ANDROID_KNOWN_ABIS)
+ set(CMAKE_ANDROID_ARCH_ABI "${abi}")
+ break()
+ endif()
+ endforeach()
+ if(NOT CMAKE_ANDROID_ARCH_ABI)
+ message(FATAL_ERROR
+ "Android: Can not determine the default ABI. Please set CMAKE_ANDROID_ARCH_ABI."
+ )
+ endif()
else()
# https://developer.android.com/ndk/guides/application_mk.html
# Default is the oldest ARM ABI.
@@ -323,15 +320,12 @@ if(NOT CMAKE_ANDROID_ARCH_ABI)
# Choose the oldest among the available arm ABIs.
if(_ANDROID_ABIS)
list(REMOVE_DUPLICATES _ANDROID_ABIS)
- cmake_policy(PUSH)
- cmake_policy(SET CMP0057 NEW)
foreach(abi armeabi armeabi-v7a arm64-v8a)
if("${abi}" IN_LIST _ANDROID_ABIS)
set(CMAKE_ANDROID_ARCH_ABI "${abi}")
break()
endif()
endforeach()
- cmake_policy(POP)
endif()
unset(_ANDROID_ABIS)
@@ -340,7 +334,13 @@ if(NOT CMAKE_ANDROID_ARCH_ABI)
endif()
endif()
endif()
-set(CMAKE_ANDROID_ARCH "${_ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_ARCH}")
+if(_INCLUDED_ABIS AND NOT CMAKE_ANDROID_ARCH_ABI IN_LIST _ANDROID_KNOWN_ABIS)
+ message(FATAL_ERROR
+ "Android: ABI '${CMAKE_ANDROID_ARCH_ABI}' is not supported by the NDK.\n"
+ "Supported ABIS: ${_ANDROID_KNOWN_ABIS}."
+ )
+endif()
+set(CMAKE_ANDROID_ARCH "${NDK_ABI_${CMAKE_ANDROID_ARCH_ABI}_ARCH}")
if(_ANDROID_SYSROOT_ARCH AND NOT "x${_ANDROID_SYSROOT_ARCH}" STREQUAL "x${CMAKE_ANDROID_ARCH}")
message(FATAL_ERROR
"Android: Architecture '${_ANDROID_SYSROOT_ARCH}' specified in CMAKE_SYSROOT:\n"
@@ -348,18 +348,102 @@ if(_ANDROID_SYSROOT_ARCH AND NOT "x${_ANDROID_SYSROOT_ARCH}" STREQUAL "x${CMAKE_
"does not match architecture '${CMAKE_ANDROID_ARCH}' for the ABI '${CMAKE_ANDROID_ARCH_ABI}'."
)
endif()
-set(CMAKE_ANDROID_ARCH_TRIPLE "${_ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_TRIPLE}")
+set(CMAKE_ANDROID_ARCH_TRIPLE "${NDK_ABI_${CMAKE_ANDROID_ARCH_ABI}_TRIPLE}")
+set(CMAKE_ANDROID_ARCH_LLVM_TRIPLE
+ "${NDK_ABI_${CMAKE_ANDROID_ARCH_ABI}_LLVM_TRIPLE}")
# Select a processor.
if(NOT CMAKE_SYSTEM_PROCESSOR)
- set(CMAKE_SYSTEM_PROCESSOR "${_ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_PROC}")
+ set(CMAKE_SYSTEM_PROCESSOR "${NDK_ABI_${CMAKE_ANDROID_ARCH_ABI}_PROC}")
endif()
# If the user specified both an ABI and a processor then they might not match.
-if(NOT _ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_PROC STREQUAL CMAKE_SYSTEM_PROCESSOR)
+if(NOT NDK_ABI_${CMAKE_ANDROID_ARCH_ABI}_PROC STREQUAL CMAKE_SYSTEM_PROCESSOR)
message(FATAL_ERROR "Android: The specified CMAKE_ANDROID_ARCH_ABI='${CMAKE_ANDROID_ARCH_ABI}' and CMAKE_SYSTEM_PROCESSOR='${CMAKE_SYSTEM_PROCESSOR}' is not a valid combination.")
endif()
+# Select an API.
+if(CMAKE_SYSTEM_VERSION)
+ set(_ANDROID_API_VAR CMAKE_SYSTEM_VERSION)
+elseif(CMAKE_ANDROID_API)
+ set(CMAKE_SYSTEM_VERSION "${CMAKE_ANDROID_API}")
+ set(_ANDROID_API_VAR CMAKE_ANDROID_API)
+elseif(_ANDROID_SYSROOT_API)
+ set(CMAKE_SYSTEM_VERSION "${_ANDROID_SYSROOT_API}")
+ set(_ANDROID_API_VAR CMAKE_SYSROOT)
+elseif(_ANDROID_STANDALONE_TOOLCHAIN_API)
+ set(CMAKE_SYSTEM_VERSION "${_ANDROID_STANDALONE_TOOLCHAIN_API}")
+endif()
+if(CMAKE_SYSTEM_VERSION)
+ if(CMAKE_ANDROID_API AND NOT "x${CMAKE_ANDROID_API}" STREQUAL "x${CMAKE_SYSTEM_VERSION}")
+ message(FATAL_ERROR
+ "Android: The API specified by CMAKE_ANDROID_API='${CMAKE_ANDROID_API}' is not consistent with CMAKE_SYSTEM_VERSION='${CMAKE_SYSTEM_VERSION}'."
+ )
+ endif()
+ if(_ANDROID_SYSROOT_API)
+ foreach(v CMAKE_ANDROID_API CMAKE_SYSTEM_VERSION)
+ if(${v} AND NOT "x${_ANDROID_SYSROOT_API}" STREQUAL "x${${v}}")
+ message(FATAL_ERROR
+ "Android: The API specified by ${v}='${${v}}' is not consistent with CMAKE_SYSROOT:\n"
+ " ${CMAKE_SYSROOT}"
+ )
+ endif()
+ endforeach()
+ endif()
+ if(CMAKE_ANDROID_NDK)
+ if (_INCLUDED_PLATFORMS)
+ if(CMAKE_SYSTEM_VERSION GREATER NDK_MAX_PLATFORM_LEVEL OR
+ CMAKE_SYSTEM_VERSION LESS NDK_MIN_PLATFORM_LEVEL)
+ message(FATAL_ERROR
+ "Android: The API level ${CMAKE_SYSTEM_VERSION} is not supported by the NDK.\n"
+ "Choose one in the range of [${NDK_MIN_PLATFORM_LEVEL}, ${NDK_MAX_PLATFORM_LEVEL}]."
+ )
+ endif()
+ else()
+ if(NOT IS_DIRECTORY "${CMAKE_ANDROID_NDK}/platforms/android-${CMAKE_SYSTEM_VERSION}")
+ message(FATAL_ERROR
+ "Android: The API specified by ${_ANDROID_API_VAR}='${${_ANDROID_API_VAR}}' does not exist in the NDK. "
+ "The directory:\n"
+ " ${CMAKE_ANDROID_NDK}/platforms/android-${CMAKE_SYSTEM_VERSION}\n"
+ "does not exist."
+ )
+ endif()
+ endif()
+ endif()
+elseif(CMAKE_ANDROID_NDK)
+ if (_INCLUDED_PLATFORMS)
+ set(CMAKE_SYSTEM_VERSION ${NDK_MIN_PLATFORM_LEVEL})
+ # And for LP64 we need to pull up to 21. No diagnostic is provided here because
+ # minSdkVersion < 21 is valid for the project even though it may not be for this
+ # ABI.
+ if(CMAKE_ANDROID_ARCH_ABI MATCHES "64(-v8a)?$" AND CMAKE_SYSTEM_VERSION LESS 21)
+ set(CMAKE_SYSTEM_VERSION 21)
+ endif()
+ else()
+ file(GLOB _ANDROID_APIS_1 RELATIVE "${CMAKE_ANDROID_NDK}/platforms" "${CMAKE_ANDROID_NDK}/platforms/android-[0-9]")
+ file(GLOB _ANDROID_APIS_2 RELATIVE "${CMAKE_ANDROID_NDK}/platforms" "${CMAKE_ANDROID_NDK}/platforms/android-[0-9][0-9]")
+ list(SORT _ANDROID_APIS_1)
+ list(SORT _ANDROID_APIS_2)
+ set(_ANDROID_APIS ${_ANDROID_APIS_1} ${_ANDROID_APIS_2})
+ unset(_ANDROID_APIS_1)
+ unset(_ANDROID_APIS_2)
+ if(_ANDROID_APIS STREQUAL "")
+ message(FATAL_ERROR
+ "Android: No APIs found in the NDK. No\n"
+ " ${CMAKE_ANDROID_NDK}/platforms/android-*\n"
+ "directories exist."
+ )
+ endif()
+ string(REPLACE "android-" "" _ANDROID_APIS "${_ANDROID_APIS}")
+ list(REVERSE _ANDROID_APIS)
+ list(GET _ANDROID_APIS 0 CMAKE_SYSTEM_VERSION)
+ unset(_ANDROID_APIS)
+ endif()
+endif()
+if(NOT CMAKE_SYSTEM_VERSION MATCHES "^[0-9]+$")
+ message(FATAL_ERROR "Android: The API specified by CMAKE_SYSTEM_VERSION='${CMAKE_SYSTEM_VERSION}' is not an integer.")
+endif()
+
if(CMAKE_ANDROID_NDK AND NOT DEFINED CMAKE_ANDROID_NDK_DEPRECATED_HEADERS)
if(IS_DIRECTORY "${CMAKE_ANDROID_NDK}/sysroot/usr/include/${CMAKE_ANDROID_ARCH_TRIPLE}")
# Unified headers exist so we use them by default.
@@ -381,6 +465,7 @@ set(CMAKE_ANDROID_ARCH_ABI \"${CMAKE_ANDROID_ARCH_ABI}\")
if(CMAKE_ANDROID_NDK)
string(APPEND CMAKE_SYSTEM_CUSTOM_CODE
"set(CMAKE_ANDROID_ARCH_TRIPLE \"${CMAKE_ANDROID_ARCH_TRIPLE}\")\n"
+ "set(CMAKE_ANDROID_ARCH_LLVM_TRIPLE \"${CMAKE_ANDROID_ARCH_LLVM_TRIPLE}\")\n"
"set(CMAKE_ANDROID_NDK_DEPRECATED_HEADERS \"${CMAKE_ANDROID_NDK_DEPRECATED_HEADERS}\")\n"
"set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG \"${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}\")\n"
"set(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED \"${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}\")\n"
@@ -418,3 +503,9 @@ endif()
message(STATUS "Android: Targeting API '${CMAKE_SYSTEM_VERSION}' with architecture '${CMAKE_ANDROID_ARCH}', ABI '${CMAKE_ANDROID_ARCH_ABI}', and processor '${CMAKE_SYSTEM_PROCESSOR}'")
cmake_policy(POP)
+
+# Include the NDK hook.
+# It can be used by NDK to inject necessary fixes for an earlier cmake.
+if(CMAKE_ANDROID_NDK)
+ include(${CMAKE_ANDROID_NDK}/build/cmake/hooks/post/Android-Determine.cmake OPTIONAL)
+endif()