Attached Files | compile_flags_config.patch [^] (841 bytes) 2008-04-21 04:47 [Show Content] [Hide Content]--- Source/cmLocalVisualStudio7Generator.cxx.orig Thu Apr 10 13:44:00 2008
+++ Source/cmLocalVisualStudio7Generator.cxx Sat Apr 19 20:22:24 2008
@@ -537,13 +537,24 @@
}
// Add the target-specific flags.
- if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS"))
+ const char* targetFlags;
+ if(targetFlags = target.GetProperty("COMPILE_FLAGS"))
{
flags += " ";
flags += targetFlags;
}
std::string configUpper = cmSystemTools::UpperCase(configName);
+
+ std::string compileFlagsConfig = "COMPILE_FLAGS_";
+ compileFlagsConfig += configUpper;
+ if(targetFlags = target.GetProperty(compileFlagsConfig.c_str()))
+ {
+ flags += " ";
+ flags += targetFlags;
+ }
+
+
std::string defPropName = "COMPILE_DEFINITIONS_";
defPropName += configUpper;
compile_flags_config_makefile.patch [^] (1,652 bytes) 2008-05-22 07:08 [Show Content] [Hide Content]Index: Source/cmMakefileTargetGenerator.cxx
===================================================================
--- Source/cmMakefileTargetGenerator.cxx (revision 11485)
+++ Source/cmMakefileTargetGenerator.cxx (working copy)
@@ -489,7 +489,25 @@
this->LocalGenerator->AppendFlags(flags, langFlags.c_str());
// Add target-specific flags.
- if(this->Target->GetProperty("COMPILE_FLAGS"))
+ std::string compileFlags;
+ {
+ const char *compileFlags_ = this->Target->GetProperty("COMPILE_FLAGS");
+
+ std::string compileFlagsConfigProp = "COMPILE_FLAGS_";
+ compileFlagsConfigProp +=
+ cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName.c_str());
+ const char *compileFlagsConfig_ = this->Target->GetProperty(compileFlagsConfigProp.c_str());
+
+ if(compileFlags_)
+ compileFlags += compileFlags_;
+ if(compileFlagsConfig_) {
+ if(!compileFlags.empty())
+ compileFlags += ' ';
+ compileFlags += compileFlagsConfig_;
+ }
+ }
+
+ if(!compileFlags.empty())
{
std::string langIncludeExpr = "CMAKE_";
langIncludeExpr += lang;
@@ -501,7 +519,7 @@
cmsys::RegularExpression r(regex);
std::vector<std::string> args;
cmSystemTools::ParseWindowsCommandLine(
- this->Target->GetProperty("COMPILE_FLAGS"),
+ compileFlags.c_str(),
args);
for(std::vector<std::string>::iterator i = args.begin();
i != args.end(); ++i)
@@ -516,7 +534,7 @@
else
{
this->LocalGenerator->AppendFlags
- (flags, this->Target->GetProperty("COMPILE_FLAGS"));
+ (flags, compileFlags.c_str());
}
}
compile_flags.diff [^] (13,283 bytes) 2008-07-14 10:47 [Show Content] [Hide Content]--- Source/cmLocalVisualStudio6Generator.cxx Mon May 05 14:13:06 2008
+++ Source/cmLocalVisualStudio6Generator.cxx Mon Jul 14 10:21:41 2008
@@ -430,13 +430,36 @@
}
}
// Add per-source and per-configuration preprocessor definitions.
std::map<cmStdString, cmStdString> cdmap;
- this->AppendDefines(compileFlags,
+ this->AppendDefines(compileFlags,
(*sf)->GetProperty("COMPILE_DEFINITIONS"), lang);
- if(const char* cdefs = (*sf)->GetProperty("COMPILE_DEFINITIONS_DEBUG"))
+ if(const char* cdefs = (*sf)->GetProperty("COMPILE_FLAGS_DEBUG"))
+ {
+ cdmap["DEBUG"] += " ";
+ cdmap["DEBUG"] += cdefs;
+ }
+ if(const char* cdefs = (*sf)->GetProperty("COMPILE_FLAGS_RELEASE"))
+ {
+ cdmap["RELEASE"] += " ";
+ cdmap["RELEASE"] += cdefs;
+ }
+ if(const char* cdefs =
+ (*sf)->GetProperty("COMPILE_FLAGS_MINSIZEREL"))
+ {
+ cdmap["MINSIZEREL"] += " ";
+ cdmap["MINSIZEREL"] += cdefs;
+ }
+ if(const char* cdefs =
+ (*sf)->GetProperty("COMPILE_FLAGS_RELWITHDEBINFO"))
+ {
+ cdmap["RELWITHDEBINFO"] += " ";
+ cdmap["RELWITHDEBINFO"] += cdefs;
+ }
+
+ if(const char* cdefs = (*sf)->GetProperty("COMPILE_DEFINITIONS_DEBUG"))
{
this->AppendDefines(cdmap["DEBUG"], cdefs, lang);
}
if(const char* cdefs = (*sf)->GetProperty("COMPILE_DEFINITIONS_RELEASE"))
{
@@ -1500,10 +1523,31 @@
if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS"))
{
flags += " ";
flags += targetFlags;
}
+ // Add per-configuration flags.
+ if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS_DEBUG"))
+ {
+ flagsDebug += " ";
+ flagsDebug += targetFlags;
+ }
+ if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS_RELEASE"))
+ {
+ flagsRelease += " ";
+ flagsRelease += targetFlags;
+ }
+ if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS_MINSIZEREL"))
+ {
+ flagsMinSize += " ";
+ flagsMinSize += targetFlags;
+ }
+ if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS_RELWITHDEBINFO"))
+ {
+ flagsDebugRel += " ";
+ flagsDebugRel += targetFlags;
+ }
// Add per-target and per-configuration preprocessor definitions.
this->AppendDefines
(flags, this->Makefile->GetProperty("COMPILE_DEFINITIONS"), 0);
this->AppendDefines(flags, target.GetProperty("COMPILE_DEFINITIONS"), 0);
--- Source/cmLocalVisualStudio7Generator.cxx Mon May 05 14:13:06 2008
+++ Source/cmLocalVisualStudio7Generator.cxx Mon Jul 14 16:27:57 2008
@@ -612,17 +612,28 @@
flags += " /TP ";
}
}
// Add the target-specific flags.
- if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS"))
+ const char* targetFlags;
+ if(targetFlags = target.GetProperty("COMPILE_FLAGS"))
{
flags += " ";
flags += targetFlags;
}
std::string configUpper = cmSystemTools::UpperCase(configName);
+
+ std::string compileFlagsConfig = "COMPILE_FLAGS_";
+ compileFlagsConfig += configUpper;
+ if(targetFlags = target.GetProperty(compileFlagsConfig.c_str()))
+ {
+ flags += " ";
+ flags += targetFlags;
+ }
+
+
std::string defPropName = "COMPILE_DEFINITIONS_";
defPropName += configUpper;
// Get preprocessor definitions for this directory.
std::string defineFlags = this->Makefile->GetDefineFlags();
@@ -1208,10 +1219,11 @@
struct cmLVS7GFileConfig
{
std::string ObjectName;
std::string CompileFlags;
+ std::string CompileFlagsConfig;
std::string CompileDefs;
std::string CompileDefsConfig;
std::string AdditionalDeps;
bool ExcludedFromBuild;
};
@@ -1255,17 +1267,25 @@
if(const char* cflags = sf.GetProperty("COMPILE_FLAGS"))
{
fc.CompileFlags = cflags;
needfc = true;
}
+
+ std::string defPropName = "COMPILE_DEFINITIONS_";
+ defPropName += configUpper;
+ if(const char* cflags = sf.GetProperty(defPropName.c_str()))
+ {
+ fc.CompileFlagsConfig = cflags;
+ needfc = true;
+ }
if(const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS"))
{
fc.CompileDefs = cdefs;
needfc = true;
}
- std::string defPropName = "COMPILE_DEFINITIONS_";
- defPropName += configUpper;
+
+ defPropName = "COMPILE_DEFINITIONS_" + configUpper;
if(const char* ccdefs = sf.GetProperty(defPropName.c_str()))
{
fc.CompileDefsConfig = ccdefs;
needfc = true;
}
@@ -1440,16 +1460,18 @@
}
fout << ">\n";
fout << "\t\t\t\t\t<Tool\n"
<< "\t\t\t\t\tName=\"" << aCompilerTool << "\"\n";
if(!fc.CompileFlags.empty() ||
+ !fc.CompileFlagsConfig.empty() ||
!fc.CompileDefs.empty() ||
!fc.CompileDefsConfig.empty())
{
Options fileOptions(this, this->Version, Options::Compiler,
this->ExtraFlagTable);
fileOptions.Parse(fc.CompileFlags.c_str());
+ fileOptions.Parse(fc.CompileFlagsConfig.c_str());
fileOptions.AddDefines(fc.CompileDefs.c_str());
fileOptions.AddDefines(fc.CompileDefsConfig.c_str());
fileOptions.OutputAdditionalOptions(fout, "\t\t\t\t\t", "\n");
fileOptions.OutputFlagMap(fout, "\t\t\t\t\t");
fileOptions.OutputPreprocessorDefinitions(fout,
--- Source/cmMakefileTargetGenerator.cxx Mon May 05 14:13:06 2008
+++ Source/cmMakefileTargetGenerator.cxx Mon Jul 14 16:27:40 2008
@@ -238,13 +238,17 @@
}
//----------------------------------------------------------------------------
void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
{
+ std::string upperConfig =
+ cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName);
+
// write language flags for target
std::set<cmStdString> languages;
this->Target->GetLanguages(languages);
+
// put the compiler in the rules.make file so that if it changes
// things rebuild
for(std::set<cmStdString>::const_iterator l = languages.begin();
l != languages.end(); ++l)
{
@@ -275,12 +279,11 @@
this->LocalGenerator->AppendDefines
(defines, this->Makefile->GetProperty("COMPILE_DEFINITIONS"), lang);
this->LocalGenerator->AppendDefines
(defines, this->Target->GetProperty("COMPILE_DEFINITIONS"), lang);
std::string defPropName = "COMPILE_DEFINITIONS_";
- defPropName +=
- cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName);
+ defPropName += upperConfig;
this->LocalGenerator->AppendDefines
(defines, this->Makefile->GetProperty(defPropName.c_str()), lang);
this->LocalGenerator->AppendDefines
(defines, this->Target->GetProperty(defPropName.c_str()), lang);
@@ -308,15 +311,32 @@
*this->FlagFileStream << lang << "_FLAGS = " << flags << "\n\n";
*this->FlagFileStream << lang << "_DEFINES = " << defines << "\n\n";
}
// Add target-specific flags.
- if(this->Target->GetProperty("COMPILE_FLAGS"))
+
+ std::string compileFlags;
+ std::string compileFlagsConfigProp = "COMPILE_FLAGS_";
+ compileFlagsConfigProp += upperConfig;
+ {
+ const char *compileFlags_ = this->Target->GetProperty("COMPILE_FLAGS");
+ const char *compileFlagsConfig_ = this->Target->GetProperty(compileFlagsConfigProp.c_str());
+
+ if(compileFlags_)
+ compileFlags += compileFlags_;
+ if(compileFlagsConfig_) {
+ if(!compileFlags.empty())
+ compileFlags += ' ';
+ compileFlags += compileFlagsConfig_;
+ }
+ }
+
+ if( ! compileFlags.empty())
{
- std::string flags;
+ std::string flags;
this->LocalGenerator->AppendFlags
- (flags, this->Target->GetProperty("COMPILE_FLAGS"));
+ (flags, compileFlags.c_str());
*this->FlagFileStream << "# TARGET_FLAGS = " << flags << "\n\n";
}
}
//----------------------------------------------------------------------------
@@ -486,12 +506,31 @@
std::string langFlags = "$(";
langFlags += lang;
langFlags += "_FLAGS)";
this->LocalGenerator->AppendFlags(flags, langFlags.c_str());
+ std::string configUpper =
+ cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName);
+
// Add target-specific flags.
- if(this->Target->GetProperty("COMPILE_FLAGS"))
+ std::string compileFlags;
+ std::string compileFlagsConfigProp = "COMPILE_FLAGS_";
+ compileFlagsConfigProp += configUpper;
+ {
+ const char *compileFlags_ = this->Target->GetProperty("COMPILE_FLAGS");
+ const char *compileFlagsConfig_ = this->Target->GetProperty(compileFlagsConfigProp.c_str());
+
+ if(compileFlags_)
+ compileFlags += compileFlags_;
+ if(compileFlagsConfig_) {
+ if(!compileFlags.empty())
+ compileFlags += ' ';
+ compileFlags += compileFlagsConfig_;
+ }
+ }
+
+ if(!compileFlags.empty())
{
std::string langIncludeExpr = "CMAKE_";
langIncludeExpr += lang;
langIncludeExpr += "_FLAG_REGEX";
const char* regex = this->Makefile->
@@ -499,11 +538,11 @@
if(regex)
{
cmsys::RegularExpression r(regex);
std::vector<std::string> args;
cmSystemTools::ParseWindowsCommandLine(
- this->Target->GetProperty("COMPILE_FLAGS"),
+ compileFlags.c_str(),
args);
for(std::vector<std::string>::iterator i = args.begin();
i != args.end(); ++i)
{
if(r.find(i->c_str()))
@@ -514,11 +553,11 @@
}
}
else
{
this->LocalGenerator->AppendFlags
- (flags, this->Target->GetProperty("COMPILE_FLAGS"));
+ (flags, compileFlags.c_str());
}
}
// Add flags from source file properties.
if (source.GetProperty("COMPILE_FLAGS"))
@@ -530,10 +569,23 @@
<< source.GetProperty("COMPILE_FLAGS")
<< "\n"
<< "\n";
}
+ // Add configuration-specific flags from source file properties.
+
+ if (source.GetProperty(compileFlagsConfigProp.c_str()))
+ {
+ this->LocalGenerator->AppendFlags
+ (flags, source.GetProperty(compileFlagsConfigProp.c_str()));
+ *this->FlagFileStream << "# Custom flags: "
+ << relativeObj << "_FLAGS_"<< configUpper.c_str() << " = "
+ << source.GetProperty(compileFlagsConfigProp.c_str())
+ << "\n"
+ << "\n";
+ }
+
// Add language-specific defines.
std::string defines = "$(";
defines += lang;
defines += "_DEFINES)";
@@ -544,12 +596,10 @@
*this->FlagFileStream << "# Custom defines: "
<< relativeObj << "_DEFINES = "
<< compile_defs << "\n"
<< "\n";
}
- std::string configUpper =
- cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName);
std::string defPropName = "COMPILE_DEFINITIONS_";
defPropName += configUpper;
if(const char* config_compile_defs =
source.GetProperty(defPropName.c_str()))
{
--- Source/cmSourceFile.cxx Mon May 05 14:13:08 2008
+++ Source/cmSourceFile.cxx Mon Jul 14 14:34:59 2008
@@ -414,10 +414,16 @@
"These flags will be added to the list of compile flags when "
"this source file builds. Use COMPILE_DEFINITIONS to pass additional "
"preprocessor definitions.");
cm->DefineProperty
+ ("COMPILE_FLAGS_<CONFIG>", cmProperty::SOURCE_FILE,
+ "Additional per-configuration flags to use when compiling this source file.",
+ "Use COMPILE_DEFINITIONS_<CONFIG> "
+ "to pass additional preprocessor definitions for a specific configuration. ");
+
+ cm->DefineProperty
("COMPILE_DEFINITIONS", cmProperty::SOURCE_FILE,
"Preprocessor definitions for compiling a source file.",
"The COMPILE_DEFINITIONS property may be set to a list of preprocessor "
"definitions using the syntax VAR or VAR=value. Function-style "
"definitions are not supported. CMake will automatically escape "
--- Source/cmTarget.cxx Mon May 05 14:13:08 2008
+++ Source/cmTarget.cxx Mon Jul 14 14:35:14 2008
@@ -89,10 +89,17 @@
"The COMPILE_FLAGS property sets additional compiler flags used "
"to build sources within the target. Use COMPILE_DEFINITIONS "
"to pass additional preprocessor definitions.");
cm->DefineProperty
+ ("COMPILE_FLAGS_<CONFIG>", cmProperty::TARGET,
+ "Additional per-configuration flags to use when compiling this target's sources.",
+ "The COMPILE_FLAGS_<CONFIG> property sets additional compiler flags used "
+ "to build sources within the target. Use COMPILE_DEFINITIONS_<CONFIG> "
+ "to pass additional preprocessor definitions for a specific configuration. ");
+
+ cm->DefineProperty
("COMPILE_DEFINITIONS", cmProperty::TARGET,
"Preprocessor definitions for compiling a target's sources.",
"The COMPILE_DEFINITIONS property may be set to a list of preprocessor "
"definitions using the syntax VAR or VAR=value. Function-style "
"definitions are not supported. CMake will automatically escape "
0001-COMPILE_FLAGS_-CONFIG.patch [^] (13,903 bytes) 2012-10-25 18:30 [Show Content] [Hide Content]From 4fa9d8562f7272dd03c12a4af9af03c683f0a012 Mon Sep 17 00:00:00 2001
From: test <tst>
Date: Fri, 5 Oct 2012 17:38:38 +0300
Subject: [PATCH] COMPILE_FLAGS_-CONFIG
---
Source/cmLocalVisualStudio6Generator.cxx | 46 ++++++++++++++++++++-
Source/cmLocalVisualStudio7Generator.cxx | 33 ++++++++++++---
Source/cmMakefileTargetGenerator.cxx | 65 ++++++++++++++++++++++++++----
Source/cmSourceFile.cxx | 10 ++++-
Source/cmTarget.cxx | 11 ++++-
Source/cmVisualStudio10TargetGenerator.cxx | 28 +++++++++++--
6 files changed, 172 insertions(+), 21 deletions(-)
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index 72b56e7..59890dd 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -427,7 +427,30 @@ void cmLocalVisualStudio6Generator
this->JoinDefines(targetCompileDefinitions, compileFlags, lang);
}
- if(const char* cdefs = (*sf)->GetProperty("COMPILE_DEFINITIONS_DEBUG"))
+ if(const char* cdefs = (*sf)->GetProperty("COMPILE_FLAGS_DEBUG"))
+ {
+ cdmap["DEBUG"] += " ";
+ cdmap["DEBUG"] += cdefs;
+ }
+ if(const char* cdefs = (*sf)->GetProperty("COMPILE_FLAGS_RELEASE"))
+ {
+ cdmap["RELEASE"] += " ";
+ cdmap["RELEASE"] += cdefs;
+ }
+ if(const char* cdefs =
+ (*sf)->GetProperty("COMPILE_FLAGS_MINSIZEREL"))
+ {
+ cdmap["MINSIZEREL"] += " ";
+ cdmap["MINSIZEREL"] += cdefs;
+ }
+ if(const char* cdefs =
+ (*sf)->GetProperty("COMPILE_FLAGS_RELWITHDEBINFO"))
+ {
+ cdmap["RELWITHDEBINFO"] += " ";
+ cdmap["RELWITHDEBINFO"] += cdefs;
+ }
+
+ if(const char* cdefs = (*sf)->GetProperty("COMPILE_DEFINITIONS_DEBUG"))
{
std::set<std::string> debugCompileDefinitions;
this->AppendDefines(debugCompileDefinitions, cdefs);
@@ -1672,6 +1695,27 @@ void cmLocalVisualStudio6Generator
flags += targetFlags;
}
+ // Add per-configuration flags.
+ if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS_DEBUG"))
+ {
+ flagsDebug += " ";
+ flagsDebug += targetFlags;
+ }
+ if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS_RELEASE"))
+ {
+ flagsRelease += " ";
+ flagsRelease += targetFlags;
+ }
+ if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS_MINSIZEREL"))
+ {
+ flagsMinSize += " ";
+ flagsMinSize += targetFlags;
+ }
+ if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS_RELWITHDEBINFO"))
+ {
+ flagsDebugRel += " ";
+ flagsDebugRel += targetFlags;
+ }
// Add per-target and per-configuration preprocessor definitions.
std::set<std::string> definesSet;
std::set<std::string> debugDefinesSet;
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 33d6e05..6823555 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -718,11 +718,22 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
}
// Add the target-specific flags.
- if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS"))
- {
- flags += " ";
- flags += targetFlags;
- }
+ const char* targetFlags;
+ if(targetFlags = target.GetProperty("COMPILE_FLAGS"))
+ {
+ flags += " ";
+ flags += targetFlags;
+ }
+
+ std::string configUpper = cmSystemTools::UpperCase(configName);
+
+ std::string compileFlagsConfig = "COMPILE_FLAGS_";
+ compileFlagsConfig += configUpper;
+ if(targetFlags = target.GetProperty(compileFlagsConfig.c_str()))
+ {
+ flags += " ";
+ flags += targetFlags;
+ }
// Get preprocessor definitions for this directory.
std::string defineFlags = this->Makefile->GetDefineFlags();
@@ -1421,6 +1432,7 @@ struct cmLVS7GFileConfig
{
std::string ObjectName;
std::string CompileFlags;
+ std::string CompileFlagsConfig;
std::string CompileDefs;
std::string CompileDefsConfig;
std::string AdditionalDeps;
@@ -1483,12 +1495,19 @@ cmLocalVisualStudio7GeneratorFCInfo
default: break;
}
}
+ std::string defPropName = "COMPILE_FLAGS_";
+ defPropName += configUpper;
+ if(const char* cflags = sf.GetProperty(defPropName.c_str()))
+ {
+ fc.CompileFlagsConfig = cflags;
+ needfc = true;
+ }
if(const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS"))
{
fc.CompileDefs = cdefs;
needfc = true;
}
- std::string defPropName = "COMPILE_DEFINITIONS_";
+ defPropName = "COMPILE_DEFINITIONS_";
defPropName += configUpper;
if(const char* ccdefs = sf.GetProperty(defPropName.c_str()))
{
@@ -1682,6 +1701,7 @@ void cmLocalVisualStudio7Generator
fout << "\t\t\t\t\t<Tool\n"
<< "\t\t\t\t\tName=\"" << aCompilerTool << "\"\n";
if(!fc.CompileFlags.empty() ||
+ !fc.CompileFlagsConfig.empty() ||
!fc.CompileDefs.empty() ||
!fc.CompileDefsConfig.empty())
{
@@ -1696,6 +1716,7 @@ void cmLocalVisualStudio7Generator
Options fileOptions(this, tool, table,
this->ExtraFlagTable);
fileOptions.Parse(fc.CompileFlags.c_str());
+ fileOptions.Parse(fc.CompileFlagsConfig.c_str());
fileOptions.AddDefines(fc.CompileDefs.c_str());
fileOptions.AddDefines(fc.CompileDefsConfig.c_str());
fileOptions.OutputAdditionalOptions(fout, "\t\t\t\t\t", "\n");
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 5cc67e2..80fca40 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -319,6 +319,9 @@ std::string cmMakefileTargetGenerator::GetDefines(const std::string &l)
void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
{
+ std::string upperConfig =
+ cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName);
+
// write language flags for target
std::set<cmStdString> languages;
this->Target->GetLanguages(languages);
@@ -343,11 +346,28 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
}
// Add target-specific flags.
- if(this->Target->GetProperty("COMPILE_FLAGS"))
+
+ std::string compileFlags;
+ std::string compileFlagsConfigProp = "COMPILE_FLAGS_";
+ compileFlagsConfigProp += upperConfig;
+ {
+ const char *compileFlags_ = this->Target->GetProperty("COMPILE_FLAGS");
+ const char *compileFlagsConfig_ = this->Target->GetProperty(compileFlagsConfigProp.c_str());
+
+ if(compileFlags_)
+ compileFlags += compileFlags_;
+ if(compileFlagsConfig_) {
+ if(!compileFlags.empty())
+ compileFlags += ' ';
+ compileFlags += compileFlagsConfig_;
+ }
+ }
+
+ if( ! compileFlags.empty())
{
std::string flags;
this->LocalGenerator->AppendFlags
- (flags, this->Target->GetProperty("COMPILE_FLAGS"));
+ (flags, compileFlags.c_str());
*this->FlagFileStream << "# TARGET_FLAGS = " << flags << "\n\n";
}
}
@@ -533,9 +553,27 @@ cmMakefileTargetGenerator
langFlags += lang;
langFlags += "_FLAGS)";
this->LocalGenerator->AppendFlags(flags, langFlags.c_str());
+ std::string configUpper =
+ cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName);
// Add target-specific flags.
- if(this->Target->GetProperty("COMPILE_FLAGS"))
+ std::string compileFlags;
+ std::string compileFlagsConfigProp = "COMPILE_FLAGS_";
+ compileFlagsConfigProp += configUpper;
+ {
+ const char *compileFlags_ = this->Target->GetProperty("COMPILE_FLAGS");
+ const char *compileFlagsConfig_ = this->Target->GetProperty(compileFlagsConfigProp.c_str());
+
+ if(compileFlags_)
+ compileFlags += compileFlags_;
+ if(compileFlagsConfig_) {
+ if(!compileFlags.empty())
+ compileFlags += ' ';
+ compileFlags += compileFlagsConfig_;
+ }
+ }
+
+ if(!compileFlags.empty())
{
std::string langIncludeExpr = "CMAKE_";
langIncludeExpr += lang;
@@ -547,7 +585,7 @@ cmMakefileTargetGenerator
cmsys::RegularExpression r(regex);
std::vector<std::string> args;
cmSystemTools::ParseWindowsCommandLine(
- this->Target->GetProperty("COMPILE_FLAGS"),
+ compileFlags.c_str(),
args);
for(std::vector<std::string>::iterator i = args.begin();
i != args.end(); ++i)
@@ -562,7 +600,7 @@ cmMakefileTargetGenerator
else
{
this->LocalGenerator->AppendFlags
- (flags, this->Target->GetProperty("COMPILE_FLAGS"));
+ (flags, compileFlags.c_str());
}
}
@@ -584,6 +622,19 @@ cmMakefileTargetGenerator
<< "\n";
}
+ // Add configuration-specific flags from source file properties.
+
+ if (source.GetProperty(compileFlagsConfigProp.c_str()))
+ {
+ this->LocalGenerator->AppendFlags
+ (flags, source.GetProperty(compileFlagsConfigProp.c_str()));
+ *this->FlagFileStream << "# Custom flags: "
+ << relativeObj << "_FLAGS_"<< configUpper.c_str() << " = "
+ << source.GetProperty(compileFlagsConfigProp.c_str())
+ << "\n"
+ << "\n";
+ }
+
// Add language-specific defines.
std::set<std::string> defines;
@@ -596,8 +647,8 @@ cmMakefileTargetGenerator
<< compile_defs << "\n"
<< "\n";
}
- std::string configUpper =
- cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName);
+// std::string configUpper =
+// cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName);
std::string defPropName = "COMPILE_DEFINITIONS_";
defPropName += configUpper;
if(const char* config_compile_defs =
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index cc3b6d6..e5aa34a 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -402,8 +402,14 @@ void cmSourceFile::DefineProperties(cmake *cm)
"this source file builds. Use COMPILE_DEFINITIONS to pass additional "
"preprocessor definitions.");
- cm->DefineProperty
- ("COMPILE_DEFINITIONS", cmProperty::SOURCE_FILE,
+ cm->DefineProperty
+ ("COMPILE_FLAGS_<CONFIG>", cmProperty::SOURCE_FILE,
+ "Additional per-configuration flags to use when compiling this source file.",
+ "Use COMPILE_DEFINITIONS_<CONFIG> "
+ "to pass additional preprocessor definitions for a specific configuration. ");
+
+ cm->DefineProperty
+ ("COMPILE_DEFINITIONS", cmProperty::SOURCE_FILE,
"Preprocessor definitions for compiling a source file.",
"The COMPILE_DEFINITIONS property may be set to a "
"semicolon-separated list of preprocessor "
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 423b350..c4d7747 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -190,8 +190,15 @@ void cmTarget::DefineProperties(cmake *cm)
"to build sources within the target. Use COMPILE_DEFINITIONS "
"to pass additional preprocessor definitions.");
- cm->DefineProperty
- ("COMPILE_DEFINITIONS", cmProperty::TARGET,
+ cm->DefineProperty
+ ("COMPILE_FLAGS_<CONFIG>", cmProperty::TARGET,
+ "Additional per-configuration flags to use when compiling this target's sources.",
+ "The COMPILE_FLAGS_<CONFIG> property sets additional compiler flags used "
+ "to build sources within the target. Use COMPILE_DEFINITIONS_<CONFIG> "
+ "to pass additional preprocessor definitions for a specific configuration. ");
+
+ cm->DefineProperty
+ ("COMPILE_DEFINITIONS", cmProperty::TARGET,
"Preprocessor definitions for compiling a target's sources.",
"The COMPILE_DEFINITIONS property may be set to a "
"semicolon-separated list of preprocessor "
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index ab57a32..4c2fe73 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -975,9 +975,20 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
}
configDefines += ccdefs;
}
+ std::string configFlags = flags;
+ std::string flagPropName = "COMPILE_FLAGS_";
+ flagPropName += configUpper;
+ if(const char* ccflags = sf.GetProperty(flagPropName.c_str()))
+ {
+ if(configFlags.size())
+ {
+ configFlags += " ";
+ }
+ configFlags += ccflags;
+ }
// if we have flags or defines for this config then
// use them
- if(flags.size() || configDefines.size())
+ if(configFlags.size() || configDefines.size())
{
(*this->BuildFileStream ) << firstString;
firstString = ""; // only do firstString once
@@ -986,7 +997,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
clOptions(this->LocalGenerator,
cmVisualStudioGeneratorOptions::Compiler,
cmVSGetCLFlagTable(this->LocalGenerator), 0, this);
- clOptions.Parse(flags.c_str());
+ clOptions.Parse(configFlags.c_str());
clOptions.AddDefines(configDefines.c_str());
clOptions.SetConfiguration((*config).c_str());
clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
@@ -1220,11 +1231,22 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
}
}
// Add the target-specific flags.
- if(const char* targetFlags = this->Target->GetProperty("COMPILE_FLAGS"))
+ const char* targetFlags;
+ if(targetFlags = this->Target->GetProperty("COMPILE_FLAGS"))
{
flags += " ";
flags += targetFlags;
}
+
+ std::string configUpper = cmSystemTools::UpperCase(configName);
+ std::string compileFlagsConfig = "COMPILE_FLAGS_";
+ compileFlagsConfig += configUpper;
+ if(targetFlags = this->Target->GetProperty(compileFlagsConfig.c_str()))
+ {
+ flags += " ";
+ flags += targetFlags;
+ }
+
// Get preprocessor definitions for this directory.
std::string defineFlags = this->Target->GetMakefile()->GetDefineFlags();
clOptions.FixExceptionHandlingDefault();
--
1.7.11
|