cmTarget: Use else/if trees rather than an if tree
Skips lots of unnecessary string comparisons.
This commit is contained in:
parent
a0dc1354fe
commit
85242b7df6
|
@ -1750,15 +1750,14 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
|
||||||
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if (prop == "NAME")
|
||||||
if (prop == "NAME")
|
|
||||||
{
|
{
|
||||||
cmOStringStream e;
|
cmOStringStream e;
|
||||||
e << "NAME property is read-only\n";
|
e << "NAME property is read-only\n";
|
||||||
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(prop == "INCLUDE_DIRECTORIES")
|
else if(prop == "INCLUDE_DIRECTORIES")
|
||||||
{
|
{
|
||||||
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
||||||
cmGeneratorExpression ge(&lfbt);
|
cmGeneratorExpression ge(&lfbt);
|
||||||
|
@ -1766,9 +1765,8 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
|
||||||
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
|
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
|
||||||
this->Internal->IncludeDirectoriesEntries.push_back(
|
this->Internal->IncludeDirectoriesEntries.push_back(
|
||||||
new cmTargetInternals::TargetPropertyEntry(cge));
|
new cmTargetInternals::TargetPropertyEntry(cge));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if(prop == "COMPILE_OPTIONS")
|
else if(prop == "COMPILE_OPTIONS")
|
||||||
{
|
{
|
||||||
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
||||||
cmGeneratorExpression ge(&lfbt);
|
cmGeneratorExpression ge(&lfbt);
|
||||||
|
@ -1776,9 +1774,8 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
|
||||||
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
|
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
|
||||||
this->Internal->CompileOptionsEntries.push_back(
|
this->Internal->CompileOptionsEntries.push_back(
|
||||||
new cmTargetInternals::TargetPropertyEntry(cge));
|
new cmTargetInternals::TargetPropertyEntry(cge));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if(prop == "COMPILE_FEATURES")
|
else if(prop == "COMPILE_FEATURES")
|
||||||
{
|
{
|
||||||
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
||||||
cmGeneratorExpression ge(&lfbt);
|
cmGeneratorExpression ge(&lfbt);
|
||||||
|
@ -1786,9 +1783,8 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
|
||||||
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
|
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
|
||||||
this->Internal->CompileFeaturesEntries.push_back(
|
this->Internal->CompileFeaturesEntries.push_back(
|
||||||
new cmTargetInternals::TargetPropertyEntry(cge));
|
new cmTargetInternals::TargetPropertyEntry(cge));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if(prop == "COMPILE_DEFINITIONS")
|
else if(prop == "COMPILE_DEFINITIONS")
|
||||||
{
|
{
|
||||||
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
||||||
cmGeneratorExpression ge(&lfbt);
|
cmGeneratorExpression ge(&lfbt);
|
||||||
|
@ -1796,25 +1792,22 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
|
||||||
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
|
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
|
||||||
this->Internal->CompileDefinitionsEntries.push_back(
|
this->Internal->CompileDefinitionsEntries.push_back(
|
||||||
new cmTargetInternals::TargetPropertyEntry(cge));
|
new cmTargetInternals::TargetPropertyEntry(cge));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if(prop == "EXPORT_NAME" && this->IsImported())
|
else if(prop == "EXPORT_NAME" && this->IsImported())
|
||||||
{
|
{
|
||||||
cmOStringStream e;
|
cmOStringStream e;
|
||||||
e << "EXPORT_NAME property can't be set on imported targets (\""
|
e << "EXPORT_NAME property can't be set on imported targets (\""
|
||||||
<< this->Name << "\")\n";
|
<< this->Name << "\")\n";
|
||||||
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (prop == "LINK_LIBRARIES")
|
else if (prop == "LINK_LIBRARIES")
|
||||||
{
|
{
|
||||||
this->Internal->LinkImplementationPropertyEntries.clear();
|
this->Internal->LinkImplementationPropertyEntries.clear();
|
||||||
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
||||||
cmValueWithOrigin entry(value, lfbt);
|
cmValueWithOrigin entry(value, lfbt);
|
||||||
this->Internal->LinkImplementationPropertyEntries.push_back(entry);
|
this->Internal->LinkImplementationPropertyEntries.push_back(entry);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (prop == "SOURCES")
|
else if (prop == "SOURCES")
|
||||||
{
|
{
|
||||||
if(this->IsImported())
|
if(this->IsImported())
|
||||||
{
|
{
|
||||||
|
@ -1831,10 +1824,12 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
|
||||||
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
|
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
|
||||||
this->Internal->SourceEntries.push_back(
|
this->Internal->SourceEntries.push_back(
|
||||||
new cmTargetInternals::TargetPropertyEntry(cge));
|
new cmTargetInternals::TargetPropertyEntry(cge));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
this->Properties.SetProperty(prop, value, cmProperty::TARGET);
|
else
|
||||||
this->MaybeInvalidatePropertyCache(prop);
|
{
|
||||||
|
this->Properties.SetProperty(prop, value, cmProperty::TARGET);
|
||||||
|
this->MaybeInvalidatePropertyCache(prop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -1850,61 +1845,55 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
|
||||||
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (prop == "NAME")
|
else if (prop == "NAME")
|
||||||
{
|
{
|
||||||
cmOStringStream e;
|
cmOStringStream e;
|
||||||
e << "NAME property is read-only\n";
|
e << "NAME property is read-only\n";
|
||||||
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(prop == "INCLUDE_DIRECTORIES")
|
else if(prop == "INCLUDE_DIRECTORIES")
|
||||||
{
|
{
|
||||||
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
||||||
cmGeneratorExpression ge(&lfbt);
|
cmGeneratorExpression ge(&lfbt);
|
||||||
this->Internal->IncludeDirectoriesEntries.push_back(
|
this->Internal->IncludeDirectoriesEntries.push_back(
|
||||||
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
|
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if(prop == "COMPILE_OPTIONS")
|
else if(prop == "COMPILE_OPTIONS")
|
||||||
{
|
{
|
||||||
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
||||||
cmGeneratorExpression ge(&lfbt);
|
cmGeneratorExpression ge(&lfbt);
|
||||||
this->Internal->CompileOptionsEntries.push_back(
|
this->Internal->CompileOptionsEntries.push_back(
|
||||||
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
|
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if(prop == "COMPILE_FEATURES")
|
else if(prop == "COMPILE_FEATURES")
|
||||||
{
|
{
|
||||||
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
||||||
cmGeneratorExpression ge(&lfbt);
|
cmGeneratorExpression ge(&lfbt);
|
||||||
this->Internal->CompileFeaturesEntries.push_back(
|
this->Internal->CompileFeaturesEntries.push_back(
|
||||||
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
|
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if(prop == "COMPILE_DEFINITIONS")
|
else if(prop == "COMPILE_DEFINITIONS")
|
||||||
{
|
{
|
||||||
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
||||||
cmGeneratorExpression ge(&lfbt);
|
cmGeneratorExpression ge(&lfbt);
|
||||||
this->Internal->CompileDefinitionsEntries.push_back(
|
this->Internal->CompileDefinitionsEntries.push_back(
|
||||||
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
|
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if(prop == "EXPORT_NAME" && this->IsImported())
|
else if(prop == "EXPORT_NAME" && this->IsImported())
|
||||||
{
|
{
|
||||||
cmOStringStream e;
|
cmOStringStream e;
|
||||||
e << "EXPORT_NAME property can't be set on imported targets (\""
|
e << "EXPORT_NAME property can't be set on imported targets (\""
|
||||||
<< this->Name << "\")\n";
|
<< this->Name << "\")\n";
|
||||||
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (prop == "LINK_LIBRARIES")
|
else if (prop == "LINK_LIBRARIES")
|
||||||
{
|
{
|
||||||
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
||||||
cmValueWithOrigin entry(value, lfbt);
|
cmValueWithOrigin entry(value, lfbt);
|
||||||
this->Internal->LinkImplementationPropertyEntries.push_back(entry);
|
this->Internal->LinkImplementationPropertyEntries.push_back(entry);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (prop == "SOURCES")
|
else if (prop == "SOURCES")
|
||||||
{
|
{
|
||||||
if(this->IsImported())
|
if(this->IsImported())
|
||||||
{
|
{
|
||||||
|
@ -1920,10 +1909,12 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
|
||||||
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
|
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
|
||||||
this->Internal->SourceEntries.push_back(
|
this->Internal->SourceEntries.push_back(
|
||||||
new cmTargetInternals::TargetPropertyEntry(cge));
|
new cmTargetInternals::TargetPropertyEntry(cge));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
this->Properties.AppendProperty(prop, value, cmProperty::TARGET, asString);
|
else
|
||||||
this->MaybeInvalidatePropertyCache(prop);
|
{
|
||||||
|
this->Properties.AppendProperty(prop, value, cmProperty::TARGET, asString);
|
||||||
|
this->MaybeInvalidatePropertyCache(prop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -3022,11 +3013,6 @@ const char *cmTarget::GetProperty(const std::string& prop,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prop == "NAME")
|
|
||||||
{
|
|
||||||
return this->GetName().c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Watch for special "computed" properties that are dependent on
|
// Watch for special "computed" properties that are dependent on
|
||||||
// other properties or variables. Always recompute them.
|
// other properties or variables. Always recompute them.
|
||||||
if(this->GetType() == cmTarget::EXECUTABLE ||
|
if(this->GetType() == cmTarget::EXECUTABLE ||
|
||||||
|
@ -3106,7 +3092,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
|
||||||
}
|
}
|
||||||
return output.c_str();
|
return output.c_str();
|
||||||
}
|
}
|
||||||
if(prop == "COMPILE_OPTIONS")
|
else if(prop == "COMPILE_OPTIONS")
|
||||||
{
|
{
|
||||||
if (this->Internal->CompileOptionsEntries.empty())
|
if (this->Internal->CompileOptionsEntries.empty())
|
||||||
{
|
{
|
||||||
|
@ -3129,7 +3115,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
|
||||||
}
|
}
|
||||||
return output.c_str();
|
return output.c_str();
|
||||||
}
|
}
|
||||||
if(prop == "COMPILE_FEATURES")
|
else if(prop == "COMPILE_FEATURES")
|
||||||
{
|
{
|
||||||
if (this->Internal->CompileFeaturesEntries.empty())
|
if (this->Internal->CompileFeaturesEntries.empty())
|
||||||
{
|
{
|
||||||
|
@ -3152,7 +3138,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
|
||||||
}
|
}
|
||||||
return output.c_str();
|
return output.c_str();
|
||||||
}
|
}
|
||||||
if(prop == "COMPILE_DEFINITIONS")
|
else if(prop == "COMPILE_DEFINITIONS")
|
||||||
{
|
{
|
||||||
if (this->Internal->CompileDefinitionsEntries.empty())
|
if (this->Internal->CompileDefinitionsEntries.empty())
|
||||||
{
|
{
|
||||||
|
@ -3175,7 +3161,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
|
||||||
}
|
}
|
||||||
return output.c_str();
|
return output.c_str();
|
||||||
}
|
}
|
||||||
if(prop == "LINK_LIBRARIES")
|
else if(prop == "LINK_LIBRARIES")
|
||||||
{
|
{
|
||||||
if (this->Internal->LinkImplementationPropertyEntries.empty())
|
if (this->Internal->LinkImplementationPropertyEntries.empty())
|
||||||
{
|
{
|
||||||
|
@ -3196,13 +3182,15 @@ const char *cmTarget::GetProperty(const std::string& prop,
|
||||||
}
|
}
|
||||||
return output.c_str();
|
return output.c_str();
|
||||||
}
|
}
|
||||||
|
else if (prop == "IMPORTED")
|
||||||
if (prop == "IMPORTED")
|
|
||||||
{
|
{
|
||||||
return this->IsImported()?"TRUE":"FALSE";
|
return this->IsImported()?"TRUE":"FALSE";
|
||||||
}
|
}
|
||||||
|
else if (prop == "NAME")
|
||||||
if(prop == "SOURCES")
|
{
|
||||||
|
return this->GetName().c_str();
|
||||||
|
}
|
||||||
|
else if(prop == "SOURCES")
|
||||||
{
|
{
|
||||||
if (this->Internal->SourceEntries.empty())
|
if (this->Internal->SourceEntries.empty())
|
||||||
{
|
{
|
||||||
|
@ -3299,12 +3287,12 @@ const char *cmTarget::GetProperty(const std::string& prop,
|
||||||
this->Properties.SetProperty("SOURCES", ss.str().c_str(),
|
this->Properties.SetProperty("SOURCES", ss.str().c_str(),
|
||||||
cmProperty::TARGET);
|
cmProperty::TARGET);
|
||||||
}
|
}
|
||||||
|
|
||||||
// the type property returns what type the target is
|
// the type property returns what type the target is
|
||||||
if (prop == "TYPE")
|
else if (prop == "TYPE")
|
||||||
{
|
{
|
||||||
return cmTarget::GetTargetTypeName(this->GetType());
|
return cmTarget::GetTargetTypeName(this->GetType());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool chain = false;
|
bool chain = false;
|
||||||
const char *retVal =
|
const char *retVal =
|
||||||
this->Properties.GetPropertyValue(prop, cmProperty::TARGET, chain);
|
this->Properties.GetPropertyValue(prop, cmProperty::TARGET, chain);
|
||||||
|
|
Loading…
Reference in New Issue