summaryrefslogtreecommitdiffstats
path: root/Modules/Platform/Android-Determine.cmake
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2020-10-07 22:54:17 (GMT)
committerHaibo Huang <hhb@google.com>2020-10-07 23:13:56 (GMT)
commit0b082c5253239351ab022a0509e8e5c3b43282bc (patch)
tree6964734e2448a4292e4c47fac13884720386a54d /Modules/Platform/Android-Determine.cmake
parenta354440de997a84351967950510cce029d9fe065 (diff)
downloadCMake-0b082c5253239351ab022a0509e8e5c3b43282bc.zip
CMake-0b082c5253239351ab022a0509e8e5c3b43282bc.tar.gz
CMake-0b082c5253239351ab022a0509e8e5c3b43282bc.tar.bz2
Android: Select Android API after ABI is determined
API level depends on ABI. E.g. for LP64 the minimum API level should be 21 instead of 16 for others.
Diffstat (limited to 'Modules/Platform/Android-Determine.cmake')
-rw-r--r--Modules/Platform/Android-Determine.cmake120
1 files changed, 60 insertions, 60 deletions
diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake
index 11a0504..59056f1 100644
--- a/Modules/Platform/Android-Determine.cmake
+++ b/Modules/Platform/Android-Determine.cmake
@@ -201,66 +201,6 @@ 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.")
-endif()
-
if(CMAKE_ANDROID_NDK)
# Identify the host platform.
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
@@ -417,6 +357,66 @@ if(NOT _ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_PROC STREQUAL CMAKE_SYSTEM_PROCESS
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 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.")
+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.