Android: Add `ANDROID` variable to indicate the target

Allow projects to use `if(ANDROID)` to condition their Android-specific
code paths.
This commit is contained in:
Brad King 2016-08-23 13:08:53 -04:00
parent c2f561e58c
commit 7b637ebdc9
4 changed files with 12 additions and 0 deletions

View File

@ -173,6 +173,7 @@ Variables that Describe the System
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
/variable/ANDROID
/variable/APPLE /variable/APPLE
/variable/BORLAND /variable/BORLAND
/variable/CMAKE_CL_64 /variable/CMAKE_CL_64

View File

@ -0,0 +1,5 @@
ANDROID
-------
Set to ``1`` when the target system (:variable:`CMAKE_SYSTEM_NAME`) is
``Android``.

View File

@ -1,5 +1,7 @@
include(Platform/Linux) include(Platform/Linux)
set(ANDROID 1)
# Android has soname, but binary names must end in ".so" so we cannot append # Android has soname, but binary names must end in ".so" so we cannot append
# a version number. Also we cannot portably represent symlinks on the host. # a version number. Also we cannot portably represent symlinks on the host.
set(CMAKE_PLATFORM_NO_VERSIONED_SONAME 1) set(CMAKE_PLATFORM_NO_VERSIONED_SONAME 1)

View File

@ -1,6 +1,10 @@
enable_language(C) enable_language(C)
enable_language(CXX) enable_language(CXX)
if(NOT ANDROID)
message(SEND_ERROR "CMake variable 'ANDROID' is not set to a true value.")
endif()
foreach(f foreach(f
"${CMAKE_C_ANDROID_TOOLCHAIN_PREFIX}gcc${CMAKE_C_ANDROID_TOOLCHAIN_SUFFIX}" "${CMAKE_C_ANDROID_TOOLCHAIN_PREFIX}gcc${CMAKE_C_ANDROID_TOOLCHAIN_SUFFIX}"
"${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}g++${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}" "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}g++${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}"