diff options
Diffstat (limited to 'Source/cmExportLibraryDependenciesCommand.cxx')
-rw-r--r-- | Source/cmExportLibraryDependenciesCommand.cxx | 56 |
1 files changed, 24 insertions, 32 deletions
diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx index 69150ae..50f8cb0 100644 --- a/Source/cmExportLibraryDependenciesCommand.cxx +++ b/Source/cmExportLibraryDependenciesCommand.cxx @@ -4,8 +4,10 @@ #include "cmsys/FStream.hxx" #include <map> +#include <memory> // IWYU pragma: keep #include <utility> +#include "cmAlgorithms.h" #include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" @@ -13,8 +15,6 @@ #include "cmSystemTools.h" #include "cmTarget.h" #include "cmTargetLinkLibraryType.h" -#include "cm_auto_ptr.hxx" -#include "cm_unordered_map.hxx" #include "cmake.h" class cmExecutionStatus; @@ -48,16 +48,15 @@ void cmExportLibraryDependenciesCommand::FinalPass() void cmExportLibraryDependenciesCommand::ConstFinalPass() const { // Use copy-if-different if not appending. - CM_AUTO_PTR<cmsys::ofstream> foutPtr; + std::unique_ptr<cmsys::ofstream> foutPtr; if (this->Append) { - CM_AUTO_PTR<cmsys::ofstream> ap( - new cmsys::ofstream(this->Filename.c_str(), std::ios::app)); - foutPtr = ap; + foutPtr = + cm::make_unique<cmsys::ofstream>(this->Filename.c_str(), std::ios::app); } else { - CM_AUTO_PTR<cmGeneratedFileStream> ap( + std::unique_ptr<cmGeneratedFileStream> ap( new cmGeneratedFileStream(this->Filename.c_str(), true)); ap->SetCopyIfDifferent(true); - foutPtr = ap; + foutPtr = std::move(ap); } std::ostream& fout = *foutPtr; @@ -75,12 +74,11 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const std::map<std::string, std::string> libDepsOld; std::map<std::string, std::string> libDepsNew; std::map<std::string, std::string> libTypes; - for (std::vector<cmMakefile*>::const_iterator i = locals.begin(); - i != locals.end(); ++i) { - const cmTargets& tgts = (*i)->GetTargets(); - for (cmTargets::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { + for (cmMakefile* local : locals) { + const cmTargets& tgts = local->GetTargets(); + for (auto const& tgt : tgts) { // Get the current target. - cmTarget const& target = l->second; + cmTarget const& target = tgt.second; // Skip non-library targets. if (target.GetType() < cmStateEnums::STATIC_LIBRARY || @@ -98,12 +96,11 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const std::string valueNew; cmTarget::LinkLibraryVectorType const& libs = target.GetOriginalLinkLibraries(); - for (cmTarget::LinkLibraryVectorType::const_iterator li = libs.begin(); - li != libs.end(); ++li) { - std::string ltVar = li->first; + for (cmTarget::LibraryID const& li : libs) { + std::string ltVar = li.first; ltVar += "_LINK_TYPE"; std::string ltValue; - switch (li->second) { + switch (li.second) { case GENERAL_LibraryType: valueNew += "general;"; ltValue = "general"; @@ -117,7 +114,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const ltValue = "optimized"; break; } - std::string lib = li->first; + std::string lib = li.first; if (cmTarget* libtgt = global->FindTarget(lib)) { // Handle simple output name changes. This command is // deprecated so we do not support full target name @@ -150,26 +147,21 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const fout << "# Generated by CMake\n\n"; fout << "if(" << vertest << ")\n"; fout << " # Information for CMake 2.6 and above.\n"; - for (std::map<std::string, std::string>::const_iterator i = - libDepsNew.begin(); - i != libDepsNew.end(); ++i) { - if (!i->second.empty()) { - fout << " set(\"" << i->first << "\" \"" << i->second << "\")\n"; + for (auto const& i : libDepsNew) { + if (!i.second.empty()) { + fout << " set(\"" << i.first << "\" \"" << i.second << "\")\n"; } } fout << "else()\n"; fout << " # Information for CMake 2.4 and lower.\n"; - for (std::map<std::string, std::string>::const_iterator i = - libDepsOld.begin(); - i != libDepsOld.end(); ++i) { - if (!i->second.empty()) { - fout << " set(\"" << i->first << "\" \"" << i->second << "\")\n"; + for (auto const& i : libDepsOld) { + if (!i.second.empty()) { + fout << " set(\"" << i.first << "\" \"" << i.second << "\")\n"; } } - for (std::map<std::string, std::string>::const_iterator i = libTypes.begin(); - i != libTypes.end(); ++i) { - if (i->second != "general") { - fout << " set(\"" << i->first << "\" \"" << i->second << "\")\n"; + for (auto const& i : libTypes) { + if (i.second != "general") { + fout << " set(\"" << i.first << "\" \"" << i.second << "\")\n"; } } fout << "endif()\n"; |