cmTarget: Split storage of compile options from genexes.

This commit is contained in:
Stephen Kelly 2015-08-04 21:19:00 +02:00
parent 1f54bc1cf3
commit 772ecef4b8
1 changed files with 31 additions and 25 deletions

View File

@ -171,7 +171,9 @@ public:
std::vector<std::string> IncludeDirectoriesEntries; std::vector<std::string> IncludeDirectoriesEntries;
std::vector<cmListFileBacktrace> IncludeDirectoriesBacktraces; std::vector<cmListFileBacktrace> IncludeDirectoriesBacktraces;
std::vector<TargetPropertyEntry*> IncludeDirectoriesItems; std::vector<TargetPropertyEntry*> IncludeDirectoriesItems;
std::vector<TargetPropertyEntry*> CompileOptionsEntries; std::vector<std::string> CompileOptionsEntries;
std::vector<cmListFileBacktrace> CompileOptionsBacktraces;
std::vector<TargetPropertyEntry*> CompileOptionsItems;
std::vector<TargetPropertyEntry*> CompileFeaturesEntries; std::vector<TargetPropertyEntry*> CompileFeaturesEntries;
std::vector<TargetPropertyEntry*> CompileDefinitionsEntries; std::vector<TargetPropertyEntry*> CompileDefinitionsEntries;
std::vector<TargetPropertyEntry*> SourceEntries; std::vector<TargetPropertyEntry*> SourceEntries;
@ -386,13 +388,12 @@ void cmTarget::SetMakefile(cmMakefile* mf)
const cmBacktraceRange parentOptionsBts = const cmBacktraceRange parentOptionsBts =
this->Makefile->GetCompileOptionsBacktraces(); this->Makefile->GetCompileOptionsBacktraces();
cmBacktraceRange::const_iterator btIt = parentOptionsBts.begin(); this->Internal->CompileOptionsEntries.insert(
for (cmStringRange::const_iterator it this->Internal->CompileOptionsEntries.end(),
= parentOptions.begin(); parentOptions.begin(), parentOptions.end());
it != parentOptions.end(); ++it, ++btIt) this->Internal->CompileOptionsBacktraces.insert(
{ this->Internal->CompileOptionsBacktraces.end(),
this->InsertCompileOption(*it, *btIt); parentOptionsBts.begin(), parentOptionsBts.end());
}
} }
if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY) if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY)
@ -461,6 +462,11 @@ void cmTarget::Compute()
this->Internal->IncludeDirectoriesEntries, this->Internal->IncludeDirectoriesEntries,
this->Internal->IncludeDirectoriesBacktraces, this->Internal->IncludeDirectoriesBacktraces,
this->Internal->IncludeDirectoriesItems); this->Internal->IncludeDirectoriesItems);
CreatePropertyGeneratorExpressions(
this->Internal->CompileOptionsEntries,
this->Internal->CompileOptionsBacktraces,
this->Internal->CompileOptionsItems);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -1699,12 +1705,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
} }
else if(prop == "COMPILE_OPTIONS") else if(prop == "COMPILE_OPTIONS")
{ {
this->Internal->CompileOptionsEntries.clear();
this->Internal->CompileOptionsBacktraces.clear();
this->Internal->CompileOptionsEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmGeneratorExpression ge(lfbt); this->Internal->CompileOptionsBacktraces.push_back(lfbt);
deleteAndClear(this->Internal->CompileOptionsEntries);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
this->Internal->CompileOptionsEntries.push_back(
new cmTargetInternals::TargetPropertyEntry(cge));
} }
else if(prop == "COMPILE_FEATURES") else if(prop == "COMPILE_FEATURES")
{ {
@ -1794,10 +1799,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
} }
else if(prop == "COMPILE_OPTIONS") else if(prop == "COMPILE_OPTIONS")
{ {
this->Internal->CompileOptionsEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmGeneratorExpression ge(lfbt); this->Internal->CompileOptionsBacktraces.push_back(lfbt);
this->Internal->CompileOptionsEntries.push_back(
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
} }
else if(prop == "COMPILE_FEATURES") else if(prop == "COMPILE_FEATURES")
{ {
@ -1927,14 +1931,16 @@ void cmTarget::InsertCompileOption(std::string const& entry,
cmListFileBacktrace const& bt, cmListFileBacktrace const& bt,
bool before) bool before)
{ {
cmGeneratorExpression ge(bt); std::vector<std::string>::iterator position =
before ? this->Internal->CompileOptionsEntries.begin()
: this->Internal->CompileOptionsEntries.end();
std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position std::vector<cmListFileBacktrace>::iterator btPosition =
= before ? this->Internal->CompileOptionsEntries.begin() before ? this->Internal->CompileOptionsBacktraces.begin()
: this->Internal->CompileOptionsEntries.end(); : this->Internal->CompileOptionsBacktraces.end();
this->Internal->CompileOptionsEntries.insert(position, this->Internal->CompileOptionsEntries.insert(position, entry);
new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); this->Internal->CompileOptionsBacktraces.insert(btPosition, bt);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -2255,7 +2261,7 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result,
} }
processCompileOptions(this, processCompileOptions(this,
this->Internal->CompileOptionsEntries, this->Internal->CompileOptionsItems,
result, result,
uniqueOptions, uniqueOptions,
&dagChecker, &dagChecker,
@ -2946,7 +2952,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
} }
static std::string output; static std::string output;
MakePropertyList(output, this->Internal->CompileOptionsEntries); output = cmJoin(this->Internal->CompileOptionsEntries, ";");
return output.c_str(); return output.c_str();
} }
else if(prop == propCOMPILE_DEFINITIONS) else if(prop == propCOMPILE_DEFINITIONS)
@ -4831,7 +4837,7 @@ cmTargetInternalPointer
cmTargetInternalPointer::~cmTargetInternalPointer() cmTargetInternalPointer::~cmTargetInternalPointer()
{ {
cmDeleteAll(this->Pointer->IncludeDirectoriesItems); cmDeleteAll(this->Pointer->IncludeDirectoriesItems);
cmDeleteAll(this->Pointer->CompileOptionsEntries); cmDeleteAll(this->Pointer->CompileOptionsItems);
cmDeleteAll(this->Pointer->CompileFeaturesEntries); cmDeleteAll(this->Pointer->CompileFeaturesEntries);
cmDeleteAll(this->Pointer->CompileDefinitionsEntries); cmDeleteAll(this->Pointer->CompileDefinitionsEntries);
cmDeleteAll(this->Pointer->SourceEntries); cmDeleteAll(this->Pointer->SourceEntries);