summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudio10TargetGenerator.cxx
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@sap.com>2017-11-30 14:06:21 (GMT)
committerMarc Chevrier <marc.chevrier@sap.com>2017-12-05 13:47:39 (GMT)
commit9432f686e62082045f53bd0ec8f8911966476df1 (patch)
tree9e03e1ae0c08fa693fbfb741b763d45c78b5feef /Source/cmVisualStudio10TargetGenerator.cxx
parentd06b8264212c893b5da8d7499328eb403aaaad37 (diff)
downloadCMake-9432f686e62082045f53bd0ec8f8911966476df1.zip
CMake-9432f686e62082045f53bd0ec8f8911966476df1.tar.gz
CMake-9432f686e62082045f53bd0ec8f8911966476df1.tar.bz2
Add generator expression support to per-source COMPILE_DEFINITIONS
This allows users to specify different genex-based compile definitions for each file in a target. Fixes: #17508
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx11
1 files changed, 10 insertions, 1 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index badd24f..8589a96 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2066,12 +2066,15 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
std::string flags;
bool configDependentFlags = false;
std::string defines;
+ bool configDependentDefines = false;
if (const char* cflags = sf.GetProperty("COMPILE_FLAGS")) {
configDependentFlags =
cmGeneratorExpression::Find(cflags) != std::string::npos;
flags += cflags;
}
if (const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS")) {
+ configDependentDefines =
+ cmGeneratorExpression::Find(cdefs) != std::string::npos;
defines += cdefs;
}
std::string lang =
@@ -2121,6 +2124,8 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
if (!configDefines.empty()) {
configDefines += ";";
}
+ configDependentDefines |=
+ cmGeneratorExpression::Find(ccdefs) != std::string::npos;
configDefines += ccdefs;
}
// if we have flags or defines for this config then
@@ -2170,7 +2175,11 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
clOptions.AppendFlag("DisableSpecificWarnings",
"%(DisableSpecificWarnings)");
}
- clOptions.AddDefines(configDefines.c_str());
+ if (configDependentDefines) {
+ clOptions.AddDefines(genexInterpreter.Evaluate(configDefines));
+ } else {
+ clOptions.AddDefines(configDefines.c_str());
+ }
clOptions.SetConfiguration((*config).c_str());
clOptions.PrependInheritedString("AdditionalOptions");
clOptions.OutputFlagMap(*this->BuildFileStream, " ");