Android: add support for native compilation, such as with the Termux app

The CMake support for Android assumes cross-compilation using the NDK,
so stub out that Android NDK support and use the Linux support that's
already invoked. Set CMAKE_HOST_SYSTEM_NAME to "Android", rather than
"Linux".

Issue: #19840
This commit is contained in:
Butta
2019-10-15 13:24:02 +05:30
parent daf6a6ba68
commit c5892e484e
7 changed files with 40 additions and 1 deletions

View File

@@ -24,6 +24,12 @@ if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
return()
endif()
# Natively compiling on an Android host doesn't use the NDK cross-compilation
# tools.
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Android")
return()
endif()
if(NOT CMAKE_SYSROOT)
if(CMAKE_ANDROID_NDK)
set(CMAKE_SYSROOT "${CMAKE_ANDROID_NDK}/platforms/android-${CMAKE_SYSTEM_VERSION}/arch-${CMAKE_ANDROID_ARCH}")