summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-04-06 13:13:24 +0000
committerKitware Robot <kwrobot@kitware.com>2023-04-06 09:13:31 -0400
commitfbdb509efe21a02f075536eaf7fde0594e9419ef (patch)
tree254d5c3b7f4692126206ed2e0383fa18e579075f /Tests
parent703f87f32f067ab2122571e652861b43dd86fb4c (diff)
parent8ecb6459345c550b77d8f689ed397137f2855fca (diff)
downloadcmake-fbdb509efe21a02f075536eaf7fde0594e9419ef.tar.gz
Merge topic 'vs-sdk-selection'
8ecb645934 VS: Select Windows SDK matching WindowsSDKVersion env var f90c8ab54e VS: Select latest available Windows SDK version by default b512c53d43 VS: Add support for setting WindowsTargetPlatformVersion to 10.0 2f3d945f83 VS: Add CMAKE_GENERATOR_PLATFORM field to control Windows SDK selection f0a67b6291 VS: Parse comma-separated fields from CMAKE_GENERATOR_PLATFORM e259063b0a VS: Defer Windows SDK selection until CMAKE_GENERATOR_PLATFORM is known 8499374c6a VS: Simplify logic to require SDK for Windows Store 1c8d4b4bf1 Tests: Teach RunCMake_TEST_FILTER to account for test variant description Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !8389
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/GeneratorPlatform/BadFieldNoComma-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorPlatform/BadFieldNoComma-stderr.txt11
-rw-r--r--Tests/RunCMake/GeneratorPlatform/BadFieldNoComma.cmake1
-rw-r--r--Tests/RunCMake/GeneratorPlatform/BadFieldUnknown-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorPlatform/BadFieldUnknown-stderr.txt11
-rw-r--r--Tests/RunCMake/GeneratorPlatform/BadFieldUnknown.cmake1
-rw-r--r--Tests/RunCMake/GeneratorPlatform/BadVersionEmpty-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorPlatform/BadVersionEmpty-stderr.txt11
-rw-r--r--Tests/RunCMake/GeneratorPlatform/BadVersionEmpty.cmake1
-rw-r--r--Tests/RunCMake/GeneratorPlatform/BadVersionMissing-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorPlatform/BadVersionMissing-stderr.txt11
-rw-r--r--Tests/RunCMake/GeneratorPlatform/BadVersionMissing.cmake1
-rw-r--r--Tests/RunCMake/GeneratorPlatform/BadVersionPlatform-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorPlatform/BadVersionPlatform-stderr.txt19
-rw-r--r--Tests/RunCMake/GeneratorPlatform/BadVersionPlatform.cmake1
-rw-r--r--Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake83
-rw-r--r--Tests/RunCMake/GeneratorPlatform/VersionExists-check.cmake9
-rw-r--r--Tests/RunCMake/GeneratorPlatform/VersionExists.cmake5
-rw-r--r--Tests/RunCMake/RunCMake.cmake8
19 files changed, 176 insertions, 2 deletions
diff --git a/Tests/RunCMake/GeneratorPlatform/BadFieldNoComma-result.txt b/Tests/RunCMake/GeneratorPlatform/BadFieldNoComma-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/GeneratorPlatform/BadFieldNoComma-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorPlatform/BadFieldNoComma-stderr.txt b/Tests/RunCMake/GeneratorPlatform/BadFieldNoComma-stderr.txt
new file mode 100644
index 0000000000..b2098bd425
--- /dev/null
+++ b/Tests/RunCMake/GeneratorPlatform/BadFieldNoComma-stderr.txt
@@ -0,0 +1,11 @@
+^CMake Error at CMakeLists.txt:[0-9]+ \(project\):
+ Generator
+
+ Visual Studio [^
+]+
+
+ given platform specification
+
+ Test Platform,nocomma
+
+ that contains a field after the first ',' with no '='\.$
diff --git a/Tests/RunCMake/GeneratorPlatform/BadFieldNoComma.cmake b/Tests/RunCMake/GeneratorPlatform/BadFieldNoComma.cmake
new file mode 100644
index 0000000000..2fc38e5c59
--- /dev/null
+++ b/Tests/RunCMake/GeneratorPlatform/BadFieldNoComma.cmake
@@ -0,0 +1 @@
+message(FATAL_ERROR "This should not be reached!")
diff --git a/Tests/RunCMake/GeneratorPlatform/BadFieldUnknown-result.txt b/Tests/RunCMake/GeneratorPlatform/BadFieldUnknown-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/GeneratorPlatform/BadFieldUnknown-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorPlatform/BadFieldUnknown-stderr.txt b/Tests/RunCMake/GeneratorPlatform/BadFieldUnknown-stderr.txt
new file mode 100644
index 0000000000..654f9201c8
--- /dev/null
+++ b/Tests/RunCMake/GeneratorPlatform/BadFieldUnknown-stderr.txt
@@ -0,0 +1,11 @@
+^CMake Error at CMakeLists.txt:[0-9]+ \(project\):
+ Generator
+
+ Visual Studio [^
+]+
+
+ given platform specification
+
+ Test Platform,unknown=
+
+ that contains invalid field 'unknown='\.$
diff --git a/Tests/RunCMake/GeneratorPlatform/BadFieldUnknown.cmake b/Tests/RunCMake/GeneratorPlatform/BadFieldUnknown.cmake
new file mode 100644
index 0000000000..2fc38e5c59
--- /dev/null
+++ b/Tests/RunCMake/GeneratorPlatform/BadFieldUnknown.cmake
@@ -0,0 +1 @@
+message(FATAL_ERROR "This should not be reached!")
diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionEmpty-result.txt b/Tests/RunCMake/GeneratorPlatform/BadVersionEmpty-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/GeneratorPlatform/BadVersionEmpty-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionEmpty-stderr.txt b/Tests/RunCMake/GeneratorPlatform/BadVersionEmpty-stderr.txt
new file mode 100644
index 0000000000..1b7804da36
--- /dev/null
+++ b/Tests/RunCMake/GeneratorPlatform/BadVersionEmpty-stderr.txt
@@ -0,0 +1,11 @@
+^CMake Error at CMakeLists.txt:[0-9]+ \(project\):
+ Generator
+
+ Visual Studio [^
+]+
+
+ given platform specification with empty
+
+ version=
+
+ field\.$
diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionEmpty.cmake b/Tests/RunCMake/GeneratorPlatform/BadVersionEmpty.cmake
new file mode 100644
index 0000000000..2fc38e5c59
--- /dev/null
+++ b/Tests/RunCMake/GeneratorPlatform/BadVersionEmpty.cmake
@@ -0,0 +1 @@
+message(FATAL_ERROR "This should not be reached!")
diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionMissing-result.txt b/Tests/RunCMake/GeneratorPlatform/BadVersionMissing-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/GeneratorPlatform/BadVersionMissing-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionMissing-stderr.txt b/Tests/RunCMake/GeneratorPlatform/BadVersionMissing-stderr.txt
new file mode 100644
index 0000000000..d82eb0bbac
--- /dev/null
+++ b/Tests/RunCMake/GeneratorPlatform/BadVersionMissing-stderr.txt
@@ -0,0 +1,11 @@
+^CMake Error at CMakeLists.txt:[0-9]+ \(project\):
+ Generator
+
+ Visual Studio [^
+]+
+
+ given platform specification with
+
+ version=1\.2\.3\.4
+
+ field, but no Windows SDK with that version was found\.$
diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionMissing.cmake b/Tests/RunCMake/GeneratorPlatform/BadVersionMissing.cmake
new file mode 100644
index 0000000000..2fc38e5c59
--- /dev/null
+++ b/Tests/RunCMake/GeneratorPlatform/BadVersionMissing.cmake
@@ -0,0 +1 @@
+message(FATAL_ERROR "This should not be reached!")
diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform-result.txt b/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform-stderr.txt b/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform-stderr.txt
new file mode 100644
index 0000000000..d3c62e3629
--- /dev/null
+++ b/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform-stderr.txt
@@ -0,0 +1,19 @@
+^CMake Error at CMakeLists.txt:[0-9]+ \(project\):
+ Generator
+
+ Visual Studio [^
+]+
+
+ given platform specification (containing a
+
+ version=8\.1
+
+ field\. The version field is not supported when targeting
+
+ Windows 8\.1(
+
+ with the Windows 8\.1 SDK installed\.)?|with
+
+ version=8\.1
+
+ field, but no Windows SDK with that version was found\.)$
diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform.cmake b/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform.cmake
new file mode 100644
index 0000000000..2fc38e5c59
--- /dev/null
+++ b/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform.cmake
@@ -0,0 +1 @@
+message(FATAL_ERROR "This should not be reached!")
diff --git a/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake
index a7519c373c..233eb0a2f0 100644
--- a/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake
@@ -26,3 +26,86 @@ else()
run_cmake(BadPlatformToolchain)
unset(RunCMake_TEST_OPTIONS)
endif()
+
+if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio (1[4567])( 20[0-9][0-9])?$")
+ unset(ENV{WindowsSDKVersion})
+
+ set(RunCMake_GENERATOR_PLATFORM "Test Platform,nocomma")
+ run_cmake(BadFieldNoComma)
+ set(RunCMake_GENERATOR_PLATFORM "Test Platform,unknown=")
+ run_cmake(BadFieldUnknown)
+ set(RunCMake_GENERATOR_PLATFORM "version=")
+ run_cmake(BadVersionEmpty)
+ set(RunCMake_GENERATOR_PLATFORM "version=1.2.3.4")
+ run_cmake(BadVersionMissing)
+ set(RunCMake_GENERATOR_PLATFORM "version=8.1")
+ run_cmake_with_options(BadVersionPlatform -DCMAKE_SYSTEM_VERSION=8.1)
+
+ if(NOT RunCMake_GENERATOR MATCHES "^Visual Studio (1[45]) ")
+ set(expect_version "10.0")
+ set(RunCMake_GENERATOR_PLATFORM "version=${expect_version}")
+ set(RunCMake_TEST_VARIANT_DESCRIPTION "-${expect_version}")
+ run_cmake_with_options(VersionExists -DCMAKE_SYSTEM_VERSION=10.0)
+ unset(RunCMake_GENERATOR_PLATFORM)
+ endif()
+
+ set(kits "")
+ cmake_host_system_information(RESULT kitsRoot10
+ QUERY WINDOWS_REGISTRY "HKLM/SOFTWARE/Microsoft/Windows Kits/Installed Roots"
+ VALUE "KitsRoot10"
+ VIEW 64_32
+ ERROR_VARIABLE kitsRoot10Error
+ )
+ if(NOT kitsRoot10Error AND IS_DIRECTORY "${kitsRoot10}/include")
+ cmake_path(SET kitsInclude "${kitsRoot10}/include")
+ file(GLOB kits RELATIVE "${kitsInclude}" "${kitsInclude}/*/um/windows.h")
+ list(TRANSFORM kits REPLACE "/.*" "")
+ endif()
+ if(kits)
+ message(STATUS "Available Kits: ${kits}")
+ if(RunCMake_GENERATOR MATCHES "^Visual Studio 14 ")
+ set(kitMax 10.0.14393.0)
+ else()
+ set(kitMax "")
+ endif()
+ if(kitMax)
+ set(kitsIn "${kits}")
+ set(kits "")
+ foreach(kit IN LISTS kitsIn)
+ if(kit VERSION_LESS_EQUAL "${kitMax}")
+ list(APPEND kits "${kit}")
+ else()
+ message(STATUS "Excluding Kit ${kit} > ${kitMax}")
+ endif()
+ endforeach()
+ endif()
+ elseif(NOT RunCMake_GENERATOR MATCHES "^Visual Studio 14 ")
+ message(FATAL_ERROR "Could not find any Windows SDKs to drive test cases.")
+ endif()
+
+ if(kits)
+ foreach(expect_version IN LISTS kits)
+ set(RunCMake_GENERATOR_PLATFORM "version=${expect_version}")
+ set(RunCMake_TEST_VARIANT_DESCRIPTION "-${expect_version}")
+ run_cmake_with_options(VersionExists -DCMAKE_SYSTEM_VERSION=10.0)
+ unset(RunCMake_GENERATOR_PLATFORM)
+ endforeach()
+ foreach(expect_version IN LISTS kits)
+ set(RunCMake_TEST_VARIANT_DESCRIPTION "-CMP0149-OLD-${expect_version}")
+ run_cmake_with_options(VersionExists -DCMAKE_SYSTEM_VERSION=${expect_version} -DCMAKE_POLICY_DEFAULT_CMP0149=OLD)
+ endforeach()
+ if(kits MATCHES "(^|;)([0-9.]+)$")
+ set(expect_version "${CMAKE_MATCH_2}")
+ foreach(test_version IN LISTS kits)
+ set(RunCMake_TEST_VARIANT_DESCRIPTION "-CMP0149-NEW-${test_version}")
+ run_cmake_with_options(VersionExists -DCMAKE_SYSTEM_VERSION=${test_version} -DCMAKE_POLICY_DEFAULT_CMP0149=NEW)
+ endforeach()
+ endif()
+ foreach(expect_version IN LISTS kits)
+ set(RunCMake_TEST_VARIANT_DESCRIPTION "-WindowsSDKVersion-${expect_version}")
+ set(ENV{WindowsSDKVersion} "${expect_version}\\")
+ run_cmake_with_options(VersionExists -DCMAKE_SYSTEM_VERSION=10.0 -DCMAKE_POLICY_DEFAULT_CMP0149=NEW)
+ unset(ENV{WindowsSDKVersion})
+ endforeach()
+ endif()
+endif()
diff --git a/Tests/RunCMake/GeneratorPlatform/VersionExists-check.cmake b/Tests/RunCMake/GeneratorPlatform/VersionExists-check.cmake
new file mode 100644
index 0000000000..6c3c8e542b
--- /dev/null
+++ b/Tests/RunCMake/GeneratorPlatform/VersionExists-check.cmake
@@ -0,0 +1,9 @@
+if(actual_stdout MATCHES "CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION='([^']+)'")
+ set(actual_version "${CMAKE_MATCH_1}")
+ if(NOT "${actual_version}" STREQUAL "${expect_version}")
+ set(RunCMake_TEST_FAILED "Actual SDK version '${actual_version}' did not match expected '${expect_version}'")
+ return()
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "No CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION found in output.")
+endif()
diff --git a/Tests/RunCMake/GeneratorPlatform/VersionExists.cmake b/Tests/RunCMake/GeneratorPlatform/VersionExists.cmake
new file mode 100644
index 0000000000..5c30e2b616
--- /dev/null
+++ b/Tests/RunCMake/GeneratorPlatform/VersionExists.cmake
@@ -0,0 +1,5 @@
+cmake_policy(GET CMP0149 cmp0149)
+message(STATUS "CMP0149='${cmp0149}'")
+message(STATUS "CMAKE_SYSTEM_VERSION='${CMAKE_SYSTEM_VERSION}'")
+message(STATUS "ENV{WindowsSDKVersion}='$ENV{WindowsSDKVersion}'")
+message(STATUS "CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION='${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}'")
diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake
index 5f01541f22..8e85f6cf46 100644
--- a/Tests/RunCMake/RunCMake.cmake
+++ b/Tests/RunCMake/RunCMake.cmake
@@ -11,8 +11,12 @@ foreach(
endforeach()
function(run_cmake test)
- if(DEFINED ENV{RunCMake_TEST_FILTER} AND NOT test MATCHES "$ENV{RunCMake_TEST_FILTER}")
- return()
+ if(DEFINED ENV{RunCMake_TEST_FILTER})
+ set(test_and_variant "${test}${RunCMake_TEST_VARIANT_DESCRIPTION}")
+ if(NOT test_and_variant MATCHES "$ENV{RunCMake_TEST_FILTER}")
+ return()
+ endif()
+ unset(test_and_variant)
endif()
set(top_src "${RunCMake_SOURCE_DIR}")