summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-06-12 15:11:04 -0400
committerBrad King <brad.king@kitware.com>2020-06-24 08:41:09 -0400
commit6051a49c78a36b82e77a62e09f0ba5a5b5d14532 (patch)
treeee9c31b9a8f5530bd0fa4a0c76ded239325f3c45 /Tests
parentbbcaf9689ea76d8deba13870dfc63f0654348b5a (diff)
downloadcmake-6051a49c78a36b82e77a62e09f0ba5a5b5d14532.tar.gz
Visual Studio: Add Android support
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt61
-rw-r--r--Tests/RunCMake/Android/RunCMakeTest.cmake53
-rw-r--r--Tests/RunCMake/Android/ndk-arm64-v8a-stderr.txt7
-rw-r--r--Tests/RunCMake/Android/ndk-armeabi-arm-stderr.txt7
-rw-r--r--Tests/RunCMake/Android/ndk-armeabi-thumb-stderr.txt7
-rw-r--r--Tests/RunCMake/Android/ndk-armeabi-v7a-neon-stderr.txt7
-rw-r--r--Tests/RunCMake/Android/ndk-armeabi-v7a-stderr.txt7
-rw-r--r--Tests/RunCMake/Android/ndk-x86-stderr.txt7
-rw-r--r--Tests/RunCMake/Android/ndk-x86_64-stderr.txt7
-rw-r--r--Tests/RunCMake/CMakeLists.txt4
-rw-r--r--Tests/VSAndroid/AndroidManifest.xml (renamed from Tests/VSNsightTegra/AndroidManifest.xml)0
-rw-r--r--Tests/VSAndroid/CMakeLists.txt (renamed from Tests/VSNsightTegra/CMakeLists.txt)2
-rw-r--r--Tests/VSAndroid/build.xml (renamed from Tests/VSNsightTegra/build.xml)0
-rw-r--r--Tests/VSAndroid/jni/first.c (renamed from Tests/VSNsightTegra/jni/first.c)0
-rw-r--r--Tests/VSAndroid/jni/first.h (renamed from Tests/VSNsightTegra/jni/first.h)0
-rw-r--r--Tests/VSAndroid/jni/second.c (renamed from Tests/VSNsightTegra/jni/second.c)0
-rw-r--r--Tests/VSAndroid/proguard-android.txt (renamed from Tests/VSNsightTegra/proguard-android.txt)0
-rw-r--r--Tests/VSAndroid/res/values/strings.xml (renamed from Tests/VSNsightTegra/res/values/strings.xml)0
-rw-r--r--Tests/VSAndroid/src/com/example/twolibs/TwoLibs.java (renamed from Tests/VSNsightTegra/src/com/example/twolibs/TwoLibs.java)0
19 files changed, 141 insertions, 28 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index b771ff501e..8c871c3d42 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -206,6 +206,26 @@ if(BUILD_TESTING)
set(${reg} 0)
endif()
endforeach()
+ if(COMMAND cmake_host_system_information)
+ set(info_vs15 "VS_15_DIR")
+ set(info_vs16 "VS_16_DIR")
+ set(vs_versions)
+ if(WIN32)
+ if(NOT CMAKE_VERSION VERSION_LESS 3.14)
+ set(vs_versions vs15 vs16)
+ elseif(NOT CMAKE_VERSION VERSION_LESS 3.8)
+ set(vs_versions vs15)
+ endif()
+ endif()
+ foreach(info ${vs_versions})
+ cmake_host_system_information(RESULT found QUERY "${info_${info}}")
+ if(found)
+ set(${info} 1)
+ else()
+ set(${info} 0)
+ endif()
+ endforeach()
+ endif()
endif()
#---------------------------------------------------------------------------
@@ -2316,32 +2336,41 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH
endforeach()
endif()
+ macro(add_test_VSAndroid name generator platform)
+ add_test(NAME "VSAndroid.${name}.${platform}" COMMAND ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/VSAndroid"
+ "${CMake_BINARY_DIR}/Tests/VSAndroid/${name}/${platform}"
+ --build-generator "${generator}"
+ --build-project VSAndroid
+ --build-config $<CONFIGURATION>
+ --build-options -DCMAKE_SYSTEM_NAME=Android "-A${platform}"
+ )
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSAndroid/${name}")
+ endmacro()
if(tegra AND NOT "${CMake_SOURCE_DIR};${CMake_BINARY_DIR}" MATCHES " ")
- macro(add_test_VSNsightTegra name generator)
- add_test(NAME VSNsightTegra.${name} COMMAND ${CMAKE_CTEST_COMMAND}
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/VSNsightTegra"
- "${CMake_BINARY_DIR}/Tests/VSNsightTegra/${name}"
- --build-generator "${generator}"
- --build-project VSNsightTegra
- --build-config $<CONFIGURATION>
- --build-options -DCMAKE_SYSTEM_NAME=Android
- )
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSNsightTegra/${name}")
- endmacro()
if(vs10)
- add_test_VSNsightTegra(vs10 "Visual Studio 10 2010")
+ add_test_VSAndroid(vs10 "Visual Studio 10 2010" "Tegra-Android")
endif()
if(vs11)
- add_test_VSNsightTegra(vs11 "Visual Studio 11 2012")
+ add_test_VSAndroid(vs11 "Visual Studio 11 2012" "Tegra-Android")
endif()
if(vs12)
- add_test_VSNsightTegra(vs12 "Visual Studio 12 2013")
+ add_test_VSAndroid(vs12 "Visual Studio 12 2013" "Tegra-Android")
endif()
if(vs14)
- add_test_VSNsightTegra(vs14 "Visual Studio 14 2015")
+ add_test_VSAndroid(vs14 "Visual Studio 14 2015" "Tegra-Android")
endif()
endif()
+ if(vs14 AND CMake_TEST_ANDROID_VS14)
+ add_test_VSAndroid(vs14 "Visual Studio 14 2015" "ARM")
+ endif()
+ if(vs15 AND CMake_TEST_ANDROID_VS15)
+ add_test_VSAndroid(vs15 "Visual Studio 15 2017" "ARM")
+ endif()
+ if(vs16 AND CMake_TEST_ANDROID_VS16)
+ add_test_VSAndroid(vs16 "Visual Studio 16 2019" "ARM")
+ endif()
if (APPLE)
if (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
diff --git a/Tests/RunCMake/Android/RunCMakeTest.cmake b/Tests/RunCMake/Android/RunCMakeTest.cmake
index 234525a5ae..81dd09020d 100644
--- a/Tests/RunCMake/Android/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Android/RunCMakeTest.cmake
@@ -33,12 +33,18 @@ function(run_Android case)
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.
@@ -82,6 +88,9 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK)
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}")
@@ -89,44 +98,58 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK)
list(REMOVE_DUPLICATES _abis_${vers})
endforeach()
+ set(ndk_arg -DCMAKE_ANDROID_NDK=${ndk})
+ if(RunCMake_GENERATOR MATCHES "Visual Studio")
+ set(ndk_arg)
+ endif()
+
# 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
- -DCMAKE_ANDROID_NDK=${ndk}
+ ${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
- -DCMAKE_ANDROID_NDK=${ndk}
+ ${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
- -DCMAKE_ANDROID_NDK=${ndk}
+ ${ndk_arg}
-DCMAKE_ANDROID_ARM_NEON=0
)
run_cmake(ndk-badneon)
endif()
set(RunCMake_TEST_OPTIONS
-DCMAKE_SYSTEM_NAME=Android
- -DCMAKE_ANDROID_NDK=${ndk}
+ ${ndk_arg}
-DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=badver
)
run_cmake(ndk-badver)
set(RunCMake_TEST_OPTIONS
-DCMAKE_SYSTEM_NAME=Android
- -DCMAKE_ANDROID_NDK=${ndk}
+ ${ndk_arg}
-DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=1.0
)
run_cmake(ndk-badvernum)
set(RunCMake_TEST_OPTIONS
-DCMAKE_SYSTEM_NAME=Android
- -DCMAKE_ANDROID_NDK=${ndk}
+ ${ndk_arg}
-DCMAKE_ANDROID_STL_TYPE=badstl
)
run_cmake(ndk-badstl)
@@ -143,6 +166,7 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK)
run_cmake(ndk-sysroot-armeabi)
unset(RunCMake_TEST_OPTIONS)
endif()
+ set(RunCMake_GENERATOR_PLATFORM "${RunCMake_GENERATOR_PLATFORM_OLD}")
# Find available STLs.
set(stl_types
@@ -169,11 +193,18 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK)
armeabi-v6
armeabi-v7a
arm64-v8a
- mips
- mips64
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)
@@ -193,7 +224,7 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK)
endif()
message(STATUS "ndk='${ndk}' vers='${vers}' stl='${stl}'${config_status}")
set(RunCMake_TEST_OPTIONS
- -DCMAKE_ANDROID_NDK=${ndk}
+ ${ndk_arg}
-DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=${vers}
-DCMAKE_ANDROID_STL_TYPE=${stl}
"${build_type_arg}"
@@ -205,6 +236,9 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK)
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
@@ -214,6 +248,7 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK)
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()
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 0000000000..a3b3634e6f
--- /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-armeabi-arm-stderr.txt b/Tests/RunCMake/Android/ndk-armeabi-arm-stderr.txt
new file mode 100644
index 0000000000..a3b3634e6f
--- /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-thumb-stderr.txt b/Tests/RunCMake/Android/ndk-armeabi-thumb-stderr.txt
new file mode 100644
index 0000000000..a3b3634e6f
--- /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-v7a-neon-stderr.txt b/Tests/RunCMake/Android/ndk-armeabi-v7a-neon-stderr.txt
new file mode 100644
index 0000000000..a3b3634e6f
--- /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-stderr.txt b/Tests/RunCMake/Android/ndk-armeabi-v7a-stderr.txt
new file mode 100644
index 0000000000..a3b3634e6f
--- /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-x86-stderr.txt b/Tests/RunCMake/Android/ndk-x86-stderr.txt
new file mode 100644
index 0000000000..a3b3634e6f
--- /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_64-stderr.txt b/Tests/RunCMake/Android/ndk-x86_64-stderr.txt
new file mode 100644
index 0000000000..a3b3634e6f
--- /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/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 6c634b5df8..192895b4d5 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -683,8 +683,8 @@ add_RunCMake_test(AutoExportDll
add_RunCMake_test(AndroidMK)
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")
+ if(NOT "${CMAKE_GENERATOR}" MATCHES "Make|Ninja|Visual Studio 1[456]")
+ message(FATAL_ERROR "Android tests supported only by Makefile, Ninja, and Visual Studio >= 14 generators")
endif()
foreach(v TEST_ANDROID_NDK TEST_ANDROID_STANDALONE_TOOLCHAIN)
if(CMake_${v})
diff --git a/Tests/VSNsightTegra/AndroidManifest.xml b/Tests/VSAndroid/AndroidManifest.xml
index 951e8f3082..951e8f3082 100644
--- a/Tests/VSNsightTegra/AndroidManifest.xml
+++ b/Tests/VSAndroid/AndroidManifest.xml
diff --git a/Tests/VSNsightTegra/CMakeLists.txt b/Tests/VSAndroid/CMakeLists.txt
index 6d74f2f85e..73b1e079cb 100644
--- a/Tests/VSNsightTegra/CMakeLists.txt
+++ b/Tests/VSAndroid/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.3)
-project(VSNsightTegra C CXX)
+project(VSAndroid C CXX)
set(CMAKE_ANDROID_ARCH armv7-a)
set(CMAKE_ANDROID_STL_TYPE stlport_shared)
diff --git a/Tests/VSNsightTegra/build.xml b/Tests/VSAndroid/build.xml
index 17a2cc07b9..17a2cc07b9 100644
--- a/Tests/VSNsightTegra/build.xml
+++ b/Tests/VSAndroid/build.xml
diff --git a/Tests/VSNsightTegra/jni/first.c b/Tests/VSAndroid/jni/first.c
index b9dee2754c..b9dee2754c 100644
--- a/Tests/VSNsightTegra/jni/first.c
+++ b/Tests/VSAndroid/jni/first.c
diff --git a/Tests/VSNsightTegra/jni/first.h b/Tests/VSAndroid/jni/first.h
index 9dfd8b886c..9dfd8b886c 100644
--- a/Tests/VSNsightTegra/jni/first.h
+++ b/Tests/VSAndroid/jni/first.h
diff --git a/Tests/VSNsightTegra/jni/second.c b/Tests/VSAndroid/jni/second.c
index 30bdc17b03..30bdc17b03 100644
--- a/Tests/VSNsightTegra/jni/second.c
+++ b/Tests/VSAndroid/jni/second.c
diff --git a/Tests/VSNsightTegra/proguard-android.txt b/Tests/VSAndroid/proguard-android.txt
index fe73baeb58..fe73baeb58 100644
--- a/Tests/VSNsightTegra/proguard-android.txt
+++ b/Tests/VSAndroid/proguard-android.txt
diff --git a/Tests/VSNsightTegra/res/values/strings.xml b/Tests/VSAndroid/res/values/strings.xml
index 858cdb40ee..858cdb40ee 100644
--- a/Tests/VSNsightTegra/res/values/strings.xml
+++ b/Tests/VSAndroid/res/values/strings.xml
diff --git a/Tests/VSNsightTegra/src/com/example/twolibs/TwoLibs.java b/Tests/VSAndroid/src/com/example/twolibs/TwoLibs.java
index ef9da01cf8..ef9da01cf8 100644
--- a/Tests/VSNsightTegra/src/com/example/twolibs/TwoLibs.java
+++ b/Tests/VSAndroid/src/com/example/twolibs/TwoLibs.java