summaryrefslogtreecommitdiff
path: root/Source/cmVisualStudio10TargetGenerator.cxx
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2021-10-08 09:20:44 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2021-10-08 09:20:44 +0900
commit99a800848c2512f7c93504fc7b28e6182a6ceb93 (patch)
tree0236502664965e5284d0c950ed2c1bf294b1233b /Source/cmVisualStudio10TargetGenerator.cxx
parentdf4ed7977a77409f899f6f05389960f6b73125a8 (diff)
downloadcmake-99a800848c2512f7c93504fc7b28e6182a6ceb93.tar.gz
cmake-99a800848c2512f7c93504fc7b28e6182a6ceb93.tar.bz2
cmake-99a800848c2512f7c93504fc7b28e6182a6ceb93.zip
Imported Upstream version 3.20.0upstream/3.20.0
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx98
1 files changed, 68 insertions, 30 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 489e42d8e..965ac3eee 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -676,7 +676,7 @@ void cmVisualStudio10TargetGenerator::Generate()
cmStrCat(this->DefaultArtifactDir, "\\nasm.props");
ConvertToWindowsSlash(propsLocal);
this->Makefile->ConfigureFile(propsTemplate, propsLocal, false, true,
- true, true);
+ true);
Elem(e1, "Import").Attribute("Project", propsLocal);
}
}
@@ -1020,9 +1020,9 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0)
cm::string_view tagName =
cm::string_view(p).substr(propNamePrefix.length());
if (!tagName.empty()) {
- const std::string& value = *props.GetPropertyValue(p);
- if (!value.empty()) {
- e2.Element(tagName, value);
+ cmProp value = props.GetPropertyValue(p);
+ if (cmNonempty(value)) {
+ e2.Element(tagName, *value);
}
}
}
@@ -1897,8 +1897,15 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1,
}
// Figure out if there's any additional flags to use
if (cmProp saf = sf->GetProperty("VS_SHADER_FLAGS")) {
+ cmGeneratorExpression ge;
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*saf);
+
for (const std::string& config : this->Configurations) {
- toolSettings[config]["AdditionalOptions"] = *saf;
+ std::string evaluated = cge->Evaluate(this->LocalGenerator, config);
+
+ if (!evaluated.empty()) {
+ toolSettings[config]["AdditionalOptions"] = evaluated;
+ }
}
}
// Figure out if debug information should be generated
@@ -2402,27 +2409,30 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
configDefines += *ccdefs;
}
- // Add precompile headers compile options.
- std::string customAndPchOptions = options;
- const std::string pchSource =
+ // We have pch state in the following situation:
+ // 1. We have SKIP_PRECOMPILE_HEADERS == true
+ // 2. We are creating the pre-compiled header
+ // 3. We are a different language than the linker language AND pch is
+ // enabled.
+ std::string const& linkLanguage =
+ this->GeneratorTarget->GetLinkerLanguage(config);
+ std::string const& pchSource =
this->GeneratorTarget->GetPchSource(config, lang);
- if (!pchSource.empty() && !sf.GetProperty("SKIP_PRECOMPILE_HEADERS")) {
- std::string pchOptions;
- if (sf.GetFullPath() == pchSource) {
- pchOptions =
- this->GeneratorTarget->GetPchCreateCompileOptions(config, lang);
- } else {
- pchOptions =
- this->GeneratorTarget->GetPchUseCompileOptions(config, lang);
- }
- customAndPchOptions = cmStrCat(customAndPchOptions, ';', pchOptions);
- }
+ const bool skipPCH =
+ pchSource.empty() || sf.GetPropertyAsBool("SKIP_PRECOMPILE_HEADERS");
+ const bool makePCH = (sf.GetFullPath() == pchSource);
+ const bool useSharedPCH = !skipPCH && (lang == linkLanguage);
+ const bool useDifferentLangPCH = !skipPCH && (lang != linkLanguage);
+ const bool useNoPCH = skipPCH && (lang != linkLanguage) &&
+ !this->GeneratorTarget->GetPchHeader(config, linkLanguage).empty();
+ const bool needsPCHFlags =
+ (makePCH || useSharedPCH || useDifferentLangPCH || useNoPCH);
// if we have flags or defines for this config then
// use them
if (!flags.empty() || !options.empty() || !configDefines.empty() ||
- !includes.empty() || compileAs || noWinRT ||
- !customAndPchOptions.empty()) {
+ !includes.empty() || compileAs || noWinRT || !options.empty() ||
+ needsPCHFlags) {
cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
cmIDEFlagTable const* flagtable = nullptr;
const std::string& srclang = source->GetLanguage();
@@ -2455,15 +2465,37 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
} else {
clOptions.Parse(flags);
}
- if (!customAndPchOptions.empty()) {
+
+ if (needsPCHFlags) {
+ // Add precompile headers compile options.
+ std::string expandedOptions;
+ std::string pchOptions;
+ if (makePCH) {
+ pchOptions =
+ this->GeneratorTarget->GetPchCreateCompileOptions(config, lang);
+ } else if (useNoPCH) {
+ clOptions.AddFlag("PrecompiledHeader", "NotUsing");
+ } else if (useSharedPCH) {
+ std::string pchHeader =
+ this->GeneratorTarget->GetPchHeader(config, lang);
+ clOptions.AddFlag("ForcedIncludeFiles", pchHeader);
+ } else if (useDifferentLangPCH) {
+ pchOptions =
+ this->GeneratorTarget->GetPchUseCompileOptions(config, lang);
+ }
+ this->LocalGenerator->AppendCompileOptions(expandedOptions,
+ pchOptions);
+ clOptions.Parse(expandedOptions);
+ }
+
+ if (!options.empty()) {
std::string expandedOptions;
if (configDependentOptions) {
this->LocalGenerator->AppendCompileOptions(
expandedOptions,
- genexInterpreter.Evaluate(customAndPchOptions, "COMPILE_OPTIONS"));
+ genexInterpreter.Evaluate(options, "COMPILE_OPTIONS"));
} else {
- this->LocalGenerator->AppendCompileOptions(expandedOptions,
- customAndPchOptions);
+ this->LocalGenerator->AppendCompileOptions(expandedOptions, options);
}
clOptions.Parse(expandedOptions);
}
@@ -2786,6 +2818,13 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
this->GeneratorTarget->GetPchHeader(configName, linkLanguage);
if (this->MSTools && vcxproj == this->ProjectType && pchHeader.empty()) {
clOptions.AddFlag("PrecompiledHeader", "NotUsing");
+ } else if (this->MSTools && vcxproj == this->ProjectType &&
+ !pchHeader.empty()) {
+ clOptions.AddFlag("PrecompiledHeader", "Use");
+ clOptions.AddFlag("PrecompiledHeaderFile", pchHeader);
+ std::string pchFile =
+ this->GeneratorTarget->GetPchFile(configName, linkLanguage);
+ clOptions.AddFlag("PrecompiledHeaderOutputFile", pchFile);
}
// Get preprocessor definitions for this directory.
@@ -4183,8 +4222,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0)
cmLocalGenerator* lg = dt->GetLocalGenerator();
std::string name = dt->GetName();
std::string path;
- cmProp p = dt->GetProperty("EXTERNAL_MSPROJECT");
- if (p) {
+ if (cmProp p = dt->GetProperty("EXTERNAL_MSPROJECT")) {
path = *p;
} else {
path = cmStrCat(lg->GetCurrentBinaryDirectory(), '/', dt->GetName(),
@@ -4972,9 +5010,9 @@ void cmVisualStudio10TargetGenerator::GetCSharpSourceProperties(
if (cmHasPrefix(p, propNamePrefix)) {
std::string tagName = p.substr(propNamePrefix.length());
if (!tagName.empty()) {
- const std::string& val = *props.GetPropertyValue(p);
- if (!val.empty()) {
- tags[tagName] = val;
+ cmProp val = props.GetPropertyValue(p);
+ if (cmNonempty(val)) {
+ tags[tagName] = *val;
} else {
tags.erase(tagName);
}