summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/manual/cmake-toolchains.7.rst204
-rw-r--r--Help/manual/cmake-variables.7.rst9
-rw-r--r--Help/prop_tgt/ANDROID_API.rst9
-rw-r--r--Help/prop_tgt/ANDROID_ARCH.rst3
-rw-r--r--Help/prop_tgt/ANDROID_GUI.rst4
-rw-r--r--Help/prop_tgt/ANDROID_STL_TYPE.rst32
-rw-r--r--Help/release/dev/android-platform-modules.rst5
-rw-r--r--Help/variable/ANDROID.rst5
-rw-r--r--Help/variable/CMAKE_ANDROID_API.rst10
-rw-r--r--Help/variable/CMAKE_ANDROID_ARCH.rst18
-rw-r--r--Help/variable/CMAKE_ANDROID_ARCH_ABI.rst17
-rw-r--r--Help/variable/CMAKE_ANDROID_ARM_MODE.rst7
-rw-r--r--Help/variable/CMAKE_ANDROID_ARM_NEON.rst6
-rw-r--r--Help/variable/CMAKE_ANDROID_NDK.rst7
-rw-r--r--Help/variable/CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION.rst13
-rw-r--r--Help/variable/CMAKE_ANDROID_STANDALONE_TOOLCHAIN.rst6
-rw-r--r--Help/variable/CMAKE_ANDROID_STL_TYPE.rst35
-rw-r--r--Help/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_PREFIX.rst11
-rw-r--r--Help/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_SUFFIX.rst7
-rw-r--r--Modules/CMakeCCompiler.cmake.in1
-rw-r--r--Modules/CMakeCXXCompiler.cmake.in1
-rw-r--r--Modules/CMakeDetermineSystem.cmake1
-rw-r--r--Modules/CMakeFortranCompiler.cmake.in2
-rw-r--r--Modules/CMakeSystem.cmake.in2
-rw-r--r--Modules/Platform/Android-Clang-C.cmake2
-rw-r--r--Modules/Platform/Android-Clang-CXX.cmake2
-rw-r--r--Modules/Platform/Android-Clang.cmake52
-rw-r--r--Modules/Platform/Android-Common.cmake158
-rw-r--r--Modules/Platform/Android-Determine-C.cmake2
-rw-r--r--Modules/Platform/Android-Determine-CXX.cmake2
-rw-r--r--Modules/Platform/Android-Determine.cmake301
-rw-r--r--Modules/Platform/Android-GNU-C.cmake2
-rw-r--r--Modules/Platform/Android-GNU-CXX.cmake2
-rw-r--r--Modules/Platform/Android-GNU.cmake43
-rw-r--r--Modules/Platform/Android-Initialize.cmake51
-rw-r--r--Modules/Platform/Android.cmake2
-rw-r--r--Modules/Platform/Android/Determine-Compiler-NDK.cmake256
-rw-r--r--Modules/Platform/Android/Determine-Compiler-Standalone.cmake69
-rw-r--r--Modules/Platform/Android/Determine-Compiler.cmake80
-rw-r--r--Modules/Platform/Android/abi-arm64-v8a-Clang.cmake8
-rw-r--r--Modules/Platform/Android/abi-arm64-v8a-GNU.cmake6
-rw-r--r--Modules/Platform/Android/abi-armeabi-Clang.cmake20
-rw-r--r--Modules/Platform/Android/abi-armeabi-GNU.cmake18
-rw-r--r--Modules/Platform/Android/abi-armeabi-v6-Clang.cmake19
-rw-r--r--Modules/Platform/Android/abi-armeabi-v6-GNU.cmake17
-rw-r--r--Modules/Platform/Android/abi-armeabi-v7a-Clang.cmake29
-rw-r--r--Modules/Platform/Android/abi-armeabi-v7a-GNU.cmake27
-rw-r--r--Modules/Platform/Android/abi-common-Clang.cmake6
-rw-r--r--Modules/Platform/Android/abi-common-GNU.cmake1
-rw-r--r--Modules/Platform/Android/abi-common.cmake4
-rw-r--r--Modules/Platform/Android/abi-mips-Clang.cmake8
-rw-r--r--Modules/Platform/Android/abi-mips-GNU.cmake6
-rw-r--r--Modules/Platform/Android/abi-mips64-Clang.cmake8
-rw-r--r--Modules/Platform/Android/abi-mips64-GNU.cmake6
-rw-r--r--Modules/Platform/Android/abi-x86-Clang.cmake8
-rw-r--r--Modules/Platform/Android/abi-x86-GNU.cmake2
-rw-r--r--Modules/Platform/Android/abi-x86_64-Clang.cmake8
-rw-r--r--Modules/Platform/Android/abi-x86_64-GNU.cmake2
-rw-r--r--Modules/Platform/Android/ndk-stl-c++.cmake13
-rw-r--r--Modules/Platform/Android/ndk-stl-c++_shared.cmake4
-rw-r--r--Modules/Platform/Android/ndk-stl-c++_static.cmake6
-rw-r--r--Modules/Platform/Android/ndk-stl-gabi++.cmake7
-rw-r--r--Modules/Platform/Android/ndk-stl-gabi++_shared.cmake4
-rw-r--r--Modules/Platform/Android/ndk-stl-gabi++_static.cmake4
-rw-r--r--Modules/Platform/Android/ndk-stl-gnustl.cmake9
-rw-r--r--Modules/Platform/Android/ndk-stl-gnustl_shared.cmake4
-rw-r--r--Modules/Platform/Android/ndk-stl-gnustl_static.cmake4
-rw-r--r--Modules/Platform/Android/ndk-stl-none.cmake2
-rw-r--r--Modules/Platform/Android/ndk-stl-stlport.cmake7
-rw-r--r--Modules/Platform/Android/ndk-stl-stlport_shared.cmake4
-rw-r--r--Modules/Platform/Android/ndk-stl-stlport_static.cmake4
-rw-r--r--Modules/Platform/Android/ndk-stl-system.cmake6
-rw-r--r--Tests/RunCMake/Android/BadSYSROOT-result.txt1
-rw-r--r--Tests/RunCMake/Android/BadSYSROOT-stderr.txt20
-rw-r--r--Tests/RunCMake/Android/BadSYSROOT.cmake0
-rw-r--r--Tests/RunCMake/Android/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/Android/RunCMakeTest.cmake218
-rw-r--r--Tests/RunCMake/Android/android.c6
-rw-r--r--Tests/RunCMake/Android/android.cxx45
-rw-r--r--Tests/RunCMake/Android/android.h103
-rw-r--r--Tests/RunCMake/Android/common.cmake60
-rw-r--r--Tests/RunCMake/Android/ndk-arm64-v8a-stdout.txt2
-rw-r--r--Tests/RunCMake/Android/ndk-arm64-v8a.cmake1
-rw-r--r--Tests/RunCMake/Android/ndk-armeabi-arm-stdout.txt3
-rw-r--r--Tests/RunCMake/Android/ndk-armeabi-arm.cmake1
-rw-r--r--Tests/RunCMake/Android/ndk-armeabi-thumb-stdout.txt3
-rw-r--r--Tests/RunCMake/Android/ndk-armeabi-thumb.cmake1
-rw-r--r--Tests/RunCMake/Android/ndk-armeabi-v7a-neon-stdout.txt3
-rw-r--r--Tests/RunCMake/Android/ndk-armeabi-v7a-neon.cmake1
-rw-r--r--Tests/RunCMake/Android/ndk-armeabi-v7a-stdout.txt3
-rw-r--r--Tests/RunCMake/Android/ndk-armeabi-v7a.cmake1
-rw-r--r--Tests/RunCMake/Android/ndk-badabi-result.txt1
-rw-r--r--Tests/RunCMake/Android/ndk-badabi-stderr.txt5
-rw-r--r--Tests/RunCMake/Android/ndk-badabi.cmake0
-rw-r--r--Tests/RunCMake/Android/ndk-badarm-result.txt1
-rw-r--r--Tests/RunCMake/Android/ndk-badarm-stderr.txt6
-rw-r--r--Tests/RunCMake/Android/ndk-badarm.cmake0
-rw-r--r--Tests/RunCMake/Android/ndk-badneon-result.txt1
-rw-r--r--Tests/RunCMake/Android/ndk-badneon-stderr.txt6
-rw-r--r--Tests/RunCMake/Android/ndk-badneon.cmake0
-rw-r--r--Tests/RunCMake/Android/ndk-badstl-result.txt1
-rw-r--r--Tests/RunCMake/Android/ndk-badstl-stderr.txt9
-rw-r--r--Tests/RunCMake/Android/ndk-badstl.cmake1
-rw-r--r--Tests/RunCMake/Android/ndk-badver-result.txt1
-rw-r--r--Tests/RunCMake/Android/ndk-badver-stderr.txt12
-rw-r--r--Tests/RunCMake/Android/ndk-badver.cmake1
-rw-r--r--Tests/RunCMake/Android/ndk-badvernum-result.txt1
-rw-r--r--Tests/RunCMake/Android/ndk-badvernum-stderr.txt13
-rw-r--r--Tests/RunCMake/Android/ndk-badvernum.cmake1
-rw-r--r--Tests/RunCMake/Android/ndk-mips-stdout.txt2
-rw-r--r--Tests/RunCMake/Android/ndk-mips.cmake1
-rw-r--r--Tests/RunCMake/Android/ndk-mips64-stdout.txt2
-rw-r--r--Tests/RunCMake/Android/ndk-mips64.cmake1
-rw-r--r--Tests/RunCMake/Android/ndk-sysroot-armeabi-stdout.txt1
-rw-r--r--Tests/RunCMake/Android/ndk-sysroot-armeabi.cmake0
-rw-r--r--Tests/RunCMake/Android/ndk-x86-stdout.txt2
-rw-r--r--Tests/RunCMake/Android/ndk-x86.cmake1
-rw-r--r--Tests/RunCMake/Android/ndk-x86_64-stdout.txt2
-rw-r--r--Tests/RunCMake/Android/ndk-x86_64.cmake1
-rw-r--r--Tests/RunCMake/Android/standalone-stdout.txt1
-rw-r--r--Tests/RunCMake/Android/standalone-sysroot-stdout.txt1
-rw-r--r--Tests/RunCMake/Android/standalone-sysroot.cmake0
-rw-r--r--Tests/RunCMake/Android/standalone.cmake1
-rw-r--r--Tests/RunCMake/CMakeLists.txt21
124 files changed, 2264 insertions, 28 deletions
diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst
index 390220c..74eab2d 100644
--- a/Help/manual/cmake-toolchains.7.rst
+++ b/Help/manual/cmake-toolchains.7.rst
@@ -290,12 +290,206 @@ Windows Store may look like this:
set(CMAKE_SYSTEM_NAME WindowsStore)
set(CMAKE_SYSTEM_VERSION 8.1)
-Cross Compiling using NVIDIA Nsight Tegra
------------------------------------------
+.. _`Cross Compiling for Android`:
-A toolchain file to configure a Visual Studio generator to
-build using NVIDIA Nsight Tegra targeting Android may look
-like this:
+Cross Compiling for Android
+---------------------------
+
+A toolchain file may configure cross-compiling for Android by setting the
+:variable:`CMAKE_SYSTEM_NAME` variable to ``Android``. Further configuration
+is specific to the Android development environment to be used.
+
+For :ref:`Visual Studio Generators`, CMake expects :ref:`NVIDIA Nsight Tegra
+Visual Studio Edition <Cross Compiling for Android with NVIDIA Nsight Tegra
+Visual Studio Edition>` to be installed. See that section for further
+configuration details.
+
+For :ref:`Makefile Generators` and the :generator:`Ninja` generator,
+CMake expects one of these environments:
+
+* :ref:`NDK <Cross Compiling for Android with the NDK>`
+* :ref:`Standalone Toolchain <Cross Compiling for Android with a Standalone Toolchain>`
+
+CMake uses the following steps to select one of the environments:
+
+* If the :variable:`CMAKE_ANDROID_NDK` variable is set, the NDK at the
+ specified location will be used.
+
+* Else, if the :variable:`CMAKE_ANDROID_STANDALONE_TOOLCHAIN` variable
+ is set, the Standalone Toolchain at the specified location will be used.
+
+* Else, if the :variable:`CMAKE_SYSROOT` variable is set to a directory
+ of the form ``<ndk>/platforms/android-<api>/arch-<arch>``, the ``<ndk>``
+ part will be used as the value of :variable:`CMAKE_ANDROID_NDK` and the
+ NDK will be used.
+
+* Else, if the :variable:`CMAKE_SYSROOT` variable is set to a directory of the
+ form ``<standalone-toolchain>/sysroot``, the ``<standalone-toolchain>`` part
+ will be used as the value of :variable:`CMAKE_ANDROID_STANDALONE_TOOLCHAIN`
+ and the Standalone Toolchain will be used.
+
+* Else, if a cmake variable ``ANDROID_NDK`` is set it will be used
+ as the value of :variable:`CMAKE_ANDROID_NDK`, and the NDK will be used.
+
+* Else, if a cmake variable ``ANDROID_STANDALONE_TOOLCHAIN`` is set, it will be
+ used as the value of :variable:`CMAKE_ANDROID_STANDALONE_TOOLCHAIN`, and the
+ Standalone Toolchain will be used.
+
+* Else, if an environment variable ``ANDROID_NDK_ROOT`` or
+ ``ANDROID_NDK`` is set, it will be used as the value of
+ :variable:`CMAKE_ANDROID_NDK`, and the NDK will be used.
+
+* Else, if an environment variable ``ANDROID_STANDALONE_TOOLCHAIN`` is
+ set then it will be used as the value of
+ :variable:`CMAKE_ANDROID_STANDALONE_TOOLCHAIN`, and the Standalone
+ Toolchain will be used.
+
+* Else, an error diagnostic will be issued that neither the NDK or
+ Standalone Toolchain can be found.
+
+.. _`Cross Compiling for Android with the NDK`:
+
+Cross Compiling for Android with the NDK
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+A toolchain file may configure :ref:`Makefile Generators` or the
+:generator:`Ninja` generator to target Android for cross-compiling.
+
+Configure use of an Android NDK with the following variables:
+
+:variable:`CMAKE_SYSTEM_NAME`
+ Set to ``Android``. Must be specified to enable cross compiling
+ for Android.
+
+:variable:`CMAKE_SYSTEM_VERSION`
+ Set to the Android API level. If not specified, the value is
+ determined as follows:
+
+ * If the :variable:`CMAKE_ANDROID_API` variable is set, its value
+ is used as the API level.
+ * If the :variable:`CMAKE_SYSROOT` variable is set, the API level is
+ detected from the NDK directory structure containing the sysroot.
+ * Otherwise, the latest API level available in the NDK is used.
+
+:variable:`CMAKE_ANDROID_ARCH_ABI`
+ Set to the Android ABI (architecture). If not specified, this
+ variable will default to ``armeabi``.
+ The :variable:`CMAKE_ANDROID_ARCH` variable will be computed
+ from ``CMAKE_ANDROID_ARCH_ABI`` automatically.
+ Also see the :variable:`CMAKE_ANDROID_ARM_MODE` and
+ :variable:`CMAKE_ANDROID_ARM_NEON` variables.
+
+:variable:`CMAKE_ANDROID_NDK`
+ Set to the absolute path to the Android NDK root directory.
+ A ``${CMAKE_ANDROID_NDK}/platforms`` directory must exist.
+ If not specified, a default for this variable will be chosen
+ as specified :ref:`above <Cross Compiling for Android>`.
+
+:variable:`CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION`
+ Set to the version of the NDK toolchain to be selected as the compiler.
+ If not specified, the latest available GCC toolchain will be used.
+
+:variable:`CMAKE_ANDROID_STL_TYPE`
+ Set to specify which C++ standard library to use. If not specified,
+ a default will be selected as described in the variable documentation.
+
+The following variables will be computed and provided automatically:
+
+:variable:`CMAKE_<LANG>_ANDROID_TOOLCHAIN_PREFIX`
+ The absolute path prefix to the binutils in the NDK toolchain.
+
+:variable:`CMAKE_<LANG>_ANDROID_TOOLCHAIN_SUFFIX`
+ The host platform suffix of the binutils in the NDK toolchain.
+
+
+For example, a toolchain file might contain:
+
+.. code-block:: cmake
+
+ set(CMAKE_SYSTEM_NAME Android)
+ set(CMAKE_SYSTEM_VERSION 21) # API level
+ set(CMAKE_ANDROID_ARCH_ABI arm64-v8a)
+ set(CMAKE_ANDROID_NDK /path/to/android-ndk)
+ set(CMAKE_ANDROID_STL_TYPE gnustl_static)
+
+Alternatively one may specify the values without a toolchain file:
+
+.. code-block:: console
+
+ $ cmake ../src \
+ -DCMAKE_SYSTEM_NAME=Android \
+ -DCMAKE_SYSTEM_VERSION=21 \
+ -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a \
+ -DCMAKE_ANDROID_NDK=/path/to/android-ndk \
+ -DCMAKE_ANDROID_STL_TYPE=gnustl_static
+
+.. _`Cross Compiling for Android with a Standalone Toolchain`:
+
+Cross Compiling for Android with a Standalone Toolchain
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+A toolchain file may configure :ref:`Makefile Generators` or the
+:generator:`Ninja` generator to target Android for cross-compiling
+using a standalone toolchain.
+
+Configure use of an Android standalone toolchain with the following variables:
+
+:variable:`CMAKE_SYSTEM_NAME`
+ Set to ``Android``. Must be specified to enable cross compiling
+ for Android.
+
+:variable:`CMAKE_ANDROID_STANDALONE_TOOLCHAIN`
+ Set to the absolute path to the standalone toolchain root directory.
+ A ``${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/sysroot`` directory
+ must exist.
+ If not specified, a default for this variable will be chosen
+ as specified :ref:`above <Cross Compiling for Android>`.
+
+:variable:`CMAKE_ANDROID_ARM_MODE`
+ When the standalone toolchain targets ARM, optionally set this to ``ON``
+ to target 32-bit ARM instead of 16-bit Thumb.
+ See variable documentation for details.
+
+:variable:`CMAKE_ANDROID_ARM_NEON`
+ When the standalone toolchain targets ARM v7, optionally set thisto ``ON``
+ to target ARM NEON devices. See variable documentation for details.
+
+The following variables will be computed and provided automatically:
+
+:variable:`CMAKE_SYSTEM_VERSION`
+ The Android API level detected from the standalone toolchain.
+
+:variable:`CMAKE_ANDROID_ARCH_ABI`
+ The Android ABI detected from the standalone toolchain.
+
+:variable:`CMAKE_<LANG>_ANDROID_TOOLCHAIN_PREFIX`
+ The absolute path prefix to the binutils in the standalone toolchain.
+
+:variable:`CMAKE_<LANG>_ANDROID_TOOLCHAIN_SUFFIX`
+ The host platform suffix of the binutils in the standalone toolchain.
+
+For example, a toolchain file might contain:
+
+.. code-block:: cmake
+
+ set(CMAKE_SYSTEM_NAME Android)
+ set(CMAKE_ANDROID_STANDALONE_TOOLCHAIN /path/to/android-toolchain)
+
+Alternatively one may specify the values without a toolchain file:
+
+.. code-block:: console
+
+ $ cmake ../src \
+ -DCMAKE_SYSTEM_NAME=Android \
+ -DCMAKE_ANDROID_STANDALONE_TOOLCHAIN=/path/to/android-toolchain
+
+.. _`Cross Compiling for Android with NVIDIA Nsight Tegra Visual Studio Edition`:
+
+Cross Compiling for Android with NVIDIA Nsight Tegra Visual Studio Edition
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+A toolchain file to configure one of the :ref:`Visual Studio Generators`
+to build using NVIDIA Nsight Tegra targeting Android may look like this:
.. code-block:: cmake
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 1138b82..275b66c 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -173,6 +173,7 @@ Variables that Describe the System
.. toctree::
:maxdepth: 1
+ /variable/ANDROID
/variable/APPLE
/variable/BORLAND
/variable/CMAKE_CL_64
@@ -225,6 +226,9 @@ Variables that Control the Build
/variable/CMAKE_ANDROID_API
/variable/CMAKE_ANDROID_API_MIN
/variable/CMAKE_ANDROID_ARCH
+ /variable/CMAKE_ANDROID_ARCH_ABI
+ /variable/CMAKE_ANDROID_ARM_MODE
+ /variable/CMAKE_ANDROID_ARM_NEON
/variable/CMAKE_ANDROID_ASSETS_DIRECTORIES
/variable/CMAKE_ANDROID_GUI
/variable/CMAKE_ANDROID_JAR_DEPENDENCIES
@@ -232,11 +236,14 @@ Variables that Control the Build
/variable/CMAKE_ANDROID_JAVA_SOURCE_DIR
/variable/CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES
/variable/CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES
+ /variable/CMAKE_ANDROID_NDK
+ /variable/CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION
/variable/CMAKE_ANDROID_PROCESS_MAX
/variable/CMAKE_ANDROID_PROGUARD
/variable/CMAKE_ANDROID_PROGUARD_CONFIG_PATH
/variable/CMAKE_ANDROID_SECURE_PROPS_PATH
/variable/CMAKE_ANDROID_SKIP_ANT_STEP
+ /variable/CMAKE_ANDROID_STANDALONE_TOOLCHAIN
/variable/CMAKE_ANDROID_STL_TYPE
/variable/CMAKE_ARCHIVE_OUTPUT_DIRECTORY
/variable/CMAKE_ARCHIVE_OUTPUT_DIRECTORY_CONFIG
@@ -337,6 +344,8 @@ Variables for Languages
/variable/CMAKE_Fortran_MODDIR_FLAG
/variable/CMAKE_Fortran_MODOUT_FLAG
/variable/CMAKE_INTERNAL_PLATFORM_ABI
+ /variable/CMAKE_LANG_ANDROID_TOOLCHAIN_PREFIX
+ /variable/CMAKE_LANG_ANDROID_TOOLCHAIN_SUFFIX
/variable/CMAKE_LANG_ARCHIVE_APPEND
/variable/CMAKE_LANG_ARCHIVE_CREATE
/variable/CMAKE_LANG_ARCHIVE_FINISH
diff --git a/Help/prop_tgt/ANDROID_API.rst b/Help/prop_tgt/ANDROID_API.rst
index 714ad58..63464d7 100644
--- a/Help/prop_tgt/ANDROID_API.rst
+++ b/Help/prop_tgt/ANDROID_API.rst
@@ -1,7 +1,8 @@
ANDROID_API
-----------
-Set the Android Target API version (e.g. ``15``). The version number
-must be a positive decimal integer. This property is initialized by
-the value of the :variable:`CMAKE_ANDROID_API` variable if it is set
-when a target is created.
+When :ref:`Cross Compiling for Android with NVIDIA Nsight Tegra Visual Studio
+Edition`, this property sets the Android target API version (e.g. ``15``).
+The version number must be a positive decimal integer. This property is
+initialized by the value of the :variable:`CMAKE_ANDROID_API` variable if
+it is set when a target is created.
diff --git a/Help/prop_tgt/ANDROID_ARCH.rst b/Help/prop_tgt/ANDROID_ARCH.rst
index 5477fb5..3e07e5a 100644
--- a/Help/prop_tgt/ANDROID_ARCH.rst
+++ b/Help/prop_tgt/ANDROID_ARCH.rst
@@ -1,7 +1,8 @@
ANDROID_ARCH
------------
-Set the Android target architecture.
+When :ref:`Cross Compiling for Android with NVIDIA Nsight Tegra Visual Studio
+Edition`, this property sets the Android target architecture.
This is a string property that could be set to the one of
the following values:
diff --git a/Help/prop_tgt/ANDROID_GUI.rst b/Help/prop_tgt/ANDROID_GUI.rst
index abdba7a..92e2041 100644
--- a/Help/prop_tgt/ANDROID_GUI.rst
+++ b/Help/prop_tgt/ANDROID_GUI.rst
@@ -1,7 +1,9 @@
ANDROID_GUI
-----------
-Build an executable as an application package on Android.
+When :ref:`Cross Compiling for Android with NVIDIA Nsight Tegra Visual Studio
+Edition`, this property specifies whether to build an executable as an
+application package on Android.
When this property is set to true the executable when built for Android
will be created as an application package. This property is initialized
diff --git a/Help/prop_tgt/ANDROID_STL_TYPE.rst b/Help/prop_tgt/ANDROID_STL_TYPE.rst
index 7256e26..386e96e 100644
--- a/Help/prop_tgt/ANDROID_STL_TYPE.rst
+++ b/Help/prop_tgt/ANDROID_STL_TYPE.rst
@@ -1,15 +1,27 @@
ANDROID_STL_TYPE
----------------
-Set the Android property that defines the type of STL support for the project.
+When :ref:`Cross Compiling for Android with NVIDIA Nsight Tegra Visual Studio
+Edition`, this property specifies the type of STL support for the project.
This is a string property that could set to the one of the following values:
-``none`` e.g. "No C++ Support"
-``system`` e.g. "Minimal C++ without STL"
-``gabi++_static`` e.g. "GAbi++ Static"
-``gabi++_shared`` e.g. "GAbi++ Shared"
-``gnustl_static`` e.g. "GNU libstdc++ Static"
-``gnustl_shared`` e.g. "GNU libstdc++ Shared"
-``stlport_static`` e.g. "STLport Static"
-``stlport_shared`` e.g. "STLport Shared"
+
+``none``
+ No C++ Support
+``system``
+ Minimal C++ without STL
+``gabi++_static``
+ GAbi++ Static
+``gabi++_shared``
+ GAbi++ Shared
+``gnustl_static``
+ GNU libstdc++ Static
+``gnustl_shared``
+ GNU libstdc++ Shared
+``stlport_static``
+ STLport Static
+``stlport_shared``
+ STLport Shared
+
This property is initialized by the value of the
-variable:`CMAKE_ANDROID_STL_TYPE` variable if it is set when a target is created.
+:variable:`CMAKE_ANDROID_STL_TYPE` variable if it is set when a target is
+created.
diff --git a/Help/release/dev/android-platform-modules.rst b/Help/release/dev/android-platform-modules.rst
new file mode 100644
index 0000000..79ae992
--- /dev/null
+++ b/Help/release/dev/android-platform-modules.rst
@@ -0,0 +1,5 @@
+android-platform-modules
+------------------------
+
+* CMake now supports :ref:`Cross Compiling for Android` with simple
+ toolchain files.
diff --git a/Help/variable/ANDROID.rst b/Help/variable/ANDROID.rst
new file mode 100644
index 0000000..fede4ca
--- /dev/null
+++ b/Help/variable/ANDROID.rst
@@ -0,0 +1,5 @@
+ANDROID
+-------
+
+Set to ``1`` when the target system (:variable:`CMAKE_SYSTEM_NAME`) is
+``Android``.
diff --git a/Help/variable/CMAKE_ANDROID_API.rst b/Help/variable/CMAKE_ANDROID_API.rst
index c8264e0..c07a05a 100644
--- a/Help/variable/CMAKE_ANDROID_API.rst
+++ b/Help/variable/CMAKE_ANDROID_API.rst
@@ -1,5 +1,11 @@
CMAKE_ANDROID_API
-----------------
-Default value for the :prop_tgt:`ANDROID_API` target property.
-See that target property for additional information.
+When :ref:`Cross Compiling for Android with NVIDIA Nsight Tegra Visual Studio
+Edition`, this variable may be set to specify the default value for the
+:prop_tgt:`ANDROID_API` target property. See that target property for
+additional information.
+
+Otherwise, when :ref:`Cross Compiling for Android`, this variable provides
+the Android API version number targeted. This will be the same value as
+the :variable:`CMAKE_SYSTEM_VERSION` variable for ``Android`` platforms.
diff --git a/Help/variable/CMAKE_ANDROID_ARCH.rst b/Help/variable/CMAKE_ANDROID_ARCH.rst
index 8fbb46d..b91ca57 100644
--- a/Help/variable/CMAKE_ANDROID_ARCH.rst
+++ b/Help/variable/CMAKE_ANDROID_ARCH.rst
@@ -1,5 +1,19 @@
CMAKE_ANDROID_ARCH
------------------
-Default value for the :prop_tgt:`ANDROID_ARCH` target property.
-See that target property for additional information.
+When :ref:`Cross Compiling for Android with NVIDIA Nsight Tegra Visual Studio
+Edition`, this variable may be set to specify the default value for the
+:prop_tgt:`ANDROID_ARCH` target property. See that target property for
+additional information.
+
+Otherwise, when :ref:`Cross Compiling for Android`, this variable provides
+the name of the Android architecture corresponding to the value of the
+:variable:`CMAKE_ANDROID_ARCH_ABI` variable. The architecture name
+may be one of:
+
+* ``arm``
+* ``arm64``
+* ``mips``
+* ``mips64``
+* ``x86``
+* ``x86_64``
diff --git a/Help/variable/CMAKE_ANDROID_ARCH_ABI.rst b/Help/variable/CMAKE_ANDROID_ARCH_ABI.rst
new file mode 100644
index 0000000..0a3ed3c
--- /dev/null
+++ b/Help/variable/CMAKE_ANDROID_ARCH_ABI.rst
@@ -0,0 +1,17 @@
+CMAKE_ANDROID_ARCH_ABI
+----------------------
+
+When :ref:`Cross Compiling for Android`, this variable specifies the
+target architecture and ABI to be used. Valid values are:
+
+* ``arm64-v8a``
+* ``armeabi-v7a``
+* ``armeabi-v6``
+* ``armeabi``
+* ``mips``
+* ``mips64``
+* ``x86``
+* ``x86_64``
+
+See also the :variable:`CMAKE_ANDROID_ARM_MODE` and
+:variable:`CMAKE_ANDROID_ARM_NEON` variables.
diff --git a/Help/variable/CMAKE_ANDROID_ARM_MODE.rst b/Help/variable/CMAKE_ANDROID_ARM_MODE.rst
new file mode 100644
index 0000000..ad3c37c
--- /dev/null
+++ b/Help/variable/CMAKE_ANDROID_ARM_MODE.rst
@@ -0,0 +1,7 @@
+CMAKE_ANDROID_ARM_MODE
+----------------------
+
+When :ref:`Cross Compiling for Android` and :variable:`CMAKE_ANDROID_ARCH_ABI`
+is set to one of the ``armeabi`` architectures, set ``CMAKE_ANDROID_ARM_MODE``
+to ``ON`` to target 32-bit ARM processors (``-marm``). Otherwise, the
+default is to target the 16-bit Thumb processors (``-mthumb``).
diff --git a/Help/variable/CMAKE_ANDROID_ARM_NEON.rst b/Help/variable/CMAKE_ANDROID_ARM_NEON.rst
new file mode 100644
index 0000000..4b7ae03
--- /dev/null
+++ b/Help/variable/CMAKE_ANDROID_ARM_NEON.rst
@@ -0,0 +1,6 @@
+CMAKE_ANDROID_ARM_NEON
+----------------------
+
+When :ref:`Cross Compiling for Android` and :variable:`CMAKE_ANDROID_ARCH_ABI`
+is set to ``armeabi-v7a`` set ``CMAKE_ANDROID_ARM_NEON`` to ``ON`` to target
+ARM NEON devices.
diff --git a/Help/variable/CMAKE_ANDROID_NDK.rst b/Help/variable/CMAKE_ANDROID_NDK.rst
new file mode 100644
index 0000000..d241dd0
--- /dev/null
+++ b/Help/variable/CMAKE_ANDROID_NDK.rst
@@ -0,0 +1,7 @@
+CMAKE_ANDROID_NDK
+-----------------
+
+When :ref:`Cross Compiling for Android with the NDK`, this variable holds
+the absolute path to the root directory of the NDK. The directory must
+contain a ``platforms`` subdirectory holding the ``android-<api>``
+directories.
diff --git a/Help/variable/CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION.rst b/Help/variable/CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION.rst
new file mode 100644
index 0000000..dff7d64
--- /dev/null
+++ b/Help/variable/CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION.rst
@@ -0,0 +1,13 @@
+CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION
+-----------------------------------
+
+When :ref:`Cross Compiling for Android with the NDK`, this variable
+may be set to specify the version of the toolchain to be used
+as the compiler. The variable must be set to one of these forms:
+
+* ``<major>.<minor>``: GCC of specified version
+* ``clang<major>.<minor>``: Clang of specified version
+* ``clang``: Clang of most recent available version
+
+A toolchain of the requested version will be selected automatically to
+match the ABI named in the :variable:`CMAKE_ANDROID_ARCH_ABI` variable.
diff --git a/Help/variable/CMAKE_ANDROID_STANDALONE_TOOLCHAIN.rst b/Help/variable/CMAKE_ANDROID_STANDALONE_TOOLCHAIN.rst
new file mode 100644
index 0000000..ea62cab
--- /dev/null
+++ b/Help/variable/CMAKE_ANDROID_STANDALONE_TOOLCHAIN.rst
@@ -0,0 +1,6 @@
+CMAKE_ANDROID_STANDALONE_TOOLCHAIN
+----------------------------------
+
+When :ref:`Cross Compiling for Android with a Standalone Toolchain`, this
+variable holds the absolute path to the root directory of the toolchain.
+The specified directory must contain a ``sysroot`` subdirectory.
diff --git a/Help/variable/CMAKE_ANDROID_STL_TYPE.rst b/Help/variable/CMAKE_ANDROID_STL_TYPE.rst
index 766b2c8..cfb76aa 100644
--- a/Help/variable/CMAKE_ANDROID_STL_TYPE.rst
+++ b/Help/variable/CMAKE_ANDROID_STL_TYPE.rst
@@ -1,5 +1,36 @@
CMAKE_ANDROID_STL_TYPE
----------------------
-Default value for the :prop_tgt:`ANDROID_STL_TYPE` target property.
-See that target property for additional information.
+When :ref:`Cross Compiling for Android with NVIDIA Nsight Tegra Visual Studio
+Edition`, this variable may be set to specify the default value for the
+:prop_tgt:`ANDROID_STL_TYPE` target property. See that target property
+for additional information.
+
+When :ref:`Cross Compiling for Android with the NDK`, this variable may be
+set to specify the STL variant to be used. The value may be one of:
+
+``none``
+ No C++ Support
+``system``
+ Minimal C++ without STL
+``gabi++_static``
+ GAbi++ Static
+``gabi++_shared``
+ GAbi++ Shared
+``gnustl_static``
+ GNU libstdc++ Static
+``gnustl_shared``
+ GNU libstdc++ Shared
+``c++_static``
+ LLVM libc++ Static
+``c++_shared``
+ LLVM libc++ Shared
+``stlport_static``
+ STLport Static
+``stlport_shared``
+ STLport Shared
+
+The default value is ``gnustl_static``. Note that this default differs from
+the native NDK build system because CMake may be used to build projects for
+Android that are not natively implemented for it and use the C++ standard
+library.
diff --git a/Help/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_PREFIX.rst b/Help/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_PREFIX.rst
new file mode 100644
index 0000000..b51422f
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_PREFIX.rst
@@ -0,0 +1,11 @@
+CMAKE_<LANG>_ANDROID_TOOLCHAIN_PREFIX
+-------------------------------------
+
+When :ref:`Cross Compiling for Android` this variable contains the absolute
+path prefixing the toolchain GNU compiler and its binutils.
+
+See also :variable:`CMAKE_<LANG>_ANDROID_TOOLCHAIN_SUFFIX`.
+
+For example, the path to the linker is::
+
+ ${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}ld${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}
diff --git a/Help/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_SUFFIX.rst b/Help/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_SUFFIX.rst
new file mode 100644
index 0000000..a4af640
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_SUFFIX.rst
@@ -0,0 +1,7 @@
+CMAKE_<LANG>_ANDROID_TOOLCHAIN_SUFFIX
+-------------------------------------
+
+When :ref:`Cross Compiling for Android` this variable contains the
+host platform suffix of the toolchain GNU compiler and its binutils.
+
+See also :variable:`CMAKE_<LANG>_ANDROID_TOOLCHAIN_PREFIX`.
diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in
index f109a14..50b12f2 100644
--- a/Modules/CMakeCCompiler.cmake.in
+++ b/Modules/CMakeCCompiler.cmake.in
@@ -59,6 +59,7 @@ if(CMAKE_C_CL_SHOWINCLUDES_PREFIX)
set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_C_CL_SHOWINCLUDES_PREFIX}")
endif()
+@CMAKE_C_COMPILER_CUSTOM_CODE@
@CMAKE_C_SYSROOT_FLAG_CODE@
@CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG_CODE@
diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in
index 9e90aea..c295b74 100644
--- a/Modules/CMakeCXXCompiler.cmake.in
+++ b/Modules/CMakeCXXCompiler.cmake.in
@@ -60,6 +60,7 @@ if(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX)
set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_CXX_CL_SHOWINCLUDES_PREFIX}")
endif()
+@CMAKE_CXX_COMPILER_CUSTOM_CODE@
@CMAKE_CXX_SYSROOT_FLAG_CODE@
@CMAKE_CXX_OSX_DEPLOYMENT_TARGET_FLAG_CODE@
diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake
index d9f7579..f7a32b7 100644
--- a/Modules/CMakeDetermineSystem.cmake
+++ b/Modules/CMakeDetermineSystem.cmake
@@ -131,6 +131,7 @@ else()
set(PRESET_CMAKE_SYSTEM_NAME FALSE)
endif()
+include(Platform/${CMAKE_SYSTEM_NAME}-Determine OPTIONAL)
macro(ADJUST_CMAKE_SYSTEM_VARIABLES _PREFIX)
if(NOT ${_PREFIX}_NAME)
diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in
index 2a4bea4..8e92f65 100644
--- a/Modules/CMakeFortranCompiler.cmake.in
+++ b/Modules/CMakeFortranCompiler.cmake.in
@@ -54,6 +54,8 @@ if(CMAKE_Fortran_LIBRARY_ARCHITECTURE)
set(CMAKE_LIBRARY_ARCHITECTURE "@CMAKE_Fortran_LIBRARY_ARCHITECTURE@")
endif()
+@CMAKE_Fortran_COMPILER_CUSTOM_CODE@
+
set(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "@CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES@")
set(CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES "@CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES@")
set(CMAKE_Fortran_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_Fortran_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@")
diff --git a/Modules/CMakeSystem.cmake.in b/Modules/CMakeSystem.cmake.in
index 70c98d5..ef8aaa0 100644
--- a/Modules/CMakeSystem.cmake.in
+++ b/Modules/CMakeSystem.cmake.in
@@ -9,7 +9,7 @@ set(CMAKE_SYSTEM "@CMAKE_SYSTEM@")
set(CMAKE_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@")
set(CMAKE_SYSTEM_VERSION "@CMAKE_SYSTEM_VERSION@")
set(CMAKE_SYSTEM_PROCESSOR "@CMAKE_SYSTEM_PROCESSOR@")
-
+@CMAKE_SYSTEM_CUSTOM_CODE@
set(CMAKE_CROSSCOMPILING "@CMAKE_CROSSCOMPILING@")
set(CMAKE_SYSTEM_LOADED 1)
diff --git a/Modules/Platform/Android-Clang-C.cmake b/Modules/Platform/Android-Clang-C.cmake
new file mode 100644
index 0000000..9e16911
--- /dev/null
+++ b/Modules/Platform/Android-Clang-C.cmake
@@ -0,0 +1,2 @@
+include(Platform/Android-Clang)
+__android_compiler_clang(C)
diff --git a/Modules/Platform/Android-Clang-CXX.cmake b/Modules/Platform/Android-Clang-CXX.cmake
new file mode 100644
index 0000000..7111836
--- /dev/null
+++ b/Modules/Platform/Android-Clang-CXX.cmake
@@ -0,0 +1,2 @@
+include(Platform/Android-Clang)
+__android_compiler_clang(CXX)
diff --git a/Modules/Platform/Android-Clang.cmake b/Modules/Platform/Android-Clang.cmake
new file mode 100644
index 0000000..7ed5046
--- /dev/null
+++ b/Modules/Platform/Android-Clang.cmake
@@ -0,0 +1,52 @@
+#=============================================================================
+# Copyright 2015-2016 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+# This module is shared by multiple languages; use include blocker.
+if(__ANDROID_COMPILER_CLANG)
+ return()
+endif()
+set(__ANDROID_COMPILER_CLANG 1)
+
+# Support for NVIDIA Nsight Tegra Visual Studio Edition was previously
+# implemented in the CMake VS IDE generators. Avoid interfering with
+# that functionality for now. Later we may try to integrate this.
+if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")
+ macro(__android_compiler_clang lang)
+ endmacro()
+ return()
+endif()
+
+# Commonly used Android toolchain files that pre-date CMake upstream support
+# set CMAKE_SYSTEM_VERSION to 1. Avoid interfering with them.
+if(CMAKE_SYSTEM_VERSION EQUAL 1)
+ macro(__android_compiler_clang lang)
+ endmacro()
+ return()
+endif()
+
+include(Platform/Android-Common)
+
+# The NDK toolchain configuration files at:
+#
+# <ndk>/[build/core/]toolchains/*-clang*/setup.mk
+#
+# contain logic to set LLVM_TRIPLE for Clang-based toolchains for each target.
+# We need to produce the same target here to produce compatible binaries.
+include(Platform/Android/abi-${CMAKE_ANDROID_ARCH_ABI}-Clang)
+
+macro(__android_compiler_clang lang)
+ __android_compiler_common(${lang})
+ if(NOT CMAKE_${lang}_COMPILER_TARGET)
+ set(CMAKE_${lang}_COMPILER_TARGET "${_ANDROID_ABI_CLANG_TARGET}")
+ endif()
+endmacro()
diff --git a/Modules/Platform/Android-Common.cmake b/Modules/Platform/Android-Common.cmake
new file mode 100644
index 0000000..6e86c10
--- /dev/null
+++ b/Modules/Platform/Android-Common.cmake
@@ -0,0 +1,158 @@
+#=============================================================================
+# Copyright 2015-2016 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+# This module is shared by multiple languages; use include blocker.
+if(__ANDROID_COMPILER_COMMON)
+ return()
+endif()
+set(__ANDROID_COMPILER_COMMON 1)
+
+if(CMAKE_ANDROID_NDK)
+ # <ndk>/build/core/definitions.mk
+
+ set(_ANDROID_STL_TYPES
+ none
+ system
+ c++_static
+ c++_shared
+ gabi++_static
+ gabi++_shared
+ gnustl_static
+ gnustl_shared
+ stlport_static
+ stlport_shared
+ )
+
+ if(CMAKE_ANDROID_STL_TYPE)
+ list(FIND _ANDROID_STL_TYPES "${CMAKE_ANDROID_STL_TYPE}" _ANDROID_STL_TYPE_FOUND)
+ if(_ANDROID_STL_TYPE_FOUND EQUAL -1)
+ string(REPLACE ";" "\n " _msg ";${_ANDROID_STL_TYPES}")
+ message(FATAL_ERROR
+ "The CMAKE_ANDROID_STL_TYPE '${CMAKE_ANDROID_STL_TYPE}' is not one of the allowed values:${_msg}\n"
+ )
+ endif()
+ unset(_ANDROID_STL_TYPE_FOUND)
+ else()
+ set(CMAKE_ANDROID_STL_TYPE "gnustl_static")
+ endif()
+
+ unset(_ANDROID_STL_TYPES)
+
+ # Forward Android-specific platform variables to try_compile projects.
+ list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
+ CMAKE_ANDROID_STL_TYPE
+ )
+endif()
+
+if(CMAKE_ANDROID_STL_TYPE)
+ if(CMAKE_ANDROID_NDK)
+
+ macro(__android_stl_inc lang dir req)
+ if(EXISTS "${dir}")
+ list(APPEND CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES "${dir}")
+ elseif(${req})
+ message(FATAL_ERROR
+ "Android: STL '${CMAKE_ANDROID_STL_TYPE}' include directory not found:\n"
+ " ${dir}"
+ )
+ endif()
+ endmacro()
+
+ macro(__android_stl_lib lang lib req)
+ if(CMAKE_ANDROID_ARCH_ABI MATCHES "^armeabi" AND NOT CMAKE_ANDROID_ARM_MODE)
+ get_filename_component(_ANDROID_STL_LIBDIR "${lib}" DIRECTORY)
+ get_filename_component(_ANDROID_STL_LIBNAME "${lib}" NAME)
+ set(_ANDROID_STL_LIBTHUMB "${_ANDROID_STL_LIBDIR}/thumb/${_ANDROID_STL_LIBNAME}")
+ unset(_ANDROID_STL_LIBDIR)
+ unset(_ANDROID_STL_LIBNAME)
+ else()
+ set(_ANDROID_STL_LIBTHUMB "")
+ endif()
+
+ if(_ANDROID_STL_LIBTHUMB AND EXISTS "${_ANDROID_STL_LIBTHUMB}")
+ string(APPEND CMAKE_${lang}_STANDARD_LIBRARIES " \"${_ANDROID_STL_LIBTHUMB}\"")
+ elseif(EXISTS "${lib}")
+ string(APPEND CMAKE_${lang}_STANDARD_LIBRARIES " \"${lib}\"")
+ elseif(${req})
+ message(FATAL_ERROR
+ "Android: STL '${CMAKE_ANDROID_STL_TYPE}' library file not found:\n"
+ " ${lib}"
+ )
+ endif()
+
+ unset(_ANDROID_STL_LIBTHUMB)
+ endmacro()
+
+ include(Platform/Android/ndk-stl-${CMAKE_ANDROID_STL_TYPE})
+ else()
+ macro(__android_stl lang)
+ endmacro()
+ endif()
+else()
+ macro(__android_stl lang)
+ endmacro()
+endif()
+
+# The NDK toolchain configuration files at:
+#
+# <ndk>/[build/core/]toolchains/*/setup.mk
+#
+# contain logic to set TARGET_CFLAGS and TARGET_LDFLAGS (and debug/release
+# variants) to tell their build system what flags to pass for each ABI.
+# We need to produce the same flags here to produce compatible binaries.
+# We initialize these variables here and set them in the compiler-specific
+# modules that include this one. Then we use them in the macro below when
+# it is called.
+set(_ANDROID_ABI_INIT_CFLAGS "")
+set(_ANDROID_ABI_INIT_CFLAGS_DEBUG "")
+set(_ANDROID_ABI_INIT_CFLAGS_RELEASE "")
+set(_ANDROID_ABI_INIT_LDFLAGS "")
+
+macro(__android_compiler_common lang)
+ if(_ANDROID_ABI_INIT_CFLAGS)
+ string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_ANDROID_ABI_INIT_CFLAGS}")
+ endif()
+ if(_ANDROID_ABI_INIT_CFLAGS_DEBUG)
+ string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " ${_ANDROID_ABI_INIT_CFLAGS_DEBUG}")
+ endif()
+ if(_ANDROID_ABI_INIT_CFLAGS_RELEASE)
+ string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " ${_ANDROID_ABI_INIT_CFLAGS_RELEASE}")
+ string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " ${_ANDROID_ABI_INIT_CFLAGS_RELEASE}")
+ string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " ${_ANDROID_ABI_INIT_CFLAGS_RELEASE}")
+ endif()
+ if(_ANDROID_ABI_INIT_LDFLAGS)
+ foreach(t EXE SHARED MODULE)
+ string(APPEND CMAKE_${t}_LINKER_FLAGS_INIT " ${_ANDROID_ABI_INIT_LDFLAGS}")
+ endforeach()
+ endif()
+
+ if(DEFINED _ANDROID_STL_EXCEPTIONS)
+ if(_ANDROID_STL_EXCEPTIONS)
+ string(APPEND CMAKE_${lang}_FLAGS_INIT " -fexceptions")
+ else()
+ string(APPEND CMAKE_${lang}_FLAGS_INIT " -fno-exceptions")
+ endif()
+ endif()
+
+ if("x${lang}" STREQUAL "xCXX" AND DEFINED _ANDROID_STL_RTTI)
+ if(_ANDROID_STL_RTTI)
+ string(APPEND CMAKE_${lang}_FLAGS_INIT " -frtti")
+ else()
+ string(APPEND CMAKE_${lang}_FLAGS_INIT " -fno-rtti")
+ endif()
+ endif()
+
+ if("x${lang}" STREQUAL "xCXX")
+ __android_stl(CXX)
+ endif()
+endmacro()
diff --git a/Modules/Platform/Android-Determine-C.cmake b/Modules/Platform/Android-Determine-C.cmake
new file mode 100644
index 0000000..c7d1d15
--- /dev/null
+++ b/Modules/Platform/Android-Determine-C.cmake
@@ -0,0 +1,2 @@
+include(Platform/Android/Determine-Compiler)
+__android_determine_compiler(C)
diff --git a/Modules/Platform/Android-Determine-CXX.cmake b/Modules/Platform/Android-Determine-CXX.cmake
new file mode 100644
index 0000000..3a3de88
--- /dev/null
+++ b/Modules/Platform/Android-Determine-CXX.cmake
@@ -0,0 +1,2 @@
+include(Platform/Android/Determine-Compiler)
+__android_determine_compiler(CXX)
diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake
new file mode 100644
index 0000000..0a89c58
--- /dev/null
+++ b/Modules/Platform/Android-Determine.cmake
@@ -0,0 +1,301 @@
+#=============================================================================
+# Copyright 2015-2016 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+# When CMAKE_SYSTEM_NAME is "Android", CMakeDetermineSystem loads this module.
+# This module detects platform-wide information about the Android target
+# in order to store it in "CMakeSystem.cmake".
+
+# Support for NVIDIA Nsight Tegra Visual Studio Edition was previously
+# implemented in the CMake VS IDE generators. Avoid interfering with
+# that functionality for now. Later we may try to integrate this.
+if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")
+ return()
+endif()
+
+# Commonly used Android toolchain files that pre-date CMake upstream support
+# set CMAKE_SYSTEM_VERSION to 1. Avoid interfering with them.
+if(CMAKE_SYSTEM_VERSION EQUAL 1)
+ return()
+endif()
+
+# If the user provided CMAKE_SYSROOT for us, extract information from it.
+set(_ANDROID_SYSROOT_NDK "")
+set(_ANDROID_SYSROOT_API "")
+set(_ANDROID_SYSROOT_ARCH "")
+set(_ANDROID_SYSROOT_STANDALONE_TOOLCHAIN "")
+if(CMAKE_SYSROOT)
+ if(NOT IS_DIRECTORY "${CMAKE_SYSROOT}")
+ message(FATAL_ERROR
+ "Android: The specified CMAKE_SYSROOT:\n"
+ " ${CMAKE_SYSROOT}\n"
+ "is not an existing directory."
+ )
+ endif()
+ if(CMAKE_SYSROOT MATCHES "^([^\\\n]*)/platforms/android-([0-9]+)/arch-([a-z0-9_]+)$")
+ set(_ANDROID_SYSROOT_NDK "${CMAKE_MATCH_1}")
+ set(_ANDROID_SYSROOT_API "${CMAKE_MATCH_2}")
+ set(_ANDROID_SYSROOT_ARCH "${CMAKE_MATCH_3}")
+ elseif(CMAKE_SYSROOT MATCHES "^([^\\\n]*)/sysroot$")
+ set(_ANDROID_SYSROOT_STANDALONE_TOOLCHAIN "${CMAKE_MATCH_1}")
+ else()
+ message(FATAL_ERROR
+ "The value of CMAKE_SYSROOT:\n"
+ " ${CMAKE_SYSROOT}\n"
+ "does not match any of the forms:\n"
+ " <ndk>/platforms/android-<api>/arch-<arch>\n"
+ " <standalone-toolchain>/sysroot\n"
+ "where:\n"
+ " <ndk> = Android NDK directory (with forward slashes)\n"
+ " <api> = Android API version number (decimal digits)\n"
+ " <arch> = Android ARCH name (lower case)\n"
+ " <standalone-toolchain> = Path to standalone toolchain prefix\n"
+ )
+ endif()
+endif()
+
+# Find the Android NDK.
+if(CMAKE_ANDROID_NDK)
+ if(NOT IS_DIRECTORY "${CMAKE_ANDROID_NDK}")
+ message(FATAL_ERROR
+ "Android: The NDK root directory specified by CMAKE_ANDROID_NDK:\n"
+ " ${CMAKE_ANDROID_NDK}\n"
+ "does not exist."
+ )
+ endif()
+elseif(CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
+ if(NOT IS_DIRECTORY "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}")
+ message(FATAL_ERROR
+ "Android: The standalone toolchain directory specified by CMAKE_ANDROID_STANDALONE_TOOLCHAIN:\n"
+ " ${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}\n"
+ "does not exist."
+ )
+ endif()
+ if(NOT EXISTS "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/sysroot/usr/include/android/api-level.h")
+ message(FATAL_ERROR
+ "Android: The standalone toolchain directory specified by CMAKE_ANDROID_STANDALONE_TOOLCHAIN:\n"
+ " ${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}\n"
+ "does not contain a sysroot with a known layout. The file:\n"
+ " ${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/sysroot/usr/include/android/api-level.h\n"
+ "does not exist."
+ )
+ endif()
+else()
+ if(IS_DIRECTORY "${_ANDROID_SYSROOT_NDK}")
+ set(CMAKE_ANDROID_NDK "${_ANDROID_SYSROOT_NDK}")
+ elseif(IS_DIRECTORY "${_ANDROID_SYSROOT_STANDALONE_TOOLCHAIN}")
+ set(CMAKE_ANDROID_STANDALONE_TOOLCHAIN "${_ANDROID_SYSROOT_STANDALONE_TOOLCHAIN}")
+ elseif(IS_DIRECTORY "${ANDROID_NDK}")
+ file(TO_CMAKE_PATH "${ANDROID_NDK}" CMAKE_ANDROID_NDK)
+ elseif(IS_DIRECTORY "${ANDROID_STANDALONE_TOOLCHAIN}")
+ file(TO_CMAKE_PATH "${ANDROID_STANDALONE_TOOLCHAIN}" CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
+ elseif(IS_DIRECTORY "$ENV{ANDROID_NDK_ROOT}")
+ file(TO_CMAKE_PATH "$ENV{ANDROID_NDK_ROOT}" CMAKE_ANDROID_NDK)
+ elseif(IS_DIRECTORY "$ENV{ANDROID_NDK}")
+ file(TO_CMAKE_PATH "$ENV{ANDROID_NDK}" CMAKE_ANDROID_NDK)
+ elseif(IS_DIRECTORY "$ENV{ANDROID_STANDALONE_TOOLCHAIN}")
+ file(TO_CMAKE_PATH "$ENV{ANDROID_STANDALONE_TOOLCHAIN}" CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
+ endif()
+ # TODO: Search harder for the NDK or standalone toolchain.
+endif()
+
+set(_ANDROID_STANDALONE_TOOLCHAIN_API "")
+if(CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
+ set(_ANDROID_API_LEVEL_H_REGEX "^[\t ]*#[\t ]*define[\t ]+__ANDROID_API__[\t ]+([0-9]+)")
+ file(STRINGS "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/sysroot/usr/include/android/api-level.h"
+ _ANDROID_API_LEVEL_H_CONTENT REGEX "${_ANDROID_API_LEVEL_H_REGEX}")
+ if(_ANDROID_API_LEVEL_H_CONTENT MATCHES "${_ANDROID_API_LEVEL_H_REGEX}")
+ set(_ANDROID_STANDALONE_TOOLCHAIN_API "${CMAKE_MATCH_1}")
+ endif()
+endif()
+
+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()
+
+# https://developer.android.com/ndk/guides/abis.html
+
+set(_ANDROID_ABI_arm64-v8a_PROC "aarch64")
+set(_ANDROID_ABI_arm64-v8a_ARCH "arm64")
+set(_ANDROID_ABI_armeabi-v7a_PROC "armv7-a")
+set(_ANDROID_ABI_armeabi-v7a_ARCH "arm")
+set(_ANDROID_ABI_armeabi-v6_PROC "armv6")
+set(_ANDROID_ABI_armeabi-v6_ARCH "arm")
+set(_ANDROID_ABI_armeabi_PROC "armv5te")
+set(_ANDROID_ABI_armeabi_ARCH "arm")
+set(_ANDROID_ABI_mips_PROC "mips")
+set(_ANDROID_ABI_mips_ARCH "mips")
+set(_ANDROID_ABI_mips64_PROC "mips64")
+set(_ANDROID_ABI_mips64_ARCH "mips64")
+set(_ANDROID_ABI_x86_PROC "i686")
+set(_ANDROID_ABI_x86_ARCH "x86")
+set(_ANDROID_ABI_x86_64_PROC "x86_64")
+set(_ANDROID_ABI_x86_64_ARCH "x86_64")
+
+set(_ANDROID_PROC_aarch64_ARCH_ABI "arm64-v8a")
+set(_ANDROID_PROC_armv7-a_ARCH_ABI "armeabi-v7a")
+set(_ANDROID_PROC_armv6_ARCH_ABI "armeabi-v6")
+set(_ANDROID_PROC_armv5te_ARCH_ABI "armeabi")
+set(_ANDROID_PROC_i686_ARCH_ABI "x86")
+set(_ANDROID_PROC_mips_ARCH_ABI "mips")
+set(_ANDROID_PROC_mips64_ARCH_ABI "mips64")
+set(_ANDROID_PROC_x86_64_ARCH_ABI "x86_64")
+
+set(_ANDROID_ARCH_arm64_ABI "arm64-v8a")
+set(_ANDROID_ARCH_arm_ABI "armeabi")
+set(_ANDROID_ARCH_mips_ABI "mips")
+set(_ANDROID_ARCH_mips64_ABI "mips64")
+set(_ANDROID_ARCH_x86_ABI "x86")
+set(_ANDROID_ARCH_x86_64_ABI "x86_64")
+
+# Validate inputs.
+if(CMAKE_ANDROID_ARCH_ABI AND NOT DEFINED "_ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_PROC")
+ message(FATAL_ERROR "Android: Unknown ABI CMAKE_ANDROID_ARCH_ABI='${CMAKE_ANDROID_ARCH_ABI}'.")
+endif()
+if(CMAKE_SYSTEM_PROCESSOR AND NOT DEFINED "_ANDROID_PROC_${CMAKE_SYSTEM_PROCESSOR}_ARCH_ABI")
+ message(FATAL_ERROR "Android: Unknown processor CMAKE_SYSTEM_PROCESSOR='${CMAKE_SYSTEM_PROCESSOR}'.")
+endif()
+if(_ANDROID_SYSROOT_ARCH AND NOT DEFINED "_ANDROID_ARCH_${_ANDROID_SYSROOT_ARCH}_ABI")
+ message(FATAL_ERROR
+ "Android: Unknown architecture '${_ANDROID_SYSROOT_ARCH}' specified in CMAKE_SYSROOT:\n"
+ " ${CMAKE_SYSROOT}"
+ )
+endif()
+
+# Select an ABI.
+if(NOT CMAKE_ANDROID_ARCH_ABI)
+ if(CMAKE_SYSTEM_PROCESSOR)
+ set(CMAKE_ANDROID_ARCH_ABI "${_ANDROID_PROC_${CMAKE_SYSTEM_PROCESSOR}_ARCH_ABI}")
+ elseif(_ANDROID_SYSROOT_ARCH)
+ set(CMAKE_ANDROID_ARCH_ABI "${_ANDROID_ARCH_${_ANDROID_SYSROOT_ARCH}_ABI}")
+ else()
+ # https://developer.android.com/ndk/guides/application_mk.html
+ # Default is the oldest ARM ABI.
+ set(CMAKE_ANDROID_ARCH_ABI "armeabi")
+ endif()
+endif()
+set(CMAKE_ANDROID_ARCH "${_ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_ARCH}")
+if(_ANDROID_SYSROOT_ARCH AND NOT "x${_ANDROID_SYSROOT_ARCH}" STREQUAL "x${CMAKE_ANDROID_ARCH}")
+ message(FATAL_ERROR
+ "Android: Architecture '${_ANDROID_SYSROOT_ARCH}' specified in CMAKE_SYSROOT:\n"
+ " ${CMAKE_SYSROOT}\n"
+ "does not match architecture '${CMAKE_ANDROID_ARCH}' for the ABI '${CMAKE_ANDROID_ARCH_ABI}'."
+ )
+endif()
+
+# Select a processor.
+if(NOT CMAKE_SYSTEM_PROCESSOR)
+ set(CMAKE_SYSTEM_PROCESSOR "${_ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_PROC}")
+endif()
+
+# If the user specified both an ABI and a processor then they might not match.
+if(NOT _ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_PROC STREQUAL CMAKE_SYSTEM_PROCESSOR)
+ 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()
+
+# Save the Android-specific information in CMakeSystem.cmake.
+set(CMAKE_SYSTEM_CUSTOM_CODE "
+set(CMAKE_ANDROID_NDK \"${CMAKE_ANDROID_NDK}\")
+set(CMAKE_ANDROID_STANDALONE_TOOLCHAIN \"${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}\")
+set(CMAKE_ANDROID_ARCH \"${CMAKE_ANDROID_ARCH}\")
+set(CMAKE_ANDROID_ARCH_ABI \"${CMAKE_ANDROID_ARCH_ABI}\")
+")
+
+# Select an ARM variant.
+if(CMAKE_ANDROID_ARCH_ABI MATCHES "^armeabi")
+ if(CMAKE_ANDROID_ARM_MODE)
+ set(CMAKE_ANDROID_ARM_MODE 1)
+ else()
+ set(CMAKE_ANDROID_ARM_MODE 0)
+ endif()
+ string(APPEND CMAKE_SYSTEM_CUSTOM_CODE
+ "set(CMAKE_ANDROID_ARM_MODE \"${CMAKE_ANDROID_ARM_MODE}\")\n"
+ )
+elseif(DEFINED CMAKE_ANDROID_ARM_MODE)
+ message(FATAL_ERROR "Android: CMAKE_ANDROID_ARM_MODE is set but is valid only for 'armeabi' architectures.")
+endif()
+
+if(CMAKE_ANDROID_ARCH_ABI STREQUAL "armeabi-v7a")
+ if(CMAKE_ANDROID_ARM_NEON)
+ set(CMAKE_ANDROID_ARM_NEON 1)
+ else()
+ set(CMAKE_ANDROID_ARM_NEON 0)
+ endif()
+ string(APPEND CMAKE_SYSTEM_CUSTOM_CODE
+ "set(CMAKE_ANDROID_ARM_NEON \"${CMAKE_ANDROID_ARM_NEON}\")\n"
+ )
+elseif(DEFINED CMAKE_ANDROID_ARM_NEON)
+ message(FATAL_ERROR "Android: CMAKE_ANDROID_ARM_NEON is set but is valid only for 'armeabi-v7a' architecture.")
+endif()
+
+# Report the chosen architecture.
+message(STATUS "Android: Targeting API '${CMAKE_SYSTEM_VERSION}' with architecture '${CMAKE_ANDROID_ARCH}', ABI '${CMAKE_ANDROID_ARCH_ABI}', and processor '${CMAKE_SYSTEM_PROCESSOR}'")
diff --git a/Modules/Platform/Android-GNU-C.cmake b/Modules/Platform/Android-GNU-C.cmake
new file mode 100644
index 0000000..78a6a50
--- /dev/null
+++ b/Modules/Platform/Android-GNU-C.cmake
@@ -0,0 +1,2 @@
+include(Platform/Android-GNU)
+__android_compiler_gnu(C)
diff --git a/Modules/Platform/Android-GNU-CXX.cmake b/Modules/Platform/Android-GNU-CXX.cmake
new file mode 100644
index 0000000..41279d1
--- /dev/null
+++ b/Modules/Platform/Android-GNU-CXX.cmake
@@ -0,0 +1,2 @@
+include(Platform/Android-GNU)
+__android_compiler_gnu(CXX)
diff --git a/Modules/Platform/Android-GNU.cmake b/Modules/Platform/Android-GNU.cmake
new file mode 100644
index 0000000..58943d0
--- /dev/null
+++ b/Modules/Platform/Android-GNU.cmake
@@ -0,0 +1,43 @@
+#=============================================================================
+# Copyright 2015-2016 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+# This module is shared by multiple languages; use include blocker.
+if(__ANDROID_COMPILER_GNU)
+ return()
+endif()
+set(__ANDROID_COMPILER_GNU 1)
+
+# Support for NVIDIA Nsight Tegra Visual Studio Edition was previously
+# implemented in the CMake VS IDE generators. Avoid interfering with
+# that functionality for now. Later we may try to integrate this.
+if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")
+ macro(__android_compiler_gnu lang)
+ endmacro()
+ return()
+endif()
+
+# Commonly used Android toolchain files that pre-date CMake upstream support
+# set CMAKE_SYSTEM_VERSION to 1. Avoid interfering with them.
+if(CMAKE_SYSTEM_VERSION EQUAL 1)
+ macro(__android_compiler_gnu lang)
+ endmacro()
+ return()
+endif()
+
+include(Platform/Android-Common)
+
+include(Platform/Android/abi-${CMAKE_ANDROID_ARCH_ABI}-GNU)
+
+macro(__android_compiler_gnu lang)
+ __android_compiler_common(${lang})
+endmacro()
diff --git a/Modules/Platform/Android-Initialize.cmake b/Modules/Platform/Android-Initialize.cmake
new file mode 100644
index 0000000..353dd0d
--- /dev/null
+++ b/Modules/Platform/Android-Initialize.cmake
@@ -0,0 +1,51 @@
+#=============================================================================
+# Copyright 2015-2016 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+# When CMAKE_SYSTEM_NAME is "Android", CMakeSystemSpecificInitialize loads this
+# module.
+
+# Support for NVIDIA Nsight Tegra Visual Studio Edition was previously
+# implemented in the CMake VS IDE generators. Avoid interfering with
+# that functionality for now. Later we may try to integrate this.
+if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")
+ return()
+endif()
+
+# Commonly used Android toolchain files that pre-date CMake upstream support
+# set CMAKE_SYSTEM_VERSION to 1. Avoid interfering with them.
+if(CMAKE_SYSTEM_VERSION EQUAL 1)
+ 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}")
+ elseif(CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
+ set(CMAKE_SYSROOT "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/sysroot")
+ endif()
+endif()
+
+if(CMAKE_SYSROOT)
+ if(NOT IS_DIRECTORY "${CMAKE_SYSROOT}")
+ message(FATAL_ERROR
+ "Android: The system root directory needed for the selected Android version and architecture does not exist:\n"
+ " ${CMAKE_SYSROOT}\n"
+ )
+ endif()
+else()
+ message(FATAL_ERROR
+ "Android: No CMAKE_SYSROOT was selected."
+ )
+endif()
+
+set(CMAKE_BUILD_TYPE_INIT Debug)
diff --git a/Modules/Platform/Android.cmake b/Modules/Platform/Android.cmake
index 1bdad04..3d69733 100644
--- a/Modules/Platform/Android.cmake
+++ b/Modules/Platform/Android.cmake
@@ -1,5 +1,7 @@
include(Platform/Linux)
+set(ANDROID 1)
+
# 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.
set(CMAKE_PLATFORM_NO_VERSIONED_SONAME 1)
diff --git a/Modules/Platform/Android/Determine-Compiler-NDK.cmake b/Modules/Platform/Android/Determine-Compiler-NDK.cmake
new file mode 100644
index 0000000..8bd0de9
--- /dev/null
+++ b/Modules/Platform/Android/Determine-Compiler-NDK.cmake
@@ -0,0 +1,256 @@
+#=============================================================================
+# Copyright 2015-2016 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+# In Android NDK releases there is build system toolchain selection logic in
+# these files:
+#
+# * <ndk>/build/core/init.mk
+# * <ndk>/build/core/setup-toolchain.mk
+# * <ndk>/[build/core/]toolchains/<toolchain>/{config.mk,setup.mk}
+#
+# We parse information out of the ``config.mk`` and ``setup.mk`` files below.
+#
+# There is also a "toolchains" directory with the prebuilt toolchains themselves:
+#
+# * <triple-or-arch>-<gcc-version>/prebuilt/<host>/bin/<triple>-gcc(.exe)?
+# The gcc compiler to be invoked.
+#
+# * llvm*/prebuilt/<host>/bin/clang
+# The clang compiler to be invoked with flags:
+# -target <triple>
+# -gcc-toolchain <ndk>/toolchains/<triple-or-arch>-<gcc-version>
+
+# Glob available toolchains in the NDK, restricted by any version request.
+if(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION STREQUAL "clang")
+ set(_ANDROID_TOOL_PATTERNS "*-clang" "*-clang[0-9].[0-9]")
+elseif(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION)
+ if(NOT CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION MATCHES "^(clang)?[0-9]\\.[0-9]$")
+ message(FATAL_ERROR
+ "Android: The CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION value '${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}' "
+ "is not one of the allowed forms:\n"
+ " <major>.<minor> = GCC of specified version\n"
+ " clang<major>.<minor> = Clang of specified version\n"
+ " clang = Clang of most recent available version\n"
+ )
+ endif()
+ set(_ANDROID_TOOL_PATTERNS "*-${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}")
+else()
+ set(_ANDROID_TOOL_PATTERNS "*-[0-9].[0-9]")
+endif()
+set(_ANDROID_CONFIG_MK_PATTERNS)
+foreach(base "build/core/toolchains" "toolchains")
+ foreach(pattern IN LISTS _ANDROID_TOOL_PATTERNS)
+ list(APPEND _ANDROID_CONFIG_MK_PATTERNS
+ "${CMAKE_ANDROID_NDK}/${base}/${pattern}/config.mk"
+ )
+ endforeach()
+endforeach()
+unset(_ANDROID_TOOL_PATTERNS)
+file(GLOB _ANDROID_CONFIG_MKS ${_ANDROID_CONFIG_MK_PATTERNS})
+unset(_ANDROID_CONFIG_MK_PATTERNS)
+
+# Find the newest toolchain version matching the ABI.
+set(_ANDROID_TOOL_NAME "")
+set(_ANDROID_TOOL_VERS 0)
+set(_ANDROID_TOOL_SETUP_MK "")
+foreach(config_mk IN LISTS _ANDROID_CONFIG_MKS)
+ # Check that the toolchain matches the ABI.
+ file(STRINGS "${config_mk}" _ANDROID_TOOL_ABIS REGEX "^TOOLCHAIN_ABIS :=.* ${CMAKE_ANDROID_ARCH_ABI}( |$)")
+ if(NOT _ANDROID_TOOL_ABIS)
+ continue()
+ endif()
+ unset(_ANDROID_TOOL_ABIS)
+
+ # Check the version.
+ if("${config_mk}" MATCHES [[/([^/]+-(clang)?([0-9]\.[0-9]|))/config.mk$]])
+ set(_ANDROID_CUR_NAME "${CMAKE_MATCH_1}")
+ set(_ANDROID_CUR_VERS "${CMAKE_MATCH_3}")
+ if(_ANDROID_TOOL_VERS STREQUAL "")
+ # already the latest possible
+ elseif(_ANDROID_CUR_VERS STREQUAL "" OR _ANDROID_CUR_VERS VERSION_GREATER _ANDROID_TOOL_VERS)
+ set(_ANDROID_TOOL_NAME "${_ANDROID_CUR_NAME}")
+ set(_ANDROID_TOOL_VERS "${_ANDROID_CUR_VERS}")
+ string(REPLACE "/config.mk" "/setup.mk" _ANDROID_TOOL_SETUP_MK "${config_mk}")
+ endif()
+ unset(_ANDROID_CUR_TOOL)
+ unset(_ANDROID_CUR_VERS)
+ endif()
+endforeach()
+
+# Verify that we have a suitable toolchain.
+if(NOT _ANDROID_TOOL_NAME)
+ if(_ANDROID_CONFIG_MKS)
+ string(REPLACE ";" "\n " _ANDROID_TOOLS_MSG "after considering:;${_ANDROID_CONFIG_MKS}")
+ else()
+ set(_ANDROID_TOOLS_MSG "")
+ endif()
+ if(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION)
+ string(CONCAT _ANDROID_TOOLS_MSG
+ "of the version specified by CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION:\n"
+ " ${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}\n"
+ "${_ANDROID_TOOLS_MSG}")
+ endif()
+ message(FATAL_ERROR
+ "Android: No toolchain for ABI '${CMAKE_ANDROID_ARCH_ABI}' found in the NDK:\n"
+ " ${CMAKE_ANDROID_NDK}\n"
+ "${_ANDROID_TOOLS_MSG}"
+ )
+endif()
+unset(_ANDROID_CONFIG_MKS)
+
+# For clang toolchains we still need to find a gcc toolchain.
+if(_ANDROID_TOOL_NAME MATCHES "-clang")
+ set(_ANDROID_TOOL_CLANG_NAME "${_ANDROID_TOOL_NAME}")
+ set(_ANDROID_TOOL_CLANG_VERS "${_ANDROID_TOOL_VERS}")
+ set(_ANDROID_TOOL_NAME "")
+ set(_ANDROID_TOOL_VERS "")
+else()
+ set(_ANDROID_TOOL_CLANG_NAME "")
+ set(_ANDROID_TOOL_CLANG_VERS "")
+endif()
+
+# Parse the toolchain setup.mk file to extract information we need.
+# Their content is not standardized across toolchains or NDK versions,
+# so we match known cases. Note that the parsing is stateful across
+# lines because we need to substitute for some Make variable references.
+if(CMAKE_ANDROID_NDK_TOOLCHAIN_DEBUG)
+ message(STATUS "loading: ${_ANDROID_TOOL_SETUP_MK}")
+endif()
+file(STRINGS "${_ANDROID_TOOL_SETUP_MK}" _ANDROID_TOOL_SETUP REGEX "^(LLVM|TOOLCHAIN)_[A-Z_]+ +:= +.*$")
+unset(_ANDROID_TOOL_SETUP_MK)
+set(_ANDROID_TOOL_PREFIX "")
+set(_ANDROID_TOOL_NAME_ONLY "")
+set(_ANDROID_TOOL_LLVM_NAME "")
+set(_ANDROID_TOOL_LLVM_VERS "")
+foreach(line IN LISTS _ANDROID_TOOL_SETUP)
+ if(CMAKE_ANDROID_NDK_TOOLCHAIN_DEBUG)
+ message(STATUS "setup.mk: ${line}")
+ endif()
+
+ if(line MATCHES [[^TOOLCHAIN_PREFIX +:= +.*/bin/([^$/ ]*) *$]])
+ # We just matched the toolchain prefix with no Make variable references.
+ set(_ANDROID_TOOL_PREFIX "${CMAKE_MATCH_1}")
+ elseif(_ANDROID_TOOL_CLANG_NAME)
+ # For clang toolchains we need to find more information.
+ if(line MATCHES [[^TOOLCHAIN_VERSION +:= +([0-9.]+) *$]])
+ # We just matched the gcc toolchain version number. Save it for later.
+ set(_ANDROID_TOOL_VERS "${CMAKE_MATCH_1}")
+ elseif(line MATCHES [[^TOOLCHAIN_NAME +:= +(.*\$\(TOOLCHAIN_VERSION\)) *$]])
+ # We just matched the gcc toolchain name with a version number placeholder, so substitute it.
+ # The gcc toolchain version number will have already been extracted from a TOOLCHAIN_VERSION line.
+ string(REPLACE "$(TOOLCHAIN_VERSION)" "${_ANDROID_TOOL_VERS}" _ANDROID_TOOL_NAME "${CMAKE_MATCH_1}")
+ elseif(line MATCHES [[^TOOLCHAIN_NAME +:= +([^$/ ]+) *$]])
+ # We just matched the gcc toolchain name without version number. Save it for later.
+ set(_ANDROID_TOOL_NAME_ONLY "${CMAKE_MATCH_1}")
+ elseif(line MATCHES [[^TOOLCHAIN_PREFIX +:= +.*/bin/(\$\(TOOLCHAIN_NAME\)-) *$]])
+ # We just matched the toolchain prefix with a name placholder, so substitute it.
+ # The gcc toolchain name will have already been extracted without version number from a TOOLCHAIN_NAME line.
+ string(REPLACE "$(TOOLCHAIN_NAME)" "${_ANDROID_TOOL_NAME_ONLY}" _ANDROID_TOOL_PREFIX "${CMAKE_MATCH_1}")
+ elseif(line MATCHES [[^LLVM_VERSION +:= +([0-9.]+)$]])
+ # We just matched the llvm prebuilt binary toolchain version number. Save it for later.
+ set(_ANDROID_TOOL_LLVM_VERS "${CMAKE_MATCH_1}")
+ elseif(line MATCHES [[^LLVM_NAME +:= +(llvm-\$\(LLVM_VERSION\)) *$]])
+ # We just matched the llvm prebuilt binary toolchain directory name with a version number placeholder,
+ # so substitute it. The llvm prebuilt binary toolchain version number will have already been extracted
+ # from a LLVM_VERSION line.
+ string(REPLACE "$(LLVM_VERSION)" "${_ANDROID_TOOL_LLVM_VERS}" _ANDROID_TOOL_LLVM_NAME "${CMAKE_MATCH_1}")
+ elseif(line MATCHES [[^LLVM_TOOLCHAIN_PREBUILT_ROOT +:= +\$\(call get-toolchain-root.*,([^$ ]+)\) *$]])
+ # We just matched the llvm prebuilt binary toolchain directory name.
+ set(_ANDROID_TOOL_LLVM_NAME "${CMAKE_MATCH_1}")
+ elseif(line MATCHES [[^TOOLCHAIN_ROOT +:= +\$\(call get-toolchain-root.*,(\$\(TOOLCHAIN_NAME\)-[0-9.]+)\) *$]])
+ # We just matched a placeholder for the name followed by a version number.
+ # The gcc toolchain name will have already been extracted without version number from a TOOLCHAIN_NAME line.
+ # Substitute for the placeholder to get the full gcc toolchain name.
+ string(REPLACE "$(TOOLCHAIN_NAME)" "${_ANDROID_TOOL_NAME_ONLY}" _ANDROID_TOOL_NAME "${CMAKE_MATCH_1}")
+ elseif(line MATCHES [[^TOOLCHAIN_ROOT +:= +\$\(call get-toolchain-root.*,([^$ ]+)\) *$]])
+ # We just matched the full gcc toolchain name without placeholder.
+ set(_ANDROID_TOOL_NAME "${CMAKE_MATCH_1}")
+ endif()
+ endif()
+endforeach()
+unset(_ANDROID_TOOL_NAME_ONLY)
+unset(_ANDROID_TOOL_LLVM_VERS)
+unset(_ANDROID_TOOL_SETUP)
+
+# Fall back to parsing the version and prefix from the tool name.
+if(NOT _ANDROID_TOOL_VERS AND "${_ANDROID_TOOL_NAME}" MATCHES "-([0-9.]+)$")
+ set(_ANDROID_TOOL_VERS "${CMAKE_MATCH_1}")
+endif()
+if(NOT _ANDROID_TOOL_PREFIX AND "${_ANDROID_TOOL_NAME}" MATCHES "^(.*-)[0-9.]+$")
+ set(_ANDROID_TOOL_PREFIX "${CMAKE_MATCH_1}")
+endif()
+
+# Identify the host platform.
+if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
+ if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ set(_ANDROID_HOST_DIR "darwin-x86_64")
+ else()
+ set(_ANDROID_HOST_DIR "darwin-x86")
+ endif()
+elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
+ if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ set(_ANDROID_HOST_DIR "linux-x86_64")
+ else()
+ set(_ANDROID_HOST_DIR "linux-x86")
+ endif()
+elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
+ if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "AMD64")
+ set(_ANDROID_HOST_DIR "windows-x86_64")
+ else()
+ set(_ANDROID_HOST_DIR "windows")
+ endif()
+else()
+ message(FATAL_ERROR "Android: Builds hosted on '${CMAKE_HOST_SYSTEM_NAME}' not supported.")
+endif()
+
+# Help CMakeFindBinUtils locate things.
+set(_CMAKE_TOOLCHAIN_PREFIX "${_ANDROID_TOOL_PREFIX}")
+
+set(_ANDROID_TOOL_C_TOOLCHAIN_VERSION "${_ANDROID_TOOL_VERS}")
+set(_ANDROID_TOOL_C_TOOLCHAIN_PREFIX "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_NAME}/prebuilt/${_ANDROID_HOST_DIR}/bin/${_ANDROID_TOOL_PREFIX}")
+set(_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX "${_ANDROID_HOST_EXT}")
+
+set(_ANDROID_TOOL_CXX_TOOLCHAIN_VERSION "${_ANDROID_TOOL_C_TOOLCHAIN_VERSION}")
+set(_ANDROID_TOOL_CXX_TOOLCHAIN_PREFIX "${_ANDROID_TOOL_C_TOOLCHAIN_PREFIX}")
+set(_ANDROID_TOOL_CXX_TOOLCHAIN_SUFFIX "${_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX}")
+
+if(_ANDROID_TOOL_CLANG_NAME)
+ message(STATUS "Android: Selected Clang toolchain '${_ANDROID_TOOL_CLANG_NAME}' with GCC toolchain '${_ANDROID_TOOL_NAME}'")
+ set(_ANDROID_TOOL_C_COMPILER "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_LLVM_NAME}/prebuilt/${_ANDROID_HOST_DIR}/bin/clang${_ANDROID_HOST_EXT}")
+ set(_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN ${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_NAME}/prebuilt/${_ANDROID_HOST_DIR})
+ set(_ANDROID_TOOL_CXX_COMPILER "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_LLVM_NAME}/prebuilt/${_ANDROID_HOST_DIR}/bin/clang++${_ANDROID_HOST_EXT}")
+ set(_ANDROID_TOOL_CXX_COMPILER_EXTERNAL_TOOLCHAIN "${_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN}")
+else()
+ message(STATUS "Android: Selected GCC toolchain '${_ANDROID_TOOL_NAME}'")
+ set(_ANDROID_TOOL_C_COMPILER "${_ANDROID_TOOL_C_TOOLCHAIN_PREFIX}gcc${_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX}")
+ set(_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN "")
+ set(_ANDROID_TOOL_CXX_COMPILER "${_ANDROID_TOOL_CXX_TOOLCHAIN_PREFIX}g++${_ANDROID_TOOL_CXX_TOOLCHAIN_SUFFIX}")
+ set(_ANDROID_TOOL_CXX_COMPILER_EXTERNAL_TOOLCHAIN "")
+endif()
+
+if(CMAKE_ANDROID_NDK_TOOLCHAIN_DEBUG)
+ message(STATUS "_ANDROID_TOOL_NAME=${_ANDROID_TOOL_NAME}")
+ message(STATUS "_ANDROID_TOOL_VERS=${_ANDROID_TOOL_VERS}")
+ message(STATUS "_ANDROID_TOOL_PREFIX=${_ANDROID_TOOL_PREFIX}")
+ message(STATUS "_ANDROID_TOOL_CLANG_NAME=${_ANDROID_TOOL_CLANG_NAME}")
+ message(STATUS "_ANDROID_TOOL_CLANG_VERS=${_ANDROID_TOOL_CLANG_VERS}")
+ message(STATUS "_ANDROID_TOOL_LLVM_NAME=${_ANDROID_TOOL_LLVM_NAME}")
+endif()
+
+unset(_ANDROID_TOOL_NAME)
+unset(_ANDROID_TOOL_VERS)
+unset(_ANDROID_TOOL_PREFIX)
+unset(_ANDROID_TOOL_CLANG_NAME)
+unset(_ANDROID_TOOL_CLANG_VERS)
+unset(_ANDROID_TOOL_LLVM_NAME)
+unset(_ANDROID_HOST_DIR)
diff --git a/Modules/Platform/Android/Determine-Compiler-Standalone.cmake b/Modules/Platform/Android/Determine-Compiler-Standalone.cmake
new file mode 100644
index 0000000..64d4ccf
--- /dev/null
+++ b/Modules/Platform/Android/Determine-Compiler-Standalone.cmake
@@ -0,0 +1,69 @@
+#=============================================================================
+# Copyright 2015-2016 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+set(_ANDROID_TOOL_C_COMPILER "")
+set(_ANDROID_TOOL_CXX_COMPILER "")
+set(_ANDROID_TOOL_PREFIX "")
+file(GLOB _gcc "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/bin/*-gcc${_ANDROID_HOST_EXT}")
+foreach(gcc IN LISTS _gcc)
+ if("${gcc}" MATCHES "/bin/([^/]*)gcc${_ANDROID_HOST_EXT}$")
+ set(_ANDROID_TOOL_PREFIX "${CMAKE_MATCH_1}")
+ break()
+ endif()
+endforeach()
+
+if(NOT _ANDROID_TOOL_PREFIX)
+ message(FATAL_ERROR
+ "Android: No '*-gcc' compiler found in CMAKE_ANDROID_STANDALONE_TOOLCHAIN:\n"
+ " ${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}"
+ )
+endif()
+
+# Help CMakeFindBinUtils locate things.
+set(_CMAKE_TOOLCHAIN_PREFIX "${_ANDROID_TOOL_PREFIX}")
+
+execute_process(
+ COMMAND "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/bin/${_ANDROID_TOOL_PREFIX}gcc${_ANDROID_HOST_EXT}" -dumpversion
+ OUTPUT_VARIABLE _gcc_version
+ ERROR_VARIABLE _gcc_error
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+if(_gcc_version MATCHES "^([0-9]+\\.[0-9]+)")
+ set(_ANDROID_TOOL_C_TOOLCHAIN_VERSION "${CMAKE_MATCH_1}")
+else()
+ message(FATAL_ERROR
+ "Android: Failed to extract the standalone toolchain version. The command:\n"
+ " '${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/bin/${_ANDROID_TOOL_PREFIX}gcc${_ANDROID_HOST_EXT}' '-dumpversion'\n"
+ "produced output:\n"
+ " ${_gcc_version}\n"
+ )
+endif()
+
+set(_ANDROID_TOOL_C_TOOLCHAIN_PREFIX "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/bin/${_ANDROID_TOOL_PREFIX}")
+set(_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX "${_ANDROID_HOST_EXT}")
+
+set(_ANDROID_TOOL_CXX_TOOLCHAIN_VERSION "${_ANDROID_TOOL_C_TOOLCHAIN_VERSION}")
+set(_ANDROID_TOOL_CXX_TOOLCHAIN_PREFIX "${_ANDROID_TOOL_C_TOOLCHAIN_PREFIX}")
+set(_ANDROID_TOOL_CXX_TOOLCHAIN_SUFFIX "${_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX}")
+
+if(EXISTS "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/bin/clang${_ANDROID_HOST_EXT}")
+ set(_ANDROID_TOOL_C_COMPILER "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/bin/clang${_ANDROID_HOST_EXT}")
+ set(_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}")
+ set(_ANDROID_TOOL_CXX_COMPILER "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/bin/clang++${_ANDROID_HOST_EXT}")
+ set(_ANDROID_TOOL_CXX_COMPILER_EXTERNAL_TOOLCHAIN "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}")
+else()
+ set(_ANDROID_TOOL_C_COMPILER "${_ANDROID_TOOL_C_TOOLCHAIN_PREFIX}gcc${_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX}")
+ set(_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN "")
+ set(_ANDROID_TOOL_CXX_COMPILER "${_ANDROID_TOOL_CXX_TOOLCHAIN_PREFIX}g++${_ANDROID_TOOL_CXX_TOOLCHAIN_SUFFIX}")
+ set(_ANDROID_TOOL_CXX_COMPILER_EXTERNAL_TOOLCHAIN "")
+endif()
diff --git a/Modules/Platform/Android/Determine-Compiler.cmake b/Modules/Platform/Android/Determine-Compiler.cmake
new file mode 100644
index 0000000..65223dc
--- /dev/null
+++ b/Modules/Platform/Android/Determine-Compiler.cmake
@@ -0,0 +1,80 @@
+#=============================================================================
+# Copyright 2015-2016 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+# This module is shared by multiple languages; use include blocker.
+if(__ANDROID_DETERMINE_COMPILER)
+ return()
+endif()
+set(__ANDROID_DETERMINE_COMPILER 1)
+
+# Support for NVIDIA Nsight Tegra Visual Studio Edition was previously
+# implemented in the CMake VS IDE generators. Avoid interfering with
+# that functionality for now. Later we may try to integrate this.
+if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")
+ macro(__android_determine_compiler lang)
+ endmacro()
+ return()
+endif()
+
+# Commonly used Android toolchain files that pre-date CMake upstream support
+# set CMAKE_SYSTEM_VERSION to 1. Avoid interfering with them.
+if(CMAKE_SYSTEM_VERSION EQUAL 1)
+ macro(__android_determine_compiler lang)
+ endmacro()
+ return()
+endif()
+
+# Identify the host platform.
+if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
+ set(_ANDROID_HOST_EXT "")
+elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
+ set(_ANDROID_HOST_EXT "")
+elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
+ set(_ANDROID_HOST_EXT ".exe")
+else()
+ message(FATAL_ERROR "Android: Builds hosted on '${CMAKE_HOST_SYSTEM_NAME}' not supported.")
+endif()
+
+if(CMAKE_ANDROID_NDK)
+ include(Platform/Android/Determine-Compiler-NDK)
+elseif(CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
+ include(Platform/Android/Determine-Compiler-Standalone)
+else()
+ set(_ANDROID_TOOL_C_COMPILER "")
+ set(_ANDROID_TOOL_C_TOOLCHAIN_VERSION "")
+ set(_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN "")
+ set(_ANDROID_TOOL_C_TOOLCHAIN_PREFIX "")
+ set(_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX "")
+ set(_ANDROID_TOOL_CXX_COMPILER "")
+ set(_ANDROID_TOOL_CXX_TOOLCHAIN_VERSION "")
+ set(_ANDROID_TOOL_CXX_COMPILER_EXTERNAL_TOOLCHAIN "")
+ set(_ANDROID_TOOL_CXX_TOOLCHAIN_PREFIX "")
+ set(_ANDROID_TOOL_CXX_TOOLCHAIN_SUFFIX "")
+endif()
+
+unset(_ANDROID_HOST_EXT)
+
+macro(__android_determine_compiler lang)
+ if(_ANDROID_TOOL_${lang}_COMPILER)
+ set(CMAKE_${lang}_COMPILER "${_ANDROID_TOOL_${lang}_COMPILER}")
+ set(CMAKE_${lang}_COMPILER_EXTERNAL_TOOLCHAIN "${_ANDROID_TOOL_${lang}_COMPILER_EXTERNAL_TOOLCHAIN}")
+
+ # Save the Android-specific information in CMake${lang}Compiler.cmake.
+ set(CMAKE_${lang}_COMPILER_CUSTOM_CODE "
+set(CMAKE_${lang}_ANDROID_TOOLCHAIN_VERSION \"${_ANDROID_TOOL_${lang}_TOOLCHAIN_VERSION}\")
+set(CMAKE_${lang}_COMPILER_EXTERNAL_TOOLCHAIN \"${_ANDROID_TOOL_${lang}_COMPILER_EXTERNAL_TOOLCHAIN}\")
+set(CMAKE_${lang}_ANDROID_TOOLCHAIN_PREFIX \"${_ANDROID_TOOL_${lang}_TOOLCHAIN_PREFIX}\")
+set(CMAKE_${lang}_ANDROID_TOOLCHAIN_SUFFIX \"${_ANDROID_TOOL_${lang}_TOOLCHAIN_SUFFIX}\")
+")
+ endif()
+endmacro()
diff --git a/Modules/Platform/Android/abi-arm64-v8a-Clang.cmake b/Modules/Platform/Android/abi-arm64-v8a-Clang.cmake
new file mode 100644
index 0000000..3ff1fe5
--- /dev/null
+++ b/Modules/Platform/Android/abi-arm64-v8a-Clang.cmake
@@ -0,0 +1,8 @@
+# <ndk>/build/core/toolchains/aarch64-linux-android-clang/setup.mk
+set(_ANDROID_ABI_CLANG_TARGET "aarch64-none-linux-android")
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -fpic"
+ )
+
+include(Platform/Android/abi-common-Clang)
diff --git a/Modules/Platform/Android/abi-arm64-v8a-GNU.cmake b/Modules/Platform/Android/abi-arm64-v8a-GNU.cmake
new file mode 100644
index 0000000..538ec2f
--- /dev/null
+++ b/Modules/Platform/Android/abi-arm64-v8a-GNU.cmake
@@ -0,0 +1,6 @@
+# <ndk>/build/core/toolchains/aarch64-linux-android-4.9/setup.mk
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -fpic"
+ )
+
+include(Platform/Android/abi-common-GNU)
diff --git a/Modules/Platform/Android/abi-armeabi-Clang.cmake b/Modules/Platform/Android/abi-armeabi-Clang.cmake
new file mode 100644
index 0000000..4fc3009
--- /dev/null
+++ b/Modules/Platform/Android/abi-armeabi-Clang.cmake
@@ -0,0 +1,20 @@
+# <ndk>/build/core/toolchains/arm-linux-androideabi-clang/setup.mk
+set(_ANDROID_ABI_CLANG_TARGET "armv5te-none-linux-androideabi")
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -march=armv5te"
+ )
+
+if(CMAKE_ANDROID_ARM_MODE)
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -marm")
+else()
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mthumb")
+endif()
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -msoft-float"
+ " -mtune=xscale"
+ " -fpic"
+ )
+
+include(Platform/Android/abi-common-Clang)
diff --git a/Modules/Platform/Android/abi-armeabi-GNU.cmake b/Modules/Platform/Android/abi-armeabi-GNU.cmake
new file mode 100644
index 0000000..10cac00
--- /dev/null
+++ b/Modules/Platform/Android/abi-armeabi-GNU.cmake
@@ -0,0 +1,18 @@
+# <ndk>/build/core/toolchains/arm-linux-androideabi-4.9/setup.mk
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -march=armv5te"
+ )
+
+if(CMAKE_ANDROID_ARM_MODE)
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -marm")
+else()
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mthumb")
+endif()
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -msoft-float"
+ " -mtune=xscale"
+ " -fpic"
+ )
+
+include(Platform/Android/abi-common-GNU)
diff --git a/Modules/Platform/Android/abi-armeabi-v6-Clang.cmake b/Modules/Platform/Android/abi-armeabi-v6-Clang.cmake
new file mode 100644
index 0000000..15f1d4a
--- /dev/null
+++ b/Modules/Platform/Android/abi-armeabi-v6-Clang.cmake
@@ -0,0 +1,19 @@
+# <ndk>/build/core/toolchains/arm-linux-androideabi-clang/setup.mk
+set(_ANDROID_ABI_CLANG_TARGET "armv6-none-linux-androideabi")
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -march=armv6"
+ )
+
+if(CMAKE_ANDROID_ARM_MODE)
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -marm")
+else()
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mthumb")
+endif()
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -mfloat-abi=softfp"
+ " -fpic"
+ )
+
+include(Platform/Android/abi-common-Clang)
diff --git a/Modules/Platform/Android/abi-armeabi-v6-GNU.cmake b/Modules/Platform/Android/abi-armeabi-v6-GNU.cmake
new file mode 100644
index 0000000..7492de0
--- /dev/null
+++ b/Modules/Platform/Android/abi-armeabi-v6-GNU.cmake
@@ -0,0 +1,17 @@
+# <ndk>/build/core/toolchains/arm-linux-androideabi-4.9/setup.mk
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -march=armv6"
+ )
+
+if(CMAKE_ANDROID_ARM_MODE)
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -marm")
+else()
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mthumb")
+endif()
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -mfloat-abi=softfp"
+ " -fpic"
+ )
+
+include(Platform/Android/abi-common-GNU)
diff --git a/Modules/Platform/Android/abi-armeabi-v7a-Clang.cmake b/Modules/Platform/Android/abi-armeabi-v7a-Clang.cmake
new file mode 100644
index 0000000..3a3efb3
--- /dev/null
+++ b/Modules/Platform/Android/abi-armeabi-v7a-Clang.cmake
@@ -0,0 +1,29 @@
+# <ndk>/build/core/toolchains/arm-linux-androideabi-clang/setup.mk
+set(_ANDROID_ABI_CLANG_TARGET "armv7-none-linux-androideabi")
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -march=armv7-a"
+ )
+
+if(CMAKE_ANDROID_ARM_MODE)
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -marm")
+else()
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mthumb")
+endif()
+
+if(CMAKE_ANDROID_ARM_NEON)
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mfpu=neon")
+else()
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mfpu=vfpv3-d16")
+endif()
+
+string(APPEND _ANDROID_ABI_INIT_LDFLAGS
+ " -Wl,--fix-cortex-a8"
+ )
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -mfloat-abi=softfp"
+ " -fpic"
+ )
+
+include(Platform/Android/abi-common-Clang)
diff --git a/Modules/Platform/Android/abi-armeabi-v7a-GNU.cmake b/Modules/Platform/Android/abi-armeabi-v7a-GNU.cmake
new file mode 100644
index 0000000..d27e37e
--- /dev/null
+++ b/Modules/Platform/Android/abi-armeabi-v7a-GNU.cmake
@@ -0,0 +1,27 @@
+# <ndk>/build/core/toolchains/arm-linux-androideabi-4.9/setup.mk
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -march=armv7-a"
+ )
+
+if(CMAKE_ANDROID_ARM_MODE)
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -marm")
+else()
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mthumb")
+endif()
+
+if(CMAKE_ANDROID_ARM_NEON)
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mfpu=neon")
+else()
+ string(APPEND _ANDROID_ABI_INIT_CFLAGS " -mfpu=vfpv3-d16")
+endif()
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -mfloat-abi=softfp"
+ " -fpic"
+ )
+
+string(APPEND _ANDROID_ABI_INIT_LDFLAGS
+ " -Wl,--fix-cortex-a8"
+ )
+
+include(Platform/Android/abi-common-GNU)
diff --git a/Modules/Platform/Android/abi-common-Clang.cmake b/Modules/Platform/Android/abi-common-Clang.cmake
new file mode 100644
index 0000000..6025170
--- /dev/null
+++ b/Modules/Platform/Android/abi-common-Clang.cmake
@@ -0,0 +1,6 @@
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ #" -Wno-invalid-command-line-argument"
+ #" -Wno-unused-command-line-argument"
+ )
+
+include(Platform/Android/abi-common)
diff --git a/Modules/Platform/Android/abi-common-GNU.cmake b/Modules/Platform/Android/abi-common-GNU.cmake
new file mode 100644
index 0000000..40d829f
--- /dev/null
+++ b/Modules/Platform/Android/abi-common-GNU.cmake
@@ -0,0 +1 @@
+include(Platform/Android/abi-common)
diff --git a/Modules/Platform/Android/abi-common.cmake b/Modules/Platform/Android/abi-common.cmake
new file mode 100644
index 0000000..12d8e5c
--- /dev/null
+++ b/Modules/Platform/Android/abi-common.cmake
@@ -0,0 +1,4 @@
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -funwind-tables"
+ " -no-canonical-prefixes"
+ )
diff --git a/Modules/Platform/Android/abi-mips-Clang.cmake b/Modules/Platform/Android/abi-mips-Clang.cmake
new file mode 100644
index 0000000..bf6b9fc
--- /dev/null
+++ b/Modules/Platform/Android/abi-mips-Clang.cmake
@@ -0,0 +1,8 @@
+# <ndk>/build/core/toolchains/mipsel-linux-android-clang/setup.mk
+set(_ANDROID_ABI_CLANG_TARGET "mipsel-none-linux-android")
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -fpic"
+ )
+
+include(Platform/Android/abi-common-Clang)
diff --git a/Modules/Platform/Android/abi-mips-GNU.cmake b/Modules/Platform/Android/abi-mips-GNU.cmake
new file mode 100644
index 0000000..d380440
--- /dev/null
+++ b/Modules/Platform/Android/abi-mips-GNU.cmake
@@ -0,0 +1,6 @@
+# <ndk>/build/core/toolchains/mipsel-linux-android-4.9/setup.mk
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -fpic"
+ )
+
+include(Platform/Android/abi-common-GNU)
diff --git a/Modules/Platform/Android/abi-mips64-Clang.cmake b/Modules/Platform/Android/abi-mips64-Clang.cmake
new file mode 100644
index 0000000..1a94107
--- /dev/null
+++ b/Modules/Platform/Android/abi-mips64-Clang.cmake
@@ -0,0 +1,8 @@
+# <ndk>/build/core/toolchains/mips64el-linux-android-clang/setup.mk
+set(_ANDROID_ABI_CLANG_TARGET "mips64el-none-linux-android")
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -fpic"
+ )
+
+include(Platform/Android/abi-common-Clang)
diff --git a/Modules/Platform/Android/abi-mips64-GNU.cmake b/Modules/Platform/Android/abi-mips64-GNU.cmake
new file mode 100644
index 0000000..4525d40
--- /dev/null
+++ b/Modules/Platform/Android/abi-mips64-GNU.cmake
@@ -0,0 +1,6 @@
+# <ndk>/build/core/toolchains/mips64el-linux-android-4.9/setup.mk
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -fpic"
+ )
+
+include(Platform/Android/abi-common-GNU)
diff --git a/Modules/Platform/Android/abi-x86-Clang.cmake b/Modules/Platform/Android/abi-x86-Clang.cmake
new file mode 100644
index 0000000..f63ed36
--- /dev/null
+++ b/Modules/Platform/Android/abi-x86-Clang.cmake
@@ -0,0 +1,8 @@
+# <ndk>/build/core/toolchains/x86-clang/setup.mk
+set(_ANDROID_ABI_CLANG_TARGET "i686-none-linux-android")
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -fPIC"
+ )
+
+include(Platform/Android/abi-common-Clang)
diff --git a/Modules/Platform/Android/abi-x86-GNU.cmake b/Modules/Platform/Android/abi-x86-GNU.cmake
new file mode 100644
index 0000000..76ea5ca
--- /dev/null
+++ b/Modules/Platform/Android/abi-x86-GNU.cmake
@@ -0,0 +1,2 @@
+# <ndk>/build/core/toolchains/x86-4.9/setup.mk
+include(Platform/Android/abi-common-GNU)
diff --git a/Modules/Platform/Android/abi-x86_64-Clang.cmake b/Modules/Platform/Android/abi-x86_64-Clang.cmake
new file mode 100644
index 0000000..c15042b
--- /dev/null
+++ b/Modules/Platform/Android/abi-x86_64-Clang.cmake
@@ -0,0 +1,8 @@
+# <ndk>/build/core/toolchains/x86_64-clang/setup.mk
+set(_ANDROID_ABI_CLANG_TARGET "x86_64-none-linux-android")
+
+string(APPEND _ANDROID_ABI_INIT_CFLAGS
+ " -fPIC"
+ )
+
+include(Platform/Android/abi-common-Clang)
diff --git a/Modules/Platform/Android/abi-x86_64-GNU.cmake b/Modules/Platform/Android/abi-x86_64-GNU.cmake
new file mode 100644
index 0000000..441bdcd
--- /dev/null
+++ b/Modules/Platform/Android/abi-x86_64-GNU.cmake
@@ -0,0 +1,2 @@
+# <ndk>/build/core/toolchains/x86_64-4.9/setup.mk
+include(Platform/Android/abi-common-GNU)
diff --git a/Modules/Platform/Android/ndk-stl-c++.cmake b/Modules/Platform/Android/ndk-stl-c++.cmake
new file mode 100644
index 0000000..14748a1
--- /dev/null
+++ b/Modules/Platform/Android/ndk-stl-c++.cmake
@@ -0,0 +1,13 @@
+# <ndk>/sources/cxx-stl/llvm-libc++/Android.mk
+set(_ANDROID_STL_RTTI 1)
+set(_ANDROID_STL_EXCEPTIONS 1)
+macro(__android_stl_cxx lang filename)
+ # Add the include directory.
+ __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libcxx/include" 1)
+
+ # Add a secondary include directory if it exists.
+ __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/android/support/include" 0)
+
+ # Add the library file.
+ __android_stl_lib(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/${CMAKE_ANDROID_ARCH_ABI}/${filename}" 1)
+endmacro()
diff --git a/Modules/Platform/Android/ndk-stl-c++_shared.cmake b/Modules/Platform/Android/ndk-stl-c++_shared.cmake
new file mode 100644
index 0000000..f585adb
--- /dev/null
+++ b/Modules/Platform/Android/ndk-stl-c++_shared.cmake
@@ -0,0 +1,4 @@
+include(Platform/Android/ndk-stl-c++)
+macro(__android_stl lang)
+ __android_stl_cxx(${lang} libc++_shared.so)
+endmacro()
diff --git a/Modules/Platform/Android/ndk-stl-c++_static.cmake b/Modules/Platform/Android/ndk-stl-c++_static.cmake
new file mode 100644
index 0000000..8e562f8
--- /dev/null
+++ b/Modules/Platform/Android/ndk-stl-c++_static.cmake
@@ -0,0 +1,6 @@
+include(Platform/Android/ndk-stl-c++)
+macro(__android_stl lang)
+ __android_stl_cxx(${lang} libc++_static.a)
+ __android_stl_lib(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/${CMAKE_ANDROID_ARCH_ABI}/libc++abi.a" 0)
+ __android_stl_lib(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/${CMAKE_ANDROID_ARCH_ABI}/libandroid_support.a" 0)
+endmacro()
diff --git a/Modules/Platform/Android/ndk-stl-gabi++.cmake b/Modules/Platform/Android/ndk-stl-gabi++.cmake
new file mode 100644
index 0000000..850a47a
--- /dev/null
+++ b/Modules/Platform/Android/ndk-stl-gabi++.cmake
@@ -0,0 +1,7 @@
+# <ndk>/sources/cxx-stl/gabi++/Android.mk
+set(_ANDROID_STL_RTTI 1)
+set(_ANDROID_STL_EXCEPTIONS 1)
+macro(__android_stl_gabixx lang filename)
+ __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/gabi++/include" 1)
+ __android_stl_lib(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/gabi++/libs/${CMAKE_ANDROID_ARCH_ABI}/${filename}" 1)
+endmacro()
diff --git a/Modules/Platform/Android/ndk-stl-gabi++_shared.cmake b/Modules/Platform/Android/ndk-stl-gabi++_shared.cmake
new file mode 100644
index 0000000..314c1e0
--- /dev/null
+++ b/Modules/Platform/Android/ndk-stl-gabi++_shared.cmake
@@ -0,0 +1,4 @@
+include(Platform/Android/ndk-stl-gabi++)
+macro(__android_stl lang)
+ __android_stl_gabixx(${lang} libgabi++_shared.so)
+endmacro()
diff --git a/Modules/Platform/Android/ndk-stl-gabi++_static.cmake b/Modules/Platform/Android/ndk-stl-gabi++_static.cmake
new file mode 100644
index 0000000..f4a1d3c
--- /dev/null
+++ b/Modules/Platform/Android/ndk-stl-gabi++_static.cmake
@@ -0,0 +1,4 @@
+include(Platform/Android/ndk-stl-gabi++)
+macro(__android_stl lang)
+ __android_stl_gabixx(${lang} libgabi++_static.a)
+endmacro()
diff --git a/Modules/Platform/Android/ndk-stl-gnustl.cmake b/Modules/Platform/Android/ndk-stl-gnustl.cmake
new file mode 100644
index 0000000..b3226ee
--- /dev/null
+++ b/Modules/Platform/Android/ndk-stl-gnustl.cmake
@@ -0,0 +1,9 @@
+# <ndk>/sources/cxx-stl/gnu-libstdc++/Android.mk
+set(_ANDROID_STL_RTTI 1)
+set(_ANDROID_STL_EXCEPTIONS 1)
+macro(__android_stl_gnustl lang filename)
+ __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${CMAKE_${lang}_ANDROID_TOOLCHAIN_VERSION}/include" 1)
+ __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${CMAKE_${lang}_ANDROID_TOOLCHAIN_VERSION}/libs/${CMAKE_ANDROID_ARCH_ABI}/include" 1)
+ __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${CMAKE_${lang}_ANDROID_TOOLCHAIN_VERSION}/include/backward" 1)
+ __android_stl_lib(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${CMAKE_${lang}_ANDROID_TOOLCHAIN_VERSION}/libs/${CMAKE_ANDROID_ARCH_ABI}/${filename}" 1)
+endmacro()
diff --git a/Modules/Platform/Android/ndk-stl-gnustl_shared.cmake b/Modules/Platform/Android/ndk-stl-gnustl_shared.cmake
new file mode 100644
index 0000000..f20cc4d
--- /dev/null
+++ b/Modules/Platform/Android/ndk-stl-gnustl_shared.cmake
@@ -0,0 +1,4 @@
+include(Platform/Android/ndk-stl-gnustl)
+macro(__android_stl lang)
+ __android_stl_gnustl(${lang} libgnustl_shared.so)
+endmacro()
diff --git a/Modules/Platform/Android/ndk-stl-gnustl_static.cmake b/Modules/Platform/Android/ndk-stl-gnustl_static.cmake
new file mode 100644
index 0000000..af4cc2a
--- /dev/null
+++ b/Modules/Platform/Android/ndk-stl-gnustl_static.cmake
@@ -0,0 +1,4 @@
+include(Platform/Android/ndk-stl-gnustl)
+macro(__android_stl lang)
+ __android_stl_gnustl(${lang} libgnustl_static.a)
+endmacro()
diff --git a/Modules/Platform/Android/ndk-stl-none.cmake b/Modules/Platform/Android/ndk-stl-none.cmake
new file mode 100644
index 0000000..9049c91
--- /dev/null
+++ b/Modules/Platform/Android/ndk-stl-none.cmake
@@ -0,0 +1,2 @@
+macro(__android_stl lang)
+endmacro()
diff --git a/Modules/Platform/Android/ndk-stl-stlport.cmake b/Modules/Platform/Android/ndk-stl-stlport.cmake
new file mode 100644
index 0000000..eab6b94
--- /dev/null
+++ b/Modules/Platform/Android/ndk-stl-stlport.cmake
@@ -0,0 +1,7 @@
+# <ndk>/sources/cxx-stl/stlport/Android.mk
+set(_ANDROID_STL_RTTI 1)
+set(_ANDROID_STL_EXCEPTIONS 1)
+macro(__android_stl_stlport lang filename)
+ __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/stlport/stlport" 1)
+ __android_stl_lib(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/stlport/libs/${CMAKE_ANDROID_ARCH_ABI}/${filename}" 1)
+endmacro()
diff --git a/Modules/Platform/Android/ndk-stl-stlport_shared.cmake b/Modules/Platform/Android/ndk-stl-stlport_shared.cmake
new file mode 100644
index 0000000..2b5846b
--- /dev/null
+++ b/Modules/Platform/Android/ndk-stl-stlport_shared.cmake
@@ -0,0 +1,4 @@
+include(Platform/Android/ndk-stl-stlport)
+macro(__android_stl lang)
+ __android_stl_stlport(${lang} libstlport_shared.so)
+endmacro()
diff --git a/Modules/Platform/Android/ndk-stl-stlport_static.cmake b/Modules/Platform/Android/ndk-stl-stlport_static.cmake
new file mode 100644
index 0000000..bf60307
--- /dev/null
+++ b/Modules/Platform/Android/ndk-stl-stlport_static.cmake
@@ -0,0 +1,4 @@
+include(Platform/Android/ndk-stl-stlport)
+macro(__android_stl lang)
+ __android_stl_stlport(${lang} libstlport_static.a)
+endmacro()
diff --git a/Modules/Platform/Android/ndk-stl-system.cmake b/Modules/Platform/Android/ndk-stl-system.cmake
new file mode 100644
index 0000000..dd554fe
--- /dev/null
+++ b/Modules/Platform/Android/ndk-stl-system.cmake
@@ -0,0 +1,6 @@
+# <ndk>/android-ndk-r11c/sources/cxx-stl/system/Android.mk
+set(_ANDROID_STL_RTTI 0)
+set(_ANDROID_STL_EXCEPTIONS 0)
+macro(__android_stl lang)
+ __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/system/include" 1)
+endmacro()
diff --git a/Tests/RunCMake/Android/BadSYSROOT-result.txt b/Tests/RunCMake/Android/BadSYSROOT-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Android/BadSYSROOT-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Android/BadSYSROOT-stderr.txt b/Tests/RunCMake/Android/BadSYSROOT-stderr.txt
new file mode 100644
index 0000000..e17ca03
--- /dev/null
+++ b/Tests/RunCMake/Android/BadSYSROOT-stderr.txt
@@ -0,0 +1,20 @@
+^CMake Error at .*/Modules/Platform/Android-Determine.cmake:[0-9]+ \(message\):
+ The value of CMAKE_SYSROOT:
+
+ .*
+
+ does not match any of the forms:
+
+ <ndk>/platforms/android-<api>/arch-<arch>
+ <standalone-toolchain>/sysroot
+
+ where:
+
+ <ndk> = Android NDK directory \(with forward slashes\)
+ <api> = Android API version number \(decimal digits\)
+ <arch> = Android ARCH name \(lower case\)
+ <standalone-toolchain> = Path to standalone toolchain prefix
+
+Call Stack \(most recent call first\):
+ .*/Modules/CMakeDetermineSystem.cmake:[0-9]+ \(include\)
+ CMakeLists.txt:2 \(project\)$
diff --git a/Tests/RunCMake/Android/BadSYSROOT.cmake b/Tests/RunCMake/Android/BadSYSROOT.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/Android/BadSYSROOT.cmake
diff --git a/Tests/RunCMake/Android/CMakeLists.txt b/Tests/RunCMake/Android/CMakeLists.txt
new file mode 100644
index 0000000..dc92486
--- /dev/null
+++ b/Tests/RunCMake/Android/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.6)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/Android/RunCMakeTest.cmake b/Tests/RunCMake/Android/RunCMakeTest.cmake
new file mode 100644
index 0000000..39b77cd
--- /dev/null
+++ b/Tests/RunCMake/Android/RunCMakeTest.cmake
@@ -0,0 +1,218 @@
+cmake_minimum_required(VERSION 3.6)
+
+include(RunCMake)
+foreach(v TEST_ANDROID_NDK TEST_ANDROID_STANDALONE_TOOLCHAIN)
+ string(REPLACE "|" ";" ${v} "${${v}}")
+endforeach()
+
+function(run_Android case)
+ set(RunCMake_TEST_OPTIONS
+ -DCMAKE_SYSTEM_NAME=Android
+ ${RunCMake_TEST_OPTIONS}
+ ${ARGN}
+ )
+
+ # Use a single build tree for a few tests without cleaning.
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ run_cmake(${case})
+ run_cmake_command(${case}-build ${CMAKE_COMMAND} --build .)
+endfunction()
+
+set(RunCMake_TEST_OPTIONS
+ -DCMAKE_SYSTEM_NAME=Android
+ -DCMAKE_SYSROOT=${CMAKE_CURRENT_SOURCE_DIR}
+ )
+run_cmake(BadSYSROOT)
+unset(RunCMake_TEST_OPTIONS)
+
+foreach(ndk IN LISTS TEST_ANDROID_NDK)
+ # Load available toolchain versions and abis.
+ file(GLOB _config_mks
+ "${ndk}/build/core/toolchains/*/config.mk"
+ "${ndk}/toolchains/*/config.mk"
+ )
+ set(_versions "")
+ set(_latest_gcc 0)
+ set(_latest_clang "")
+ set(_latest_clang_vers 0)
+ foreach(config_mk IN LISTS _config_mks)
+ file(STRINGS "${config_mk}" _abis REGEX "^TOOLCHAIN_ABIS +:= +[^ ].*( |$)")
+ if(_abis AND "${config_mk}" MATCHES [[-((clang)?([0-9]\.[0-9]|))/config\.mk$]])
+ set(_version "${CMAKE_MATCH_1}")
+ set(_is_clang "${CMAKE_MATCH_2}")
+ set(_cur_vers "${CMAKE_MATCH_3}")
+ if(_is_clang)
+ if(_latest_clang_vers STREQUAL "")
+ # already the latest possible
+ elseif(_cur_vers STREQUAL "" OR _cur_vers VERSION_GREATER _latest_clang_vers)
+ set(_latest_clang_vers "${_cur_vers}")
+ set(_latest_clang "${_version}")
+ endif()
+ else()
+ if(_version VERSION_GREATER _latest_gcc)
+ set(_latest_gcc ${_version})
+ endif()
+ endif()
+ list(APPEND _versions "${_version}")
+ string(REGEX MATCHALL "[a-z][a-z0-9_-]+" _abis "${_abis}")
+ list(APPEND _abis_${_version} ${_abis})
+ endif()
+ endforeach()
+ set(_abis_ ${_abis_${_latest_gcc}})
+ set(_abis_clang ${_abis_${_latest_clang}})
+ if(_versions MATCHES "clang")
+ set(_versions "clang" ${_versions})
+ endif()
+ list(REMOVE_DUPLICATES _versions)
+ list(SORT _versions)
+ set(_versions ";${_versions}")
+ foreach(vers IN LISTS _versions)
+ list(REMOVE_DUPLICATES _abis_${vers})
+ endforeach()
+
+ # Test failure cases.
+ message(STATUS "ndk='${ndk}'")
+ set(RunCMake_TEST_OPTIONS
+ -DCMAKE_SYSTEM_NAME=Android
+ -DCMAKE_ANDROID_NDK=${ndk}
+ -DCMAKE_ANDROID_ARCH_ABI=badabi
+ )
+ run_cmake(ndk-badabi)
+ set(RunCMake_TEST_OPTIONS
+ -DCMAKE_SYSTEM_NAME=Android
+ -DCMAKE_ANDROID_NDK=${ndk}
+ -DCMAKE_ANDROID_ARCH_ABI=x86
+ -DCMAKE_ANDROID_ARM_MODE=0
+ )
+ run_cmake(ndk-badarm)
+ set(RunCMake_TEST_OPTIONS
+ -DCMAKE_SYSTEM_NAME=Android
+ -DCMAKE_ANDROID_NDK=${ndk}
+ -DCMAKE_ANDROID_ARM_NEON=0
+ )
+ run_cmake(ndk-badneon)
+ set(RunCMake_TEST_OPTIONS
+ -DCMAKE_SYSTEM_NAME=Android
+ -DCMAKE_ANDROID_NDK=${ndk}
+ -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=badver
+ )
+ run_cmake(ndk-badver)
+ set(RunCMake_TEST_OPTIONS
+ -DCMAKE_SYSTEM_NAME=Android
+ -DCMAKE_ANDROID_NDK=${ndk}
+ -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=1.0
+ )
+ run_cmake(ndk-badvernum)
+ set(RunCMake_TEST_OPTIONS
+ -DCMAKE_SYSTEM_NAME=Android
+ -DCMAKE_ANDROID_NDK=${ndk}
+ -DCMAKE_ANDROID_STL_TYPE=badstl
+ )
+ run_cmake(ndk-badstl)
+ unset(RunCMake_TEST_OPTIONS)
+
+ # Find a sysroot to test.
+ file(GLOB _sysroots "${ndk}/platforms/android-[0-9][0-9]/arch-arm")
+ if(_sysroots)
+ list(GET _sysroots 0 _sysroot)
+ set(RunCMake_TEST_OPTIONS
+ -DCMAKE_SYSTEM_NAME=Android
+ -DCMAKE_SYSROOT=${_sysroot}
+ )
+ run_cmake(ndk-sysroot-armeabi)
+ unset(RunCMake_TEST_OPTIONS)
+ endif()
+
+ # Find available STLs.
+ set(stl_types
+ none
+ system
+ gnustl_static
+ gnustl_shared
+ )
+
+ if(IS_DIRECTORY "${ndk}/sources/cxx-stl/gabi++/libs")
+ list(APPEND stl_types gabi++_static gabi++_shared)
+ endif()
+ if(IS_DIRECTORY "${ndk}/sources/cxx-stl/stlport/libs")
+ list(APPEND stl_types stlport_static stlport_shared)
+ endif()
+ if(IS_DIRECTORY "${ndk}/sources/cxx-stl/llvm-libc++/libs")
+ list(APPEND stl_types c++_static c++_shared)
+ endif()
+
+ # List possible ABIs.
+ set(abi_names
+ armeabi
+ armeabi-v6
+ armeabi-v7a
+ arm64-v8a
+ mips
+ mips64
+ x86
+ x86_64
+ )
+
+ # Test all combinations.
+ foreach(vers IN LISTS _versions)
+ foreach(stl IN LISTS stl_types)
+ foreach(config Release Debug)
+ # Test this combination for all available abis.
+ message(STATUS "ndk='${ndk}' vers='${vers}' stl='${stl}' config='${config}'")
+ set(RunCMake_TEST_OPTIONS
+ -DCMAKE_ANDROID_NDK=${ndk}
+ -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=${vers}
+ -DCMAKE_ANDROID_STL_TYPE=${stl}
+ -DCMAKE_BUILD_TYPE=${config}
+ )
+ foreach(abi IN LISTS abi_names)
+ # Skip ABIs not supported by this compiler.
+ if(NOT ";${_abis_${vers}};" MATCHES ";${abi};")
+ continue()
+ endif()
+
+ # Skip combinations that seem to be broken.
+ if("${stl};${abi}" MATCHES [[^c\+\+_static;armeabi]])
+ continue()
+ endif()
+
+ # Run the tests for this combination.
+ if("${abi}" STREQUAL "armeabi")
+ run_Android(ndk-armeabi-thumb) # default: -DCMAKE_ANDROID_ARCH_ABI=armeabi -DCMAKE_ANDROID_ARM_MODE=0
+ run_Android(ndk-armeabi-arm -DCMAKE_ANDROID_ARM_MODE=1) # default: -DCMAKE_ANDROID_ARCH_ABI=armeabi
+ else()
+ run_Android(ndk-${abi} -DCMAKE_ANDROID_ARCH_ABI=${abi})
+ if("${abi}" STREQUAL "armeabi-v7a")
+ run_Android(ndk-${abi}-neon -DCMAKE_ANDROID_ARCH_ABI=${abi} -DCMAKE_ANDROID_ARM_NEON=1)
+ endif()
+ endif()
+ endforeach()
+ unset(RunCMake_TEST_OPTIONS)
+ endforeach()
+ endforeach()
+ endforeach()
+endforeach()
+
+foreach(toolchain IN LISTS TEST_ANDROID_STANDALONE_TOOLCHAIN)
+ message(STATUS "toolchain='${toolchain}'")
+
+ set(RunCMake_TEST_OPTIONS
+ -DCMAKE_SYSTEM_NAME=Android
+ -DCMAKE_SYSROOT=${toolchain}/sysroot
+ )
+ run_cmake(standalone-sysroot)
+ unset(RunCMake_TEST_OPTIONS)
+
+ foreach(config Release Debug)
+ message(STATUS "toolchain='${toolchain}' config='${config}'")
+ set(RunCMake_TEST_OPTIONS
+ -DCMAKE_ANDROID_STANDALONE_TOOLCHAIN=${toolchain}
+ -DCMAKE_BUILD_TYPE=${config}
+ )
+ run_Android(standalone)
+ unset(RunCMake_TEST_OPTIONS)
+ endforeach()
+endforeach()
diff --git a/Tests/RunCMake/Android/android.c b/Tests/RunCMake/Android/android.c
new file mode 100644
index 0000000..30e8574
--- /dev/null
+++ b/Tests/RunCMake/Android/android.c
@@ -0,0 +1,6 @@
+#include "android.h"
+
+int main(void)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/Android/android.cxx b/Tests/RunCMake/Android/android.cxx
new file mode 100644
index 0000000..e6a6cda
--- /dev/null
+++ b/Tests/RunCMake/Android/android.cxx
@@ -0,0 +1,45 @@
+#include "android.h"
+
+#ifndef STL_NONE
+#include <cmath>
+#include <cstdio>
+#ifndef STL_SYSTEM
+#include <exception>
+#include <typeinfo>
+#ifndef STL_GABI
+#include <iostream>
+#include <string>
+#endif
+#endif
+#endif
+
+int main()
+{
+#if !defined(STL_NONE)
+ // Require -lm implied by linking as C++.
+ std::printf("%p\n", static_cast<double (*)(double)>(&std::sin));
+#endif
+#if defined(STL_NONE)
+ return 0;
+#elif defined(STL_SYSTEM)
+ return 0;
+#else
+ try {
+ delete (new int);
+ } catch (std::exception const& e) {
+#if defined(STL_GABI)
+ e.what();
+ typeid(e).name();
+#else
+ std::cerr << e.what() << std::endl;
+ std::cerr << typeid(e).name() << std::endl;
+#endif
+ }
+#if defined(STL_GABI)
+ return 0;
+#else
+ std::string s;
+ return static_cast<int>(s.size());
+#endif
+#endif
+}
diff --git a/Tests/RunCMake/Android/android.h b/Tests/RunCMake/Android/android.h
new file mode 100644
index 0000000..a5fd67e
--- /dev/null
+++ b/Tests/RunCMake/Android/android.h
@@ -0,0 +1,103 @@
+#ifndef __ANDROID__
+#error "__ANDROID__ not defined"
+#endif
+
+#include <android/api-level.h>
+
+#if API_LEVEL != __ANDROID_API__
+#error "API levels do not match"
+#endif
+
+#ifdef COMPILER_IS_CLANG
+#ifndef __clang__
+#error "COMPILER_IS_CLANG but __clang__ is not defined"
+#endif
+#else
+#ifdef __clang__
+#error "!COMPILER_IS_CLANG but __clang__ is defined"
+#endif
+#endif
+
+#ifdef ARM_MODE
+#if ARM_MODE == 1 && defined(__thumb__)
+#error "ARM_MODE==1 but __thumb__ is defined"
+#elif ARM_MODE == 0 && !defined(__thumb__)
+#error "ARM_MODE==0 but __thumb__ is not defined"
+#endif
+#endif
+
+#ifdef ARM_NEON
+#if ARM_NEON == 0 && defined(__ARM_NEON__)
+#error "ARM_NEON==0 but __ARM_NEON__ is defined"
+#elif ARM_NEON == 1 && !defined(__ARM_NEON__)
+#error "ARM_NEON==1 but __ARM_NEON__ is not defined"
+#endif
+#endif
+
+#ifdef ABI_armeabi
+#ifndef __ARM_EABI__
+#error "ABI_armeabi: __ARM_EABI__ not defined"
+#endif
+#if __ARM_ARCH != 5
+#error "ABI_armeabi: __ARM_ARCH is not 5"
+#endif
+#endif
+
+#ifdef ABI_armeabi_v6
+#ifndef __ARM_EABI__
+#error "ABI_armeabi_v6: __ARM_EABI__ not defined"
+#endif
+#if __ARM_ARCH != 6
+#error "ABI_armeabi_v6: __ARM_ARCH is not 6"
+#endif
+#endif
+
+#ifdef ABI_armeabi_v7a
+#ifndef __ARM_EABI__
+#error "ABI_armeabi_v7a: __ARM_EABI__ not defined"
+#endif
+#if __ARM_ARCH != 7
+#error "ABI_armeabi_v7a: __ARM_ARCH is not 7"
+#endif
+#endif
+
+#ifdef ABI_arm64_v8a
+#ifdef __ARM_EABI__
+#error "ABI_arm64_v8a: __ARM_EABI__ defined"
+#endif
+#ifndef __aarch64__
+#error "ABI_arm64_v8a: __aarch64__ not defined"
+#endif
+#endif
+
+#ifdef ABI_mips
+#if __mips != 32
+#error "ABI_mips: __mips != 32"
+#endif
+#ifndef _ABIO32
+#error "ABI_mips: _ABIO32 not defined"
+#endif
+#endif
+
+#ifdef ABI_mips64
+#if __mips != 64
+#error "ABI_mips64: __mips != 64"
+#endif
+#ifndef _ABI64
+#error "ABI_mips: _ABI64 not defined"
+#endif
+#endif
+
+#ifdef ABI_x86
+#ifndef __i686__
+#error "ABI_x86: __i686__ not defined"
+#endif
+#endif
+
+#ifdef ABI_x86_64
+#ifndef __x86_64__
+#error "ABI_x86_64: __x86_64__ not defined"
+#endif
+#endif
+
+#include <stddef.h>
diff --git a/Tests/RunCMake/Android/common.cmake b/Tests/RunCMake/Android/common.cmake
new file mode 100644
index 0000000..7eac5d6
--- /dev/null
+++ b/Tests/RunCMake/Android/common.cmake
@@ -0,0 +1,60 @@
+enable_language(C)
+enable_language(CXX)
+
+if(NOT ANDROID)
+ message(SEND_ERROR "CMake variable 'ANDROID' is not set to a true value.")
+endif()
+
+foreach(f
+ "${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}cpp${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}"
+ "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}ar${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}"
+ "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}ld${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}"
+ )
+ if(NOT EXISTS "${f}")
+ message(SEND_ERROR "Expected file does not exist:\n \"${f}\"")
+ endif()
+endforeach()
+
+string(APPEND CMAKE_C_FLAGS " -Werror")
+string(APPEND CMAKE_CXX_FLAGS " -Werror")
+string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,-no-undefined")
+
+if(CMAKE_ANDROID_NDK)
+ if(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION MATCHES "clang")
+ add_definitions(-DCOMPILER_IS_CLANG)
+ endif()
+elseif(CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
+ execute_process(
+ COMMAND ${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/bin/clang --version
+ OUTPUT_VARIABLE _out
+ ERROR_VARIABLE _err
+ RESULT_VARIABLE _res
+ )
+ if(_res EQUAL 0)
+ add_definitions(-DCOMPILER_IS_CLANG)
+ endif()
+endif()
+
+if(CMAKE_ANDROID_STL_TYPE STREQUAL "none")
+ add_definitions(-DSTL_NONE)
+elseif(CMAKE_ANDROID_STL_TYPE STREQUAL "system")
+ add_definitions(-DSTL_SYSTEM)
+elseif(CMAKE_ANDROID_STL_TYPE MATCHES [[^gabi\+\+]])
+ add_definitions(-DSTL_GABI)
+endif()
+
+string(REPLACE "-" "_" abi "${CMAKE_ANDROID_ARCH_ABI}")
+add_definitions(-DABI_${abi})
+add_definitions(-DAPI_LEVEL=${CMAKE_SYSTEM_VERSION})
+if(CMAKE_ANDROID_ARCH_ABI MATCHES "^armeabi")
+ add_definitions(-DARM_MODE=${CMAKE_ANDROID_ARM_MODE})
+ message(STATUS "CMAKE_ANDROID_ARM_MODE=${CMAKE_ANDROID_ARM_MODE}")
+endif()
+if(CMAKE_ANDROID_ARCH_ABI STREQUAL "armeabi-v7a")
+ add_definitions(-DARM_NEON=${CMAKE_ANDROID_ARM_NEON})
+ message(STATUS "CMAKE_ANDROID_ARM_NEON=${CMAKE_ANDROID_ARM_NEON}")
+endif()
+add_executable(android_c android.c)
+add_executable(android_cxx android.cxx)
diff --git a/Tests/RunCMake/Android/ndk-arm64-v8a-stdout.txt b/Tests/RunCMake/Android/ndk-arm64-v8a-stdout.txt
new file mode 100644
index 0000000..8d0bdc2
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-arm64-v8a-stdout.txt
@@ -0,0 +1,2 @@
+-- Android: Targeting API '[0-9]+' with architecture 'arm64', ABI 'arm64-v8a', and processor 'aarch64'
+-- Android: Selected (Clang toolchain '[^']+' with )?GCC toolchain '[^']+'
diff --git a/Tests/RunCMake/Android/ndk-arm64-v8a.cmake b/Tests/RunCMake/Android/ndk-arm64-v8a.cmake
new file mode 100644
index 0000000..a3185fe
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-arm64-v8a.cmake
@@ -0,0 +1 @@
+include(common.cmake)
diff --git a/Tests/RunCMake/Android/ndk-armeabi-arm-stdout.txt b/Tests/RunCMake/Android/ndk-armeabi-arm-stdout.txt
new file mode 100644
index 0000000..3741da3
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-armeabi-arm-stdout.txt
@@ -0,0 +1,3 @@
+-- Android: Targeting API '[0-9]+' with architecture 'arm', ABI 'armeabi', and processor 'armv5te'
+-- Android: Selected (Clang toolchain '[^']+' with )?GCC toolchain '[^']+'
+.*-- CMAKE_ANDROID_ARM_MODE=1
diff --git a/Tests/RunCMake/Android/ndk-armeabi-arm.cmake b/Tests/RunCMake/Android/ndk-armeabi-arm.cmake
new file mode 100644
index 0000000..a3185fe
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-armeabi-arm.cmake
@@ -0,0 +1 @@
+include(common.cmake)
diff --git a/Tests/RunCMake/Android/ndk-armeabi-thumb-stdout.txt b/Tests/RunCMake/Android/ndk-armeabi-thumb-stdout.txt
new file mode 100644
index 0000000..ce0dea2
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-armeabi-thumb-stdout.txt
@@ -0,0 +1,3 @@
+-- Android: Targeting API '[0-9]+' with architecture 'arm', ABI 'armeabi', and processor 'armv5te'
+-- Android: Selected (Clang toolchain '[^']+' with )?GCC toolchain '[^']+'
+.*-- CMAKE_ANDROID_ARM_MODE=0
diff --git a/Tests/RunCMake/Android/ndk-armeabi-thumb.cmake b/Tests/RunCMake/Android/ndk-armeabi-thumb.cmake
new file mode 100644
index 0000000..a3185fe
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-armeabi-thumb.cmake
@@ -0,0 +1 @@
+include(common.cmake)
diff --git a/Tests/RunCMake/Android/ndk-armeabi-v7a-neon-stdout.txt b/Tests/RunCMake/Android/ndk-armeabi-v7a-neon-stdout.txt
new file mode 100644
index 0000000..ac2bfd5
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-armeabi-v7a-neon-stdout.txt
@@ -0,0 +1,3 @@
+-- Android: Targeting API '[0-9]+' with architecture 'arm', ABI 'armeabi-v7a', and processor 'armv7-a'
+-- Android: Selected (Clang toolchain '[^']+' with )?GCC toolchain '[^']+'
+.*-- CMAKE_ANDROID_ARM_NEON=1
diff --git a/Tests/RunCMake/Android/ndk-armeabi-v7a-neon.cmake b/Tests/RunCMake/Android/ndk-armeabi-v7a-neon.cmake
new file mode 100644
index 0000000..a3185fe
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-armeabi-v7a-neon.cmake
@@ -0,0 +1 @@
+include(common.cmake)
diff --git a/Tests/RunCMake/Android/ndk-armeabi-v7a-stdout.txt b/Tests/RunCMake/Android/ndk-armeabi-v7a-stdout.txt
new file mode 100644
index 0000000..0edb4f7
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-armeabi-v7a-stdout.txt
@@ -0,0 +1,3 @@
+-- Android: Targeting API '[0-9]+' with architecture 'arm', ABI 'armeabi-v7a', and processor 'armv7-a'
+-- Android: Selected (Clang toolchain '[^']+' with )?GCC toolchain '[^']+'
+.*-- CMAKE_ANDROID_ARM_NEON=0
diff --git a/Tests/RunCMake/Android/ndk-armeabi-v7a.cmake b/Tests/RunCMake/Android/ndk-armeabi-v7a.cmake
new file mode 100644
index 0000000..a3185fe
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-armeabi-v7a.cmake
@@ -0,0 +1 @@
+include(common.cmake)
diff --git a/Tests/RunCMake/Android/ndk-badabi-result.txt b/Tests/RunCMake/Android/ndk-badabi-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-badabi-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Android/ndk-badabi-stderr.txt b/Tests/RunCMake/Android/ndk-badabi-stderr.txt
new file mode 100644
index 0000000..c089235
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-badabi-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at .*/Modules/Platform/Android-Determine.cmake:[0-9]+ \(message\):
+ Android: Unknown ABI CMAKE_ANDROID_ARCH_ABI='badabi'.
+Call Stack \(most recent call first\):
+ .*/Modules/CMakeDetermineSystem.cmake:[0-9]+ \(include\)
+ CMakeLists.txt:[0-9]+ \(project\)$
diff --git a/Tests/RunCMake/Android/ndk-badabi.cmake b/Tests/RunCMake/Android/ndk-badabi.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-badabi.cmake
diff --git a/Tests/RunCMake/Android/ndk-badarm-result.txt b/Tests/RunCMake/Android/ndk-badarm-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-badarm-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Android/ndk-badarm-stderr.txt b/Tests/RunCMake/Android/ndk-badarm-stderr.txt
new file mode 100644
index 0000000..f62bfc4
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-badarm-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at .*/Modules/Platform/Android-Determine.cmake:[0-9]+ \(message\):
+ Android: CMAKE_ANDROID_ARM_MODE is set but is valid only for 'armeabi'
+ architectures.
+Call Stack \(most recent call first\):
+ .*/Modules/CMakeDetermineSystem.cmake:[0-9]+ \(include\)
+ CMakeLists.txt:[0-9]+ \(project\)$
diff --git a/Tests/RunCMake/Android/ndk-badarm.cmake b/Tests/RunCMake/Android/ndk-badarm.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-badarm.cmake
diff --git a/Tests/RunCMake/Android/ndk-badneon-result.txt b/Tests/RunCMake/Android/ndk-badneon-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-badneon-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Android/ndk-badneon-stderr.txt b/Tests/RunCMake/Android/ndk-badneon-stderr.txt
new file mode 100644
index 0000000..1f0bf00
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-badneon-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at .*/Modules/Platform/Android-Determine.cmake:[0-9]+ \(message\):
+ Android: CMAKE_ANDROID_ARM_NEON is set but is valid only for 'armeabi-v7a'
+ architecture.
+Call Stack \(most recent call first\):
+ .*/Modules/CMakeDetermineSystem.cmake:[0-9]+ \(include\)
+ CMakeLists.txt:[0-9]+ \(project\)$
diff --git a/Tests/RunCMake/Android/ndk-badneon.cmake b/Tests/RunCMake/Android/ndk-badneon.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-badneon.cmake
diff --git a/Tests/RunCMake/Android/ndk-badstl-result.txt b/Tests/RunCMake/Android/ndk-badstl-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-badstl-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Android/ndk-badstl-stderr.txt b/Tests/RunCMake/Android/ndk-badstl-stderr.txt
new file mode 100644
index 0000000..c61824e
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-badstl-stderr.txt
@@ -0,0 +1,9 @@
+^CMake Error at .*/Modules/Platform/Android-Common.cmake:[0-9]+ \(message\):
+ The CMAKE_ANDROID_STL_TYPE 'badstl' is not one of the allowed values:
+
+ .*
+
+Call Stack \(most recent call first\):
+.*
+ ndk-badstl.cmake:1 \(enable_language\)
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Android/ndk-badstl.cmake b/Tests/RunCMake/Android/ndk-badstl.cmake
new file mode 100644
index 0000000..fa2fc91
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-badstl.cmake
@@ -0,0 +1 @@
+enable_language(CXX)
diff --git a/Tests/RunCMake/Android/ndk-badver-result.txt b/Tests/RunCMake/Android/ndk-badver-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-badver-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Android/ndk-badver-stderr.txt b/Tests/RunCMake/Android/ndk-badver-stderr.txt
new file mode 100644
index 0000000..df2c5e6
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-badver-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at .*/Modules/Platform/Android/Determine-Compiler-NDK.cmake:[0-9]+ \(message\):
+ Android: The CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION value 'badver' is not one
+ of the allowed forms:
+
+ <major>.<minor> = GCC of specified version
+ clang<major>.<minor> = Clang of specified version
+ clang = Clang of most recent available version
+
+Call Stack \(most recent call first\):
+.*
+ ndk-badver.cmake:1 \(enable_language\)
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Android/ndk-badver.cmake b/Tests/RunCMake/Android/ndk-badver.cmake
new file mode 100644
index 0000000..c00af08
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-badver.cmake
@@ -0,0 +1 @@
+enable_language(C)
diff --git a/Tests/RunCMake/Android/ndk-badvernum-result.txt b/Tests/RunCMake/Android/ndk-badvernum-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-badvernum-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Android/ndk-badvernum-stderr.txt b/Tests/RunCMake/Android/ndk-badvernum-stderr.txt
new file mode 100644
index 0000000..25bbaf9
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-badvernum-stderr.txt
@@ -0,0 +1,13 @@
+^CMake Error at .*/Modules/Platform/Android/Determine-Compiler-NDK.cmake:[0-9]+ \(message\):
+ Android: No toolchain for ABI 'armeabi' found in the NDK:
+
+ .*
+
+ of the version specified by CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION:
+
+ 1\.0
+
+Call Stack \(most recent call first\):
+.*
+ ndk-badvernum.cmake:1 \(enable_language\)
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Android/ndk-badvernum.cmake b/Tests/RunCMake/Android/ndk-badvernum.cmake
new file mode 100644
index 0000000..c00af08
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-badvernum.cmake
@@ -0,0 +1 @@
+enable_language(C)
diff --git a/Tests/RunCMake/Android/ndk-mips-stdout.txt b/Tests/RunCMake/Android/ndk-mips-stdout.txt
new file mode 100644
index 0000000..c744683
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-mips-stdout.txt
@@ -0,0 +1,2 @@
+-- Android: Targeting API '[0-9]+' with architecture 'mips', ABI 'mips', and processor 'mips'
+-- Android: Selected (Clang toolchain '[^']+' with )?GCC toolchain '[^']+'
diff --git a/Tests/RunCMake/Android/ndk-mips.cmake b/Tests/RunCMake/Android/ndk-mips.cmake
new file mode 100644
index 0000000..a3185fe
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-mips.cmake
@@ -0,0 +1 @@
+include(common.cmake)
diff --git a/Tests/RunCMake/Android/ndk-mips64-stdout.txt b/Tests/RunCMake/Android/ndk-mips64-stdout.txt
new file mode 100644
index 0000000..839ddfd
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-mips64-stdout.txt
@@ -0,0 +1,2 @@
+-- Android: Targeting API '[0-9]+' with architecture 'mips64', ABI 'mips64', and processor 'mips64'
+-- Android: Selected (Clang toolchain '[^']+' with )?GCC toolchain '[^']+'
diff --git a/Tests/RunCMake/Android/ndk-mips64.cmake b/Tests/RunCMake/Android/ndk-mips64.cmake
new file mode 100644
index 0000000..a3185fe
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-mips64.cmake
@@ -0,0 +1 @@
+include(common.cmake)
diff --git a/Tests/RunCMake/Android/ndk-sysroot-armeabi-stdout.txt b/Tests/RunCMake/Android/ndk-sysroot-armeabi-stdout.txt
new file mode 100644
index 0000000..d309e72
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-sysroot-armeabi-stdout.txt
@@ -0,0 +1 @@
+-- Android: Targeting API '[0-9][0-9]' with architecture 'arm', ABI 'armeabi', and processor 'armv5te'
diff --git a/Tests/RunCMake/Android/ndk-sysroot-armeabi.cmake b/Tests/RunCMake/Android/ndk-sysroot-armeabi.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-sysroot-armeabi.cmake
diff --git a/Tests/RunCMake/Android/ndk-x86-stdout.txt b/Tests/RunCMake/Android/ndk-x86-stdout.txt
new file mode 100644
index 0000000..2dbb2f0
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-x86-stdout.txt
@@ -0,0 +1,2 @@
+-- Android: Targeting API '[0-9]+' with architecture 'x86', ABI 'x86', and processor 'i686'
+-- Android: Selected (Clang toolchain '[^']+' with )?GCC toolchain '[^']+'
diff --git a/Tests/RunCMake/Android/ndk-x86.cmake b/Tests/RunCMake/Android/ndk-x86.cmake
new file mode 100644
index 0000000..a3185fe
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-x86.cmake
@@ -0,0 +1 @@
+include(common.cmake)
diff --git a/Tests/RunCMake/Android/ndk-x86_64-stdout.txt b/Tests/RunCMake/Android/ndk-x86_64-stdout.txt
new file mode 100644
index 0000000..a7ae91d
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-x86_64-stdout.txt
@@ -0,0 +1,2 @@
+-- Android: Targeting API '[0-9]+' with architecture 'x86_64', ABI 'x86_64', and processor 'x86_64'
+-- Android: Selected (Clang toolchain '[^']+' with )?GCC toolchain '[^']+'
diff --git a/Tests/RunCMake/Android/ndk-x86_64.cmake b/Tests/RunCMake/Android/ndk-x86_64.cmake
new file mode 100644
index 0000000..a3185fe
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-x86_64.cmake
@@ -0,0 +1 @@
+include(common.cmake)
diff --git a/Tests/RunCMake/Android/standalone-stdout.txt b/Tests/RunCMake/Android/standalone-stdout.txt
new file mode 100644
index 0000000..20b095c
--- /dev/null
+++ b/Tests/RunCMake/Android/standalone-stdout.txt
@@ -0,0 +1 @@
+-- Android: Targeting API '[0-9]+' with architecture '[a-z0-9_-]+', ABI '[a-z0-9_-]+', and processor '[a-z0-9_-]+'
diff --git a/Tests/RunCMake/Android/standalone-sysroot-stdout.txt b/Tests/RunCMake/Android/standalone-sysroot-stdout.txt
new file mode 100644
index 0000000..20b095c
--- /dev/null
+++ b/Tests/RunCMake/Android/standalone-sysroot-stdout.txt
@@ -0,0 +1 @@
+-- Android: Targeting API '[0-9]+' with architecture '[a-z0-9_-]+', ABI '[a-z0-9_-]+', and processor '[a-z0-9_-]+'
diff --git a/Tests/RunCMake/Android/standalone-sysroot.cmake b/Tests/RunCMake/Android/standalone-sysroot.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/Android/standalone-sysroot.cmake
diff --git a/Tests/RunCMake/Android/standalone.cmake b/Tests/RunCMake/Android/standalone.cmake
new file mode 100644
index 0000000..a3185fe
--- /dev/null
+++ b/Tests/RunCMake/Android/standalone.cmake
@@ -0,0 +1 @@
+include(common.cmake)
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index dbd5530..323a36b 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -327,3 +327,24 @@ add_RunCMake_test_group(CPack "DEB;RPM;TGZ")
# add a test to make sure symbols are exported from a shared library
# for MSVC compilers CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS property is used
add_RunCMake_test(AutoExportDll)
+
+if(CMake_TEST_ANDROID_NDK OR CMake_TEST_ANDROID_STANDALONE_TOOLCHAIN)
+ if(NOT "${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
+ message(FATAL_ERROR "Android tests supported only by Makefile and Ninja generators")
+ endif()
+ foreach(v TEST_ANDROID_NDK TEST_ANDROID_STANDALONE_TOOLCHAIN)
+ if(CMake_${v})
+ string(REPLACE ";" "|" ${v} "${CMake_${v}}")
+ list(APPEND Android_ARGS "-D${v}=${${v}}")
+ endif()
+ endforeach()
+
+ add_RunCMake_test(Android)
+
+ # This test can take a very long time due to lots of combinations.
+ # Use a long default timeout and provide an option to customize it.
+ if(NOT DEFINED CMake_TEST_ANDROID_TIMEOUT)
+ set(CMake_TEST_ANDROID_TIMEOUT 3000)
+ endif()
+ set_property(TEST RunCMake.Android PROPERTY TIMEOUT ${CMake_TEST_ANDROID_TIMEOUT})
+endif()