VS: Simplify generation of per-source PCH settings

Avoid looking up the PCH create/use flags just to map them through
flag tables back to the `.vcxproj` settings.  Instead, simply
generate the PCH settings directly for each source file.

Since commit 9df1f33c9a (VisualStudio: move PCH rules to projects when
possible., 2020-10-15, v3.20.0-rc1~638^2) we already do this for the
target-wide PCH settings.
This commit is contained in:
Brad King
2022-02-03 15:46:24 -05:00
parent 3d85c0072d
commit dd1e2cc80c

View File

@@ -2736,11 +2736,15 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
if (needsPCHFlags) {
// Add precompile headers compile options.
std::string expandedOptions;
std::string pchOptions;
if (makePCH) {
pchOptions =
this->GeneratorTarget->GetPchCreateCompileOptions(config, lang);
clOptions.AddFlag("PrecompiledHeader", "Create");
std::string pchHeader =
this->GeneratorTarget->GetPchHeader(config, lang);
clOptions.AddFlag("PrecompiledHeaderFile", pchHeader);
std::string pchFile =
this->GeneratorTarget->GetPchFile(config, lang);
clOptions.AddFlag("PrecompiledHeaderOutputFile", pchFile);
clOptions.AddFlag("ForcedIncludeFiles", pchHeader);
} else if (useNoPCH) {
clOptions.AddFlag("PrecompiledHeader", "NotUsing");
} else if (useSharedPCH) {
@@ -2748,12 +2752,15 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
this->GeneratorTarget->GetPchHeader(config, lang);
clOptions.AddFlag("ForcedIncludeFiles", pchHeader);
} else if (useDifferentLangPCH) {
pchOptions =
this->GeneratorTarget->GetPchUseCompileOptions(config, lang);
clOptions.AddFlag("PrecompiledHeader", "Use");
std::string pchHeader =
this->GeneratorTarget->GetPchHeader(config, lang);
clOptions.AddFlag("PrecompiledHeaderFile", pchHeader);
std::string pchFile =
this->GeneratorTarget->GetPchFile(config, lang);
clOptions.AddFlag("PrecompiledHeaderOutputFile", pchFile);
clOptions.AddFlag("ForcedIncludeFiles", pchHeader);
}
this->LocalGenerator->AppendCompileOptions(expandedOptions,
pchOptions);
clOptions.Parse(expandedOptions);
}
if (!options.empty()) {