mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
VS: Restore support for VS 2019 with toolset v142 versions before 14.29
Since commit 7db3dbddb2 (VS: Suppress MSBuild default flags not
specified by project or user, 2025-06-02, v4.1.0-rc1~69^2) we suppress
the `-Zc:inline` default flag when the project/user does not specify it.
That triggers an apparent bug in VS 2019 with v142 toolset versions
before 14.29 in which MSBuild fails when both `-Zc:inline` and `-nologo`
are suppressed. This happens when `CMAKE_VERBOSE_MAKEFILE` is enabled,
such as in `try_compile` projects like our builtin compiler inspection.
Since `-nologo` is incidental, avoid suppressing it if `-Zc:inline` is
also suppressed. Limit this workaround to relevant toolset versions.
Fixes: #27439
This commit is contained in:
@@ -170,11 +170,17 @@ public:
|
||||
std::string const cond =
|
||||
this->TargetGenerator->CalcCondition(this->GetConfiguration());
|
||||
this->Parent->WritePlatformConfigTag(tag, cond, content);
|
||||
} else if (!this->SuppressStartupBannerCondition.empty() &&
|
||||
tag == "SuppressStartupBanner"_s) {
|
||||
this->Parent->WritePlatformConfigTag(
|
||||
tag, this->SuppressStartupBannerCondition, content);
|
||||
} else {
|
||||
this->Parent->Element(tag, content);
|
||||
}
|
||||
}
|
||||
|
||||
std::string SuppressStartupBannerCondition;
|
||||
|
||||
private:
|
||||
cmVisualStudio10TargetGenerator* const TargetGenerator;
|
||||
Elem* Parent = nullptr;
|
||||
@@ -3656,6 +3662,13 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
|
||||
}
|
||||
if (!clOptions.HasFlag("RemoveUnreferencedCodeData")) {
|
||||
clOptions.AddFlag("RemoveUnreferencedCodeData", "");
|
||||
// Visual Studio 2019 with toolset v142 versions 14.20 to 14.28.16.9
|
||||
// fails if both RemoveUnreferencedCodeData and SuppressStartupBanner
|
||||
// are empty. Since the latter is incidental, make it conditional.
|
||||
if (this->GlobalGenerator->GetPlatformToolsetString() == "v142"_s) {
|
||||
clOptions.SuppressStartupBannerCondition =
|
||||
"'$(VCToolsVersion)' >= '14.29'";
|
||||
}
|
||||
}
|
||||
if (!clOptions.HasFlag("RuntimeLibrary")) {
|
||||
clOptions.AddFlag("RuntimeLibrary", "");
|
||||
|
||||
Reference in New Issue
Block a user