summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/Android
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/RunCMake/Android')
-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.cmake285
-rw-r--r--Tests/RunCMake/Android/android.c6
-rw-r--r--Tests/RunCMake/Android/android.cxx48
-rw-r--r--Tests/RunCMake/Android/android.h103
-rw-r--r--Tests/RunCMake/Android/android_lib.cxx4
-rw-r--r--Tests/RunCMake/Android/android_sysinc.c7
-rw-r--r--Tests/RunCMake/Android/android_sysinc.cxx7
-rw-r--r--Tests/RunCMake/Android/check_binary.cmake8
-rw-r--r--Tests/RunCMake/Android/common.cmake140
-rw-r--r--Tests/RunCMake/Android/ndk-arm64-v8a-stderr.txt7
-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-stderr.txt7
-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-stderr.txt7
-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-stderr.txt7
-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-stderr.txt7
-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.txt13
-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.txt15
-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-search-order.cmake17
-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-stderr.txt7
-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-stderr.txt7
-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/Android/sysinc/dlfcn.h1
64 files changed, 797 insertions, 0 deletions
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..aa0cf4d
--- /dev/null
+++ b/Tests/RunCMake/Android/RunCMakeTest.cmake
@@ -0,0 +1,285 @@
+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})
+ set(configs ".")
+ if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(configs Release Debug)
+ endif()
+ foreach(config IN LISTS configs)
+ set(build_suffix)
+ set(config_arg)
+ if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(build_suffix "-${config}")
+ set(config_arg --config "${config}")
+ endif()
+ run_cmake_command(${case}-build${build_suffix} ${CMAKE_COMMAND} --build . ${config_arg})
+ endforeach()
+endfunction()
+
+set(RunCMake_GENERATOR_PLATFORM_OLD "${RunCMake_GENERATOR_PLATFORM}")
+
+if(RunCMake_GENERATOR MATCHES "Visual Studio")
+ set(RunCMake_GENERATOR_PLATFORM "ARM")
+endif()
+set(RunCMake_TEST_OPTIONS
+ -DCMAKE_SYSTEM_NAME=Android
+ -DCMAKE_SYSROOT=${CMAKE_CURRENT_SOURCE_DIR}
+ )
+run_cmake(BadSYSROOT)
+unset(RunCMake_TEST_OPTIONS)
+set(RunCMake_GENERATOR_PLATFORM "${RunCMake_GENERATOR_PLATFORM_OLD}")
+
+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_clang ${_abis_${_latest_clang}})
+ if(_latest_gcc)
+ set(_abis_ ${_abis_${_latest_gcc}})
+ else()
+ set(_abis_ ${_abis_clang})
+ endif()
+ if(_versions MATCHES "clang")
+ set(_versions "clang" ${_versions})
+ endif()
+ if(RunCMake_GENERATOR MATCHES "Visual Studio")
+ set(_versions "clang")
+ endif()
+ list(REMOVE_DUPLICATES _versions)
+ list(SORT _versions)
+ set(_versions ";${_versions}")
+ foreach(vers IN LISTS _versions)
+ list(REMOVE_DUPLICATES _abis_${vers})
+ endforeach()
+
+ set(ndk_arg -DCMAKE_ANDROID_NDK=${ndk})
+ if(RunCMake_GENERATOR MATCHES "Visual Studio")
+ set(ndk_arg)
+ endif()
+
+ set(RunCMake_TEST_OPTIONS
+ -DCMAKE_SYSTEM_NAME=Android
+ -DCMAKE_FIND_ROOT_PATH=/tmp
+ ${ndk_arg}
+ )
+ run_cmake(ndk-search-order)
+
+ # Test failure cases.
+ message(STATUS "ndk='${ndk}'")
+ if(RunCMake_GENERATOR MATCHES "Visual Studio")
+ set(RunCMake_GENERATOR_PLATFORM "ARM")
+ endif()
+ set(RunCMake_TEST_OPTIONS
+ -DCMAKE_SYSTEM_NAME=Android
+ ${ndk_arg}
+ -DCMAKE_ANDROID_ARCH_ABI=badabi
+ )
+ run_cmake(ndk-badabi)
+ if(RunCMake_GENERATOR MATCHES "Visual Studio")
+ set(RunCMake_GENERATOR_PLATFORM "x86")
+ endif()
+ set(RunCMake_TEST_OPTIONS
+ -DCMAKE_SYSTEM_NAME=Android
+ ${ndk_arg}
+ -DCMAKE_ANDROID_ARCH_ABI=x86
+ -DCMAKE_ANDROID_ARM_MODE=0
+ )
+ run_cmake(ndk-badarm)
+ if(RunCMake_GENERATOR MATCHES "Visual Studio")
+ set(RunCMake_GENERATOR_PLATFORM "ARM")
+ endif()
+ if("armeabi" IN_LIST _abis_)
+ set(RunCMake_TEST_OPTIONS
+ -DCMAKE_SYSTEM_NAME=Android
+ ${ndk_arg}
+ -DCMAKE_ANDROID_ARM_NEON=0
+ )
+ run_cmake(ndk-badneon)
+ endif()
+ set(RunCMake_TEST_OPTIONS
+ -DCMAKE_SYSTEM_NAME=Android
+ ${ndk_arg}
+ -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=badver
+ )
+ run_cmake(ndk-badver)
+ set(RunCMake_TEST_OPTIONS
+ -DCMAKE_SYSTEM_NAME=Android
+ ${ndk_arg}
+ -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=1.0
+ )
+ run_cmake(ndk-badvernum)
+ set(RunCMake_TEST_OPTIONS
+ -DCMAKE_SYSTEM_NAME=Android
+ ${ndk_arg}
+ -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 AND "armeabi" IN_LIST _abis_)
+ 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()
+ set(RunCMake_GENERATOR_PLATFORM "${RunCMake_GENERATOR_PLATFORM_OLD}")
+
+ # Find available STLs.
+ set(stl_types
+ none
+ system
+ )
+
+ if(IS_DIRECTORY "${ndk}/sources/cxx-stl/gnu-libstdc++")
+ list(APPEND stl_types gnustl_static gnustl_shared)
+ endif()
+ 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
+ x86
+ x86_64
+ )
+ if(NOT RunCMake_GENERATOR MATCHES "Visual Studio")
+ list(APPEND abi_names mips mips64)
+ endif()
+ set(abi_to_arch_armeabi ARM)
+ set(abi_to_arch_armeabi-v6 ARM)
+ set(abi_to_arch_armeabi-v7a ARM)
+ set(abi_to_arch_arm64-v8a ARM64)
+ set(abi_to_arch_x86 x86)
+ set(abi_to_arch_x86_64 x64)
+
+ # Test all combinations.
+ foreach(vers IN LISTS _versions)
+ foreach(stl IN LISTS stl_types)
+ set(configs Release Debug)
+ set(foreach_list "${configs}")
+ if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(foreach_list ".")
+ endif()
+ foreach(config IN LISTS foreach_list)
+ # Test this combination for all available abis.
+ set(config_status " config='${config}'")
+ set(build_type_arg "-DCMAKE_BUILD_TYPE=${config}")
+ if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(config_status)
+ string(REPLACE ";" "\\\\;" build_type_arg "-DCMAKE_CONFIGURATION_TYPES=${configs}")
+ endif()
+ message(STATUS "ndk='${ndk}' vers='${vers}' stl='${stl}'${config_status}")
+ set(RunCMake_TEST_OPTIONS
+ ${ndk_arg}
+ -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=${vers}
+ -DCMAKE_ANDROID_STL_TYPE=${stl}
+ "${build_type_arg}"
+ )
+ foreach(abi IN LISTS abi_names)
+ # Skip ABIs not supported by this compiler.
+ if(NOT ";${_abis_${vers}};" MATCHES ";${abi};")
+ continue()
+ endif()
+
+ # Run the tests for this combination.
+ if(RunCMake_GENERATOR MATCHES "Visual Studio")
+ set(RunCMake_GENERATOR_PLATFORM "${abi_to_arch_${abi}}")
+ endif()
+ 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()
+ set(RunCMake_GENERATOR_PLATFORM "${RunCMake_GENERATOR_PLATFORM_OLD}")
+ 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..a6d8c55
--- /dev/null
+++ b/Tests/RunCMake/Android/android.cxx
@@ -0,0 +1,48 @@
+#include "android.h"
+
+#ifndef STL_NONE
+# include <cmath>
+# include <cstdio>
+# ifndef STL_SYSTEM
+# include <exception>
+# include <typeinfo>
+# ifndef STL_STLPORT
+# include <cxxabi.h>
+# endif
+# 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..2c5cd95
--- /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/android_lib.cxx b/Tests/RunCMake/Android/android_lib.cxx
new file mode 100644
index 0000000..82f9d27
--- /dev/null
+++ b/Tests/RunCMake/Android/android_lib.cxx
@@ -0,0 +1,4 @@
+int android_lib()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/Android/android_sysinc.c b/Tests/RunCMake/Android/android_sysinc.c
new file mode 100644
index 0000000..f7cc6f0
--- /dev/null
+++ b/Tests/RunCMake/Android/android_sysinc.c
@@ -0,0 +1,7 @@
+#include <dlfcn.h>
+
+#ifndef NOT_SYSTEM_DLFCN_HEADER
+# error "sysroot /usr/include appears too early"
+#endif
+
+#include "android.c"
diff --git a/Tests/RunCMake/Android/android_sysinc.cxx b/Tests/RunCMake/Android/android_sysinc.cxx
new file mode 100644
index 0000000..9379f14
--- /dev/null
+++ b/Tests/RunCMake/Android/android_sysinc.cxx
@@ -0,0 +1,7 @@
+#include <dlfcn.h>
+
+#ifndef NOT_SYSTEM_DLFCN_HEADER
+# error "sysroot /usr/include appears too early"
+#endif
+
+#include "android.cxx"
diff --git a/Tests/RunCMake/Android/check_binary.cmake b/Tests/RunCMake/Android/check_binary.cmake
new file mode 100644
index 0000000..1d1b01a
--- /dev/null
+++ b/Tests/RunCMake/Android/check_binary.cmake
@@ -0,0 +1,8 @@
+if(NOT EXISTS "${file}")
+ message(FATAL_ERROR "Missing file:\n ${file}")
+endif()
+execute_process(COMMAND "${objdump}" -p ${file} OUTPUT_VARIABLE out)
+if(out MATCHES "NEEDED[^\n]*stdc\\+\\+")
+ string(REPLACE "\n" "\n " out " ${out}")
+ message(FATAL_ERROR "File:\n ${file}\ndepends on libstdc++:\n${out}")
+endif()
diff --git a/Tests/RunCMake/Android/common.cmake b/Tests/RunCMake/Android/common.cmake
new file mode 100644
index 0000000..7c80a04
--- /dev/null
+++ b/Tests/RunCMake/Android/common.cmake
@@ -0,0 +1,140 @@
+enable_language(C)
+enable_language(CXX)
+
+if(NOT ANDROID)
+ message(SEND_ERROR "CMake variable 'ANDROID' is not set to a true value.")
+endif()
+
+set(files
+ "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}ar${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}"
+ )
+if(NOT CMAKE_ANDROID_NDK_VERSION VERSION_GREATER_EQUAL 22)
+ list(APPEND files
+ "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}ld${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}"
+ )
+endif()
+if(NOT CMAKE_ANDROID_NDK_VERSION VERSION_GREATER_EQUAL 19)
+ list(APPEND files
+ "${CMAKE_C_ANDROID_TOOLCHAIN_PREFIX}gcc${CMAKE_C_ANDROID_TOOLCHAIN_SUFFIX}"
+ "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}g++${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}"
+ )
+endif()
+foreach(f IN LISTS files)
+ if(NOT EXISTS "${f}")
+ message(SEND_ERROR "Expected file does not exist:\n \"${f}\"")
+ endif()
+endforeach()
+
+string(APPEND CMAKE_C_FLAGS " -Werror -Wno-attributes")
+string(APPEND CMAKE_CXX_FLAGS " -Werror -Wno-attributes")
+string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,-no-undefined")
+
+if(CMAKE_ANDROID_NDK)
+ if(NOT CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION)
+ message(SEND_ERROR "CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION is not set!")
+ elseif(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION MATCHES "^clang")
+ add_definitions(-DCOMPILER_IS_CLANG)
+ elseif(NOT "${CMAKE_C_COMPILER}" MATCHES "toolchains/[^/]+-${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}/prebuilt")
+ message(SEND_ERROR "CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION is\n"
+ " ${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}\n"
+ "which does not appear in CMAKE_C_COMPILER:\n"
+ " ${CMAKE_C_COMPILER}")
+ endif()
+ if(NOT CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG)
+ message(SEND_ERROR "CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG is not set!")
+ elseif(NOT "${CMAKE_C_COMPILER}" MATCHES "prebuilt/${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}/bin")
+ message(SEND_ERROR "CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG is\n"
+ " ${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}\n"
+ "which does not appear in CMAKE_C_COMPILER:\n"
+ " ${CMAKE_C_COMPILER}")
+ 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()
+
+set(gcc ${CMAKE_C_ANDROID_TOOLCHAIN_PREFIX}gcc${CMAKE_C_ANDROID_TOOLCHAIN_SUFFIX})
+if(EXISTS "${gcc}")
+ execute_process(
+ COMMAND "${CMAKE_C_ANDROID_TOOLCHAIN_PREFIX}gcc${CMAKE_C_ANDROID_TOOLCHAIN_SUFFIX}" -dumpmachine
+ OUTPUT_VARIABLE _out OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_VARIABLE _err
+ RESULT_VARIABLE _res
+ )
+ if(NOT _res EQUAL 0)
+ message(SEND_ERROR "Failed to run 'gcc -dumpmachine':\n ${_res}")
+ endif()
+ string(REPLACE "--" "-" _out_check "${_out}")
+ if(NOT _out_check STREQUAL "${CMAKE_C_ANDROID_TOOLCHAIN_MACHINE}"
+ AND NOT (_out STREQUAL "arm--linux-android" AND CMAKE_C_ANDROID_TOOLCHAIN_MACHINE STREQUAL "arm-linux-androideabi"))
+ message(SEND_ERROR "'gcc -dumpmachine' produced:\n"
+ " ${_out}\n"
+ "which does not match CMAKE_C_ANDROID_TOOLCHAIN_MACHINE:\n"
+ " ${CMAKE_C_ANDROID_TOOLCHAIN_MACHINE}"
+ )
+ 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)
+elseif(CMAKE_ANDROID_STL_TYPE MATCHES [[^stlport]])
+ add_definitions(-DSTL_STLPORT)
+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)
+add_library(android_cxx_lib SHARED android_lib.cxx)
+
+set(objdump "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}objdump${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}")
+if(NOT EXISTS "${objdump}")
+ message(FATAL_ERROR "Expected tool missing:\n ${objdump}")
+endif()
+
+if(NOT CMAKE_ANDROID_STL_TYPE MATCHES "^(system|stlport_static|stlport_shared)$")
+ foreach(tgt android_cxx android_cxx_lib)
+ add_custom_command(TARGET ${tgt} POST_BUILD
+ COMMAND ${CMAKE_COMMAND}
+ -Dobjdump=${objdump}
+ -Dfile=$<TARGET_FILE:${tgt}>
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/check_binary.cmake
+ )
+ endforeach()
+endif()
+
+# Test that an explicit /usr/include is ignored in favor of
+# appearing as a standard include directory at the end.
+set(sysinc_dirs)
+if(CMAKE_ANDROID_NDK)
+ if(NOT CMAKE_ANDROID_NDK_DEPRECATED_HEADERS)
+ list(APPEND sysinc_dirs ${CMAKE_SYSROOT_COMPILE}/usr/include)
+ else()
+ list(APPEND sysinc_dirs ${CMAKE_SYSROOT}/usr/include)
+ endif()
+endif()
+list(APPEND sysinc_dirs ${CMAKE_CURRENT_SOURCE_DIR}/sysinc)
+add_executable(android_sysinc_c android_sysinc.c)
+target_include_directories(android_sysinc_c SYSTEM PRIVATE ${sysinc_dirs})
+add_executable(android_sysinc_cxx android_sysinc.cxx)
+target_include_directories(android_sysinc_cxx SYSTEM PRIVATE ${sysinc_dirs})
diff --git a/Tests/RunCMake/Android/ndk-arm64-v8a-stderr.txt b/Tests/RunCMake/Android/ndk-arm64-v8a-stderr.txt
new file mode 100644
index 0000000..a3b3634
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-arm64-v8a-stderr.txt
@@ -0,0 +1,7 @@
+^(CMake Warning:
+ You are using Visual Studio tools for Android, which does not support
+ standalone executables\. However, the following executable targets do not
+ have the ANDROID_GUI property set, and thus will not be built as expected\.
+ They will be built as shared libraries with executable filenames:
+
+ android_c, android_cxx, android_sysinc_c, android_sysinc_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..a228ccc
--- /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 (unified Clang toolchain|(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-stderr.txt b/Tests/RunCMake/Android/ndk-armeabi-arm-stderr.txt
new file mode 100644
index 0000000..a3b3634
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-armeabi-arm-stderr.txt
@@ -0,0 +1,7 @@
+^(CMake Warning:
+ You are using Visual Studio tools for Android, which does not support
+ standalone executables\. However, the following executable targets do not
+ have the ANDROID_GUI property set, and thus will not be built as expected\.
+ They will be built as shared libraries with executable filenames:
+
+ android_c, android_cxx, android_sysinc_c, android_sysinc_cxx)?$
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..72ec00e
--- /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 (unified Clang toolchain|(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-stderr.txt b/Tests/RunCMake/Android/ndk-armeabi-thumb-stderr.txt
new file mode 100644
index 0000000..a3b3634
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-armeabi-thumb-stderr.txt
@@ -0,0 +1,7 @@
+^(CMake Warning:
+ You are using Visual Studio tools for Android, which does not support
+ standalone executables\. However, the following executable targets do not
+ have the ANDROID_GUI property set, and thus will not be built as expected\.
+ They will be built as shared libraries with executable filenames:
+
+ android_c, android_cxx, android_sysinc_c, android_sysinc_cxx)?$
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-stderr.txt b/Tests/RunCMake/Android/ndk-armeabi-v7a-neon-stderr.txt
new file mode 100644
index 0000000..a3b3634
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-armeabi-v7a-neon-stderr.txt
@@ -0,0 +1,7 @@
+^(CMake Warning:
+ You are using Visual Studio tools for Android, which does not support
+ standalone executables\. However, the following executable targets do not
+ have the ANDROID_GUI property set, and thus will not be built as expected\.
+ They will be built as shared libraries with executable filenames:
+
+ android_c, android_cxx, android_sysinc_c, android_sysinc_cxx)?$
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..8bd87fa
--- /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 (unified Clang toolchain|(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-stderr.txt b/Tests/RunCMake/Android/ndk-armeabi-v7a-stderr.txt
new file mode 100644
index 0000000..a3b3634
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-armeabi-v7a-stderr.txt
@@ -0,0 +1,7 @@
+^(CMake Warning:
+ You are using Visual Studio tools for Android, which does not support
+ standalone executables\. However, the following executable targets do not
+ have the ANDROID_GUI property set, and thus will not be built as expected\.
+ They will be built as shared libraries with executable filenames:
+
+ android_c, android_cxx, android_sysinc_c, android_sysinc_cxx)?$
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..554548e
--- /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 (unified Clang toolchain|(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..ce6bc4e
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-badver-stderr.txt
@@ -0,0 +1,13 @@
+^CMake Error at .*/Modules/Platform/Android/Determine-Compiler-NDK.cmake:[0-9]+ \(message\):
+ Android: The CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION value 'badver' is not(
+ supported by this NDK. It must be 'clang' or not set at all\.| 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..aec91d9
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-badvernum-stderr.txt
@@ -0,0 +1,15 @@
+^CMake Error at .*/Modules/Platform/Android/Determine-Compiler-NDK.cmake:[0-9]+ \(message\):(
+ Android: The CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION value '1.0' is not
+ supported by this NDK. It must be 'clang' or not set at all.|
+ Android: No toolchain for ABI 'armeabi(-v7a)?' 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..8ce544d
--- /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 (unified Clang toolchain|(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..1d7edea
--- /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 (unified Clang toolchain|(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-search-order.cmake b/Tests/RunCMake/Android/ndk-search-order.cmake
new file mode 100644
index 0000000..498d775
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-search-order.cmake
@@ -0,0 +1,17 @@
+if(NOT CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
+ return()
+endif()
+
+find_library(LIBDL dl)
+if(NOT LIBDL)
+ message(FATAL_ERROR "libdl not found.")
+endif()
+
+if(LIBDL MATCHES ".a$")
+ message(FATAL_ERROR "found libdl.a")
+endif()
+
+find_program(CLANG clang)
+if(NOT CLANG)
+ message(FATAL_ERROR "clang not found")
+endif()
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-stderr.txt b/Tests/RunCMake/Android/ndk-x86-stderr.txt
new file mode 100644
index 0000000..a3b3634
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-x86-stderr.txt
@@ -0,0 +1,7 @@
+^(CMake Warning:
+ You are using Visual Studio tools for Android, which does not support
+ standalone executables\. However, the following executable targets do not
+ have the ANDROID_GUI property set, and thus will not be built as expected\.
+ They will be built as shared libraries with executable filenames:
+
+ android_c, android_cxx, android_sysinc_c, android_sysinc_cxx)?$
diff --git a/Tests/RunCMake/Android/ndk-x86-stdout.txt b/Tests/RunCMake/Android/ndk-x86-stdout.txt
new file mode 100644
index 0000000..8d710fe
--- /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 (unified Clang toolchain|(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-stderr.txt b/Tests/RunCMake/Android/ndk-x86_64-stderr.txt
new file mode 100644
index 0000000..a3b3634
--- /dev/null
+++ b/Tests/RunCMake/Android/ndk-x86_64-stderr.txt
@@ -0,0 +1,7 @@
+^(CMake Warning:
+ You are using Visual Studio tools for Android, which does not support
+ standalone executables\. However, the following executable targets do not
+ have the ANDROID_GUI property set, and thus will not be built as expected\.
+ They will be built as shared libraries with executable filenames:
+
+ android_c, android_cxx, android_sysinc_c, android_sysinc_cxx)?$
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..695a088
--- /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 (unified Clang toolchain|(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/Android/sysinc/dlfcn.h b/Tests/RunCMake/Android/sysinc/dlfcn.h
new file mode 100644
index 0000000..273306c
--- /dev/null
+++ b/Tests/RunCMake/Android/sysinc/dlfcn.h
@@ -0,0 +1 @@
+#define NOT_SYSTEM_DLFCN_HEADER