diff options
author | Brad King <brad.king@kitware.com> | 2019-02-11 13:08:13 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-02-11 13:08:22 (GMT) |
commit | 4b37b4f1bb785a305ab742f37e5268d4cffef693 (patch) | |
tree | f9c6e15ac0925bfa8b15fce4c3475d3233a820f6 /Source/cmLocalVisualStudio7Generator.cxx | |
parent | 17de1eea806d7ba87a4ba6ad1073ced5f7ea9473 (diff) | |
parent | 01b2d6ab7465e7f22fb821876027df86b0c8f363 (diff) | |
download | CMake-4b37b4f1bb785a305ab742f37e5268d4cffef693.zip CMake-4b37b4f1bb785a305ab742f37e5268d4cffef693.tar.gz CMake-4b37b4f1bb785a305ab742f37e5268d4cffef693.tar.bz2 |
Merge topic 'modernize-for-loops'
01b2d6ab74 Modernize: Use ranged for-loops when possible
15bdbec017 cmAlgorithms: Make cmRange advance/retreat safe for rvalues
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
Merge-request: !2901
Diffstat (limited to 'Source/cmLocalVisualStudio7Generator.cxx')
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 108 |
1 files changed, 45 insertions, 63 deletions
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 3946285..b809be4 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -293,9 +293,8 @@ void cmLocalVisualStudio7Generator::WriteConfigurations( const std::string& libName, cmGeneratorTarget* target) { fout << "\t<Configurations>\n"; - for (std::vector<std::string>::const_iterator i = configs.begin(); - i != configs.end(); ++i) { - this->WriteConfiguration(fout, i->c_str(), libName, target); + for (std::string const& config : configs) { + this->WriteConfiguration(fout, config.c_str(), libName, target); } fout << "\t</Configurations>\n"; } @@ -569,9 +568,8 @@ public: void Finish() { this->Stream << (this->First ? "" : "\"") << "/>\n"; } void Write(std::vector<cmCustomCommand> const& ccs) { - for (std::vector<cmCustomCommand>::const_iterator ci = ccs.begin(); - ci != ccs.end(); ++ci) { - this->Write(*ci); + for (cmCustomCommand const& command : ccs) { + this->Write(command); } } void Write(cmCustomCommand const& cc) @@ -897,10 +895,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( target->GetManifests(manifest_srcs, configName); if (!manifest_srcs.empty()) { fout << "\n\t\t\t\tAdditionalManifestFiles=\""; - for (std::vector<cmSourceFile const*>::const_iterator mi = - manifest_srcs.begin(); - mi != manifest_srcs.end(); ++mi) { - std::string m = (*mi)->GetFullPath(); + for (cmSourceFile const* manifest : manifest_srcs) { + std::string m = manifest->GetFullPath(); fout << this->ConvertToXMLOutputPath(m.c_str()) << ";"; } fout << "\""; @@ -1300,14 +1296,14 @@ void cmLocalVisualStudio7GeneratorInternals::OutputLibraries( { cmLocalVisualStudio7Generator* lg = this->LocalGenerator; std::string currentBinDir = lg->GetCurrentBinaryDirectory(); - for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) { - if (l->IsPath) { + for (auto const& lib : libs) { + if (lib.IsPath) { std::string rel = - lg->MaybeConvertToRelativePath(currentBinDir, l->Value.c_str()); + lg->MaybeConvertToRelativePath(currentBinDir, lib.Value.c_str()); fout << lg->ConvertToXMLOutputPath(rel.c_str()) << " "; - } else if (!l->Target || - l->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { - fout << l->Value << " "; + } else if (!lib.Target || + lib.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { + fout << lib.Value << " "; } } } @@ -1325,10 +1321,9 @@ void cmLocalVisualStudio7GeneratorInternals::OutputObjects( gt->GetExternalObjects(objs, configName); const char* sep = isep ? isep : ""; - for (std::vector<cmSourceFile const*>::const_iterator i = objs.begin(); - i != objs.end(); ++i) { - if (!(*i)->GetObjectLibrary().empty()) { - std::string const& objFile = (*i)->GetFullPath(); + for (cmSourceFile const* obj : objs) { + if (!obj->GetObjectLibrary().empty()) { + std::string const& objFile = obj->GetFullPath(); std::string rel = lg->MaybeConvertToRelativePath(currentBinDir, objFile); fout << sep << lg->ConvertToXMLOutputPath(rel.c_str()); sep = " "; @@ -1341,10 +1336,8 @@ void cmLocalVisualStudio7Generator::OutputLibraryDirectories( { const char* comma = ""; std::string currentBinDir = this->GetCurrentBinaryDirectory(); - for (std::vector<std::string>::const_iterator d = dirs.begin(); - d != dirs.end(); ++d) { + for (std::string dir : dirs) { // Remove any trailing slash and skip empty paths. - std::string dir = *d; if (dir.back() == '/') { dir = dir.substr(0, dir.size() - 1); } @@ -1480,9 +1473,8 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo( // Compute per-source, per-config information. size_t ci = 0; - for (std::vector<std::string>::const_iterator i = configs.begin(); - i != configs.end(); ++i, ++ci) { - std::string configUpper = cmSystemTools::UpperCase(*i); + for (std::string const& config : configs) { + std::string configUpper = cmSystemTools::UpperCase(config); cmLVS7GFileConfig fc; std::string lang = @@ -1495,7 +1487,7 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo( lang = sourceLang; } - cmGeneratorExpressionInterpreter genexInterpreter(lg, *i, gt, lang); + cmGeneratorExpressionInterpreter genexInterpreter(lg, config, gt, lang); bool needfc = false; if (!objectName.empty()) { @@ -1561,7 +1553,7 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo( } } - const std::string& linkLanguage = gt->GetLinkerLanguage(i->c_str()); + const std::string& linkLanguage = gt->GetLinkerLanguage(config.c_str()); // If HEADER_FILE_ONLY is set, we must suppress this generation in // the project file fc.ExcludedFromBuild = sf.GetPropertyAsBool("HEADER_FILE_ONLY") || @@ -1586,8 +1578,9 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo( } if (needfc) { - this->FileConfigMap[*i] = fc; + this->FileConfigMap[config] = fc; } + ++ci; } } @@ -1651,16 +1644,14 @@ bool cmLocalVisualStudio7Generator::WriteGroup( } // Loop through each source in the source group. - for (std::vector<const cmSourceFile*>::const_iterator sf = - sourceFiles.begin(); - sf != sourceFiles.end(); ++sf) { - std::string source = (*sf)->GetFullPath(); + for (const cmSourceFile* sf : sourceFiles) { + std::string source = sf->GetFullPath(); if (source != libName || target->GetType() == cmStateEnums::UTILITY || target->GetType() == cmStateEnums::GLOBAL_TARGET) { // Look up the source kind and configs. std::map<cmSourceFile const*, size_t>::const_iterator map_it = - sources.Index.find(*sf); + sources.Index.find(sf); // The map entry must exist because we populated it earlier. assert(map_it != sources.Index.end()); cmGeneratorTarget::AllConfigSource const& acs = @@ -1673,7 +1664,7 @@ bool cmLocalVisualStudio7Generator::WriteGroup( // Tell MS-Dev what the source is. If the compiler knows how to // build it, then it will. fout << "\t\t\t\tRelativePath=\"" << d << "\">\n"; - if (cmCustomCommand const* command = (*sf)->GetCustomCommand()) { + if (cmCustomCommand const* command = sf->GetCustomCommand()) { this->WriteCustomRule(fout, configs, source.c_str(), *command, fcinfo); } else if (!fcinfo.FileConfigMap.empty()) { const char* aCompilerTool = "VCCLCompilerTool"; @@ -1681,8 +1672,8 @@ bool cmLocalVisualStudio7Generator::WriteGroup( if (this->FortranProject) { aCompilerTool = "VFFortranCompilerTool"; } - std::string const& lang = (*sf)->GetLanguage(); - std::string ext = (*sf)->GetExtension(); + std::string const& lang = sf->GetLanguage(); + std::string ext = sf->GetExtension(); ext = cmSystemTools::LowerCase(ext); if (ext == "idl") { aCompilerTool = "VCMIDLTool"; @@ -1710,12 +1701,10 @@ bool cmLocalVisualStudio7Generator::WriteGroup( if (acs.Kind == cmGeneratorTarget::SourceKindExternalObject) { aCompilerTool = "VCCustomBuildTool"; } - for (std::map<std::string, cmLVS7GFileConfig>::const_iterator fci = - fcinfo.FileConfigMap.begin(); - fci != fcinfo.FileConfigMap.end(); ++fci) { - cmLVS7GFileConfig const& fc = fci->second; + for (auto const& fci : fcinfo.FileConfigMap) { + cmLVS7GFileConfig const& fc = fci.second; fout << "\t\t\t\t<FileConfiguration\n" - << "\t\t\t\t\tName=\"" << fci->first << "|" + << "\t\t\t\t\tName=\"" << fci.first << "|" << gg->GetPlatformName() << "\""; if (fc.ExcludedFromBuild) { fout << " ExcludedFromBuild=\"true\""; @@ -1738,7 +1727,7 @@ bool cmLocalVisualStudio7Generator::WriteGroup( fileOptions.AddDefines(fc.CompileDefsConfig); // validate source level include directories std::vector<std::string> includes; - this->AppendIncludeDirectories(includes, fc.IncludeDirs, **sf); + this->AppendIncludeDirectories(includes, fc.IncludeDirs, *sf); fileOptions.AddIncludes(includes); fileOptions.OutputFlagMap(fout, 5); fileOptions.OutputAdditionalIncludeDirectories( @@ -1791,12 +1780,11 @@ void cmLocalVisualStudio7Generator::WriteCustomRule( if (this->FortranProject) { customTool = "VFCustomBuildTool"; } - for (std::vector<std::string>::const_iterator i = configs.begin(); - i != configs.end(); ++i) { - cmCustomCommandGenerator ccg(command, *i, this); - cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i]; + for (std::string const& config : configs) { + cmCustomCommandGenerator ccg(command, config, this); + cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[config]; fout << "\t\t\t\t<FileConfiguration\n"; - fout << "\t\t\t\t\tName=\"" << *i << "|" << gg->GetPlatformName() + fout << "\t\t\t\t\tName=\"" << config << "|" << gg->GetPlatformName() << "\">\n"; if (!fc.CompileFlags.empty()) { fout << "\t\t\t\t\t<Tool\n" @@ -1808,7 +1796,7 @@ void cmLocalVisualStudio7Generator::WriteCustomRule( std::string comment = this->ConstructComment(ccg); std::string script = this->ConstructScript(ccg); if (this->FortranProject) { - cmSystemTools::ReplaceString(script, "$(Configuration)", i->c_str()); + cmSystemTools::ReplaceString(script, "$(Configuration)", config.c_str()); } /* clang-format off */ fout << "\t\t\t\t\t<Tool\n" @@ -1829,12 +1817,10 @@ void cmLocalVisualStudio7Generator::WriteCustomRule( fout << this->ConvertToXMLOutputPath(source); } else { // Write out the dependencies for the rule. - for (std::vector<std::string>::const_iterator d = - ccg.GetDepends().begin(); - d != ccg.GetDepends().end(); ++d) { + for (std::string const& d : ccg.GetDepends()) { // Get the real name of the dependency in case it is a CMake target. std::string dep; - if (this->GetRealDependency(d->c_str(), i->c_str(), dep)) { + if (this->GetRealDependency(d.c_str(), config.c_str(), dep)) { fout << this->ConvertToXMLOutputPath(dep.c_str()) << ";"; } } @@ -1846,10 +1832,8 @@ void cmLocalVisualStudio7Generator::WriteCustomRule( } else { // Write a rule for the output generated by this command. const char* sep = ""; - for (std::vector<std::string>::const_iterator o = - ccg.GetOutputs().begin(); - o != ccg.GetOutputs().end(); ++o) { - fout << sep << this->ConvertToXMLOutputPathSingle(o->c_str()); + for (std::string const& output : ccg.GetOutputs()) { + fout << sep << this->ConvertToXMLOutputPathSingle(output.c_str()); sep = ";"; } } @@ -2060,16 +2044,14 @@ void cmLocalVisualStudio7Generator::WriteVCProjFooter( { fout << "\t<Globals>\n"; - std::vector<std::string> const& props = target->GetPropertyKeys(); - for (std::vector<std::string>::const_iterator i = props.begin(); - i != props.end(); ++i) { - if (i->find("VS_GLOBAL_") == 0) { - std::string name = i->substr(10); + for (std::string const& key : target->GetPropertyKeys()) { + if (key.find("VS_GLOBAL_") == 0) { + std::string name = key.substr(10); if (!name.empty()) { /* clang-format off */ fout << "\t\t<Global\n" << "\t\t\tName=\"" << name << "\"\n" - << "\t\t\tValue=\"" << target->GetProperty(*i) << "\"\n" + << "\t\t\tValue=\"" << target->GetProperty(key) << "\"\n" << "\t\t/>\n"; /* clang-format on */ } |