From 97ce676e75900dfeeb30ea1c6ba5a139befe9562 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 8 Feb 2014 05:27:45 -0500 Subject: [PATCH] cmTarget: Fast path for regular properties --- Source/cmTarget.cxx | 326 +++++++++++++++++++++++--------------------- 1 file changed, 171 insertions(+), 155 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8be14f356..62b30fd05 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 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; - } - - 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::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::const_iterator - i = this->Internal->SourceEntries.begin(); - i != this->Internal->SourceEntries.end(); ++i) - { - std::string entry = (*i)->ge->GetInput(); - - std::vector files; - cmSystemTools::ExpandListArgument(entry, files); - for (std::vector::const_iterator - li = files.begin(); li != files.end(); ++li) + if (this->Internal->IncludeDirectoriesEntries.empty()) { - if(cmHasLiteralPrefix(*li, "$size() - 1] == '>') + return 0; + } + + 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::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::const_iterator + i = this->Internal->SourceEntries.begin(); + i != this->Internal->SourceEntries.end(); ++i) + { + std::string entry = (*i)->ge->GetInput(); + + std::vector files; + cmSystemTools::ExpandListArgument(entry, files); + for (std::vector::const_iterator + li = files.begin(); li != files.end(); ++li) { - std::string objLibName = li->substr(17, li->size()-18); + if(cmHasLiteralPrefix(*li, "$size() - 1] == '>') + { + std::string objLibName = li->substr(17, li->size()-18); - if (cmGeneratorExpression::Find(objLibName) != std::string::npos) - { - ss << sep; - sep = ";"; - ss << *li; - continue; - } + 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; + 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 " + "$ 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) - { - e << "Target \"" << this->Name << "\" contains $ " - "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) + 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;