summaryrefslogtreecommitdiffstats
path: root/Source/cmTarget.cxx
diff options
context:
space:
mode:
authorBen Boeckel <mathstuf@gmail.com>2014-02-08 10:27:45 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2014-07-17 15:17:49 (GMT)
commit97ce676e75900dfeeb30ea1c6ba5a139befe9562 (patch)
tree81fb7ec4afac3752514f2a666d5fe8abe93ff9c1 /Source/cmTarget.cxx
parent4cfa918a9ae983274a7995ca89fb46fdf570b00c (diff)
downloadCMake-97ce676e75900dfeeb30ea1c6ba5a139befe9562.zip
CMake-97ce676e75900dfeeb30ea1c6ba5a139befe9562.tar.gz
CMake-97ce676e75900dfeeb30ea1c6ba5a139befe9562.tar.bz2
cmTarget: Fast path for regular properties
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r--Source/cmTarget.cxx298
1 files changed, 157 insertions, 141 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 8be14f3..62b30fd 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -3085,180 +3085,196 @@ const char *cmTarget::GetProperty(const std::string& prop,
}
}
}
- if(prop == "INCLUDE_DIRECTORIES")
+ static std::set<std::string> specialProps;
+ if(specialProps.empty())
{
- if (this->Internal->IncludeDirectoriesEntries.empty())
- {
- return 0;
- }
-
- static std::string output;
- MakePropertyList(output, this->Internal->IncludeDirectoriesEntries);
- return output.c_str();
+ specialProps.insert("INCLUDE_DIRECTORIES");
+ specialProps.insert("COMPILE_FEATURES");
+ specialProps.insert("COMPILE_OPTIONS");
+ specialProps.insert("COMPILE_DEFINITIONS");
+ specialProps.insert("LINK_LIBRARIES");
+ specialProps.insert("IMPORTED");
+ specialProps.insert("NAME");
+ specialProps.insert("SOURCES");
+ specialProps.insert("TYPE");
}
- else if(prop == "COMPILE_OPTIONS")
+ if(specialProps.count(prop))
{
- if (this->Internal->CompileOptionsEntries.empty())
+ if(prop == "INCLUDE_DIRECTORIES")
{
- return 0;
- }
+ if (this->Internal->IncludeDirectoriesEntries.empty())
+ {
+ return 0;
+ }
- static std::string output;
- MakePropertyList(output, this->Internal->CompileOptionsEntries);
- return output.c_str();
- }
- else if(prop == "COMPILE_FEATURES")
- {
- if (this->Internal->CompileFeaturesEntries.empty())
- {
- return 0;
+ static std::string output;
+ MakePropertyList(output, this->Internal->IncludeDirectoriesEntries);
+ return output.c_str();
}
-
- static std::string output;
- MakePropertyList(output, this->Internal->CompileFeaturesEntries);
- return output.c_str();
- }
- else if(prop == "COMPILE_DEFINITIONS")
- {
- if (this->Internal->CompileDefinitionsEntries.empty())
+ else if(prop == "COMPILE_OPTIONS")
{
- return 0;
+ if (this->Internal->CompileOptionsEntries.empty())
+ {
+ return 0;
+ }
+
+ static std::string output;
+ MakePropertyList(output, this->Internal->CompileOptionsEntries);
+ return output.c_str();
}
+ else if(prop == "COMPILE_FEATURES")
+ {
+ if (this->Internal->CompileFeaturesEntries.empty())
+ {
+ return 0;
+ }
- static std::string output;
- MakePropertyList(output, this->Internal->CompileDefinitionsEntries);
- return output.c_str();
- }
- else if(prop == "LINK_LIBRARIES")
- {
- if (this->Internal->LinkImplementationPropertyEntries.empty())
+ static std::string output;
+ MakePropertyList(output, this->Internal->CompileFeaturesEntries);
+ return output.c_str();
+ }
+ else if(prop == "COMPILE_DEFINITIONS")
{
- return 0;
+ if (this->Internal->CompileDefinitionsEntries.empty())
+ {
+ return 0;
+ }
+
+ static std::string output;
+ MakePropertyList(output, this->Internal->CompileDefinitionsEntries);
+ return output.c_str();
}
+ else if(prop == "LINK_LIBRARIES")
+ {
+ if (this->Internal->LinkImplementationPropertyEntries.empty())
+ {
+ return 0;
+ }
- static std::string output;
- output = "";
- std::string sep;
- for (std::vector<cmValueWithOrigin>::const_iterator
- it = this->Internal->LinkImplementationPropertyEntries.begin(),
- end = this->Internal->LinkImplementationPropertyEntries.end();
- it != end; ++it)
+ static std::string output;
+ output = "";
+ std::string sep;
+ for (std::vector<cmValueWithOrigin>::const_iterator
+ it = this->Internal->LinkImplementationPropertyEntries.begin(),
+ end = this->Internal->LinkImplementationPropertyEntries.end();
+ it != end; ++it)
+ {
+ output += sep;
+ output += it->Value;
+ sep = ";";
+ }
+ return output.c_str();
+ }
+ else if (prop == "IMPORTED")
{
- output += sep;
- output += it->Value;
- sep = ";";
+ return this->IsImported()?"TRUE":"FALSE";
}
- return output.c_str();
- }
- else if (prop == "IMPORTED")
- {
- return this->IsImported()?"TRUE":"FALSE";
- }
- else if (prop == "NAME")
- {
- return this->GetName().c_str();
- }
- else if(prop == "SOURCES")
- {
- if (this->Internal->SourceEntries.empty())
+ else if (prop == "NAME")
{
- return 0;
+ return this->GetName().c_str();
}
-
- cmOStringStream ss;
- const char* sep = "";
- typedef cmTargetInternals::TargetPropertyEntry
- TargetPropertyEntry;
- for(std::vector<TargetPropertyEntry*>::const_iterator
- i = this->Internal->SourceEntries.begin();
- i != this->Internal->SourceEntries.end(); ++i)
+ else if(prop == "SOURCES")
{
- std::string entry = (*i)->ge->GetInput();
+ if (this->Internal->SourceEntries.empty())
+ {
+ return 0;
+ }
- std::vector<std::string> files;
- cmSystemTools::ExpandListArgument(entry, files);
- for (std::vector<std::string>::const_iterator
- li = files.begin(); li != files.end(); ++li)
+ cmOStringStream ss;
+ const char* sep = "";
+ typedef cmTargetInternals::TargetPropertyEntry
+ TargetPropertyEntry;
+ for(std::vector<TargetPropertyEntry*>::const_iterator
+ i = this->Internal->SourceEntries.begin();
+ i != this->Internal->SourceEntries.end(); ++i)
{
- if(cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") &&
- (*li)[li->size() - 1] == '>')
- {
- std::string objLibName = li->substr(17, li->size()-18);
+ std::string entry = (*i)->ge->GetInput();
- if (cmGeneratorExpression::Find(objLibName) != std::string::npos)
+ std::vector<std::string> files;
+ cmSystemTools::ExpandListArgument(entry, files);
+ for (std::vector<std::string>::const_iterator
+ li = files.begin(); li != files.end(); ++li)
+ {
+ if(cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") &&
+ (*li)[li->size() - 1] == '>')
{
- ss << sep;
- sep = ";";
- ss << *li;
- continue;
- }
+ std::string objLibName = li->substr(17, li->size()-18);
- bool addContent = false;
- bool noMessage = true;
- cmOStringStream e;
- cmake::MessageType messageType = cmake::AUTHOR_WARNING;
- switch(context->GetPolicyStatus(cmPolicies::CMP0051))
- {
- case cmPolicies::WARN:
- e << (this->Makefile->GetPolicies()
- ->GetPolicyWarning(cmPolicies::CMP0051)) << "\n";
- noMessage = false;
- case cmPolicies::OLD:
- break;
- case cmPolicies::REQUIRED_ALWAYS:
- case cmPolicies::REQUIRED_IF_USED:
- case cmPolicies::NEW:
- addContent = true;
- }
- if (!noMessage)
- {
- e << "Target \"" << this->Name << "\" contains $<TARGET_OBJECTS> "
- "generator expression in its sources list. This content was not "
- "previously part of the SOURCES property when that property was "
- "read at configure time. Code reading that property needs to be "
- "adapted to ignore the generator expression using the "
- "string(GENEX_STRIP) command.";
- context->IssueMessage(messageType, e.str());
+ if (cmGeneratorExpression::Find(objLibName) != std::string::npos)
+ {
+ ss << sep;
+ sep = ";";
+ ss << *li;
+ continue;
+ }
+
+ bool addContent = false;
+ bool noMessage = true;
+ cmOStringStream e;
+ cmake::MessageType messageType = cmake::AUTHOR_WARNING;
+ switch(context->GetPolicyStatus(cmPolicies::CMP0051))
+ {
+ case cmPolicies::WARN:
+ e << (this->Makefile->GetPolicies()
+ ->GetPolicyWarning(cmPolicies::CMP0051)) << "\n";
+ noMessage = false;
+ case cmPolicies::OLD:
+ break;
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::NEW:
+ addContent = true;
+ }
+ if (!noMessage)
+ {
+ e << "Target \"" << this->Name << "\" contains "
+ "$<TARGET_OBJECTS> generator expression in its sources list. "
+ "This content was not previously part of the SOURCES property "
+ "when that property was read at configure time. Code reading "
+ "that property needs to be adapted to ignore the generator "
+ "expression using the string(GENEX_STRIP) command.";
+ context->IssueMessage(messageType, e.str());
+ }
+ if (addContent)
+ {
+ ss << sep;
+ sep = ";";
+ ss << *li;
+ }
}
- if (addContent)
+ else if (cmGeneratorExpression::Find(*li) == std::string::npos)
{
ss << sep;
sep = ";";
ss << *li;
}
- }
- else if (cmGeneratorExpression::Find(*li) == std::string::npos)
- {
- ss << sep;
- sep = ";";
- ss << *li;
- }
- else
- {
- cmSourceFile *sf = this->Makefile->GetOrCreateSource(*li);
- // Construct what is known about this source file location.
- cmSourceFileLocation const& location = sf->GetLocation();
- std::string sname = location.GetDirectory();
- if(!sname.empty())
+ else
{
- sname += "/";
- }
- sname += location.GetName();
+ cmSourceFile *sf = this->Makefile->GetOrCreateSource(*li);
+ // Construct what is known about this source file location.
+ cmSourceFileLocation const& location = sf->GetLocation();
+ std::string sname = location.GetDirectory();
+ if(!sname.empty())
+ {
+ sname += "/";
+ }
+ sname += location.GetName();
- ss << sep;
- sep = ";";
- // Append this list entry.
- ss << sname;
+ ss << sep;
+ sep = ";";
+ // Append this list entry.
+ ss << sname;
+ }
}
}
+ this->Properties.SetProperty("SOURCES", ss.str().c_str(),
+ cmProperty::TARGET);
+ }
+ // the type property returns what type the target is
+ else if (prop == "TYPE")
+ {
+ return cmTarget::GetTargetTypeName(this->GetType());
}
- this->Properties.SetProperty("SOURCES", ss.str().c_str(),
- cmProperty::TARGET);
- }
- // the type property returns what type the target is
- else if (prop == "TYPE")
- {
- return cmTarget::GetTargetTypeName(this->GetType());
}
bool chain = false;