diff options
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 147 |
1 files changed, 51 insertions, 96 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 94a6de3..8e060c4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -226,13 +226,7 @@ cmLinkImplItem cmTargetInternals::TargetPropertyEntry::NoLinkImplItem; static void deleteAndClear( std::vector<cmTargetInternals::TargetPropertyEntry*> &entries) { - for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator - it = entries.begin(), - end = entries.end(); - it != end; ++it) - { - delete *it; - } + cmDeleteAll(entries); entries.clear(); } @@ -424,12 +418,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) const std::set<std::string> parentSystemIncludes = this->Makefile->GetSystemIncludeDirectories(); - for (std::set<std::string>::const_iterator it - = parentSystemIncludes.begin(); - it != parentSystemIncludes.end(); ++it) - { - this->SystemIncludeDirectories.insert(*it); - } + this->SystemIncludeDirectories.insert(parentSystemIncludes.begin(), + parentSystemIncludes.end()); const std::vector<cmValueWithOrigin> parentOptions = this->Makefile->GetCompileOptionsEntries(); @@ -548,6 +538,7 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkInterfaceMap.clear(); this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->LinkClosureMap.clear(); + this->Internal->SourceFilesMap.clear(); for (cmTargetLinkInformationMap::const_iterator it = this->LinkInformation.begin(); it != this->LinkInformation.end(); ++it) @@ -686,7 +677,7 @@ static bool processSources(cmTarget const* tgt, if (!targetName.empty() && !cmSystemTools::FileIsFullPath(src.c_str())) { - cmOStringStream err; + std::ostringstream err; if (!targetName.empty()) { err << "Target \"" << targetName << "\" contains relative " @@ -863,7 +854,7 @@ cmTarget::GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const thisConfigFiles += (*fi)->GetFullPath(); sep = "\n "; } - cmOStringStream e; + std::ostringstream e; e << "Target \"" << this->Name << "\" has source files which vary by " "configuration. This is not supported by the \"" << this->Makefile->GetLocalGenerator() @@ -923,16 +914,7 @@ void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files, //---------------------------------------------------------------------------- void cmTarget::AddTracedSources(std::vector<std::string> const& srcs) { - std::string srcFiles; - const char* sep = ""; - for(std::vector<std::string>::const_iterator i = srcs.begin(); - i != srcs.end(); ++i) - { - std::string filename = *i; - srcFiles += sep; - srcFiles += filename; - sep = ";"; - } + std::string srcFiles = cmJoin(srcs, ";"); if (!srcFiles.empty()) { this->Internal->SourceFilesMap.clear(); @@ -996,7 +978,7 @@ std::string cmTarget::ProcessSourceItemCMP0049(const std::string& s) this->Makefile->ExpandVariablesInString(src); if (src != s) { - cmOStringStream e; + std::ostringstream e; bool noMessage = false; cmake::MessageType messageType = cmake::AUTHOR_WARNING; switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0049)) @@ -1279,7 +1261,7 @@ bool cmTarget::PushTLLCommandTrace(TLLSignature signature) } //---------------------------------------------------------------------------- -void cmTarget::GetTllSignatureTraces(cmOStringStream &s, +void cmTarget::GetTllSignatureTraces(std::ostringstream &s, TLLSignature sig) const { std::vector<cmListFileBacktrace> sigs; @@ -1307,7 +1289,7 @@ void cmTarget::GetTllSignatureTraces(cmOStringStream &s, if(i != it->end()) { cmListFileContext const& lfc = *i; - cmOStringStream line; + std::ostringstream line; line << " * " << (lfc.Line? "": " in ") << lfc << std::endl; if (emitted.insert(line.str()).second) { @@ -1397,22 +1379,14 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, void cmTarget::AddSystemIncludeDirectories(const std::set<std::string> &incs) { - for(std::set<std::string>::const_iterator li = incs.begin(); - li != incs.end(); ++li) - { - this->SystemIncludeDirectories.insert(*li); - } + this->SystemIncludeDirectories.insert(incs.begin(), incs.end()); } //---------------------------------------------------------------------------- void cmTarget::AddSystemIncludeDirectories(const std::vector<std::string> &incs) { - for(std::vector<std::string>::const_iterator li = incs.begin(); - li != incs.end(); ++li) - { - this->SystemIncludeDirectories.insert(*li); - } + this->SystemIncludeDirectories.insert(incs.begin(), incs.end()); } #if defined(_WIN32) && !defined(__CYGWIN__) @@ -1749,7 +1723,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) if (this->GetType() == INTERFACE_LIBRARY && !whiteListedInterfaceProperty(prop)) { - cmOStringStream e; + std::ostringstream e; e << "INTERFACE_LIBRARY targets may only have whitelisted properties. " "The property \"" << prop << "\" is not allowed."; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); @@ -1757,7 +1731,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if (prop == "NAME") { - cmOStringStream e; + std::ostringstream e; e << "NAME property is read-only\n"; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; @@ -1800,7 +1774,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "EXPORT_NAME" && this->IsImported()) { - cmOStringStream e; + std::ostringstream e; e << "EXPORT_NAME property can't be set on imported targets (\"" << this->Name << "\")\n"; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); @@ -1816,7 +1790,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) { if(this->IsImported()) { - cmOStringStream e; + std::ostringstream e; e << "SOURCES property can't be set on imported targets (\"" << this->Name << "\")\n"; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); @@ -1844,7 +1818,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, if (this->GetType() == INTERFACE_LIBRARY && !whiteListedInterfaceProperty(prop)) { - cmOStringStream e; + std::ostringstream e; e << "INTERFACE_LIBRARY targets may only have whitelisted properties. " "The property \"" << prop << "\" is not allowed."; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); @@ -1852,7 +1826,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if (prop == "NAME") { - cmOStringStream e; + std::ostringstream e; e << "NAME property is read-only\n"; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; @@ -1887,7 +1861,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "EXPORT_NAME" && this->IsImported()) { - cmOStringStream e; + std::ostringstream e; e << "EXPORT_NAME property can't be set on imported targets (\"" << this->Name << "\")\n"; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); @@ -1902,7 +1876,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, { if(this->IsImported()) { - cmOStringStream e; + std::ostringstream e; e << "SOURCES property can't be set on imported targets (\"" << this->Name << "\")\n"; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); @@ -1931,7 +1905,7 @@ std::string cmTarget::GetExportName() const { if (!cmGeneratorExpression::IsValidTargetName(exportName)) { - cmOStringStream e; + std::ostringstream e; e << "EXPORT_NAME property \"" << exportName << "\" for \"" << this->GetName() << "\": is not valid."; cmSystemTools::Error(e.str().c_str()); @@ -2043,7 +2017,7 @@ static void processIncludeDirectories(cmTarget const* tgt, if (fromImported && !cmSystemTools::FileExists(li->c_str())) { - cmOStringStream e; + std::ostringstream e; cmake::MessageType messageType = cmake::FATAL_ERROR; if (checkCMP0027) { @@ -2076,7 +2050,7 @@ static void processIncludeDirectories(cmTarget const* tgt, if (!cmSystemTools::FileIsFullPath(li->c_str())) { - cmOStringStream e; + std::ostringstream e; bool noMessage = false; cmake::MessageType messageType = cmake::FATAL_ERROR; if (!targetName.empty()) @@ -2426,7 +2400,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, { case cmPolicies::WARN: { - cmOStringStream e; + std::ostringstream e; e << this->Makefile->GetCMakeInstance()->GetPolicies() ->GetPolicyWarning(cmPolicies::CMP0043); this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, @@ -2559,7 +2533,7 @@ static void cmTargetCheckLINK_INTERFACE_LIBRARIES( "LINK_INTERFACE_LIBRARIES"); // Report an error. - cmOStringStream e; + std::ostringstream e; e << "Property " << prop << " may not contain link-type keyword \"" << keys.match(2) << "\". " << "The " << base << " property has a per-configuration " @@ -2596,7 +2570,7 @@ static void cmTargetCheckINTERFACE_LINK_LIBRARIES(const char* value, } // Report an error. - cmOStringStream e; + std::ostringstream e; e << "Property INTERFACE_LINK_LIBRARIES may not contain link-type " "keyword \"" << keys.match(2) << "\". The INTERFACE_LINK_LIBRARIES " @@ -2895,7 +2869,7 @@ bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const { return true; } - cmOStringStream e; + std::ostringstream e; const char *modal = 0; cmake::MessageType messageType = cmake::AUTHOR_WARNING; switch (context->GetPolicyStatus(cmPolicies::CMP0026)) @@ -2954,7 +2928,7 @@ const char *cmTarget::GetProperty(const std::string& prop, if (this->GetType() == INTERFACE_LIBRARY && !whiteListedInterfaceProperty(prop)) { - cmOStringStream e; + std::ostringstream e; e << "INTERFACE_LIBRARY targets may only have whitelisted properties. " "The property \"" << prop << "\" is not allowed."; context->IssueMessage(cmake::FATAL_ERROR, e.str()); @@ -3130,7 +3104,7 @@ const char *cmTarget::GetProperty(const std::string& prop, return 0; } - cmOStringStream ss; + std::ostringstream ss; const char* sep = ""; typedef cmTargetInternals::TargetPropertyEntry TargetPropertyEntry; @@ -3160,7 +3134,7 @@ const char *cmTarget::GetProperty(const std::string& prop, bool addContent = false; bool noMessage = true; - cmOStringStream e; + std::ostringstream e; cmake::MessageType messageType = cmake::AUTHOR_WARNING; switch(context->GetPolicyStatus(cmPolicies::CMP0051)) { @@ -3258,7 +3232,7 @@ public: { bool noMessage = false; cmake::MessageType messageType = cmake::FATAL_ERROR; - cmOStringStream e; + std::ostringstream e; switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) { case cmPolicies::WARN: @@ -3379,7 +3353,7 @@ public: } else if(this->Preferred.size() > 1) { - cmOStringStream e; + std::ostringstream e; e << "Target " << this->Target->GetName() << " contains multiple languages with the highest linker preference" << " (" << this->Preference << "):\n"; @@ -3751,7 +3725,7 @@ bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const if(!this->Makefile->IsSet("CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG")) { - cmOStringStream w; + std::ostringstream w; w << "Attempting to use"; if(macosx_rpath) { @@ -5049,7 +5023,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, report += compatibilityAgree(t, propContent != consistent.second); if (!consistent.first) { - cmOStringStream e; + std::ostringstream e; e << "Property " << p << " on target \"" << tgt->GetName() << "\" does\nnot match the " "INTERFACE_" << p << " property requirement\nof " @@ -5082,7 +5056,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, report += compatibilityAgree(t, propContent != consistent.second); if (!consistent.first) { - cmOStringStream e; + std::ostringstream e; e << "Property " << p << " on target \"" << tgt->GetName() << "\" is\nimplied to be " << defaultValue << " because it was used to determine the link libraries\n" @@ -5116,7 +5090,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, report += compatibilityAgree(t, propContent != consistent.second); if (!consistent.first) { - cmOStringStream e; + std::ostringstream e; e << "The INTERFACE_" << p << " property of \"" << theTarget->GetName() << "\" does\nnot agree with the value " "of " << p << " already determined\nfor \"" @@ -6024,7 +5998,7 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( if (newExplicitLibraries && strcmp(newExplicitLibraries, explicitLibraries) != 0) { - cmOStringStream w; + std::ostringstream w; w << (thisTarget->Makefile->GetPolicies() ->GetPolicyWarning(cmPolicies::CMP0022)) << "\n" @@ -6070,8 +6044,8 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( // The link implementation is the default link interface. cmTarget::LinkImplementationLibraries const* impl = thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); - std::copy(impl->Libraries.begin(), impl->Libraries.end(), - std::back_inserter(iface.Libraries)); + iface.Libraries.insert(iface.Libraries.end(), + impl->Libraries.begin(), impl->Libraries.end()); if(thisTarget->PolicyStatusCMP0022 == cmPolicies::WARN && !this->PolicyWarnedCMP0022 && !usage_requirements_only) { @@ -6088,30 +6062,14 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( } if (ifaceLibs != iface.Libraries) { - std::string oldLibraries; - std::string newLibraries; - const char *sep = ""; - for(std::vector<cmLinkImplItem>::const_iterator it - = impl->Libraries.begin(); it != impl->Libraries.end(); ++it) - { - oldLibraries += sep; - oldLibraries += *it; - sep = ";"; - } - sep = ""; - for(std::vector<cmLinkItem>::const_iterator it - = ifaceLibs.begin(); it != ifaceLibs.end(); ++it) - { - newLibraries += sep; - newLibraries += *it; - sep = ";"; - } + std::string oldLibraries = cmJoin(impl->Libraries, ";"); + std::string newLibraries = cmJoin(ifaceLibs, ";"); if(oldLibraries.empty()) { oldLibraries = "(empty)"; } if(newLibraries.empty()) { newLibraries = "(empty)"; } - cmOStringStream w; + std::ostringstream w; w << (thisTarget->Makefile->GetPolicies() ->GetPolicyWarning(cmPolicies::CMP0022)) << "\n" @@ -6366,7 +6324,7 @@ cmTargetInternals::ComputeLinkImplementationLibraries( { bool noMessage = false; cmake::MessageType messageType = cmake::FATAL_ERROR; - cmOStringStream e; + std::ostringstream e; switch(thisTarget->GetPolicyStatusCMP0038()) { case cmPolicies::WARN: @@ -6449,11 +6407,8 @@ cmTargetInternals::ComputeLinkImplementationLanguages( // Get languages used in our source files. thisTarget->GetLanguages(languages, config); // Copy the set of langauges to the link implementation. - for(std::set<std::string>::iterator li = languages.begin(); - li != languages.end(); ++li) - { - impl.Languages.push_back(*li); - } + impl.Languages.insert(impl.Languages.begin(), + languages.begin(), languages.end()); } //---------------------------------------------------------------------------- @@ -6472,7 +6427,7 @@ cmTarget const* cmTarget::FindTargetToLink(std::string const& name) const if(tgt && tgt->GetType() == cmTarget::OBJECT_LIBRARY) { - cmOStringStream e; + std::ostringstream e; e << "Target \"" << this->GetName() << "\" links to " "OBJECT library \"" << tgt->GetName() << "\" but this is not " "allowed. " @@ -6511,7 +6466,7 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const { case cmPolicies::WARN: { - cmOStringStream w; + std::ostringstream w; w << (this->Makefile->GetPolicies() ->GetPolicyWarning(cmPolicies::CMP0004)) << "\n" << "Target \"" << this->GetName() << "\" links to item \"" @@ -6523,7 +6478,7 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const break; case cmPolicies::NEW: { - cmOStringStream e; + std::ostringstream e; e << "Target \"" << this->GetName() << "\" links to item \"" << item << "\" which has leading or trailing whitespace. " << "This is now an error according to policy CMP0004."; @@ -6533,7 +6488,7 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: { - cmOStringStream e; + std::ostringstream e; e << (this->Makefile->GetPolicies() ->GetRequiredPolicyError(cmPolicies::CMP0004)) << "\n" << "Target \"" << this->GetName() << "\" links to item \"" @@ -6614,7 +6569,7 @@ void checkPropertyConsistency(cmTarget const* depender, std::string pfile = pdir + pname + ".rst"; if(cmSystemTools::FileExists(pfile.c_str(), true)) { - cmOStringStream e; + std::ostringstream e; e << "Target \"" << dependee->GetName() << "\" has property \"" << *pi << "\" listed in its " << propName << " property. " "This is not allowed. Only user-defined properties may appear " @@ -6776,7 +6731,7 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, { propsString += " and the " + *props.begin(); } - cmOStringStream e; + std::ostringstream e; e << "Property \"" << prop << "\" appears in both the " << propsString << " property in the dependencies of target \"" << this->GetName() << |