Move GetCompileDefinitions to cmTarget.

This commit is contained in:
Stephen Kelly 2012-12-26 03:40:49 +01:00 committed by Brad King
parent 21fc6c46df
commit 0e10782ba7
11 changed files with 47 additions and 51 deletions

View File

@ -621,7 +621,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
->GetGeneratorTarget(target); ->GetGeneratorTarget(target);
// the compilerdefines for this target // the compilerdefines for this target
std::string cdefs = gtgt->GetCompileDefinitions(); std::string cdefs = target->GetCompileDefinitions();
if(!cdefs.empty()) if(!cdefs.empty())
{ {

View File

@ -254,32 +254,3 @@ std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories(
{ {
return this->Target->GetIncludeDirectories(config); return this->Target->GetIncludeDirectories(config);
} }
//----------------------------------------------------------------------------
std::string cmGeneratorTarget::GetCompileDefinitions(const char *config)
{
std::string defPropName = "COMPILE_DEFINITIONS";
if (config)
{
defPropName += "_" + cmSystemTools::UpperCase(config);
}
const char *prop = this->Target->GetProperty(defPropName.c_str());
if (!prop)
{
return "";
}
cmListFileBacktrace lfbt;
cmGeneratorExpression ge(lfbt);
cmGeneratorExpressionDAGChecker dagChecker(lfbt,
this->GetName(),
defPropName, 0, 0);
return ge.Parse(prop)->Evaluate(this->Makefile,
config,
false,
this->Target,
&dagChecker);
}

View File

@ -68,8 +68,6 @@ public:
/** Get the include directories for this target. */ /** Get the include directories for this target. */
std::vector<std::string> GetIncludeDirectories(const char *config); std::vector<std::string> GetIncludeDirectories(const char *config);
std::string GetCompileDefinitions(const char *config = 0);
private: private:
void ClassifySources(); void ClassifySources();
void LookupObjectLibraries(); void LookupObjectLibraries();

View File

@ -1681,11 +1681,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
this->AppendDefines(ppDefs, exportMacro); this->AppendDefines(ppDefs, exportMacro);
} }
cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target);
this->AppendDefines(ppDefs, gtgt->GetCompileDefinitions().c_str()); this->AppendDefines(ppDefs, target.GetCompileDefinitions().c_str());
if(configName) if(configName)
{ {
this->AppendDefines(ppDefs, this->AppendDefines(ppDefs,
gtgt->GetCompileDefinitions(configName).c_str()); target.GetCompileDefinitions(configName).c_str());
} }
buildSettings->AddAttribute buildSettings->AddAttribute
("GCC_PREPROCESSOR_DEFINITIONS", ppDefs.CreateList()); ("GCC_PREPROCESSOR_DEFINITIONS", ppDefs.CreateList());

View File

@ -1697,25 +1697,21 @@ void cmLocalVisualStudio6Generator
std::set<std::string> minsizeDefinesSet; std::set<std::string> minsizeDefinesSet;
std::set<std::string> debugrelDefinesSet; std::set<std::string> debugrelDefinesSet;
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target);
this->AppendDefines( this->AppendDefines(
definesSet, definesSet,
gt->GetCompileDefinitions()); target.GetCompileDefinitions());
this->AppendDefines( this->AppendDefines(
debugDefinesSet, debugDefinesSet,
gt->GetCompileDefinitions("DEBUG")); target.GetCompileDefinitions("DEBUG"));
this->AppendDefines( this->AppendDefines(
releaseDefinesSet, releaseDefinesSet,
gt->GetCompileDefinitions("RELEASE")); target.GetCompileDefinitions("RELEASE"));
this->AppendDefines( this->AppendDefines(
minsizeDefinesSet, minsizeDefinesSet,
gt->GetCompileDefinitions("MINSIZEREL")); target.GetCompileDefinitions("MINSIZEREL"));
this->AppendDefines( this->AppendDefines(
debugrelDefinesSet, debugrelDefinesSet,
gt->GetCompileDefinitions("RELWITHDEBINFO")); target.GetCompileDefinitions("RELWITHDEBINFO"));
std::string defines = " "; std::string defines = " ";
std::string debugDefines = " "; std::string debugDefines = " ";

View File

@ -745,8 +745,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
targetOptions.ParseFinish(); targetOptions.ParseFinish();
cmGeneratorTarget* gt = cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target); this->GlobalGenerator->GetGeneratorTarget(&target);
targetOptions.AddDefines(gt->GetCompileDefinitions().c_str()); targetOptions.AddDefines(target.GetCompileDefinitions().c_str());
targetOptions.AddDefines(gt->GetCompileDefinitions(configName).c_str()); targetOptions.AddDefines(target.GetCompileDefinitions(configName).c_str());
targetOptions.SetVerboseMakefile( targetOptions.SetVerboseMakefile(
this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));

