Browse Source
CMAKE_SYSTEM_NAME by default, then disable CMake's built-in NDK support when CMAKE_SYSTEM_NAME is set to Android.android-5
Butta
5 years ago
committed by
Fredrik Fornwall
8 changed files with 115 additions and 0 deletions
@ -0,0 +1,13 @@ |
|||||
|
diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake
|
||||
|
index dc208c600..f3ec4da2d 100644
|
||||
|
--- a/Modules/CMakeDetermineSystem.cmake
|
||||
|
+++ b/Modules/CMakeDetermineSystem.cmake
|
||||
|
@@ -43,7 +43,7 @@ if(CMAKE_HOST_UNIX)
|
||||
|
else() |
||||
|
exec_program(${CMAKE_UNAME} ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION) |
||||
|
endif() |
||||
|
- if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|CYGWIN.*|Darwin|^GNU$")
|
||||
|
+ if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|CYGWIN.*|Darwin|^GNU$|Android")
|
||||
|
exec_program(${CMAKE_UNAME} ARGS -m OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR |
||||
|
RETURN_VALUE val) |
||||
|
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" AND |
@ -0,0 +1,17 @@ |
|||||
|
diff --git a/Modules/Platform/Android-Clang.cmake b/Modules/Platform/Android-Clang.cmake
|
||||
|
index 9ed1e01f9..6443512ee 100644
|
||||
|
--- a/Modules/Platform/Android-Clang.cmake
|
||||
|
+++ b/Modules/Platform/Android-Clang.cmake
|
||||
|
@@ -24,6 +24,12 @@ if(CMAKE_SYSTEM_VERSION EQUAL 1)
|
||||
|
return() |
||||
|
endif() |
||||
|
|
||||
|
+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: |
@ -0,0 +1,19 @@ |
|||||
|
diff --git a/Modules/Platform/Android/Determine-Compiler.cmake b/Modules/Platform/Android/Determine-Compiler.cmake
|
||||
|
index a03ebcc29..34d527741 100644
|
||||
|
--- a/Modules/Platform/Android/Determine-Compiler.cmake
|
||||
|
+++ b/Modules/Platform/Android/Determine-Compiler.cmake
|
||||
|
@@ -31,6 +31,14 @@ 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")
|
||||
|
+ 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() |
@ -0,0 +1,15 @@ |
|||||
|
diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake
|
||||
|
index bb42eedde..0e8229d5e 100644
|
||||
|
--- a/Modules/Platform/Android-Determine.cmake
|
||||
|
+++ b/Modules/Platform/Android-Determine.cmake
|
||||
|
@@ -18,6 +18,10 @@ if(CMAKE_SYSTEM_VERSION EQUAL 1)
|
||||
|
return() |
||||
|
endif() |
||||
|
|
||||
|
+if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Android")
|
||||
|
+ return()
|
||||
|
+endif()
|
||||
|
+
|
||||
|
cmake_policy(PUSH) |
||||
|
cmake_policy(SET CMP0057 NEW) # if IN_LIST |
||||
|
|
@ -0,0 +1,15 @@ |
|||||
|
diff --git a/Modules/Platform/Android-Initialize.cmake b/Modules/Platform/Android-Initialize.cmake
|
||||
|
index a434f90ea..407ed3358 100644
|
||||
|
--- a/Modules/Platform/Android-Initialize.cmake
|
||||
|
+++ b/Modules/Platform/Android-Initialize.cmake
|
||||
|
@@ -17,6 +17,10 @@ if(CMAKE_SYSTEM_VERSION EQUAL 1)
|
||||
|
return() |
||||
|
endif() |
||||
|
|
||||
|
+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}") |
@ -0,0 +1,15 @@ |
|||||
|
diff --git a/Modules/Platform/Android.cmake b/Modules/Platform/Android.cmake
|
||||
|
index f08f84176..9e719df39 100644
|
||||
|
--- a/Modules/Platform/Android.cmake
|
||||
|
+++ b/Modules/Platform/Android.cmake
|
||||
|
@@ -2,6 +2,10 @@ include(Platform/Linux)
|
||||
|
|
||||
|
set(ANDROID 1) |
||||
|
|
||||
|
+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) |
@ -0,0 +1,20 @@ |
|||||
|
diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx
|
||||
|
index 63bec710b..19286c50e 100644
|
||||
|
--- a/Source/cmStateSnapshot.cxx
|
||||
|
+++ b/Source/cmStateSnapshot.cxx
|
||||
|
@@ -316,11 +316,15 @@ void cmStateSnapshot::SetDefaultDefinitions()
|
||||
|
this->SetDefinition("UNIX", "1"); |
||||
|
this->SetDefinition("CMAKE_HOST_UNIX", "1"); |
||||
|
|
||||
|
+#if defined(__ANDROID__)
|
||||
|
+ this->SetDefinition("CMAKE_HOST_SYSTEM_NAME", "Android");
|
||||
|
+#else
|
||||
|
struct utsname uts_name; |
||||
|
if (uname(&uts_name) >= 0) { |
||||
|
this->SetDefinition("CMAKE_HOST_SYSTEM_NAME", uts_name.sysname); |
||||
|
} |
||||
|
#endif |
||||
|
+#endif
|
||||
|
#if defined(__CYGWIN__) |
||||
|
std::string legacy; |
||||
|
if (cmSystemTools::GetEnv("CMAKE_LEGACY_CYGWIN_WIN32", legacy) && |
Loading…
Reference in new issue