cmTarget: Fast path for regular properties
This commit is contained in:
parent
4cfa918a9a
commit
97ce676e75
|
@ -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())
|
specialProps.insert("INCLUDE_DIRECTORIES");
|
||||||
{
|
specialProps.insert("COMPILE_FEATURES");
|
||||||
return 0;
|
specialProps.insert("COMPILE_OPTIONS");
|
||||||
}
|
specialProps.insert("COMPILE_DEFINITIONS");
|
||||||
|
specialProps.insert("LINK_LIBRARIES");
|
||||||
static std::string output;
|
specialProps.insert("IMPORTED");
|
||||||
MakePropertyList(output, this->Internal->IncludeDirectoriesEntries);
|
specialProps.insert("NAME");
|
||||||
return output.c_str();
|
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())
|
||||||
}
|
|
||||||
|
|
||||||
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->CompileFeaturesEntries);
|
|
||||||
return output.c_str();
|
|
||||||
}
|
|
||||||
else if(prop == "COMPILE_DEFINITIONS")
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
output += sep;
|
|
||||||
output += it->Value;
|
|
||||||
sep = ";";
|
|
||||||
}
|
|
||||||
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())
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
std::string entry = (*i)->ge->GetInput();
|
|
||||||
|
|
||||||
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:") &&
|
return 0;
|
||||||
(*li)[li->size() - 1] == '>')
|
}
|
||||||
|
|
||||||
|
static std::string output;
|
||||||
|
MakePropertyList(output, this->Internal->IncludeDirectoriesEntries);
|
||||||
|
return output.c_str();
|
||||||
|
}
|
||||||
|
else if(prop == "COMPILE_OPTIONS")
|
||||||
|
{
|
||||||
|
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->CompileFeaturesEntries);
|
||||||
|
return output.c_str();
|
||||||
|
}
|
||||||
|
else if(prop == "COMPILE_DEFINITIONS")
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
output += sep;
|
||||||
|
output += it->Value;
|
||||||
|
sep = ";";
|
||||||
|
}
|
||||||
|
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())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
std::string entry = (*i)->ge->GetInput();
|
||||||
|
|
||||||
|
std::vector<std::string> files;
|
||||||
|
cmSystemTools::ExpandListArgument(entry, files);
|
||||||
|
for (std::vector<std::string>::const_iterator
|
||||||
|
li = files.begin(); li != files.end(); ++li)
|
||||||
{
|
{
|
||||||
std::string objLibName = li->substr(17, li->size()-18);
|
if(cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") &&
|
||||||
|
(*li)[li->size() - 1] == '>')
|
||||||
|
{
|
||||||
|
std::string objLibName = li->substr(17, li->size()-18);
|
||||||
|
|
||||||
if (cmGeneratorExpression::Find(objLibName) != std::string::npos)
|
if (cmGeneratorExpression::Find(objLibName) != std::string::npos)
|
||||||
{
|
{
|
||||||
ss << sep;
|
ss << sep;
|
||||||
sep = ";";
|
sep = ";";
|
||||||
ss << *li;
|
ss << *li;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool addContent = false;
|
bool addContent = false;
|
||||||
bool noMessage = true;
|
bool noMessage = true;
|
||||||
cmOStringStream e;
|
cmOStringStream e;
|
||||||
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
|
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
|
||||||
switch(context->GetPolicyStatus(cmPolicies::CMP0051))
|
switch(context->GetPolicyStatus(cmPolicies::CMP0051))
|
||||||
{
|
{
|
||||||
case cmPolicies::WARN:
|
case cmPolicies::WARN:
|
||||||
e << (this->Makefile->GetPolicies()
|
e << (this->Makefile->GetPolicies()
|
||||||
->GetPolicyWarning(cmPolicies::CMP0051)) << "\n";
|
->GetPolicyWarning(cmPolicies::CMP0051)) << "\n";
|
||||||
noMessage = false;
|
noMessage = false;
|
||||||
case cmPolicies::OLD:
|
case cmPolicies::OLD:
|
||||||
break;
|
break;
|
||||||
case cmPolicies::REQUIRED_ALWAYS:
|
case cmPolicies::REQUIRED_ALWAYS:
|
||||||
case cmPolicies::REQUIRED_IF_USED:
|
case cmPolicies::REQUIRED_IF_USED:
|
||||||
case cmPolicies::NEW:
|
case cmPolicies::NEW:
|
||||||
addContent = true;
|
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 (!noMessage)
|
else if (cmGeneratorExpression::Find(*li) == std::string::npos)
|
||||||
{
|
|
||||||
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;
|
ss << sep;
|
||||||
sep = ";";
|
sep = ";";
|
||||||
ss << *li;
|
ss << *li;
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
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())
|
|
||||||
{
|
{
|
||||||
sname += "/";
|
cmSourceFile *sf = this->Makefile->GetOrCreateSource(*li);
|
||||||
}
|
// Construct what is known about this source file location.
|
||||||
sname += location.GetName();
|
cmSourceFileLocation const& location = sf->GetLocation();
|
||||||
|
std::string sname = location.GetDirectory();
|
||||||
|
if(!sname.empty())
|
||||||
|
{
|
||||||
|
sname += "/";
|
||||||
|
}
|
||||||
|
sname += location.GetName();
|
||||||
|
|
||||||
ss << sep;
|
ss << sep;
|
||||||
sep = ";";
|
sep = ";";
|
||||||
// Append this list entry.
|
// Append this list entry.
|
||||||
ss << sname;
|
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;
|
bool chain = false;
|
||||||
|
|
Loading…
Reference in New Issue