summaryrefslogtreecommitdiff
path: root/Source
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 /Source
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
Diffstat (limited to 'Source')
-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
8 files changed, 137 insertions, 2 deletions
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());