summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-06-28 13:22:31 +0000
committerKitware Robot <kwrobot@kitware.com>2021-06-28 09:22:38 -0400
commit117b1545a9d9c231f70ff24bfe8155149a5c0429 (patch)
treec312c76f705d1ab182f45c141802fcf4e8d42b75
parent5b44b7eee3bfd01ed37de9bfa07b5436ed8c1c35 (diff)
parent93c718791e4e81f37dcc3413b3e847d94313d5c9 (diff)
downloadcmake-117b1545a9d9c231f70ff24bfe8155149a5c0429.tar.gz
Merge topic 'vs2022' into release-3.21
93c718791e VS: Use 64-bit MSBuild in VS 2022 c46b265839 VS: Add Visual Studio 17 2022 generator b610b7a35c VS: Update v142 CL flag table for VS 17.0 Preview 1 43375c6418 Help: Remove unnecessary Sphinx versionadded markup in VS toolset selection Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !6268
-rw-r--r--Help/generator/VS_TOOLSET_HOST_ARCH.txt18
-rw-r--r--Help/generator/VS_TOOLSET_HOST_ARCH_LEGACY.txt11
-rw-r--r--Help/generator/Visual Studio 12 2013.rst2
-rw-r--r--Help/generator/Visual Studio 14 2015.rst2
-rw-r--r--Help/generator/Visual Studio 15 2017.rst2
-rw-r--r--Help/generator/Visual Studio 17 2022.rst61
-rw-r--r--Help/manual/cmake-generators.7.rst1
-rw-r--r--Help/release/3.21.rst4
-rw-r--r--Help/variable/MSVC_VERSION.rst3
-rw-r--r--Source/cmCMakeHostSystemInformationCommand.cxx16
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx2
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx11
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h3
-rw-r--r--Source/cmGlobalVisualStudioVersionedGenerator.cxx97
-rw-r--r--Source/cmGlobalVisualStudioVersionedGenerator.h3
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx1
-rw-r--r--Source/cmake.cxx6
-rw-r--r--Templates/MSBuild/FlagTables/v142_CL.json7
-rw-r--r--Tests/CMakeLists.txt8
-rw-r--r--Tests/RunCMake/CommandLine/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake10
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake2
-rw-r--r--Tests/VSExternalInclude/CMakeLists.txt4
24 files changed, 252 insertions, 28 deletions
diff --git a/Help/generator/VS_TOOLSET_HOST_ARCH.txt b/Help/generator/VS_TOOLSET_HOST_ARCH.txt
index 069638bd2d..029363115b 100644
--- a/Help/generator/VS_TOOLSET_HOST_ARCH.txt
+++ b/Help/generator/VS_TOOLSET_HOST_ARCH.txt
@@ -1,11 +1,7 @@
-.. versionadded:: 3.8
- For each toolset that comes with this version of Visual Studio, there are
- variants that are themselves compiled for 32-bit (``x86``) and
- 64-bit (``x64``) hosts (independent of the architecture they target).
- |VS_TOOLSET_HOST_ARCH_DEFAULT|
- One may explicitly request use of either the 32-bit or 64-bit host tools
- by adding either ``host=x86`` or ``host=x64`` to the toolset specification.
- See the :variable:`CMAKE_GENERATOR_TOOLSET` variable for details.
-
-.. versionadded:: 3.14
- Added support for ``host=x86`` option.
+For each toolset that comes with this version of Visual Studio, there are
+variants that are themselves compiled for 32-bit (``x86``) and
+64-bit (``x64``) hosts (independent of the architecture they target).
+|VS_TOOLSET_HOST_ARCH_DEFAULT|
+One may explicitly request use of either the 32-bit or 64-bit host tools
+by adding either ``host=x86`` or ``host=x64`` to the toolset specification.
+See the :variable:`CMAKE_GENERATOR_TOOLSET` variable for details.
diff --git a/Help/generator/VS_TOOLSET_HOST_ARCH_LEGACY.txt b/Help/generator/VS_TOOLSET_HOST_ARCH_LEGACY.txt
new file mode 100644
index 0000000000..069638bd2d
--- /dev/null
+++ b/Help/generator/VS_TOOLSET_HOST_ARCH_LEGACY.txt
@@ -0,0 +1,11 @@
+.. versionadded:: 3.8
+ For each toolset that comes with this version of Visual Studio, there are
+ variants that are themselves compiled for 32-bit (``x86``) and
+ 64-bit (``x64``) hosts (independent of the architecture they target).
+ |VS_TOOLSET_HOST_ARCH_DEFAULT|
+ One may explicitly request use of either the 32-bit or 64-bit host tools
+ by adding either ``host=x86`` or ``host=x64`` to the toolset specification.
+ See the :variable:`CMAKE_GENERATOR_TOOLSET` variable for details.
+
+.. versionadded:: 3.14
+ Added support for ``host=x86`` option.
diff --git a/Help/generator/Visual Studio 12 2013.rst b/Help/generator/Visual Studio 12 2013.rst
index b5fa1bf490..3b4b1f26d6 100644
--- a/Help/generator/Visual Studio 12 2013.rst
+++ b/Help/generator/Visual Studio 12 2013.rst
@@ -46,4 +46,4 @@ via the :manual:`cmake(1)` ``-T`` option, to specify another toolset.
.. |VS_TOOLSET_HOST_ARCH_DEFAULT| replace::
By default this generator uses the 32-bit variant even on a 64-bit host.
-.. include:: VS_TOOLSET_HOST_ARCH.txt
+.. include:: VS_TOOLSET_HOST_ARCH_LEGACY.txt
diff --git a/Help/generator/Visual Studio 14 2015.rst b/Help/generator/Visual Studio 14 2015.rst
index 9c616414f0..825772329d 100644
--- a/Help/generator/Visual Studio 14 2015.rst
+++ b/Help/generator/Visual Studio 14 2015.rst
@@ -44,7 +44,7 @@ via the :manual:`cmake(1)` ``-T`` option, to specify another toolset.
.. |VS_TOOLSET_HOST_ARCH_DEFAULT| replace::
By default this generator uses the 32-bit variant even on a 64-bit host.
-.. include:: VS_TOOLSET_HOST_ARCH.txt
+.. include:: VS_TOOLSET_HOST_ARCH_LEGACY.txt
.. _`Windows 10 SDK Maximum Version for VS 2015`:
diff --git a/Help/generator/Visual Studio 15 2017.rst b/Help/generator/Visual Studio 15 2017.rst
index a002f2ff6d..a80c57d822 100644
--- a/Help/generator/Visual Studio 15 2017.rst
+++ b/Help/generator/Visual Studio 15 2017.rst
@@ -63,4 +63,4 @@ via the :manual:`cmake(1)` ``-T`` option, to specify another toolset.
.. |VS_TOOLSET_HOST_ARCH_DEFAULT| replace::
By default this generator uses the 32-bit variant even on a 64-bit host.
-.. include:: VS_TOOLSET_HOST_ARCH.txt
+.. include:: VS_TOOLSET_HOST_ARCH_LEGACY.txt
diff --git a/Help/generator/Visual Studio 17 2022.rst b/Help/generator/Visual Studio 17 2022.rst
new file mode 100644
index 0000000000..c53f8b79a4
--- /dev/null
+++ b/Help/generator/Visual Studio 17 2022.rst
@@ -0,0 +1,61 @@
+Visual Studio 17 2022
+---------------------
+
+.. versionadded:: 3.21
+
+Generates Visual Studio 17 (VS 2022) project files.
+
+.. warning::
+
+ This is experimental and based on "Visual Studio 2022 Preview 1.1".
+ As of this version of CMake, VS 2022 has not been released.
+
+Project Types
+^^^^^^^^^^^^^
+
+Only Visual C++ and C# projects may be generated. Other types of
+projects (JavaScript, Powershell, Python, etc.) are not supported.
+
+Instance Selection
+^^^^^^^^^^^^^^^^^^
+
+VS 2022 supports multiple installations on the same machine.
+The :variable:`CMAKE_GENERATOR_INSTANCE` variable may be set as a
+cache entry containing the absolute path to a Visual Studio instance.
+If the value is not specified explicitly by the user or a toolchain file,
+CMake queries the Visual Studio Installer to locate VS instances, chooses
+one, and sets the variable as a cache entry to hold the value persistently.
+
+When CMake first chooses an instance, if the ``VS170COMNTOOLS`` environment
+variable is set and points to the ``Common7/Tools`` directory within
+one of the instances, that instance will be used. Otherwise, if more
+than one instance is installed we do not define which one is chosen
+by default.
+
+Platform Selection
+^^^^^^^^^^^^^^^^^^
+
+The default target platform name (architecture) is that of the host
+and is provided in the :variable:`CMAKE_VS_PLATFORM_NAME_DEFAULT` variable.
+
+The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
+via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
+name (architecture). For example:
+
+* ``cmake -G "Visual Studio 17 2022" -A Win32``
+* ``cmake -G "Visual Studio 17 2022" -A x64``
+* ``cmake -G "Visual Studio 17 2022" -A ARM``
+* ``cmake -G "Visual Studio 17 2022" -A ARM64``
+
+Toolset Selection
+^^^^^^^^^^^^^^^^^
+
+The ``v142`` toolset that comes with VS 17 2022 Preview 1.1 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.
+
+.. |VS_TOOLSET_HOST_ARCH_DEFAULT| replace::
+ By default this generator uses the 64-bit variant on x64 hosts and
+ the 32-bit variant otherwise.
+
+.. include:: VS_TOOLSET_HOST_ARCH.txt
diff --git a/Help/manual/cmake-generators.7.rst b/Help/manual/cmake-generators.7.rst
index 8ca2bf6444..663b18d465 100644
--- a/Help/manual/cmake-generators.7.rst
+++ b/Help/manual/cmake-generators.7.rst
@@ -91,6 +91,7 @@ Visual Studio Generators
/generator/Visual Studio 14 2015
/generator/Visual Studio 15 2017
/generator/Visual Studio 16 2019
+ /generator/Visual Studio 17 2022
Other Generators
^^^^^^^^^^^^^^^^
diff --git a/Help/release/3.21.rst b/Help/release/3.21.rst
index 04354dba72..1f7a4a15fe 100644
--- a/Help/release/3.21.rst
+++ b/Help/release/3.21.rst
@@ -26,6 +26,10 @@ Presets
Generators
----------
+* The :generator:`Visual Studio 17 2022` generator was added. This is
+ experimental and based on "Visual Studio 2022 Preview 1.1" because this
+ version of VS has not been released.
+
* The :ref:`Makefile Generators` and the :generator:`Ninja` generator
learned to add linker launcher tools along with the linker for ``C``,
``CXX``, ``OBJC``, and ``OBJCXX`` languages.
diff --git a/Help/variable/MSVC_VERSION.rst b/Help/variable/MSVC_VERSION.rst
index 45df37fa00..241eb0384e 100644
--- a/Help/variable/MSVC_VERSION.rst
+++ b/Help/variable/MSVC_VERSION.rst
@@ -20,5 +20,8 @@ Known version numbers are::
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
:variable:`MSVC_TOOLSET_VERSION` variable.
diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx
index 26e9af0279..0550568876 100644
--- a/Source/cmCMakeHostSystemInformationCommand.cxx
+++ b/Source/cmCMakeHostSystemInformationCommand.cxx
@@ -171,6 +171,22 @@ bool GetValue(cmExecutionStatus& status, cmsys::SystemInformation& info,
if (vsSetupAPIHelper.GetVSInstanceInfo(value)) {
cmSystemTools::ConvertToUnixSlashes(value);
}
+ } else if (key == "VS_17_DIR") {
+ // If generating for the VS 17 IDE, use the same instance.
+ cmGlobalGenerator* gg = status.GetMakefile().GetGlobalGenerator();
+ if (cmHasLiteralPrefix(gg->GetName(), "Visual Studio 17 ")) {
+ cmGlobalVisualStudioVersionedGenerator* vs17gen =
+ static_cast<cmGlobalVisualStudioVersionedGenerator*>(gg);
+ if (vs17gen->GetVSInstance(value)) {
+ return true;
+ }
+ }
+
+ // Otherwise, find a VS 17 instance ourselves.
+ cmVSSetupAPIHelper vsSetupAPIHelper(17);
+ if (vsSetupAPIHelper.GetVSInstanceInfo(value)) {
+ cmSystemTools::ConvertToUnixSlashes(value);
+ }
#endif
} else {
std::string e = "does not recognize <key> " + key;
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index fc2665b42b..fdb71554ce 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -1277,6 +1277,8 @@ const char* cmGlobalVisualStudio10Generator::GetToolsVersion() const
return "15.0";
case cmGlobalVisualStudioGenerator::VS16:
return "16.0";
+ case cmGlobalVisualStudioGenerator::VS17:
+ return "17.0";
}
return "";
}
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index c23ee94511..cdecea03a4 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -104,6 +104,8 @@ const char* cmGlobalVisualStudioGenerator::GetIDEVersion() const
return "15.0";
case cmGlobalVisualStudioGenerator::VS16:
return "16.0";
+ case cmGlobalVisualStudioGenerator::VS17:
+ return "17.0";
}
return "";
}
@@ -170,6 +172,15 @@ void cmGlobalVisualStudioGenerator::WriteSLNHeader(std::ostream& fout)
fout << "# Visual Studio Version 16\n";
}
break;
+ case cmGlobalVisualStudioGenerator::VS17:
+ // Visual Studio 17 writes .sln format 12.00
+ fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n";
+ if (this->ExpressEdition) {
+ fout << "# Visual Studio Express 17 for Windows Desktop\n";
+ } else {
+ fout << "# Visual Studio Version 17\n";
+ }
+ break;
}
}
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index 3bfcbd04d9..151f39f12d 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -38,7 +38,8 @@ public:
/* VS13 = 130 was skipped */
VS14 = 140,
VS15 = 150,
- VS16 = 160
+ VS16 = 160,
+ VS17 = 170
};
virtual ~cmGlobalVisualStudioGenerator();
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
index c8213c54c7..aafc9d5e96 100644
--- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
@@ -79,6 +79,8 @@ static unsigned int VSVersionToMajor(
return 15;
case cmGlobalVisualStudioGenerator::VS16:
return 16;
+ case cmGlobalVisualStudioGenerator::VS17:
+ return 17;
}
return 0;
}
@@ -101,6 +103,9 @@ static const char* VSVersionToToolset(
return "v141";
case cmGlobalVisualStudioGenerator::VS16:
return "v142";
+ case cmGlobalVisualStudioGenerator::VS17:
+ // FIXME: VS 2022 Preview 1 uses v142. Will it be v143 later?
+ return "v142";
}
return "";
}
@@ -118,6 +123,7 @@ static const char* VSVersionToAndroidToolset(
return "Clang_3_8";
case cmGlobalVisualStudioGenerator::VS15:
case cmGlobalVisualStudioGenerator::VS16:
+ case cmGlobalVisualStudioGenerator::VS17:
return "Clang_5_0";
}
return "";
@@ -219,6 +225,7 @@ cmGlobalVisualStudioVersionedGenerator::NewFactory15()
}
static const char vs16generatorName[] = "Visual Studio 16 2019";
+static const char vs17generatorName[] = "Visual Studio 17 2022";
// Map generator name without year to name with year.
static const char* cmVS16GenName(const std::string& name, std::string& genName)
@@ -235,6 +242,20 @@ static const char* cmVS16GenName(const std::string& name, std::string& genName)
return p;
}
+static const char* cmVS17GenName(const std::string& name, std::string& genName)
+{
+ if (strncmp(name.c_str(), vs17generatorName,
+ sizeof(vs17generatorName) - 6) != 0) {
+ return 0;
+ }
+ const char* p = name.c_str() + sizeof(vs17generatorName) - 6;
+ if (cmHasLiteralPrefix(p, " 2022")) {
+ p += 5;
+ }
+ genName = std::string(vs17generatorName) + p;
+ return p;
+}
+
class cmGlobalVisualStudioVersionedGenerator::Factory16
: public cmGlobalGeneratorFactory
{
@@ -299,6 +320,70 @@ cmGlobalVisualStudioVersionedGenerator::NewFactory16()
return std::unique_ptr<cmGlobalGeneratorFactory>(new Factory16);
}
+class cmGlobalVisualStudioVersionedGenerator::Factory17
+ : public cmGlobalGeneratorFactory
+{
+public:
+ std::unique_ptr<cmGlobalGenerator> CreateGlobalGenerator(
+ const std::string& name, bool /*allowArch*/, cmake* cm) const override
+ {
+ std::string genName;
+ const char* p = cmVS17GenName(name, genName);
+ if (!p) {
+ return std::unique_ptr<cmGlobalGenerator>();
+ }
+ if (!*p) {
+ return std::unique_ptr<cmGlobalGenerator>(
+ new cmGlobalVisualStudioVersionedGenerator(
+ cmGlobalVisualStudioGenerator::VS17, cm, genName, ""));
+ }
+ return std::unique_ptr<cmGlobalGenerator>();
+ }
+
+ void GetDocumentation(cmDocumentationEntry& entry) const override
+ {
+ entry.Name = std::string(vs17generatorName);
+ entry.Brief = "Generates Visual Studio 2022 project files. "
+ "Use -A option to specify architecture.";
+ }
+
+ std::vector<std::string> GetGeneratorNames() const override
+ {
+ std::vector<std::string> names;
+ names.push_back(vs17generatorName);
+ return names;
+ }
+
+ std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+ {
+ return std::vector<std::string>();
+ }
+
+ bool SupportsToolset() const override { return true; }
+ bool SupportsPlatform() const override { return true; }
+
+ std::vector<std::string> GetKnownPlatforms() const override
+ {
+ std::vector<std::string> platforms;
+ platforms.emplace_back("x64");
+ platforms.emplace_back("Win32");
+ platforms.emplace_back("ARM");
+ platforms.emplace_back("ARM64");
+ return platforms;
+ }
+
+ std::string GetDefaultPlatformName() const override
+ {
+ return VSHostPlatformName();
+ }
+};
+
+std::unique_ptr<cmGlobalGeneratorFactory>
+cmGlobalVisualStudioVersionedGenerator::NewFactory17()
+{
+ return std::unique_ptr<cmGlobalGeneratorFactory>(new Factory17);
+}
+
cmGlobalVisualStudioVersionedGenerator::cmGlobalVisualStudioVersionedGenerator(
VSVersion version, cmake* cm, const std::string& name,
std::string const& platformInGeneratorName)
@@ -339,6 +424,11 @@ bool cmGlobalVisualStudioVersionedGenerator::MatchesGeneratorName(
return genName == this->GetName();
}
break;
+ case cmGlobalVisualStudioGenerator::VS17:
+ if (cmVS17GenName(name, genName)) {
+ return genName == this->GetName();
+ }
+ break;
}
return false;
}
@@ -446,6 +536,7 @@ cmGlobalVisualStudioVersionedGenerator::GetAndroidApplicationTypeRevision()
return "2.0";
case cmGlobalVisualStudioGenerator::VS15:
case cmGlobalVisualStudioGenerator::VS16:
+ case cmGlobalVisualStudioGenerator::VS17:
return "3.0";
}
return "";
@@ -625,6 +716,12 @@ std::string cmGlobalVisualStudioVersionedGenerator::FindMSBuildCommand()
// Ask Visual Studio Installer tool.
std::string vs;
if (vsSetupAPIHelper.GetVSInstanceInfo(vs)) {
+ if (this->Version >= cmGlobalVisualStudioGenerator::VS17) {
+ msbuild = vs + "/MSBuild/Current/Bin/amd64/MSBuild.exe";
+ if (cmSystemTools::FileExists(msbuild)) {
+ return msbuild;
+ }
+ }
msbuild = vs + "/MSBuild/Current/Bin/MSBuild.exe";
if (cmSystemTools::FileExists(msbuild)) {
return msbuild;
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.h b/Source/cmGlobalVisualStudioVersionedGenerator.h
index e6c19e4b34..f07492dff5 100644
--- a/Source/cmGlobalVisualStudioVersionedGenerator.h
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.h
@@ -21,6 +21,7 @@ class cmGlobalVisualStudioVersionedGenerator
public:
static std::unique_ptr<cmGlobalGeneratorFactory> NewFactory15();
static std::unique_ptr<cmGlobalGeneratorFactory> NewFactory16();
+ static std::unique_ptr<cmGlobalGeneratorFactory> NewFactory17();
bool MatchesGeneratorName(const std::string& name) const override;
@@ -68,5 +69,7 @@ private:
friend class Factory15;
class Factory16;
friend class Factory16;
+ class Factory17;
+ friend class Factory17;
mutable cmVSSetupAPIHelper vsSetupAPIHelper;
};
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 505d58ac3a..058ffb4958 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -75,6 +75,7 @@ void cmVisualStudioGeneratorOptions::FixExceptionHandlingDefault()
case cmGlobalVisualStudioGenerator::VS14:
case cmGlobalVisualStudioGenerator::VS15:
case cmGlobalVisualStudioGenerator::VS16:
+ case cmGlobalVisualStudioGenerator::VS17:
// by default VS puts <ExceptionHandling></ExceptionHandling> empty
// for a project, to make our projects look the same put a new line
// and space over for the closing </ExceptionHandling> as the default
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 7868859290..14f66d9e70 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -2201,7 +2201,9 @@ std::unique_ptr<cmGlobalGenerator> cmake::EvaluateDefaultGlobalGenerator()
"\\Setup\\VC;ProductDir", //
";InstallDir" //
};
- if (cmVSSetupAPIHelper(16).IsVSInstalled()) {
+ if (cmVSSetupAPIHelper(17).IsVSInstalled()) {
+ found = "Visual Studio 17 2022";
+ } else if (cmVSSetupAPIHelper(16).IsVSInstalled()) {
found = "Visual Studio 16 2019";
} else if (cmVSSetupAPIHelper(15).IsVSInstalled()) {
found = "Visual Studio 15 2017";
@@ -2506,6 +2508,8 @@ void cmake::AddDefaultGenerators()
#if defined(_WIN32) && !defined(__CYGWIN__)
# if !defined(CMAKE_BOOT_MINGW)
this->Generators.push_back(
+ cmGlobalVisualStudioVersionedGenerator::NewFactory17());
+ this->Generators.push_back(
cmGlobalVisualStudioVersionedGenerator::NewFactory16());
this->Generators.push_back(
cmGlobalVisualStudioVersionedGenerator::NewFactory15());
diff --git a/Templates/MSBuild/FlagTables/v142_CL.json b/Templates/MSBuild/FlagTables/v142_CL.json
index c21a3def6a..49776d0fe0 100644
--- a/Templates/MSBuild/FlagTables/v142_CL.json
+++ b/Templates/MSBuild/FlagTables/v142_CL.json
@@ -477,6 +477,13 @@
},
{
"name": "LanguageStandard",
+ "switch": "std:c++20",
+ "comment": "ISO C++20 Standard",
+ "value": "stdcpp20",
+ "flags": []
+ },
+ {
+ "name": "LanguageStandard",
"switch": "std:c++17",
"comment": "ISO C++17 Standard",
"value": "stdcpp17",
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 6d7355492f..341aba6351 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -209,9 +209,12 @@ if(BUILD_TESTING)
if(CMAKE_HOST_WIN32 AND COMMAND cmake_host_system_information)
set(info_vs15 "VS_15_DIR")
set(info_vs16 "VS_16_DIR")
+ set(info_vs17 "VS_17_DIR")
set(vs_versions)
if(WIN32)
- if(NOT CMAKE_VERSION VERSION_LESS 3.14)
+ if(NOT CMAKE_VERSION VERSION_LESS 3.21.20210624)
+ set(vs_versions vs15 vs16 vs17)
+ elseif(NOT CMAKE_VERSION VERSION_LESS 3.14)
set(vs_versions vs15 vs16)
elseif(NOT CMAKE_VERSION VERSION_LESS 3.8)
set(vs_versions vs15)
@@ -2459,6 +2462,9 @@ if(BUILD_TESTING)
if(vs16 AND CMake_TEST_ANDROID_VS16)
add_test_VSAndroid(vs16 "Visual Studio 16 2019" "ARM")
endif()
+ if(vs17 AND CMake_TEST_ANDROID_VS17)
+ add_test_VSAndroid(vs17 "Visual Studio 17 2022" "ARM")
+ endif()
if (APPLE)
if (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index c4d3e4ae61..c58b1d06df 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -313,7 +313,7 @@ function(run_EnvironmentGenerator)
unset(ENV{CMAKE_GENERATOR_PLATFORM})
endif()
# Instance is available since VS 2017.
- if(RunCMake_GENERATOR MATCHES "Visual Studio (15|16).*")
+ if(RunCMake_GENERATOR MATCHES "Visual Studio 1[567].*")
set(ENV{CMAKE_GENERATOR_INSTANCE} "invalid")
# Envvar shouldn't affect existing build tree
run_cmake_command(Envgen-instance-existing ${CMAKE_COMMAND} -E chdir ..
diff --git a/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake
index 83e63f9185..a7519c373c 100644
--- a/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake
@@ -3,7 +3,7 @@ include(RunCMake)
set(RunCMake_GENERATOR_PLATFORM "")
run_cmake(NoPlatform)
-if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio ([89]|1[012456])( 20[0-9][0-9])?$")
+if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio ([89]|1[0124567])( 20[0-9][0-9])?$")
set(RunCMake_GENERATOR_PLATFORM "x64")
run_cmake(x64Platform)
else()
@@ -17,7 +17,7 @@ set(RunCMake_TEST_OPTIONS -A "Test Platform" -A "Extra Platform")
run_cmake(TwoPlatforms)
unset(RunCMake_TEST_OPTIONS)
-if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio ([89]|1[012456])( 20[0-9][0-9])?$")
+if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio ([89]|1[0124567])( 20[0-9][0-9])?$")
set(RunCMake_TEST_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/TestPlatform-toolchain.cmake)
run_cmake(TestPlatformToolchain)
unset(RunCMake_TEST_OPTIONS)
diff --git a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake
index faed8f7d4d..a7423918fd 100644
--- a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake
@@ -1,6 +1,6 @@
include(RunCMake)
-if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[012456]")
+if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[0124567]")
run_cmake(VsNormal)
include("${RunCMake_BINARY_DIR}/VsNormal-build/defaults.cmake" OPTIONAL)
message(STATUS "VsNormal: platform='${VsNormal_Platform}' toolset='${VsNormal_Toolset}'")
@@ -9,7 +9,7 @@ endif()
set(RunCMake_GENERATOR_TOOLSET "")
run_cmake(NoToolset)
-if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[012456]")
+if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[0124567]")
set(RunCMake_GENERATOR_TOOLSET "Test Toolset")
run_cmake(TestToolset)
set(RunCMake_GENERATOR_TOOLSET "Test Toolset,cuda=0.0")
@@ -43,7 +43,7 @@ if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[012456]")
set(RunCMake_GENERATOR_TOOLSET "${VsNormal_Toolset},customFlagTableDir=does_not_exist")
run_cmake(BadToolsetCustomFlagTableDir)
endif()
- if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[2456]")
+ if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[24567]")
set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64")
run_cmake(TestToolsetHostArchBoth)
set(RunCMake_GENERATOR_TOOLSET ",host=x64")
@@ -58,7 +58,7 @@ if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[012456]")
run_cmake(BadToolsetHostArch)
set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64,host=x86")
run_cmake(BadToolsetHostArchTwice)
- if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[56]")
+ if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[567]")
set(RunCMake_GENERATOR_TOOLSET "VCTargetsPath=Test Path")
run_cmake(TestToolsetVCTargetsPathOnly)
set(RunCMake_GENERATOR_TOOLSET "Test Toolset,version=Test Toolset Version")
@@ -109,7 +109,7 @@ set(RunCMake_TEST_OPTIONS -T "Test Toolset" -T "Extra Toolset")
run_cmake(TwoToolsets)
unset(RunCMake_TEST_OPTIONS)
-if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[012456]|Xcode")
+if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[0124567]|Xcode")
set(RunCMake_TEST_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/TestToolset-toolchain.cmake)
run_cmake(TestToolsetToolchain)
unset(RunCMake_TEST_OPTIONS)
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake
index 085bb6b173..854f3dc4df 100644
--- a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake
@@ -1,7 +1,7 @@
message(STATUS "CMAKE_VS_PLATFORM_TOOLSET='${CMAKE_VS_PLATFORM_TOOLSET}'")
message(STATUS "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}'")
-if(CMAKE_GENERATOR MATCHES "Visual Studio 1[6]")
+if(CMAKE_GENERATOR MATCHES "Visual Studio 1[67]")
cmake_host_system_information(RESULT is_64_bit QUERY IS_64BIT)
if(is_64_bit)
if(NOT "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" STREQUAL "x64")
diff --git a/Tests/VSExternalInclude/CMakeLists.txt b/Tests/VSExternalInclude/CMakeLists.txt
index e38df8e81a..a3fd8d8ebe 100644
--- a/Tests/VSExternalInclude/CMakeLists.txt
+++ b/Tests/VSExternalInclude/CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required (VERSION 2.8.12)
project(VSExternalInclude)
-if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[012456]")
+if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[0124567]")
set(PROJECT_EXT vcxproj)
else()
set(PROJECT_EXT vcproj)
@@ -55,7 +55,7 @@ add_dependencies(VSExternalInclude lib2)
# and the sln file can no longer be the only source
# of that depend. So, for VS 10 make the executable
# depend on lib1 and lib2
-if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[012456]")
+if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[0124567]")
add_dependencies(VSExternalInclude lib1)
endif()