summaryrefslogtreecommitdiff
path: root/Modules/Platform
diff options
context:
space:
mode:
authorButta <gl@butta.fastem.com>2019-10-15 13:24:02 +0530
committerButta <gl@butta.fastem.com>2019-10-15 21:13:51 +0530
commitc5892e484e21f49abf2afd138dddd6720bf91adc (patch)
tree71895167fb4b068785a68f06c0a5ca339df57eca /Modules/Platform
parentdaf6a6ba68a6fa1c5d1956f151104d903f3447cc (diff)
downloadcmake-c5892e484e21f49abf2afd138dddd6720bf91adc.tar.gz
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
Diffstat (limited to 'Modules/Platform')
-rw-r--r--Modules/Platform/Android-Clang.cmake8
-rw-r--r--Modules/Platform/Android-Determine.cmake6
-rw-r--r--Modules/Platform/Android-Initialize.cmake6
-rw-r--r--Modules/Platform/Android.cmake5
-rw-r--r--Modules/Platform/Android/Determine-Compiler.cmake10
5 files changed, 35 insertions, 0 deletions
diff --git a/Modules/Platform/Android-Clang.cmake b/Modules/Platform/Android-Clang.cmake
index 847178fbd4..759448b8ec 100644
--- a/Modules/Platform/Android-Clang.cmake
+++ b/Modules/Platform/Android-Clang.cmake
@@ -24,6 +24,14 @@ if(CMAKE_SYSTEM_VERSION EQUAL 1)
return()
endif()
+# Natively compiling on an Android host doesn't use the NDK cross-compilation
+# tools.
+if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Android")
+ macro(__android_compiler_clang lang)
+ endmacro()
+ return()
+endif()
+
include(Platform/Android-Common)
# The NDK toolchain configuration files at:
diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake
index e7c1b48a94..2225897fab 100644
--- a/Modules/Platform/Android-Determine.cmake
+++ b/Modules/Platform/Android-Determine.cmake
@@ -18,6 +18,12 @@ if(CMAKE_SYSTEM_VERSION EQUAL 1)
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()
+
cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW) # if IN_LIST
diff --git a/Modules/Platform/Android-Initialize.cmake b/Modules/Platform/Android-Initialize.cmake
index a5d282085e..b90dd7a569 100644
--- a/Modules/Platform/Android-Initialize.cmake
+++ b/Modules/Platform/Android-Initialize.cmake
@@ -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}")
diff --git a/Modules/Platform/Android.cmake b/Modules/Platform/Android.cmake
index f08f84176d..8ffa1b2d3b 100644
--- a/Modules/Platform/Android.cmake
+++ b/Modules/Platform/Android.cmake
@@ -2,6 +2,11 @@ include(Platform/Linux)
set(ANDROID 1)
+# Natively compiling on an Android host doesn't need these flags to be reset.
+if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Android")
+ return()
+endif()
+
# Conventionally Android does not use versioned soname
# But in modern versions it is acceptable
if(NOT DEFINED CMAKE_PLATFORM_NO_VERSIONED_SONAME)
diff --git a/Modules/Platform/Android/Determine-Compiler.cmake b/Modules/Platform/Android/Determine-Compiler.cmake
index 5c6b97b8bc..f9c2d8968a 100644
--- a/Modules/Platform/Android/Determine-Compiler.cmake
+++ b/Modules/Platform/Android/Determine-Compiler.cmake
@@ -31,6 +31,16 @@ elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
set(_ANDROID_HOST_EXT "")
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set(_ANDROID_HOST_EXT ".exe")
+elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Android")
+ # Natively compiling on an Android host doesn't use the NDK cross-compilation
+ # tools.
+ macro(__android_determine_compiler lang)
+ # Do nothing
+ endmacro()
+ if(NOT CMAKE_CXX_COMPILER_NAMES)
+ set(CMAKE_CXX_COMPILER_NAMES c++)
+ endif()
+ return()
else()
message(FATAL_ERROR "Android: Builds hosted on '${CMAKE_HOST_SYSTEM_NAME}' not supported.")
endif()