View File

@ -303,10 +303,10 @@ std::string cmMakefileTargetGenerator::GetDefines(const std::string &l)
// Add preprocessor definitions for this target and configuration. // Add preprocessor definitions for this target and configuration.
this->LocalGenerator->AppendDefines this->LocalGenerator->AppendDefines
(defines, this->GeneratorTarget->GetCompileDefinitions()); (defines, this->Target->GetCompileDefinitions());
this->LocalGenerator->AppendDefines this->LocalGenerator->AppendDefines
(defines, this->GeneratorTarget->GetCompileDefinitions( (defines, this->Target->GetCompileDefinitions(
this->LocalGenerator->ConfigurationName.c_str())); this->LocalGenerator->ConfigurationName.c_str()));
std::string definesString; std::string definesString;

View File

@ -228,7 +228,7 @@ ComputeDefines(cmSourceFile *source, const std::string& language)
// Add preprocessor definitions for this target and configuration. // Add preprocessor definitions for this target and configuration.
this->LocalGenerator->AppendDefines this->LocalGenerator->AppendDefines
(defines, (defines,
this->GeneratorTarget->GetCompileDefinitions()); this->Target->GetCompileDefinitions());
this->LocalGenerator->AppendDefines this->LocalGenerator->AppendDefines
(defines, (defines,
source->GetProperty("COMPILE_DEFINITIONS")); source->GetProperty("COMPILE_DEFINITIONS"));
@ -237,7 +237,7 @@ ComputeDefines(cmSourceFile *source, const std::string& language)
defPropName += cmSystemTools::UpperCase(this->GetConfigName()); defPropName += cmSystemTools::UpperCase(this->GetConfigName());
this->LocalGenerator->AppendDefines this->LocalGenerator->AppendDefines
(defines, (defines,
this->GeneratorTarget->GetCompileDefinitions(this->GetConfigName())); this->Target->GetCompileDefinitions(this->GetConfigName()));
this->LocalGenerator->AppendDefines this->LocalGenerator->AppendDefines
(defines, (defines,
source->GetProperty(defPropName.c_str())); source->GetProperty(defPropName.c_str()));

View File

@ -2803,6 +2803,35 @@ std::vector<std::string> cmTarget::GetIncludeDirectories(const char *config)
return includes; return includes;
} }
//----------------------------------------------------------------------------
std::string cmTarget::GetCompileDefinitions(const char *config)
{
std::string defPropName = "COMPILE_DEFINITIONS";
if (config)
{
defPropName += "_" + cmSystemTools::UpperCase(config);
}
const char *prop = this->GetProperty(defPropName.c_str());
if (!prop)
{
return "";
}
cmListFileBacktrace lfbt;
cmGeneratorExpression ge(lfbt);
cmGeneratorExpressionDAGChecker dagChecker(lfbt,
this->GetName(),
defPropName, 0, 0);
return ge.Parse(prop)->Evaluate(this->Makefile,
config,
false,
this,
&dagChecker);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::MaybeInvalidatePropertyCache(const char* prop) void cmTarget::MaybeInvalidatePropertyCache(const char* prop)
{ {

View File

@ -430,6 +430,8 @@ public:
If no macro should be defined null is returned. */ If no macro should be defined null is returned. */
const char* GetExportMacro(); const char* GetExportMacro();
std::string GetCompileDefinitions(const char *config = 0);
// Compute the set of languages compiled by the target. This is // Compute the set of languages compiled by the target. This is
// computed every time it is called because the languages can change // computed every time it is called because the languages can change
// when source file properties are changed and we do not have enough // when source file properties are changed and we do not have enough

View File

@ -1221,8 +1221,8 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
clOptions.Parse(flags.c_str()); clOptions.Parse(flags.c_str());
clOptions.Parse(defineFlags.c_str()); clOptions.Parse(defineFlags.c_str());
clOptions.AddDefines( clOptions.AddDefines(
this->GeneratorTarget->GetCompileDefinitions().c_str()); this->Target->GetCompileDefinitions().c_str());
clOptions.AddDefines(this->GeneratorTarget->GetCompileDefinitions( clOptions.AddDefines(this->Target->GetCompileDefinitions(
configName.c_str()).c_str()); configName.c_str()).c_str());
clOptions.SetVerboseMakefile( clOptions.SetVerboseMakefile(
this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));