From 0c7f918fb1100c96e043c2f7c13732553b746ced Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Wed, 14 Jul 2021 14:05:50 -0400
Subject: [PATCH] VS: Update Visual Studio 17 2022 generator for Preview 2

In particular, update to toolset `v143`.

Fixes: #22339
---
 Help/generator/Visual Studio 17 2022.rst          |  4 ++--
 Help/release/3.21.rst                             | 13 ++++++++++++-
 Help/variable/MSVC_VERSION.rst                    |  2 --
 Source/cmGlobalVisualStudioVersionedGenerator.cxx |  3 +--
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/Help/generator/Visual Studio 17 2022.rst b/Help/generator/Visual Studio 17 2022.rst
index 06deda463f0..60073658c63 100644
--- a/Help/generator/Visual Studio 17 2022.rst	
+++ b/Help/generator/Visual Studio 17 2022.rst	
@@ -7,7 +7,7 @@ Generates Visual Studio 17 (VS 2022) project files.
 
 .. warning::
 
-  This is experimental and based on "Visual Studio 2022 Preview 1.1".
+  This is experimental and based on "Visual Studio 2022 Preview 2".
   As of this version of CMake, VS 2022 has not been released.
 
 Project Types
@@ -51,7 +51,7 @@ name (architecture).  For example:
 Toolset Selection
 ^^^^^^^^^^^^^^^^^
 
-The ``v142`` toolset that comes with VS 17 2022 Preview 1.1 is selected by
+The ``v143`` toolset that comes with VS 17 2022 Preview 2 is selected by
 default.  The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps
 via the :manual:`cmake(1)` ``-T`` option, to specify another toolset.
 
diff --git a/Help/release/3.21.rst b/Help/release/3.21.rst
index 204880b7b42..3e705529fe1 100644
--- a/Help/release/3.21.rst
+++ b/Help/release/3.21.rst
@@ -27,7 +27,7 @@ Generators
 ----------
 
 * The :generator:`Visual Studio 17 2022` generator was added.  This is
-  experimental and based on "Visual Studio 2022 Preview 1.1" because this
+  experimental and based on "Visual Studio 2022 Preview 2" because this
   version of VS has not been released.
 
 * The :ref:`Makefile Generators` and the :generator:`Ninja` generator
@@ -293,3 +293,14 @@ Other Changes
   `cmake.org <https://cmake.org/download/>`_ now support
   ``liblzma`` multi-threading.  See the :variable:`CPACK_THREADS` and
   :variable:`CPACK_ARCHIVE_THREADS` variables.
+
+Updates
+=======
+
+Changes made since CMake 3.21.0 include the following.
+
+3.21.1
+------
+
+* The :generator:`Visual Studio 17 2022` generator is now based on
+  "Visual Studio 2022 Preview 2".  Previously it was based on "Preview 1.1".
diff --git a/Help/variable/MSVC_VERSION.rst b/Help/variable/MSVC_VERSION.rst
index 241eb0384e3..cbb3a3c3828 100644
--- a/Help/variable/MSVC_VERSION.rst
+++ b/Help/variable/MSVC_VERSION.rst
@@ -19,8 +19,6 @@ Known version numbers are::
   1900      = VS 14.0 (v140 toolset)
   1910-1919 = VS 15.0 (v141 toolset)
   1920-1929 = VS 16.0 (v142 toolset)
-
-..
   1930-1939 = VS 17.0 (v143 toolset)
 
 See also the  :variable:`CMAKE_<LANG>_COMPILER_VERSION` and
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
index 4fab0b930b9..79c06d6a154 100644
--- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
@@ -104,8 +104,7 @@ static const char* VSVersionToToolset(
     case cmGlobalVisualStudioGenerator::VS16:
       return "v142";
     case cmGlobalVisualStudioGenerator::VS17:
-      // FIXME: VS 2022 Preview 1 uses v142.  Will it be v143 later?
-      return "v142";
+      return "v143";
   }
   return "";
 }
-- 
GitLab