summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/bindexplib.cxx10
-rw-r--r--Source/cmAddCompileOptionsCommand.cxx5
-rw-r--r--Source/cmAddCustomCommandCommand.cxx15
-rw-r--r--Source/cmAddDefinitionsCommand.cxx5
-rw-r--r--Source/cmCLocaleEnvironmentScope.cxx5
-rw-r--r--Source/cmCMakeMinimumRequired.cxx10
-rw-r--r--Source/cmCPackPropertiesGenerator.cxx15
-rw-r--r--Source/cmCPluginAPI.cxx9
-rw-r--r--Source/cmCTest.cxx37
-rw-r--r--Source/cmCacheManager.cxx23
-rw-r--r--Source/cmCommandArgumentParserHelper.cxx4
-rw-r--r--Source/cmCommandArgumentsHelper.cxx44
-rw-r--r--Source/cmCommonTargetGenerator.cxx11
-rw-r--r--Source/cmComputeComponentGraph.cxx10
-rw-r--r--Source/cmComputeLinkDepends.cxx91
-rw-r--r--Source/cmComputeLinkInformation.cxx111
-rw-r--r--Source/cmComputeTargetDepends.cxx97
-rw-r--r--Source/cmCoreTryCompile.cxx51
-rw-r--r--Source/cmCryptoHash.cxx7
-rw-r--r--Source/cmCustomCommandGenerator.cxx20
-rw-r--r--Source/cmDefinitions.cxx27
-rw-r--r--Source/cmDepends.cxx6
-rw-r--r--Source/cmDependsC.cxx67
-rw-r--r--Source/cmDependsFortran.cxx91
-rw-r--r--Source/cmDependsJavaParserHelper.cxx40
-rw-r--r--Source/cmDocumentation.cxx43
-rw-r--r--Source/cmDocumentationFormatter.cxx15
-rw-r--r--Source/cmDynamicLoader.cxx6
-rw-r--r--Source/cmELF.cxx12
-rw-r--r--Source/cmEnableLanguageCommand.cxx7
-rw-r--r--Source/cmExecProgramCommand.cxx14
-rw-r--r--Source/cmExecuteProcessCommand.cxx10
-rw-r--r--Source/cmExportBuildAndroidMKGenerator.cxx36
-rw-r--r--Source/cmExportBuildFileGenerator.cxx39
-rw-r--r--Source/cmExportCommand.cxx24
-rw-r--r--Source/cmExportFileGenerator.cxx96
-rw-r--r--Source/cmExportInstallAndroidMKGenerator.cxx5
-rw-r--r--Source/cmExportInstallFileGenerator.cxx53
-rw-r--r--Source/cmExportLibraryDependenciesCommand.cxx42
-rw-r--r--Source/cmExportSet.cxx5
-rw-r--r--Source/cmExportTryCompileFileGenerator.cxx26
-rw-r--r--Source/cmExtraCodeBlocksGenerator.cxx152
-rw-r--r--Source/cmExtraCodeLiteGenerator.cxx101
-rw-r--r--Source/cmExtraEclipseCDT4Generator.cxx162
-rw-r--r--Source/cmExtraKateGenerator.cxx50
-rw-r--r--Source/cmExtraSublimeTextGenerator.cxx55
-rw-r--r--Source/cmFileCommand.cxx49
-rw-r--r--Source/cmFileLockPool.cxx28
-rw-r--r--Source/cmFileMonitor.cxx33
-rw-r--r--Source/cmFindBase.cxx12
-rw-r--r--Source/cmFindCommon.cxx38
-rw-r--r--Source/cmFindLibraryCommand.cxx68
-rw-r--r--Source/cmFindPackageCommand.cxx121
-rw-r--r--Source/cmFindPathCommand.cxx22
-rw-r--r--Source/cmFindProgramCommand.cxx38
-rw-r--r--Source/cmForEachCommand.cxx4
-rw-r--r--Source/cmFortranParserImpl.cxx5
-rw-r--r--Source/cmFunctionCommand.cxx4
-rw-r--r--Source/cmGeneratorExpression.cxx9
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.cxx13
-rw-r--r--Source/cmGeneratorExpressionNode.cxx42
-rw-r--r--Source/cmGeneratorTarget.cxx462
-rw-r--r--Source/cmGlobalGenerator.cxx319
-rw-r--r--Source/cmGlobalKdevelopGenerator.cxx76
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx283
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx151
-rw-r--r--Source/cmGraphVizWriter.cxx109
-rw-r--r--Source/cmIfCommand.cxx38
-rw-r--r--Source/cmIncludeExternalMSProjectCommand.cxx5
-rw-r--r--Source/cmInstallCommand.cxx59
-rw-r--r--Source/cmInstallCommandArguments.cxx6
-rw-r--r--Source/cmInstallDirectoryGenerator.cxx12
-rw-r--r--Source/cmInstallExportGenerator.cxx23
-rw-r--r--Source/cmInstallFilesGenerator.cxx5
-rw-r--r--Source/cmInstallGenerator.cxx5
-rw-r--r--Source/cmInstallTargetGenerator.cxx33
-rw-r--r--Source/cmInstalledFile.cxx6
-rw-r--r--Source/cmLinkDirectoriesCommand.cxx5
-rw-r--r--Source/cmLinkLineComputer.cxx28
-rw-r--r--Source/cmLinkLineDeviceComputer.cxx18
-rw-r--r--Source/cmLoadCacheCommand.cxx23
-rw-r--r--Source/cmLocalCommonGenerator.cxx5
-rw-r--r--Source/cmLocalGenerator.cxx250
-rw-r--r--Source/cmLocalNinjaGenerator.cxx40
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx229
-rw-r--r--Source/cmMacroCommand.cxx20
-rw-r--r--Source/cmMakefile.cxx191
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx18
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx36
-rw-r--r--Source/cmMakefileTargetGenerator.cxx181
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx60
-rw-r--r--Source/cmNinjaTargetGenerator.cxx76
-rw-r--r--Source/cmNinjaUtilityTargetGenerator.cxx19
-rw-r--r--Source/cmOSXBundleGenerator.cxx7
-rw-r--r--Source/cmOrderDirectories.cxx55
-rw-r--r--Source/cmOutputConverter.cxx7
-rw-r--r--Source/cmOutputRequiredFilesCommand.cxx64
-rw-r--r--Source/cmParseArgumentsCommand.cxx86
-rw-r--r--Source/cmPathLabel.cxx6
-rw-r--r--Source/cmPolicies.cxx5
-rw-r--r--Source/cmProjectCommand.cxx9
-rw-r--r--Source/cmPropertyMap.cxx5
-rw-r--r--Source/cmQtAutoGeneratorInitializer.cxx22
-rw-r--r--Source/cmQtAutoGenerators.cxx75
-rw-r--r--Source/cmRST.cxx8
-rw-r--r--Source/cmRemoveCommand.cxx8
-rw-r--r--Source/cmRemoveDefinitionsCommand.cxx5
-rw-r--r--Source/cmScriptGenerator.cxx22
-rw-r--r--Source/cmSearchPath.cxx45
-rw-r--r--Source/cmSeparateArgumentsCommand.cxx24
-rw-r--r--Source/cmServerProtocol.cxx62
-rw-r--r--Source/cmSetPropertyCommand.cxx37
-rw-r--r--Source/cmSourceFile.cxx20
-rw-r--r--Source/cmSourceGroupCommand.cxx21
-rw-r--r--Source/cmState.cxx12
-rw-r--r--Source/cmStateDirectory.cxx12
-rw-r--r--Source/cmStringCommand.cxx8
-rw-r--r--Source/cmSubdirCommand.cxx19
-rw-r--r--Source/cmSystemTools.cxx36
-rw-r--r--Source/cmTarget.cxx43
-rw-r--r--Source/cmTargetCompileDefinitionsCommand.cxx9
-rw-r--r--Source/cmTargetCompileFeaturesCommand.cxx5
-rw-r--r--Source/cmTargetIncludeDirectoriesCommand.cxx22
-rw-r--r--Source/cmTargetLinkLibrariesCommand.cxx10
-rw-r--r--Source/cmTestGenerator.cxx20
-rw-r--r--Source/cmUseMangledMesaCommand.cxx5
-rw-r--r--Source/cmVariableWatch.cxx13
-rw-r--r--Source/cmVariableWatchCommand.cxx6
-rw-r--r--Source/cmWhileCommand.cxx13
-rw-r--r--Source/cmake.cxx154
-rw-r--r--Source/cmakemain.cxx14
-rw-r--r--Source/cmcmd.cxx11
-rw-r--r--Source/cmcmd.h2
133 files changed, 2456 insertions, 3592 deletions
diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx
index e96226a..05e1c66 100644
--- a/Source/bindexplib.cxx
+++ b/Source/bindexplib.cxx
@@ -394,12 +394,10 @@ bool bindexplib::AddDefinitionFile(const char* filename)
void bindexplib::WriteFile(FILE* file)
{
fprintf(file, "EXPORTS \n");
- for (std::set<std::string>::const_iterator i = this->DataSymbols.begin();
- i != this->DataSymbols.end(); ++i) {
- fprintf(file, "\t%s \t DATA\n", i->c_str());
+ for (std::string const& ds : this->DataSymbols) {
+ fprintf(file, "\t%s \t DATA\n", ds.c_str());
}
- for (std::set<std::string>::const_iterator i = this->Symbols.begin();
- i != this->Symbols.end(); ++i) {
- fprintf(file, "\t%s\n", i->c_str());
+ for (std::string const& s : this->Symbols) {
+ fprintf(file, "\t%s\n", s.c_str());
}
}
diff --git a/Source/cmAddCompileOptionsCommand.cxx b/Source/cmAddCompileOptionsCommand.cxx
index 21a8012..c37fd9a 100644
--- a/Source/cmAddCompileOptionsCommand.cxx
+++ b/Source/cmAddCompileOptionsCommand.cxx
@@ -13,9 +13,8 @@ bool cmAddCompileOptionsCommand::InitialPass(
return true;
}
- for (std::vector<std::string>::const_iterator i = args.begin();
- i != args.end(); ++i) {
- this->Makefile->AddCompileOption(i->c_str());
+ for (std::string const& i : args) {
+ this->Makefile->AddCompileOption(i.c_str());
}
return true;
}
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx
index bd054e8..7fed52d 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -68,9 +68,7 @@ bool cmAddCustomCommandCommand::InitialPass(
tdoing doing = doing_nothing;
- for (unsigned int j = 0; j < args.size(); ++j) {
- std::string const& copy = args[j];
-
+ for (std::string const& copy : args) {
if (copy == "SOURCE") {
doing = doing_source;
} else if (copy == "COMMAND") {
@@ -355,12 +353,11 @@ bool cmAddCustomCommandCommand::InitialPass(
bool cmAddCustomCommandCommand::CheckOutputs(
const std::vector<std::string>& outputs)
{
- for (std::vector<std::string>::const_iterator o = outputs.begin();
- o != outputs.end(); ++o) {
+ for (std::string const& o : outputs) {
// Make sure the file will not be generated into the source
// directory during an out of source build.
- if (!this->Makefile->CanIWriteThisFile(o->c_str())) {
- std::string e = "attempted to have a file \"" + *o +
+ if (!this->Makefile->CanIWriteThisFile(o.c_str())) {
+ std::string e = "attempted to have a file \"" + o +
"\" in a source directory as an output of custom command.";
this->SetError(e);
cmSystemTools::SetFatalErrorOccured();
@@ -368,10 +365,10 @@ bool cmAddCustomCommandCommand::CheckOutputs(
}
// Make sure the output file name has no invalid characters.
- std::string::size_type pos = o->find_first_of("#<>");
+ std::string::size_type pos = o.find_first_of("#<>");
if (pos != std::string::npos) {
std::ostringstream msg;
- msg << "called with OUTPUT containing a \"" << (*o)[pos]
+ msg << "called with OUTPUT containing a \"" << o[pos]
<< "\". This character is not allowed.";
this->SetError(msg.str());
return false;
diff --git a/Source/cmAddDefinitionsCommand.cxx b/Source/cmAddDefinitionsCommand.cxx
index 9e0607c..261fb5b 100644
--- a/Source/cmAddDefinitionsCommand.cxx
+++ b/Source/cmAddDefinitionsCommand.cxx
@@ -15,9 +15,8 @@ bool cmAddDefinitionsCommand::InitialPass(std::vector<std::string> const& args,
return true;
}
- for (std::vector<std::string>::const_iterator i = args.begin();
- i != args.end(); ++i) {
- this->Makefile->AddDefineFlag(i->c_str());
+ for (std::string const& i : args) {
+ this->Makefile->AddDefineFlag(i.c_str());
}
return true;
}
diff --git a/Source/cmCLocaleEnvironmentScope.cxx b/Source/cmCLocaleEnvironmentScope.cxx
index 28e8f2e..737e3ea 100644
--- a/Source/cmCLocaleEnvironmentScope.cxx
+++ b/Source/cmCLocaleEnvironmentScope.cxx
@@ -45,10 +45,9 @@ void cmCLocaleEnvironmentScope::SetEnv(std::string const& key,
cmCLocaleEnvironmentScope::~cmCLocaleEnvironmentScope()
{
- for (backup_map_t::const_iterator i = this->EnvironmentBackup.begin();
- i != this->EnvironmentBackup.end(); ++i) {
+ for (auto const& envb : this->EnvironmentBackup) {
std::ostringstream tmp;
- tmp << i->first << "=" << i->second;
+ tmp << envb.first << "=" << envb.second;
cmSystemTools::PutEnv(tmp.str());
}
}
diff --git a/Source/cmCMakeMinimumRequired.cxx b/Source/cmCMakeMinimumRequired.cxx
index 942688c..bcc41fc 100644
--- a/Source/cmCMakeMinimumRequired.cxx
+++ b/Source/cmCMakeMinimumRequired.cxx
@@ -19,10 +19,10 @@ bool cmCMakeMinimumRequired::InitialPass(std::vector<std::string> const& args,
// Process arguments.
std::string version_string;
bool doing_version = false;
- for (unsigned int i = 0; i < args.size(); ++i) {
- if (args[i] == "VERSION") {
+ for (std::string const& arg : args) {
+ if (arg == "VERSION") {
doing_version = true;
- } else if (args[i] == "FATAL_ERROR") {
+ } else if (arg == "FATAL_ERROR") {
if (doing_version) {
this->SetError("called with no value for VERSION.");
return false;
@@ -30,9 +30,9 @@ bool cmCMakeMinimumRequired::InitialPass(std::vector<std::string> const& args,
doing_version = false;
} else if (doing_version) {
doing_version = false;
- version_string = args[i];
+ version_string = arg;
} else {
- this->UnknownArguments.push_back(args[i]);
+ this->UnknownArguments.push_back(arg);
}
}
if (doing_version) {
diff --git a/Source/cmCPackPropertiesGenerator.cxx b/Source/cmCPackPropertiesGenerator.cxx
index 57a8b38..a33b824 100644
--- a/Source/cmCPackPropertiesGenerator.cxx
+++ b/Source/cmCPackPropertiesGenerator.cxx
@@ -6,7 +6,6 @@
#include <map>
#include <ostream>
-#include <utility>
cmCPackPropertiesGenerator::cmCPackPropertiesGenerator(
cmLocalGenerator* lg, cmInstalledFile const& installedFile,
@@ -27,19 +26,17 @@ void cmCPackPropertiesGenerator::GenerateScriptForConfig(
cmInstalledFile::PropertyMapType const& properties =
this->InstalledFile.GetProperties();
- for (cmInstalledFile::PropertyMapType::const_iterator i = properties.begin();
- i != properties.end(); ++i) {
- std::string const& name = i->first;
- cmInstalledFile::Property const& property = i->second;
+ for (cmInstalledFile::PropertyMapType::value_type const& i : properties) {
+ std::string const& name = i.first;
+ cmInstalledFile::Property const& property = i.second;
os << indent << "set_property(INSTALL "
<< cmOutputConverter::EscapeForCMake(expandedFileName) << " PROPERTY "
<< cmOutputConverter::EscapeForCMake(name);
- for (cmInstalledFile::ExpressionVectorType::const_iterator j =
- property.ValueExpressions.begin();
- j != property.ValueExpressions.end(); ++j) {
- std::string value = (*j)->Evaluate(this->LG, config);
+ for (cmInstalledFile::ExpressionVectorType::value_type const& j :
+ property.ValueExpressions) {
+ std::string value = j->Evaluate(this->LG, config);
os << " " << cmOutputConverter::EscapeForCMake(value);
}
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index e0b1711..e259f4d 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -504,8 +504,8 @@ public:
typedef derived::value_type value_type;
~cmCPluginAPISourceFileMap()
{
- for (iterator i = this->begin(); i != this->end(); ++i) {
- delete i->second;
+ for (auto const& i : *this) {
+ delete i.second;
}
}
};
@@ -568,9 +568,8 @@ void* CCONV cmAddSource(void* arg, void* arg2)
// Create the real cmSourceFile instance and copy over saved information.
cmSourceFile* rsf = mf->GetOrCreateSource(osf->FullPath);
rsf->GetProperties() = osf->Properties;
- for (std::vector<std::string>::iterator i = osf->Depends.begin();
- i != osf->Depends.end(); ++i) {
- rsf->AddDepend(*i);
+ for (std::string const& d : osf->Depends) {
+ rsf->AddDepend(d);
}
// Create the proxy for the real source file.
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 66b8f07..a164b37 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -222,8 +222,7 @@ std::string cmCTest::MakeURLSafe(const std::string& str)
{
std::ostringstream ost;
char buffer[10];
- for (std::string::size_type pos = 0; pos < str.size(); pos++) {
- unsigned char ch = str[pos];
+ for (unsigned char ch : str) {
if ((ch > 126 || ch < 32 || ch == '&' || ch == '%' || ch == '+' ||
ch == '=' || ch == '@') &&
ch != 9) {
@@ -973,9 +972,8 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
}
std::vector<const char*> argv;
- for (std::vector<std::string>::const_iterator a = args.begin();
- a != args.end(); ++a) {
- argv.push_back(a->c_str());
+ for (std::string const& a : args) {
+ argv.push_back(a.c_str());
}
argv.push_back(nullptr);
@@ -1009,9 +1007,9 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
<< " " << std::flush);
while (cmsysProcess_WaitForData(cp, &data, &length, nullptr)) {
processOutput.DecodeText(data, length, strdata);
- for (size_t cc = 0; cc < strdata.size(); ++cc) {
- if (strdata[cc] == 0) {
- strdata[cc] = '\n';
+ for (char& cc : strdata) {
+ if (cc == 0) {
+ cc = '\n';
}
}
output.append(strdata);
@@ -1107,18 +1105,18 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
inst.SetStreams(&oss, &oss);
std::vector<std::string> args;
- for (unsigned int i = 0; i < argv.size(); ++i) {
- if (argv[i]) {
+ for (char const* i : argv) {
+ if (i) {
// make sure we pass the timeout in for any build and test
// invocations. Since --build-generator is required this is a
// good place to check for it, and to add the arguments in
- if (strcmp(argv[i], "--build-generator") == 0 && timeout > 0) {
+ if (strcmp(i, "--build-generator") == 0 && timeout > 0) {
args.push_back("--test-timeout");
std::ostringstream msg;
msg << timeout;
args.push_back(msg.str());
}
- args.push_back(argv[i]);
+ args.push_back(i);
}
}
if (log) {
@@ -1348,9 +1346,8 @@ void cmCTest::AddSiteProperties(cmXMLWriter& xml)
std::string l = labels;
std::vector<std::string> args;
cmSystemTools::ExpandListArgument(l, args);
- for (std::vector<std::string>::iterator i = args.begin();
- i != args.end(); ++i) {
- xml.Element("Label", *i);
+ for (std::string const& i : args) {
+ xml.Element("Label", i);
}
xml.EndElement();
}
@@ -2352,9 +2349,8 @@ void cmCTest::PopulateCustomVector(cmMakefile* mf, const std::string& def,
vec.clear();
cmSystemTools::ExpandListArgument(dval, vec);
- for (std::vector<std::string>::const_iterator it = vec.begin();
- it != vec.end(); ++it) {
- cmCTestLog(this, DEBUG, " -- " << *it << std::endl);
+ for (std::string const& it : vec) {
+ cmCTestLog(this, DEBUG, " -- " << it << std::endl);
}
}
@@ -2592,9 +2588,8 @@ bool cmCTest::RunCommand(const char* command, std::string* stdOut,
}
std::vector<const char*> argv;
- for (std::vector<std::string>::const_iterator a = args.begin();
- a != args.end(); ++a) {
- argv.push_back(a->c_str());
+ for (std::string const& a : args) {
+ argv.push_back(a.c_str());
}
argv.push_back(nullptr);
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index d599275..56f48c3 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -297,10 +297,8 @@ bool cmCacheManager::SaveCache(const std::string& path)
fout << "########################\n";
fout << "\n";
- for (std::map<std::string, CacheEntry>::const_iterator i =
- this->Cache.begin();
- i != this->Cache.end(); ++i) {
- const CacheEntry& ce = (*i).second;
+ for (auto const& i : this->Cache) {
+ CacheEntry const& ce = i.second;
cmStateEnums::CacheEntryType t = ce.Type;
if (!ce.Initialized) {
/*
@@ -315,7 +313,7 @@ bool cmCacheManager::SaveCache(const std::string& path)
} else {
cmCacheManager::OutputHelpString(fout, "Missing description");
}
- this->OutputKey(fout, i->first);
+ this->OutputKey(fout, i.first);
fout << ":" << cmState::CacheEntryTypeToString(t) << "=";
this->OutputValue(fout, ce.Value);
fout << "\n\n";
@@ -462,11 +460,9 @@ void cmCacheManager::PrintCache(std::ostream& out) const
{
out << "=================================================" << std::endl;
out << "CMakeCache Contents:" << std::endl;
- for (std::map<std::string, CacheEntry>::const_iterator i =
- this->Cache.begin();
- i != this->Cache.end(); ++i) {
- if ((*i).second.Type != cmStateEnums::INTERNAL) {
- out << (*i).first << " = " << (*i).second.Value << std::endl;
+ for (auto const& i : this->Cache) {
+ if (i.second.Type != cmStateEnums::INTERNAL) {
+ out << i.first << " = " << i.second.Value << std::endl;
}
}
out << "\n\n";
@@ -494,11 +490,10 @@ void cmCacheManager::AddCacheEntry(const std::string& key, const char* value,
cmSystemTools::ExpandListArgument(e.Value, paths);
const char* sep = "";
e.Value = "";
- for (std::vector<std::string>::iterator i = paths.begin();
- i != paths.end(); ++i) {
- cmSystemTools::ConvertToUnixSlashes(*i);
+ for (std::string& i : paths) {
+ cmSystemTools::ConvertToUnixSlashes(i);
e.Value += sep;
- e.Value += *i;
+ e.Value += i;
sep = ";";
}
} else {
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index 4764620..f9daf5f 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -258,8 +258,8 @@ int cmCommandArgumentParserHelper::ParseString(const char* str, int verb)
void cmCommandArgumentParserHelper::CleanupParser()
{
std::vector<char*>::iterator sit;
- for (sit = this->Variables.begin(); sit != this->Variables.end(); ++sit) {
- delete[] * sit;
+ for (char* var : this->Variables) {
+ delete[] var;
}
this->Variables.erase(this->Variables.begin(), this->Variables.end());
}
diff --git a/Source/cmCommandArgumentsHelper.cxx b/Source/cmCommandArgumentsHelper.cxx
index 36d4da4..651b3c8 100644
--- a/Source/cmCommandArgumentsHelper.cxx
+++ b/Source/cmCommandArgumentsHelper.cxx
@@ -61,11 +61,9 @@ bool cmCommandArgument::KeyMatches(const std::string& key) const
void cmCommandArgument::ApplyOwnGroup()
{
if (this->Group != nullptr) {
- for (std::vector<cmCommandArgument*>::const_iterator it =
- this->Group->ContainedArguments.begin();
- it != this->Group->ContainedArguments.end(); ++it) {
- if (*it != this) {
- this->ArgumentsBefore.insert(*it);
+ for (cmCommandArgument* cargs : this->Group->ContainedArguments) {
+ if (cargs != this) {
+ this->ArgumentsBefore.insert(cargs);
}
}
}
@@ -180,19 +178,15 @@ void cmCADisabler::DoReset()
void cmCommandArgumentGroup::Follows(const cmCommandArgument* arg)
{
- for (std::vector<cmCommandArgument*>::iterator it =
- this->ContainedArguments.begin();
- it != this->ContainedArguments.end(); ++it) {
- (*it)->Follows(arg);
+ for (cmCommandArgument* ca : this->ContainedArguments) {
+ ca->Follows(arg);
}
}
void cmCommandArgumentGroup::FollowsGroup(const cmCommandArgumentGroup* group)
{
- for (std::vector<cmCommandArgument*>::iterator it =
- this->ContainedArguments.begin();
- it != this->ContainedArguments.end(); ++it) {
- (*it)->FollowsGroup(group);
+ for (cmCommandArgument* ca : this->ContainedArguments) {
+ ca->FollowsGroup(group);
}
}
@@ -203,37 +197,31 @@ void cmCommandArgumentsHelper::Parse(const std::vector<std::string>* args,
return;
}
- for (std::vector<cmCommandArgument*>::iterator argIt =
- this->Arguments.begin();
- argIt != this->Arguments.end(); ++argIt) {
- (*argIt)->ApplyOwnGroup();
- (*argIt)->Reset();
+ for (cmCommandArgument* ca : this->Arguments) {
+ ca->ApplyOwnGroup();
+ ca->Reset();
}
cmCommandArgument* activeArgument = nullptr;
const cmCommandArgument* previousArgument = nullptr;
- for (std::vector<std::string>::const_iterator it = args->begin();
- it != args->end(); ++it) {
- for (std::vector<cmCommandArgument*>::iterator argIt =
- this->Arguments.begin();
- argIt != this->Arguments.end(); ++argIt) {
- if ((*argIt)->KeyMatches(*it) &&
- ((*argIt)->MayFollow(previousArgument))) {
- activeArgument = *argIt;
+ for (std::string const& it : *args) {
+ for (cmCommandArgument* ca : this->Arguments) {
+ if (ca->KeyMatches(it) && (ca->MayFollow(previousArgument))) {
+ activeArgument = ca;
activeArgument->Activate();
break;
}
}
if (activeArgument) {
- bool argDone = activeArgument->Consume(*it);
+ bool argDone = activeArgument->Consume(it);
previousArgument = activeArgument;
if (argDone) {
activeArgument = nullptr;
}
} else {
if (unconsumedArgs != nullptr) {
- unconsumedArgs->push_back(*it);
+ unconsumedArgs->push_back(it);
}
}
}
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index a70839e..bd4077f 100644
--- a/Source/cmCommonTargetGenerator.cxx
+++ b/Source/cmCommonTargetGenerator.cxx
@@ -147,10 +147,8 @@ std::vector<std::string> cmCommonTargetGenerator::GetLinkedTargetDirectories()
if (cmComputeLinkInformation* cli =
this->GeneratorTarget->GetLinkInformation(this->ConfigName)) {
cmComputeLinkInformation::ItemVector const& items = cli->GetItems();
- for (cmComputeLinkInformation::ItemVector::const_iterator i =
- items.begin();
- i != items.end(); ++i) {
- cmGeneratorTarget const* linkee = i->Target;
+ for (auto const& item : items) {
+ cmGeneratorTarget const* linkee = item.Target;
if (linkee && !linkee->IsImported()
// We can ignore the INTERFACE_LIBRARY items because
// Target->GetLinkInformation already processed their
@@ -196,12 +194,11 @@ std::string cmCommonTargetGenerator::GetManifests()
this->GeneratorTarget->GetManifests(manifest_srcs, this->ConfigName);
std::vector<std::string> manifests;
- for (std::vector<cmSourceFile const*>::iterator mi = manifest_srcs.begin();
- mi != manifest_srcs.end(); ++mi) {
+ for (cmSourceFile const* manifest_src : manifest_srcs) {
manifests.push_back(this->LocalCommonGenerator->ConvertToOutputFormat(
this->LocalCommonGenerator->ConvertToRelativePath(
this->LocalCommonGenerator->GetWorkingDirectory(),
- (*mi)->GetFullPath()),
+ manifest_src->GetFullPath()),
cmOutputConverter::SHELL));
}
diff --git a/Source/cmComputeComponentGraph.cxx b/Source/cmComputeComponentGraph.cxx
index a02d885..9ec98ae 100644
--- a/Source/cmComputeComponentGraph.cxx
+++ b/Source/cmComputeComponentGraph.cxx
@@ -57,8 +57,8 @@ void cmComputeComponentGraph::TarjanVisit(int i)
// Follow outgoing edges.
EdgeList const& nl = this->InputGraph[i];
- for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
- int j = *ni;
+ for (cmGraphEdge const& ni : nl) {
+ int j = ni;
// Ignore edges to nodes that have been reached by a previous DFS
// walk. Since we did not reach the current node from that walk
@@ -119,14 +119,14 @@ void cmComputeComponentGraph::TransferEdges()
for (int i = 0; i < n; ++i) {
int i_component = this->TarjanComponents[i];
EdgeList const& nl = this->InputGraph[i];
- for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
- int j = *ni;
+ for (cmGraphEdge const& ni : nl) {
+ int j = ni;
int j_component = this->TarjanComponents[j];
if (i_component != j_component) {
// We do not attempt to combine duplicate edges, but instead
// store the inter-component edges with suitable multiplicity.
this->ComponentGraph[i_component].push_back(
- cmGraphEdge(j_component, ni->IsStrong()));
+ cmGraphEdge(j_component, ni.IsStrong()));
}
}
}
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 2277bbe..d9efc2e 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -357,10 +357,8 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry qe)
this->FollowSharedDeps(depender_index, iface);
// Support for CMP0003.
- for (std::vector<cmLinkItem>::const_iterator oi =
- iface->WrongConfigLibraries.begin();
- oi != iface->WrongConfigLibraries.end(); ++oi) {
- this->CheckWrongConfigItem(*oi);
+ for (cmLinkItem const& oi : iface->WrongConfigLibraries) {
+ this->CheckWrongConfigItem(oi);
}
}
} else {
@@ -385,10 +383,9 @@ void cmComputeLinkDepends::FollowSharedDeps(int depender_index,
void cmComputeLinkDepends::QueueSharedDependencies(
int depender_index, std::vector<cmLinkItem> const& deps)
{
- for (std::vector<cmLinkItem>::const_iterator li = deps.begin();
- li != deps.end(); ++li) {
+ for (cmLinkItem const& li : deps) {
SharedDepEntry qe;
- qe.Item = *li;
+ qe.Item = li;
qe.DependerIndex = depender_index;
this->SharedDepQueue.push(qe);
}
@@ -445,25 +442,24 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
std::vector<cmLinkItem> actual_libs;
cmTargetLinkLibraryType llt = GENERAL_LibraryType;
bool haveLLT = false;
- for (std::vector<std::string>::const_iterator di = deplist.begin();
- di != deplist.end(); ++di) {
- if (*di == "debug") {
+ for (std::string const& d : deplist) {
+ if (d == "debug") {
llt = DEBUG_LibraryType;
haveLLT = true;
- } else if (*di == "optimized") {
+ } else if (d == "optimized") {
llt = OPTIMIZED_LibraryType;
haveLLT = true;
- } else if (*di == "general") {
+ } else if (d == "general") {
llt = GENERAL_LibraryType;
haveLLT = true;
- } else if (!di->empty()) {
+ } else if (!d.empty()) {
// If no explicit link type was given prior to this entry then
// check if the entry has its own link type variable. This is
// needed for compatibility with dependency files generated by
// the export_library_dependencies command from CMake 2.4 and
// lower.
if (!haveLLT) {
- std::string var = *di;
+ std::string var = d;
var += "_LINK_TYPE";
if (const char* val = this->Makefile->GetDefinition(var)) {
if (strcmp(val, "debug") == 0) {
@@ -476,10 +472,10 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
// If the library is meant for this link type then use it.
if (llt == GENERAL_LibraryType || llt == this->LinkType) {
- cmLinkItem item(*di, this->FindTargetToLink(depender_index, *di));
+ cmLinkItem item(d, this->FindTargetToLink(depender_index, d));
actual_libs.push_back(item);
} else if (this->OldLinkDirMode) {
- cmLinkItem item(*di, this->FindTargetToLink(depender_index, *di));
+ cmLinkItem item(d, this->FindTargetToLink(depender_index, d));
this->CheckWrongConfigItem(item);
}
@@ -499,10 +495,8 @@ void cmComputeLinkDepends::AddDirectLinkEntries()
cmLinkImplementation const* impl =
this->Target->GetLinkImplementation(this->Config);
this->AddLinkEntries(-1, impl->Libraries);
- for (std::vector<cmLinkItem>::const_iterator wi =
- impl->WrongConfigLibraries.begin();
- wi != impl->WrongConfigLibraries.end(); ++wi) {
- this->CheckWrongConfigItem(*wi);
+ for (cmLinkItem const& wi : impl->WrongConfigLibraries) {
+ this->CheckWrongConfigItem(wi);
}
}
@@ -514,17 +508,16 @@ void cmComputeLinkDepends::AddLinkEntries(int depender_index,
std::map<int, DependSet> dependSets;
// Loop over the libraries linked directly by the depender.
- for (typename std::vector<T>::const_iterator li = libs.begin();
- li != libs.end(); ++li) {
+ for (T const& l : libs) {
// Skip entries that will resolve to the target getting linked or
// are empty.
- cmLinkItem const& item = *li;
+ cmLinkItem const& item = l;
if (item == this->Target->GetName() || item.empty()) {
continue;
}
// Add a link entry for this item.
- int dependee_index = this->AddLinkEntry(*li);
+ int dependee_index = this->AddLinkEntry(l);
// The dependee must come after the depender.
if (depender_index >= 0) {
@@ -535,16 +528,15 @@ void cmComputeLinkDepends::AddLinkEntries(int depender_index,
}
// Update the inferred dependencies for earlier items.
- for (std::map<int, DependSet>::iterator dsi = dependSets.begin();
- dsi != dependSets.end(); ++dsi) {
+ for (auto& dependSet : dependSets) {
// Add this item to the inferred dependencies of other items.
// Target items are never inferred dependees because unknown
// items are outside libraries that should not be depending on
// targets.
if (!this->EntryList[dependee_index].Target &&
!this->EntryList[dependee_index].IsFlag &&
- dependee_index != dsi->first) {
- dsi->second.insert(dependee_index);
+ dependee_index != dependSet.first) {
+ dependSet.second.insert(dependee_index);
}
}
@@ -556,9 +548,8 @@ void cmComputeLinkDepends::AddLinkEntries(int depender_index,
}
// Store the inferred dependency sets discovered for this list.
- for (std::map<int, DependSet>::iterator dsi = dependSets.begin();
- dsi != dependSets.end(); ++dsi) {
- this->InferredDependSets[dsi->first]->push_back(dsi->second);
+ for (auto const& dependSet : dependSets) {
+ this->InferredDependSets[dependSet.first]->push_back(dependSet.second);
}
}
@@ -608,14 +599,14 @@ void cmComputeLinkDepends::InferDependencies()
void cmComputeLinkDepends::CleanConstraintGraph()
{
- for (Graph::iterator i = this->EntryConstraintGraph.begin();
- i != this->EntryConstraintGraph.end(); ++i) {
+ for (cmGraphEdgeList& edgeList : this->EntryConstraintGraph) {
// Sort the outgoing edges for each graph node so that the
// original order will be preserved as much as possible.
- std::sort(i->begin(), i->end());
+ std::sort(edgeList.begin(), edgeList.end());
// Make the edge list unique.
- i->erase(std::unique(i->begin(), i->end()), i->end());
+ edgeList.erase(std::unique(edgeList.begin(), edgeList.end()),
+ edgeList.end());
}
}
@@ -660,9 +651,8 @@ void cmComputeLinkDepends::OrderLinkEntires()
}
// Start with the original link line.
- for (std::vector<int>::const_iterator i = this->OriginalEntries.begin();
- i != this->OriginalEntries.end(); ++i) {
- this->VisitEntry(*i);
+ for (int originalEntry : this->OriginalEntries) {
+ this->VisitEntry(originalEntry);
}
// Now explore anything left pending. Since the component graph is
@@ -684,13 +674,12 @@ void cmComputeLinkDepends::DisplayComponents()
for (unsigned int c = 0; c < components.size(); ++c) {
fprintf(stderr, "Component (%u):\n", c);
NodeList const& nl = components[c];
- for (NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
- int i = *ni;
+ for (int i : nl) {
fprintf(stderr, " item %d [%s]\n", i, this->EntryList[i].Item.c_str());
}
EdgeList const& ol = this->CCG->GetComponentGraphEdges(c);
- for (EdgeList::const_iterator oi = ol.begin(); oi != ol.end(); ++oi) {
- int i = *oi;
+ for (cmGraphEdge const& oi : ol) {
+ int i = oi;
fprintf(stderr, " followed by Component (%d)\n", i);
}
fprintf(stderr, " topo order index %d\n", this->ComponentOrder[c]);
@@ -771,10 +760,10 @@ void cmComputeLinkDepends::VisitEntry(int index)
// are now pending.
if (completed) {
EdgeList const& ol = this->CCG->GetComponentGraphEdges(component);
- for (EdgeList::const_iterator oi = ol.begin(); oi != ol.end(); ++oi) {
+ for (cmGraphEdge const& oi : ol) {
// This entire component is now pending no matter whether it has
// been partially seen already.
- this->MakePendingComponent(*oi);
+ this->MakePendingComponent(oi);
}
}
}
@@ -816,8 +805,8 @@ cmComputeLinkDepends::MakePendingComponent(unsigned int component)
int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl)
{
unsigned int count = 2;
- for (NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
- if (cmGeneratorTarget const* target = this->EntryList[*ni].Target) {
+ for (int ni : nl) {
+ if (cmGeneratorTarget const* target = this->EntryList[ni].Target) {
if (cmLinkInterface const* iface =
target->GetLinkInterface(this->Config, this->Target)) {
if (iface->Multiplicity > count) {
@@ -832,13 +821,11 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl)
void cmComputeLinkDepends::DisplayFinalEntries()
{
fprintf(stderr, "target [%s] links to:\n", this->Target->GetName().c_str());
- for (std::vector<LinkEntry>::const_iterator lei =
- this->FinalLinkEntries.begin();
- lei != this->FinalLinkEntries.end(); ++lei) {
- if (lei->Target) {
- fprintf(stderr, " target [%s]\n", lei->Target->GetName().c_str());
+ for (LinkEntry const& lei : this->FinalLinkEntries) {
+ if (lei.Target) {
+ fprintf(stderr, " target [%s]\n", lei.Target->GetName().c_str());
} else {
- fprintf(stderr, " item [%s]\n", lei->Item.c_str());
+ fprintf(stderr, " item [%s]\n", lei.Item.c_str());
}
}
fprintf(stderr, "\n");
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index f348a7e..0311043 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -468,13 +468,11 @@ bool cmComputeLinkInformation::Compute()
cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute();
// Add the link line items.
- for (cmComputeLinkDepends::EntryVector::const_iterator lei =
- linkEntries.begin();
- lei != linkEntries.end(); ++lei) {
- if (lei->IsSharedDep) {
- this->AddSharedDepItem(lei->Item, lei->Target);
+ for (cmComputeLinkDepends::LinkEntry const& linkEntry : linkEntries) {
+ if (linkEntry.IsSharedDep) {
+ this->AddSharedDepItem(linkEntry.Item, linkEntry.Target);
} else {
- this->AddItem(lei->Item, lei->Target);
+ this->AddItem(linkEntry.Item, linkEntry.Target);
}
}
@@ -494,10 +492,7 @@ bool cmComputeLinkInformation::Compute()
// directories.
std::set<cmGeneratorTarget const*> const& wrongItems =
cld.GetOldWrongConfigItems();
- for (std::set<cmGeneratorTarget const*>::const_iterator i =
- wrongItems.begin();
- i != wrongItems.end(); ++i) {
- cmGeneratorTarget const* tgt = *i;
+ for (cmGeneratorTarget const* tgt : wrongItems) {
bool implib = (this->UseImportLibrary &&
(tgt->GetType() == cmStateEnums::SHARED_LIBRARY));
cmStateEnums::ArtifactType artifact = implib
@@ -540,11 +535,10 @@ void cmComputeLinkInformation::AddImplicitLinkInfo()
// The link closure lists all languages whose implicit info is needed.
cmGeneratorTarget::LinkClosure const* lc =
this->Target->GetLinkClosure(this->Config);
- for (std::vector<std::string>::const_iterator li = lc->Languages.begin();
- li != lc->Languages.end(); ++li) {
+ for (std::string const& li : lc->Languages) {
// Skip those of the linker language. They are implicit.
- if (*li != this->LinkLanguage) {
- this->AddImplicitLinkInfo(*li);
+ if (li != this->LinkLanguage) {
+ this->AddImplicitLinkInfo(li);
}
}
}
@@ -559,10 +553,9 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang)
if (const char* libs = this->Makefile->GetDefinition(libVar)) {
std::vector<std::string> libsVec;
cmSystemTools::ExpandListArgument(libs, libsVec);
- for (std::vector<std::string>::const_iterator i = libsVec.begin();
- i != libsVec.end(); ++i) {
- if (this->ImplicitLinkLibs.find(*i) == this->ImplicitLinkLibs.end()) {
- this->AddItem(*i, nullptr);
+ for (std::string const& i : libsVec) {
+ if (this->ImplicitLinkLibs.find(i) == this->ImplicitLinkLibs.end()) {
+ this->AddItem(i, nullptr);
}
}
}
@@ -811,18 +804,16 @@ void cmComputeLinkInformation::ComputeItemParserInfo()
mf->GetDefinition("CMAKE_EXTRA_LINK_EXTENSIONS")) {
std::vector<std::string> linkSuffixVec;
cmSystemTools::ExpandListArgument(linkSuffixes, linkSuffixVec);
- for (std::vector<std::string>::iterator i = linkSuffixVec.begin();
- i != linkSuffixVec.end(); ++i) {
- this->AddLinkExtension(i->c_str(), LinkUnknown);
+ for (std::string const& i : linkSuffixVec) {
+ this->AddLinkExtension(i.c_str(), LinkUnknown);
}
}
if (const char* sharedSuffixes =
mf->GetDefinition("CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES")) {
std::vector<std::string> sharedSuffixVec;
cmSystemTools::ExpandListArgument(sharedSuffixes, sharedSuffixVec);
- for (std::vector<std::string>::iterator i = sharedSuffixVec.begin();
- i != sharedSuffixVec.end(); ++i) {
- this->AddLinkExtension(i->c_str(), LinkShared);
+ for (std::string const& i : sharedSuffixVec) {
+ this->AddLinkExtension(i.c_str(), LinkShared);
}
}
@@ -840,9 +831,8 @@ void cmComputeLinkInformation::ComputeItemParserInfo()
// be the library name. Match index 3 will be the library
// extension.
reg = "^(";
- for (std::set<std::string>::iterator p = this->LinkPrefixes.begin();
- p != this->LinkPrefixes.end(); ++p) {
- reg += *p;
+ for (std::string const& p : this->LinkPrefixes) {
+ reg += p;
reg += "|";
}
reg += ")";
@@ -906,8 +896,7 @@ std::string cmComputeLinkInformation::CreateExtensionRegex(
// Build a list of extension choices.
std::string libext = "(";
const char* sep = "";
- for (std::vector<std::string>::const_iterator i = exts.begin();
- i != exts.end(); ++i) {
+ for (std::string const& i : exts) {
// Separate this choice from the previous one.
libext += sep;
sep = "|";
@@ -915,9 +904,9 @@ std::string cmComputeLinkInformation::CreateExtensionRegex(
// Store this extension choice with the "." escaped.
libext += "\\";
#if defined(_WIN32) && !defined(__CYGWIN__)
- libext += this->NoCaseExpression(i->c_str());
+ libext += this->NoCaseExpression(i.c_str());
#else
- libext += *i;
+ libext += i;
#endif
}
@@ -1457,10 +1446,8 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories()
}
// Add the link directories for full path items.
- for (std::vector<std::string>::const_iterator i =
- this->OldLinkDirItems.begin();
- i != this->OldLinkDirItems.end(); ++i) {
- this->OrderLinkerSearchPath->AddLinkLibrary(*i);
+ for (std::string const& i : this->OldLinkDirItems) {
+ this->OrderLinkerSearchPath->AddLinkLibrary(i);
}
return true;
}
@@ -1489,19 +1476,17 @@ void cmComputeLinkInformation::PrintLinkPolicyDiagnosis(std::ostream& os)
std::string::size_type max_size = 76;
std::string line;
const char* sep = " ";
- for (std::vector<std::string>::const_iterator i =
- this->OldUserFlagItems.begin();
- i != this->OldUserFlagItems.end(); ++i) {
+ for (std::string const& i : this->OldUserFlagItems) {
// If the addition of another item will exceed the limit then
// output the current line and reset it. Note that the separator
// is either " " or ", " which is always 2 characters.
- if (!line.empty() && (line.size() + i->size() + 2) > max_size) {
+ if (!line.empty() && (line.size() + i.size() + 2) > max_size) {
os << line << "\n";
sep = " ";
line = "";
}
line += sep;
- line += *i;
+ line += i;
// Convert to the other separator.
sep = ", ";
}
@@ -1513,11 +1498,9 @@ void cmComputeLinkInformation::PrintLinkPolicyDiagnosis(std::ostream& os)
// List the paths old behavior is adding.
os << "and other libraries with known full path:\n";
std::set<std::string> emitted;
- for (std::vector<std::string>::const_iterator i =
- this->OldLinkDirItems.begin();
- i != this->OldLinkDirItems.end(); ++i) {
- if (emitted.insert(cmSystemTools::GetFilenamePath(*i)).second) {
- os << " " << *i << "\n";
+ for (std::string const& i : this->OldLinkDirItems) {
+ if (emitted.insert(cmSystemTools::GetFilenamePath(i)).second) {
+ os << " " << i << "\n";
}
}
@@ -1544,9 +1527,8 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo()
// and add them to the set
if (const char* libraryArch =
this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE")) {
- for (std::vector<std::string>::const_iterator i = implicitDirVec.begin();
- i != implicitDirVec.end(); ++i) {
- this->ImplicitLinkDirs.insert(*i + "/" + libraryArch);
+ for (std::string const& i : implicitDirVec) {
+ this->ImplicitLinkDirs.insert(i + "/" + libraryArch);
}
}
@@ -1573,11 +1555,9 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo()
}
// Store implicit link libraries.
- for (std::vector<std::string>::const_iterator i = implicitLibVec.begin();
- i != implicitLibVec.end(); ++i) {
+ for (std::string const& item : implicitLibVec) {
// Items starting in '-' but not '-l' are flags, not libraries,
// and should not be filtered by this implicit list.
- std::string const& item = *i;
if (item[0] != '-' || item[1] == 'l') {
this->ImplicitLinkLibs.insert(item);
}
@@ -1694,10 +1674,9 @@ static void cmCLI_ExpandListUnique(const char* str,
{
std::vector<std::string> tmp;
cmSystemTools::ExpandListArgument(str, tmp);
- for (std::vector<std::string>::iterator i = tmp.begin(); i != tmp.end();
- ++i) {
- if (emitted.insert(*i).second) {
- out.push_back(*i);
+ for (std::string const& i : tmp) {
+ if (emitted.insert(i).second) {
+ out.push_back(i);
}
}
}
@@ -1750,12 +1729,11 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
this->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
cmSystemTools::ConvertToUnixSlashes(rootPath);
std::vector<std::string> const& rdirs = this->GetRuntimeSearchPath();
- for (std::vector<std::string>::const_iterator ri = rdirs.begin();
- ri != rdirs.end(); ++ri) {
+ for (std::string const& ri : rdirs) {
// Put this directory in the rpath if using build-tree rpath
// support or if using the link path as an rpath.
if (use_build_rpath) {
- std::string d = *ri;
+ std::string d = ri;
if (!rootPath.empty() && d.find(rootPath) == 0) {
d = d.substr(rootPath.size());
} else if (stagePath && *stagePath && d.find(stagePath) == 0) {
@@ -1773,11 +1751,11 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
const char* topSourceDir = this->CMakeInstance->GetHomeDirectory();
const char* topBinaryDir =
this->CMakeInstance->GetHomeOutputDirectory();
- if (!cmSystemTools::ComparePath(*ri, topSourceDir) &&
- !cmSystemTools::ComparePath(*ri, topBinaryDir) &&
- !cmSystemTools::IsSubDirectory(*ri, topSourceDir) &&
- !cmSystemTools::IsSubDirectory(*ri, topBinaryDir)) {
- std::string d = *ri;
+ if (!cmSystemTools::ComparePath(ri, topSourceDir) &&
+ !cmSystemTools::ComparePath(ri, topBinaryDir) &&
+ !cmSystemTools::IsSubDirectory(ri, topSourceDir) &&
+ !cmSystemTools::IsSubDirectory(ri, topBinaryDir)) {
+ std::string d = ri;
if (!rootPath.empty() && d.find(rootPath) == 0) {
d = d.substr(rootPath.size());
} else if (stagePath && *stagePath && d.find(stagePath) == 0) {
@@ -1800,12 +1778,11 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
{
cmGeneratorTarget::LinkClosure const* lc =
this->Target->GetLinkClosure(this->Config);
- for (std::vector<std::string>::const_iterator li = lc->Languages.begin();
- li != lc->Languages.end(); ++li) {
+ for (std::string const& li : lc->Languages) {
std::string useVar =
- "CMAKE_" + *li + "_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH";
+ "CMAKE_" + li + "_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH";
if (this->Makefile->IsOn(useVar)) {
- std::string dirVar = "CMAKE_" + *li + "_IMPLICIT_LINK_DIRECTORIES";
+ std::string dirVar = "CMAKE_" + li + "_IMPLICIT_LINK_DIRECTORIES";
if (const char* dirs = this->Makefile->GetDefinition(dirVar)) {
cmCLI_ExpandListUnique(dirs, runtimeDirs, emitted);
}
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index ff0052b..963c2df 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -148,10 +148,10 @@ void cmComputeTargetDepends::GetTargetDirectDepends(cmGeneratorTarget const* t,
// Get its final dependencies.
EdgeList const& nl = this->FinalGraph[i];
- for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
- cmGeneratorTarget const* dep = this->Targets[*ni];
+ for (cmGraphEdge const& ni : nl) {
+ cmGeneratorTarget const* dep = this->Targets[ni];
cmTargetDependSet::iterator di = deps.insert(dep).first;
- di->SetType(ni->IsStrong());
+ di->SetType(ni.IsStrong());
}
}
@@ -160,15 +160,13 @@ void cmComputeTargetDepends::CollectTargets()
// Collect all targets from all generators.
std::vector<cmLocalGenerator*> const& lgens =
this->GlobalGenerator->GetLocalGenerators();
- for (unsigned int i = 0; i < lgens.size(); ++i) {
+ for (cmLocalGenerator* lgen : lgens) {
const std::vector<cmGeneratorTarget*>& targets =
- lgens[i]->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
- ti != targets.end(); ++ti) {
- cmGeneratorTarget* gt = *ti;
+ lgen->GetGeneratorTargets();
+ for (cmGeneratorTarget const* ti : targets) {
int index = static_cast<int>(this->Targets.size());
- this->TargetIndex[gt] = index;
- this->Targets.push_back(gt);
+ this->TargetIndex[ti] = index;
+ this->Targets.push_back(ti);
}
}
}
@@ -204,14 +202,11 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
if (configs.empty()) {
configs.push_back("");
}
- for (std::vector<std::string>::const_iterator it = configs.begin();
- it != configs.end(); ++it) {
+ for (std::string const& it : configs) {
std::vector<cmSourceFile const*> objectFiles;
- depender->GetExternalObjects(objectFiles, *it);
- for (std::vector<cmSourceFile const*>::const_iterator oi =
- objectFiles.begin();
- oi != objectFiles.end(); ++oi) {
- std::string objLib = (*oi)->GetObjectLibrary();
+ depender->GetExternalObjects(objectFiles, it);
+ for (cmSourceFile const* o : objectFiles) {
+ std::string objLib = o->GetObjectLibrary();
if (!objLib.empty() && emitted.insert(objLib).second) {
if (depender->GetType() != cmStateEnums::EXECUTABLE &&
depender->GetType() != cmStateEnums::STATIC_LIBRARY &&
@@ -228,17 +223,15 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
}
}
- cmLinkImplementation const* impl = depender->GetLinkImplementation(*it);
+ cmLinkImplementation const* impl = depender->GetLinkImplementation(it);
// A target should not depend on itself.
emitted.insert(depender->GetName());
- for (std::vector<cmLinkImplItem>::const_iterator lib =
- impl->Libraries.begin();
- lib != impl->Libraries.end(); ++lib) {
+ for (cmLinkImplItem const& lib : impl->Libraries) {
// Don't emit the same library twice for this target.
- if (emitted.insert(*lib).second) {
- this->AddTargetDepend(depender_index, *lib, true);
- this->AddInterfaceDepends(depender_index, *lib, *it, emitted);
+ if (emitted.insert(lib).second) {
+ this->AddTargetDepend(depender_index, lib, true);
+ this->AddInterfaceDepends(depender_index, lib, it, emitted);
}
}
}
@@ -250,11 +243,10 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
std::set<std::string> emitted;
// A target should not depend on itself.
emitted.insert(depender->GetName());
- for (std::set<cmLinkItem>::const_iterator util = tutils.begin();
- util != tutils.end(); ++util) {
+ for (cmLinkItem const& litem : tutils) {
// Don't emit the same utility twice for this target.
- if (emitted.insert(*util).second) {
- this->AddTargetDepend(depender_index, *util, false);
+ if (emitted.insert(litem).second) {
+ this->AddTargetDepend(depender_index, litem, false);
}
}
}
@@ -267,13 +259,11 @@ void cmComputeTargetDepends::AddInterfaceDepends(
cmGeneratorTarget const* depender = this->Targets[depender_index];
if (cmLinkInterface const* iface =
dependee->GetLinkInterface(config, depender)) {
- for (std::vector<cmLinkItem>::const_iterator lib =
- iface->Libraries.begin();
- lib != iface->Libraries.end(); ++lib) {
+ for (cmLinkItem const& lib : iface->Libraries) {
// Don't emit the same library twice for this target.
- if (emitted.insert(*lib).second) {
- this->AddTargetDepend(depender_index, *lib, true);
- this->AddInterfaceDepends(depender_index, *lib, config, emitted);
+ if (emitted.insert(lib).second) {
+ this->AddTargetDepend(depender_index, lib, true);
+ this->AddInterfaceDepends(depender_index, lib, config, emitted);
}
}
}
@@ -365,9 +355,8 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
// Skip IMPORTED and INTERFACE targets but follow their utility
// dependencies.
std::set<cmLinkItem> const& utils = dependee->GetUtilityItems();
- for (std::set<cmLinkItem>::const_iterator i = utils.begin();
- i != utils.end(); ++i) {
- if (cmGeneratorTarget const* transitive_dependee = i->Target) {
+ for (cmLinkItem const& i : utils) {
+ if (cmGeneratorTarget const* transitive_dependee = i.Target) {
this->AddTargetDepend(depender_index, transitive_dependee, false);
}
}
@@ -395,11 +384,11 @@ void cmComputeTargetDepends::DisplayGraph(Graph const& graph,
cmGeneratorTarget const* depender = this->Targets[depender_index];
fprintf(stderr, "target %d is [%s]\n", depender_index,
depender->GetName().c_str());
- for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
- int dependee_index = *ni;
+ for (cmGraphEdge const& ni : nl) {
+ int dependee_index = ni;
cmGeneratorTarget const* dependee = this->Targets[dependee_index];
fprintf(stderr, " depends on target %d [%s] (%s)\n", dependee_index,
- dependee->GetName().c_str(), ni->IsStrong() ? "strong" : "weak");
+ dependee->GetName().c_str(), ni.IsStrong() ? "strong" : "weak");
}
}
fprintf(stderr, "\n");
@@ -414,8 +403,7 @@ void cmComputeTargetDepends::DisplayComponents(
for (int c = 0; c < n; ++c) {
NodeList const& nl = components[c];
fprintf(stderr, "Component (%d):\n", c);
- for (NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
- int i = *ni;
+ for (int i : nl) {
fprintf(stderr, " contains target %d [%s]\n", i,
this->Targets[i]->GetName().c_str());
}
@@ -446,8 +434,8 @@ bool cmComputeTargetDepends::CheckComponents(
}
// Make sure the component is all STATIC_LIBRARY targets.
- for (NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
- if (this->Targets[*ni]->GetType() != cmStateEnums::STATIC_LIBRARY) {
+ for (int ni : nl) {
+ if (this->Targets[ni]->GetType() != cmStateEnums::STATIC_LIBRARY) {
this->ComplainAboutBadComponent(ccg, c);
return false;
}
@@ -466,9 +454,8 @@ void cmComputeTargetDepends::ComplainAboutBadComponent(
std::vector<NodeList> const& components = ccg.GetComponents();
std::vector<int> const& cmap = ccg.GetComponentMap();
NodeList const& cl = components[c];
- for (NodeList::const_iterator ci = cl.begin(); ci != cl.end(); ++ci) {
+ for (int i : cl) {
// Get the depender.
- int i = *ci;
cmGeneratorTarget const* depender = this->Targets[i];
// Describe the depender.
@@ -477,12 +464,12 @@ void cmComputeTargetDepends::ComplainAboutBadComponent(
// List its dependencies that are inside the component.
EdgeList const& nl = this->InitialGraph[i];
- for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
- int j = *ni;
+ for (cmGraphEdge const& ni : nl) {
+ int j = ni;
if (cmap[j] == c) {
cmGeneratorTarget const* dependee = this->Targets[j];
e << " depends on \"" << dependee->GetName() << "\""
- << " (" << (ni->IsStrong() ? "strong" : "weak") << ")\n";
+ << " (" << (ni.IsStrong() ? "strong" : "weak") << ")\n";
}
}
}
@@ -514,9 +501,9 @@ bool cmComputeTargetDepends::IntraComponent(std::vector<int> const& cmap,
if (emitted.insert(i).second) {
// Honor strong intra-component edges in the final order.
EdgeList const& el = this->InitialGraph[i];
- for (EdgeList::const_iterator ei = el.begin(); ei != el.end(); ++ei) {
- int j = *ei;
- if (cmap[j] == c && ei->IsStrong()) {
+ for (cmGraphEdge const& edge : el) {
+ int j = edge;
+ if (cmap[j] == c && edge.IsStrong()) {
this->FinalGraph[i].push_back(cmGraphEdge(j, true));
if (!this->IntraComponent(cmap, c, j, head, emitted, visited)) {
return false;
@@ -573,11 +560,11 @@ bool cmComputeTargetDepends::ComputeFinalDepends(
++depender_component) {
int depender_component_tail = this->ComponentTail[depender_component];
EdgeList const& nl = cgraph[depender_component];
- for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
- int dependee_component = *ni;
+ for (cmGraphEdge const& ni : nl) {
+ int dependee_component = ni;
int dependee_component_head = this->ComponentHead[dependee_component];
this->FinalGraph[depender_component_tail].push_back(
- cmGraphEdge(dependee_component_head, ni->IsStrong()));
+ cmGraphEdge(dependee_component_head, ni.IsStrong()));
}
}
return true;
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 86f5282..d1270a0 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -417,16 +417,15 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
// Detect languages to enable.
cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
std::set<std::string> testLangs;
- for (std::vector<std::string>::iterator si = sources.begin();
- si != sources.end(); ++si) {
- std::string ext = cmSystemTools::GetFilenameLastExtension(*si);
+ for (std::string const& si : sources) {
+ std::string ext = cmSystemTools::GetFilenameLastExtension(si);
std::string lang = gg->GetLanguageFromExtension(ext.c_str());
if (!lang.empty()) {
testLangs.insert(lang);
} else {
std::ostringstream err;
err << "Unknown extension \"" << ext << "\" for file\n"
- << " " << *si << "\n"
+ << " " << si << "\n"
<< "try_compile() works only for enabled languages. "
<< "Currently these are:\n ";
std::vector<std::string> langs;
@@ -467,11 +466,10 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
}
std::string projectLangs;
- for (std::set<std::string>::iterator li = testLangs.begin();
- li != testLangs.end(); ++li) {
- projectLangs += " " + *li;
+ for (std::string const& li : testLangs) {
+ projectLangs += " " + li;
std::string rulesOverrideBase = "CMAKE_USER_MAKE_RULES_OVERRIDE";
- std::string rulesOverrideLang = rulesOverrideBase + "_" + *li;
+ std::string rulesOverrideLang = rulesOverrideBase + "_" + li;
if (const char* rulesOverridePath =
this->Makefile->GetDefinition(rulesOverrideLang)) {
fprintf(fout, "set(%s \"%s\")\n", rulesOverrideLang.c_str(),
@@ -484,15 +482,14 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
}
fprintf(fout, "project(CMAKE_TRY_COMPILE%s)\n", projectLangs.c_str());
fprintf(fout, "set(CMAKE_VERBOSE_MAKEFILE 1)\n");
- for (std::set<std::string>::iterator li = testLangs.begin();
- li != testLangs.end(); ++li) {
- std::string langFlags = "CMAKE_" + *li + "_FLAGS";
+ for (std::string const& li : testLangs) {
+ std::string langFlags = "CMAKE_" + li + "_FLAGS";
const char* flags = this->Makefile->GetDefinition(langFlags);
- fprintf(fout, "set(CMAKE_%s_FLAGS %s)\n", li->c_str(),
+ fprintf(fout, "set(CMAKE_%s_FLAGS %s)\n", li.c_str(),
cmOutputConverter::EscapeForCMake(flags ? flags : "").c_str());
fprintf(fout, "set(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}"
" ${COMPILE_DEFINITIONS}\")\n",
- li->c_str(), li->c_str());
+ li.c_str(), li.c_str());
}
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0066)) {
case cmPolicies::WARN:
@@ -522,9 +519,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
static std::string const cfgDefault = "DEBUG";
std::string const cfg =
!tcConfig.empty() ? cmSystemTools::UpperCase(tcConfig) : cfgDefault;
- for (std::set<std::string>::iterator li = testLangs.begin();
- li != testLangs.end(); ++li) {
- std::string const langFlagsCfg = "CMAKE_" + *li + "_FLAGS_" + cfg;
+ for (std::string const& li : testLangs) {
+ std::string const langFlagsCfg = "CMAKE_" + li + "_FLAGS_" + cfg;
const char* flagsCfg = this->Makefile->GetDefinition(langFlagsCfg);
fprintf(fout, "set(%s %s)\n", langFlagsCfg.c_str(),
cmOutputConverter::EscapeForCMake(flagsCfg ? flagsCfg : "")
@@ -638,9 +634,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
cmakeFlags.push_back(flag);
}
- for (std::set<std::string>::iterator vi = vars.begin(); vi != vars.end();
- ++vi) {
- std::string const& var = *vi;
+ for (std::string const& var : vars) {
if (const char* val = this->Makefile->GetDefinition(var)) {
std::string flag = "-D" + var + "=" + val;
cmakeFlags.push_back(flag);
@@ -669,13 +663,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
/* Create the actual static library. */
fprintf(fout, "add_library(%s STATIC", targetName.c_str());
}
- for (std::vector<std::string>::iterator si = sources.begin();
- si != sources.end(); ++si) {
- fprintf(fout, " \"%s\"", si->c_str());
+ for (std::string const& si : sources) {
+ fprintf(fout, " \"%s\"", si.c_str());
// Add dependencies on any non-temporary sources.
- if (si->find("CMakeTmp") == std::string::npos) {
- this->Makefile->AddCMakeDependFile(*si);
+ if (si.find("CMakeTmp") == std::string::npos) {
+ this->Makefile->AddCMakeDependFile(si);
}
}
fprintf(fout, ")\n");
@@ -762,9 +755,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
"is not honoring language standard variables in the test project:\n"
;
/* clang-format on */
- for (std::vector<std::string>::iterator vi = this->WarnCMP0067.begin();
- vi != this->WarnCMP0067.end(); ++vi) {
- w << " " << *vi << "\n";
+ for (std::string const& vi : this->WarnCMP0067) {
+ w << " " << vi << "\n";
}
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
}
@@ -963,10 +955,9 @@ void cmCoreTryCompile::FindOutputFile(const std::string& targetName,
#endif
searchDirs.push_back("/Development");
- for (std::vector<std::string>::const_iterator it = searchDirs.begin();
- it != searchDirs.end(); ++it) {
+ for (std::string const& sdir : searchDirs) {
std::string command = this->BinaryDirectory;
- command += *it;
+ command += sdir;
command += tmpOutputFile;
if (cmSystemTools::FileExists(command.c_str())) {
this->OutputFile = cmSystemTools::CollapseFullPath(command);
diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx
index 623c5e0..965f55b 100644
--- a/Source/cmCryptoHash.cxx
+++ b/Source/cmCryptoHash.cxx
@@ -103,10 +103,9 @@ std::string cmCryptoHash::ByteHashToString(
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
std::string res;
- for (std::vector<unsigned char>::const_iterator vit = hash.begin();
- vit != hash.end(); ++vit) {
- res.push_back(hex[(*vit) >> 4]);
- res.push_back(hex[(*vit) & 0xF]);
+ for (unsigned char v : hash) {
+ res.push_back(hex[v >> 4]);
+ res.push_back(hex[v & 0xF]);
}
return res;
}
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index fdc0a97..9e26cd2 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -24,12 +24,10 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
, GE(new cmGeneratorExpression(cc.GetBacktrace()))
{
const cmCustomCommandLines& cmdlines = this->CC.GetCommandLines();
- for (cmCustomCommandLines::const_iterator cmdline = cmdlines.begin();
- cmdline != cmdlines.end(); ++cmdline) {
+ for (cmCustomCommandLine const& cmdline : cmdlines) {
cmCustomCommandLine argv;
- for (cmCustomCommandLine::const_iterator clarg = cmdline->begin();
- clarg != cmdline->end(); ++clarg) {
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = this->GE->Parse(*clarg);
+ for (std::string const& clarg : cmdline) {
+ CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = this->GE->Parse(clarg);
std::string parsed_arg = cge->Evaluate(this->LG, this->Config);
if (this->CC.GetCommandExpandLists()) {
std::vector<std::string> ExpandedArg;
@@ -43,16 +41,14 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
}
std::vector<std::string> depends = this->CC.GetDepends();
- for (std::vector<std::string>::const_iterator i = depends.begin();
- i != depends.end(); ++i) {
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = this->GE->Parse(*i);
+ for (std::string const& d : depends) {
+ CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = this->GE->Parse(d);
std::vector<std::string> result;
cmSystemTools::ExpandListArgument(cge->Evaluate(this->LG, this->Config),
result);
- for (std::vector<std::string>::iterator it = result.begin();
- it != result.end(); ++it) {
- if (cmSystemTools::FileIsFullPath(it->c_str())) {
- *it = cmSystemTools::CollapseFullPath(*it);
+ for (std::string& it : result) {
+ if (cmSystemTools::FileIsFullPath(it.c_str())) {
+ it = cmSystemTools::CollapseFullPath(it);
}
}
this->Depends.insert(this->Depends.end(), result.begin(), result.end());
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 021f2e8..e766854 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -66,10 +66,9 @@ std::vector<std::string> cmDefinitions::UnusedKeys() const
std::vector<std::string> keys;
keys.reserve(this->Map.size());
// Consider local definitions.
- for (MapType::const_iterator mi = this->Map.begin(); mi != this->Map.end();
- ++mi) {
- if (!mi->second.Used) {
- keys.push_back(mi->first);
+ for (auto const& mi : this->Map) {
+ if (!mi.second.Used) {
+ keys.push_back(mi.first);
}
}
return keys;
@@ -81,15 +80,14 @@ cmDefinitions cmDefinitions::MakeClosure(StackIter begin, StackIter end)
std::set<std::string> undefined;
for (StackIter it = begin; it != end; ++it) {
// Consider local definitions.
- for (MapType::const_iterator mi = it->Map.begin(); mi != it->Map.end();
- ++mi) {
+ for (auto const& mi : it->Map) {
// Use this key if it is not already set or unset.
- if (closure.Map.find(mi->first) == closure.Map.end() &&
- undefined.find(mi->first) == undefined.end()) {
- if (mi->second.Exists) {
- closure.Map.insert(*mi);
+ if (closure.Map.find(mi.first) == closure.Map.end() &&
+ undefined.find(mi.first) == undefined.end()) {
+ if (mi.second.Exists) {
+ closure.Map.insert(mi);
} else {
- undefined.insert(mi->first);
+ undefined.insert(mi.first);
}
}
}
@@ -105,11 +103,10 @@ std::vector<std::string> cmDefinitions::ClosureKeys(StackIter begin,
for (StackIter it = begin; it != end; ++it) {
defined.reserve(defined.size() + it->Map.size());
- for (MapType::const_iterator mi = it->Map.begin(); mi != it->Map.end();
- ++mi) {
+ for (auto const& mi : it->Map) {
// Use this key if it is not already set or unset.
- if (bound.insert(mi->first).second && mi->second.Exists) {
- defined.push_back(mi->first);
+ if (bound.insert(mi.first).second && mi.second.Exists) {
+ defined.push_back(mi.first);
}
}
}
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index fc2bd0f..cdab671 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -53,12 +53,10 @@ bool cmDepends::Write(std::ostream& makeDepends, std::ostream& internalDepends)
std::string const& obj = *si++;
dependencies[obj].insert(src);
}
- for (std::map<std::string, std::set<std::string>>::const_iterator it =
- dependencies.begin();
- it != dependencies.end(); ++it) {
+ for (auto const& d : dependencies) {
// Write the dependencies for this pair.
- if (!this->WriteDependencies(it->second, it->first, makeDepends,
+ if (!this->WriteDependencies(d.second, d.first, makeDepends,
internalDepends)) {
return false;
}
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index 588a78c..1ab3fa2 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -110,12 +110,11 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
int srcFiles = static_cast<int>(sources.size());
this->Encountered.clear();
- for (std::set<std::string>::const_iterator srcIt = sources.begin();
- srcIt != sources.end(); ++srcIt) {
+ for (std::string const& src : sources) {
UnscannedEntry root;
- root.FileName = *srcIt;
+ root.FileName = src;
this->Unscanned.push(root);
- this->Encountered.insert(*srcIt);
+ this->Encountered.insert(src);
}
std::set<std::string> scanned;
@@ -150,14 +149,12 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
if (headerLocationIt != this->HeaderLocationCache.end()) {
fullName = headerLocationIt->second;
} else {
- for (std::vector<std::string>::const_iterator i =
- this->IncludePath.begin();
- i != this->IncludePath.end(); ++i) {
+ for (std::string const& i : this->IncludePath) {
// Construct the name of the file as if it were in the current
// include directory. Avoid using a leading "./".
tempPathStr =
- cmSystemTools::CollapseCombinedPath(*i, current.FileName);
+ cmSystemTools::CollapseCombinedPath(i, current.FileName);
// Look for the file in this location.
if (cmSystemTools::FileExists(tempPathStr.c_str(), true)) {
@@ -189,13 +186,11 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
if (fileIt != this->FileCache.end()) {
fileIt->second->Used = true;
dependencies.insert(fullName);
- for (std::vector<UnscannedEntry>::const_iterator incIt =
- fileIt->second->UnscannedEntries.begin();
- incIt != fileIt->second->UnscannedEntries.end(); ++incIt) {
- if (this->Encountered.find(incIt->FileName) ==
+ for (UnscannedEntry const& inc : fileIt->second->UnscannedEntries) {
+ if (this->Encountered.find(inc.FileName) ==
this->Encountered.end()) {
- this->Encountered.insert(incIt->FileName);
- this->Unscanned.push(*incIt);
+ this->Encountered.insert(inc.FileName);
+ this->Unscanned.push(inc);
}
}
} else {
@@ -234,14 +229,13 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i.c_str());
internalDepends << obj_i << std::endl;
- for (std::set<std::string>::const_iterator i = dependencies.begin();
- i != dependencies.end(); ++i) {
+ for (std::string const& dep : dependencies) {
makeDepends
<< obj_m << ": "
<< cmSystemTools::ConvertToOutputPath(
- this->LocalGenerator->ConvertToRelativePath(binDir, *i).c_str())
+ this->LocalGenerator->ConvertToRelativePath(binDir, dep).c_str())
<< std::endl;
- internalDepends << " " << *i << std::endl;
+ internalDepends << " " << dep << std::endl;
}
makeDepends << std::endl;
@@ -330,20 +324,16 @@ void cmDependsC::WriteCacheFile() const
cacheOut << this->IncludeRegexComplainString << "\n\n";
cacheOut << this->IncludeRegexTransformString << "\n\n";
- for (std::map<std::string, cmIncludeLines*>::const_iterator fileIt =
- this->FileCache.begin();
- fileIt != this->FileCache.end(); ++fileIt) {
- if (fileIt->second->Used) {
- cacheOut << fileIt->first << std::endl;
-
- for (std::vector<UnscannedEntry>::const_iterator incIt =
- fileIt->second->UnscannedEntries.begin();
- incIt != fileIt->second->UnscannedEntries.end(); ++incIt) {
- cacheOut << incIt->FileName << std::endl;
- if (incIt->QuotedLocation.empty()) {
+ for (auto const& fileIt : this->FileCache) {
+ if (fileIt.second->Used) {
+ cacheOut << fileIt.first << std::endl;
+
+ for (UnscannedEntry const& inc : fileIt.second->UnscannedEntries) {
+ cacheOut << inc.FileName << std::endl;
+ if (inc.QuotedLocation.empty()) {
cacheOut << "-" << std::endl;
} else {
- cacheOut << incIt->QuotedLocation << std::endl;
+ cacheOut << inc.QuotedLocation << std::endl;
}
}
cacheOut << std::endl;
@@ -411,9 +401,8 @@ void cmDependsC::SetupTransforms()
if (const char* xform = mf->GetDefinition("CMAKE_INCLUDE_TRANSFORMS")) {
cmSystemTools::ExpandListArgument(xform, transformRules, true);
}
- for (std::vector<std::string>::const_iterator tri = transformRules.begin();
- tri != transformRules.end(); ++tri) {
- this->ParseTransform(*tri);
+ for (std::string const& tr : transformRules) {
+ this->ParseTransform(tr);
}
this->IncludeRegexTransformString = INCLUDE_REGEX_TRANSFORM_MARKER;
@@ -422,10 +411,9 @@ void cmDependsC::SetupTransforms()
// transformed.
std::string xform = "^([ \t]*[#%][ \t]*(include|import)[ \t]*)(";
const char* sep = "";
- for (TransformRulesType::const_iterator tri = this->TransformRules.begin();
- tri != this->TransformRules.end(); ++tri) {
+ for (auto const& tr : this->TransformRules) {
xform += sep;
- xform += tri->first;
+ xform += tr.first;
sep = "|";
}
xform += ")[ \t]*\\(([^),]*)\\)";
@@ -434,12 +422,11 @@ void cmDependsC::SetupTransforms()
// Build a string that encodes all transformation rules and will
// change when rules are changed.
this->IncludeRegexTransformString += xform;
- for (TransformRulesType::const_iterator tri = this->TransformRules.begin();
- tri != this->TransformRules.end(); ++tri) {
+ for (auto const& tr : this->TransformRules) {
this->IncludeRegexTransformString += " ";
- this->IncludeRegexTransformString += tri->first;
+ this->IncludeRegexTransformString += tr.first;
this->IncludeRegexTransformString += "(%)=";
- this->IncludeRegexTransformString += tri->second;
+ this->IncludeRegexTransformString += tr.second;
}
}
}
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx
index e149a19..f209f3c 100644
--- a/Source/cmDependsFortran.cxx
+++ b/Source/cmDependsFortran.cxx
@@ -73,12 +73,10 @@ cmDependsFortran::cmDependsFortran(cmLocalGenerator* lg)
// translate i.e. FOO=BAR to FOO and add it to the list of defined
// preprocessor symbols
- for (std::vector<std::string>::const_iterator it = definitions.begin();
- it != definitions.end(); ++it) {
- std::string def = *it;
+ for (std::string def : definitions) {
std::string::size_type assignment = def.find('=');
if (assignment != std::string::npos) {
- def = it->substr(0, assignment);
+ def = def.substr(0, assignment);
}
this->PPDefinitions.insert(def);
}
@@ -105,9 +103,7 @@ bool cmDependsFortran::WriteDependencies(const std::set<std::string>& sources,
}
bool okay = true;
- for (std::set<std::string>::const_iterator it = sources.begin();
- it != sources.end(); ++it) {
- const std::string& src = *it;
+ for (std::string const& src : sources) {
// Get the information object for this source.
cmFortranSourceInfo& info =
this->Internal->CreateObjectInfo(obj.c_str(), src.c_str());
@@ -154,9 +150,8 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
// Actually write dependencies to the streams.
typedef cmDependsFortranInternals::ObjectInfoMap ObjectInfoMap;
ObjectInfoMap const& objInfo = this->Internal->ObjectInfo;
- for (ObjectInfoMap::const_iterator i = objInfo.begin(); i != objInfo.end();
- ++i) {
- if (!this->WriteDependenciesReal(i->first.c_str(), i->second, mod_dir,
+ for (auto const& i : objInfo) {
+ if (!this->WriteDependenciesReal(i.first.c_str(), i.second, mod_dir,
stamp_dir, makeDepends,
internalDepends)) {
return false;
@@ -170,9 +165,8 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
fiStream << "# The fortran modules provided by this target.\n";
fiStream << "provides\n";
std::set<std::string> const& provides = this->Internal->TargetProvides;
- for (std::set<std::string>::const_iterator i = provides.begin();
- i != provides.end(); ++i) {
- fiStream << " " << *i << "\n";
+ for (std::string const& i : provides) {
+ fiStream << " " << i << "\n";
}
// Create a script to clean the modules.
@@ -184,19 +178,18 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
fcStream << "FILE(REMOVE";
std::string currentBinDir =
this->LocalGenerator->GetCurrentBinaryDirectory();
- for (std::set<std::string>::const_iterator i = provides.begin();
- i != provides.end(); ++i) {
+ for (std::string const& i : provides) {
std::string mod_upper = mod_dir;
mod_upper += "/";
- mod_upper += cmSystemTools::UpperCase(*i);
+ mod_upper += cmSystemTools::UpperCase(i);
mod_upper += ".mod";
std::string mod_lower = mod_dir;
mod_lower += "/";
- mod_lower += *i;
+ mod_lower += i;
mod_lower += ".mod";
std::string stamp = stamp_dir;
stamp += "/";
- stamp += *i;
+ stamp += i;
stamp += ".mod.stamp";
fcStream << "\n";
fcStream << " \""
@@ -219,16 +212,14 @@ void cmDependsFortran::LocateModules()
// Collect the set of modules provided and required by all sources.
typedef cmDependsFortranInternals::ObjectInfoMap ObjectInfoMap;
ObjectInfoMap const& objInfo = this->Internal->ObjectInfo;
- for (ObjectInfoMap::const_iterator infoI = objInfo.begin();
- infoI != objInfo.end(); ++infoI) {
- cmFortranSourceInfo const& info = infoI->second;
+ for (auto const& infoI : objInfo) {
+ cmFortranSourceInfo const& info = infoI.second;
// Include this module in the set provided by this target.
this->Internal->TargetProvides.insert(info.Provides.begin(),
info.Provides.end());
- for (std::set<std::string>::const_iterator i = info.Requires.begin();
- i != info.Requires.end(); ++i) {
- this->Internal->TargetRequires[*i] = "";
+ for (std::string const& r : info.Requires) {
+ this->Internal->TargetRequires[r] = "";
}
}
@@ -247,9 +238,8 @@ void cmDependsFortran::LocateModules()
mf->GetDefinition("CMAKE_TARGET_LINKED_INFO_FILES")) {
cmSystemTools::ExpandListArgument(infoFilesValue, infoFiles);
}
- for (std::vector<std::string>::const_iterator i = infoFiles.begin();
- i != infoFiles.end(); ++i) {
- std::string targetDir = cmSystemTools::GetFilenamePath(*i);
+ for (std::string const& i : infoFiles) {
+ std::string targetDir = cmSystemTools::GetFilenamePath(i);
std::string fname = targetDir + "/fortran.internal";
cmsys::ifstream fin(fname.c_str());
if (fin) {
@@ -262,9 +252,8 @@ void cmDependsFortran::MatchLocalModules()
{
const char* stampDir = this->TargetDirectory.c_str();
std::set<std::string> const& provides = this->Internal->TargetProvides;
- for (std::set<std::string>::const_iterator i = provides.begin();
- i != provides.end(); ++i) {
- this->ConsiderModule(i->c_str(), stampDir);
+ for (std::string const& i : provides) {
+ this->ConsiderModule(i.c_str(), stampDir);
}
}
@@ -326,35 +315,32 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i.c_str());
internalDepends << obj_i << std::endl;
internalDepends << " " << src << std::endl;
- for (std::set<std::string>::const_iterator i = info.Includes.begin();
- i != info.Includes.end(); ++i) {
+ for (std::string const& i : info.Includes) {
makeDepends << obj_m << ": "
<< cmSystemTools::ConvertToOutputPath(
- this->MaybeConvertToRelativePath(binDir, *i).c_str())
+ this->MaybeConvertToRelativePath(binDir, i).c_str())
<< std::endl;
- internalDepends << " " << *i << std::endl;
+ internalDepends << " " << i << std::endl;
}
makeDepends << std::endl;
// Write module requirements to the output stream.
- for (std::set<std::string>::const_iterator i = info.Requires.begin();
- i != info.Requires.end(); ++i) {
+ for (std::string const& i : info.Requires) {
// Require only modules not provided in the same source.
- if (std::set<std::string>::const_iterator(info.Provides.find(*i)) !=
- info.Provides.end()) {
+ if (info.Provides.find(i) != info.Provides.cend()) {
continue;
}
// If the module is provided in this target special handling is
// needed.
- if (this->Internal->TargetProvides.find(*i) !=
+ if (this->Internal->TargetProvides.find(i) !=
this->Internal->TargetProvides.end()) {
// The module is provided by a different source in the same
// target. Add the proxy dependency to make sure the other
// source builds first.
std::string proxy = stamp_dir;
proxy += "/";
- proxy += *i;
+ proxy += i;
proxy += ".mod.proxy";
proxy = cmSystemTools::ConvertToOutputPath(
this->MaybeConvertToRelativePath(binDir, proxy).c_str());
@@ -366,7 +352,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
// The object file should depend on timestamped files for the
// modules it uses.
TargetRequiresMap::const_iterator required =
- this->Internal->TargetRequires.find(*i);
+ this->Internal->TargetRequires.find(i);
if (required == this->Internal->TargetRequires.end()) {
abort();
}
@@ -379,7 +365,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
// This module is not known to CMake. Try to locate it where
// the compiler will and depend on that.
std::string module;
- if (this->FindModule(*i, module)) {
+ if (this->FindModule(i, module)) {
module = cmSystemTools::ConvertToOutputPath(
this->MaybeConvertToRelativePath(binDir, module).c_str());
makeDepends << obj_m << ": " << module << "\n";
@@ -388,11 +374,10 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
}
// Write provided modules to the output stream.
- for (std::set<std::string>::const_iterator i = info.Provides.begin();
- i != info.Provides.end(); ++i) {
+ for (std::string const& i : info.Provides) {
std::string proxy = stamp_dir;
proxy += "/";
- proxy += *i;
+ proxy += i;
proxy += ".mod.proxy";
proxy = cmSystemTools::ConvertToOutputPath(
this->MaybeConvertToRelativePath(binDir, proxy).c_str());
@@ -404,18 +389,17 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
// Create a target to copy the module after the object file
// changes.
makeDepends << obj_m << ".provides.build:\n";
- for (std::set<std::string>::const_iterator i = info.Provides.begin();
- i != info.Provides.end(); ++i) {
+ for (std::string const& i : info.Provides) {
// Include this module in the set provided by this target.
- this->Internal->TargetProvides.insert(*i);
+ this->Internal->TargetProvides.insert(i);
// Always use lower case for the mod stamp file name. The
// cmake_copy_f90_mod will call back to this class, which will
// try various cases for the real mod file name.
- std::string m = cmSystemTools::LowerCase(*i);
+ std::string m = cmSystemTools::LowerCase(i);
std::string modFile = mod_dir;
modFile += "/";
- modFile += *i;
+ modFile += i;
modFile = this->LocalGenerator->ConvertToOutputFormat(
this->MaybeConvertToRelativePath(binDir, modFile),
cmOutputConverter::SHELL);
@@ -462,10 +446,9 @@ bool cmDependsFortran::FindModule(std::string const& name, std::string& module)
// Search the include path for the module.
std::string fullName;
- for (std::vector<std::string>::const_iterator i = this->IncludePath.begin();
- i != this->IncludePath.end(); ++i) {
+ for (std::string const& ip : this->IncludePath) {
// Try the lower-case name.
- fullName = *i;
+ fullName = ip;
fullName += "/";
fullName += mod_lower;
if (cmSystemTools::FileExists(fullName.c_str(), true)) {
@@ -474,7 +457,7 @@ bool cmDependsFortran::FindModule(std::string const& name, std::string& module)
}
// Try the upper-case name.
- fullName = *i;
+ fullName = ip;
fullName += "/";
fullName += mod_upper;
if (cmSystemTools::FileExists(fullName.c_str(), true)) {
diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx
index 3a57a38..85dfc7d 100644
--- a/Source/cmDependsJavaParserHelper.cxx
+++ b/Source/cmDependsJavaParserHelper.cxx
@@ -40,10 +40,8 @@ void cmDependsJavaParserHelper::CurrentClass::AddFileNamesForPrinting(
}
rname += this->Name;
files->push_back(rname);
- std::vector<CurrentClass>::const_iterator it;
- for (it = this->NestedClasses.begin(); it != this->NestedClasses.end();
- ++it) {
- it->AddFileNamesForPrinting(files, rname.c_str(), sep);
+ for (CurrentClass const& nc : this->NestedClasses) {
+ nc.AddFileNamesForPrinting(files, rname.c_str(), sep);
}
}
@@ -64,9 +62,8 @@ void cmDependsJavaParserHelper::AddClassFound(const char* sclass)
if (!sclass) {
return;
}
- std::vector<std::string>::iterator it;
- for (it = this->ClassesFound.begin(); it != this->ClassesFound.end(); it++) {
- if (*it == sclass) {
+ for (std::string const& cf : this->ClassesFound) {
+ if (cf == sclass) {
return;
}
}
@@ -75,10 +72,8 @@ void cmDependsJavaParserHelper::AddClassFound(const char* sclass)
void cmDependsJavaParserHelper::AddPackagesImport(const char* sclass)
{
- std::vector<std::string>::iterator it;
- for (it = this->PackagesImport.begin(); it != this->PackagesImport.end();
- it++) {
- if (*it == sclass) {
+ for (std::string const& pi : this->PackagesImport) {
+ if (pi == sclass) {
return;
}
}
@@ -208,10 +203,8 @@ void cmDependsJavaParserHelper::PrintClasses()
std::cerr << "Error when parsing. No classes on class stack" << std::endl;
abort();
}
- std::vector<std::string> files = this->GetFilesProduced();
- std::vector<std::string>::iterator sit;
- for (sit = files.begin(); sit != files.end(); ++sit) {
- std::cout << " " << *sit << ".class" << std::endl;
+ for (std::string const& f : this->GetFilesProduced()) {
+ std::cout << " " << f << ".class" << std::endl;
}
}
@@ -219,10 +212,8 @@ std::vector<std::string> cmDependsJavaParserHelper::GetFilesProduced()
{
std::vector<std::string> files;
CurrentClass const& toplevel = this->ClassStack.front();
- std::vector<CurrentClass>::const_iterator it;
- for (it = toplevel.NestedClasses.begin(); it != toplevel.NestedClasses.end();
- ++it) {
- it->AddFileNamesForPrinting(&files, nullptr, "$");
+ for (CurrentClass const& nc : toplevel.NestedClasses) {
+ nc.AddFileNamesForPrinting(&files, nullptr, "$");
}
return files;
}
@@ -262,10 +253,8 @@ int cmDependsJavaParserHelper::ParseString(const char* str, int verb)
std::cout << std::endl;
std::cout << "Depends on:";
if (!this->ClassesFound.empty()) {
- std::vector<std::string>::iterator it;
- for (it = this->ClassesFound.begin(); it != this->ClassesFound.end();
- ++it) {
- std::cout << " " << *it;
+ for (std::string const& cf : this->ClassesFound) {
+ std::cout << " " << cf;
}
}
std::cout << std::endl;
@@ -282,9 +271,8 @@ int cmDependsJavaParserHelper::ParseString(const char* str, int verb)
void cmDependsJavaParserHelper::CleanupParser()
{
- std::vector<char*>::iterator it;
- for (it = this->Allocates.begin(); it != this->Allocates.end(); ++it) {
- delete[] * it;
+ for (char* allocate : this->Allocates) {
+ delete[] allocate;
}
this->Allocates.erase(this->Allocates.begin(), this->Allocates.end());
}
diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx
index 4af44b4..0c96860 100644
--- a/Source/cmDocumentation.cxx
+++ b/Source/cmDocumentation.cxx
@@ -123,23 +123,21 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os)
bool result = true;
// Loop over requested documentation types.
- for (std::vector<RequestedHelpItem>::const_iterator i =
- this->RequestedHelpItems.begin();
- i != this->RequestedHelpItems.end(); ++i) {
- this->CurrentArgument = i->Argument;
+ for (RequestedHelpItem const& rhi : this->RequestedHelpItems) {
+ this->CurrentArgument = rhi.Argument;
// If a file name was given, use it. Otherwise, default to the
// given stream.
cmsys::ofstream fout;
std::ostream* s = &os;
- if (!i->Filename.empty()) {
- fout.open(i->Filename.c_str());
+ if (!rhi.Filename.empty()) {
+ fout.open(rhi.Filename.c_str());
s = &fout;
} else if (++count > 1) {
os << "\n\n";
}
// Print this documentation type to the stream.
- if (!this->PrintDocumentation(i->HelpType, *s) || s->fail()) {
+ if (!this->PrintDocumentation(rhi.HelpType, *s) || s->fail()) {
result = false;
}
}
@@ -394,10 +392,8 @@ void cmDocumentation::SetSection(const char* name, const char* docs[][2])
void cmDocumentation::SetSections(
std::map<std::string, cmDocumentationSection*>& sections)
{
- for (std::map<std::string, cmDocumentationSection*>::const_iterator it =
- sections.begin();
- it != sections.end(); ++it) {
- this->SetSection(it->first.c_str(), it->second);
+ for (auto const& s : sections) {
+ this->SetSection(s.first.c_str(), s.second);
}
}
@@ -489,10 +485,9 @@ void cmDocumentation::PrintNames(std::ostream& os, std::string const& pattern)
std::vector<std::string> files;
this->GlobHelp(files, pattern);
std::vector<std::string> names;
- for (std::vector<std::string>::const_iterator i = files.begin();
- i != files.end(); ++i) {
+ for (std::string const& f : files) {
std::string line;
- cmsys::ifstream fin(i->c_str());
+ cmsys::ifstream fin(f.c_str());
while (fin && cmSystemTools::GetLineFromStream(fin, line)) {
if (!line.empty() && (isalnum(line[0]) || line[0] == '<')) {
names.push_back(line);
@@ -501,9 +496,8 @@ void cmDocumentation::PrintNames(std::ostream& os, std::string const& pattern)
}
}
std::sort(names.begin(), names.end());
- for (std::vector<std::string>::iterator i = names.begin(); i != names.end();
- ++i) {
- os << *i << "\n";
+ for (std::string const& n : names) {
+ os << n << "\n";
}
}
@@ -514,9 +508,8 @@ bool cmDocumentation::PrintFiles(std::ostream& os, std::string const& pattern)
this->GlobHelp(files, pattern);
std::sort(files.begin(), files.end());
cmRST r(os, cmSystemTools::GetCMakeRoot() + "/Help");
- for (std::vector<std::string>::const_iterator i = files.begin();
- i != files.end(); ++i) {
- found = r.ProcessFile(*i) || found;
+ for (std::string const& f : files) {
+ found = r.ProcessFile(f) || found;
}
return found;
}
@@ -586,15 +579,13 @@ bool cmDocumentation::PrintHelpListModules(std::ostream& os)
std::vector<std::string> files;
this->GlobHelp(files, "module/*");
std::vector<std::string> modules;
- for (std::vector<std::string>::iterator fi = files.begin();
- fi != files.end(); ++fi) {
- std::string module = cmSystemTools::GetFilenameName(*fi);
+ for (std::string const& f : files) {
+ std::string module = cmSystemTools::GetFilenameName(f);
modules.push_back(module.substr(0, module.size() - 4));
}
std::sort(modules.begin(), modules.end());
- for (std::vector<std::string>::iterator i = modules.begin();
- i != modules.end(); ++i) {
- os << *i << "\n";
+ for (std::string const& m : modules) {
+ os << m << "\n";
}
return true;
}
diff --git a/Source/cmDocumentationFormatter.cxx b/Source/cmDocumentationFormatter.cxx
index 0018263..6b996e4 100644
--- a/Source/cmDocumentationFormatter.cxx
+++ b/Source/cmDocumentationFormatter.cxx
@@ -168,26 +168,25 @@ void cmDocumentationFormatter::PrintSection(
os << section.GetName() << "\n";
const std::vector<cmDocumentationEntry>& entries = section.GetEntries();
- for (std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
- op != entries.end(); ++op) {
- if (!op->Name.empty()) {
- os << " " << op->Name;
+ for (cmDocumentationEntry const& entry : entries) {
+ if (!entry.Name.empty()) {
+ os << " " << entry.Name;
this->TextIndent = " ";
int align = static_cast<int>(strlen(this->TextIndent)) - 4;
- for (int i = static_cast<int>(op->Name.size()); i < align; ++i) {
+ for (int i = static_cast<int>(entry.Name.size()); i < align; ++i) {
os << " ";
}
- if (op->Name.size() > strlen(this->TextIndent) - 4) {
+ if (entry.Name.size() > strlen(this->TextIndent) - 4) {
os << "\n";
os.write(this->TextIndent, strlen(this->TextIndent) - 2);
}
os << "= ";
- this->PrintColumn(os, op->Brief.c_str());
+ this->PrintColumn(os, entry.Brief.c_str());
os << "\n";
} else {
os << "\n";
this->TextIndent = "";
- this->PrintFormatted(os, op->Brief.c_str());
+ this->PrintFormatted(os, entry.Brief.c_str());
}
}
os << "\n";
diff --git a/Source/cmDynamicLoader.cxx b/Source/cmDynamicLoader.cxx
index 2fe0360..7da6ff5 100644
--- a/Source/cmDynamicLoader.cxx
+++ b/Source/cmDynamicLoader.cxx
@@ -65,10 +65,8 @@ bool cmDynamicLoaderCache::FlushCache(const char* path)
void cmDynamicLoaderCache::FlushCache()
{
- for (std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator
- it = this->CacheMap.begin();
- it != this->CacheMap.end(); it++) {
- cmsys::DynamicLoader::CloseLibrary(it->second);
+ for (auto const& it : this->CacheMap) {
+ cmsys::DynamicLoader::CloseLibrary(it.second);
}
delete cmDynamicLoaderCache::Instance;
cmDynamicLoaderCache::Instance = nullptr;
diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx
index e2655e7..62d875c 100644
--- a/Source/cmELF.cxx
+++ b/Source/cmELF.cxx
@@ -547,10 +547,7 @@ cmELF::DynamicEntryList cmELFInternalImpl<Types>::GetDynamicEntries()
// Copy into public array
result.reserve(this->DynamicSectionEntries.size());
- for (typename std::vector<ELF_Dyn>::iterator di =
- this->DynamicSectionEntries.begin();
- di != this->DynamicSectionEntries.end(); ++di) {
- ELF_Dyn& dyn = *di;
+ for (ELF_Dyn& dyn : this->DynamicSectionEntries) {
result.push_back(
std::pair<unsigned long, unsigned long>(dyn.d_tag, dyn.d_un.d_val));
}
@@ -565,12 +562,11 @@ std::vector<char> cmELFInternalImpl<Types>::EncodeDynamicEntries(
std::vector<char> result;
result.reserve(sizeof(ELF_Dyn) * entries.size());
- for (cmELF::DynamicEntryList::const_iterator it = entries.begin();
- it != entries.end(); it++) {
+ for (auto const& entry : entries) {
// Store the entry in an ELF_Dyn, byteswap it, then serialize to chars
ELF_Dyn dyn;
- dyn.d_tag = static_cast<tagtype>(it->first);
- dyn.d_un.d_val = static_cast<tagtype>(it->second);
+ dyn.d_tag = static_cast<tagtype>(entry.first);
+ dyn.d_un.d_val = static_cast<tagtype>(entry.second);
if (this->NeedSwap) {
ByteSwap(dyn);
diff --git a/Source/cmEnableLanguageCommand.cxx b/Source/cmEnableLanguageCommand.cxx
index c57b7b1..ddd26de 100644
--- a/Source/cmEnableLanguageCommand.cxx
+++ b/Source/cmEnableLanguageCommand.cxx
@@ -16,12 +16,11 @@ bool cmEnableLanguageCommand::InitialPass(std::vector<std::string> const& args,
this->SetError("called with incorrect number of arguments");
return false;
}
- for (std::vector<std::string>::const_iterator it = args.begin();
- it != args.end(); ++it) {
- if ((*it) == "OPTIONAL") {
+ for (std::string const& it : args) {
+ if (it == "OPTIONAL") {
optional = true;
} else {
- languages.push_back(*it);
+ languages.push_back(it);
}
}
diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx
index 3c39816..88e085d 100644
--- a/Source/cmExecProgramCommand.cxx
+++ b/Source/cmExecProgramCommand.cxx
@@ -26,8 +26,8 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args,
bool haveoutput_variable = false;
std::string return_variable;
bool havereturn_variable = false;
- for (size_t i = 0; i < args.size(); ++i) {
- if (args[i] == "OUTPUT_VARIABLE") {
+ for (std::string const& arg : args) {
+ if (arg == "OUTPUT_VARIABLE") {
count++;
doingargs = false;
havereturn_variable = false;
@@ -37,10 +37,10 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args,
this->SetError("called with incorrect number of arguments");
return false;
}
- output_variable = args[i];
+ output_variable = arg;
haveoutput_variable = false;
count++;
- } else if (args[i] == "RETURN_VALUE") {
+ } else if (arg == "RETURN_VALUE") {
count++;
doingargs = false;
haveoutput_variable = false;
@@ -50,16 +50,16 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args,
this->SetError("called with incorrect number of arguments");
return false;
}
- return_variable = args[i];
+ return_variable = arg;
havereturn_variable = false;
count++;
- } else if (args[i] == "ARGS") {
+ } else if (arg == "ARGS") {
count++;
havereturn_variable = false;
haveoutput_variable = false;
doingargs = true;
} else if (doingargs) {
- arguments += args[i];
+ arguments += arg;
arguments += " ";
count++;
}
diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx
index 22246b2..39e774e 100644
--- a/Source/cmExecuteProcessCommand.cxx
+++ b/Source/cmExecuteProcessCommand.cxx
@@ -170,13 +170,13 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args,
this->SetError(" called with no COMMAND argument.");
return false;
}
- for (unsigned int i = 0; i < cmds.size(); ++i) {
- if (cmds[i].empty()) {
+ for (auto& cmd : cmds) {
+ if (cmd.empty()) {
this->SetError(" given COMMAND argument with no value.");
return false;
}
// Add the null terminating pointer to the command argument list.
- cmds[i].push_back(nullptr);
+ cmd.push_back(nullptr);
}
// Parse the timeout string.
@@ -192,8 +192,8 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args,
cmsysProcess* cp = cmsysProcess_New();
// Set the command sequence.
- for (unsigned int i = 0; i < cmds.size(); ++i) {
- cmsysProcess_AddCommand(cp, &*cmds[i].begin());
+ for (auto const& cmd : cmds) {
+ cmsysProcess_AddCommand(cp, &*cmd.begin());
}
// Set the process working directory.
diff --git a/Source/cmExportBuildAndroidMKGenerator.cxx b/Source/cmExportBuildAndroidMKGenerator.cxx
index 8662e8a..b5b7214 100644
--- a/Source/cmExportBuildAndroidMKGenerator.cxx
+++ b/Source/cmExportBuildAndroidMKGenerator.cxx
@@ -3,7 +3,6 @@
#include "cmExportBuildAndroidMKGenerator.h"
#include <algorithm>
-#include <map>
#include <sstream>
#include <utility>
@@ -98,43 +97,41 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties(
}
if (!properties.empty()) {
os << "LOCAL_CPP_FEATURES := rtti exceptions\n";
- for (ImportPropertyMap::const_iterator pi = properties.begin();
- pi != properties.end(); ++pi) {
- if (pi->first == "INTERFACE_COMPILE_OPTIONS") {
+ for (auto const& property : properties) {
+ if (property.first == "INTERFACE_COMPILE_OPTIONS") {
os << "LOCAL_CPP_FEATURES += ";
- os << (pi->second) << "\n";
- } else if (pi->first == "INTERFACE_LINK_LIBRARIES") {
+ os << (property.second) << "\n";
+ } else if (property.first == "INTERFACE_LINK_LIBRARIES") {
// need to look at list in pi->second and see if static or shared
// FindTargetToLink
// target->GetLocalGenerator()->FindGeneratorTargetToUse()
// then add to LOCAL_CPPFLAGS
std::vector<std::string> libraries;
- cmSystemTools::ExpandListArgument(pi->second, libraries);
+ cmSystemTools::ExpandListArgument(property.second, libraries);
std::string staticLibs;
std::string sharedLibs;
std::string ldlibs;
- for (std::vector<std::string>::iterator i = libraries.begin();
- i != libraries.end(); ++i) {
+ for (std::string const& lib : libraries) {
cmGeneratorTarget* gt =
- target->GetLocalGenerator()->FindGeneratorTargetToUse(*i);
+ target->GetLocalGenerator()->FindGeneratorTargetToUse(lib);
if (gt) {
if (gt->GetType() == cmStateEnums::SHARED_LIBRARY ||
gt->GetType() == cmStateEnums::MODULE_LIBRARY) {
- sharedLibs += " " + *i;
+ sharedLibs += " " + lib;
} else {
- staticLibs += " " + *i;
+ staticLibs += " " + lib;
}
} else {
// evaluate any generator expressions with the current
// build type of the makefile
cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(*i);
+ CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(lib);
std::string evaluated =
cge->Evaluate(target->GetLocalGenerator(), config);
bool relpath = false;
if (type == cmExportBuildAndroidMKGenerator::INSTALL) {
- relpath = i->substr(0, 3) == "../";
+ relpath = lib.substr(0, 3) == "../";
}
// check for full path or if it already has a -l, or
// in the case of an install check for relative paths
@@ -157,20 +154,19 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties(
if (!ldlibs.empty()) {
os << "LOCAL_EXPORT_LDLIBS :=" << ldlibs << "\n";
}
- } else if (pi->first == "INTERFACE_INCLUDE_DIRECTORIES") {
- std::string includes = pi->second;
+ } else if (property.first == "INTERFACE_INCLUDE_DIRECTORIES") {
+ std::string includes = property.second;
std::vector<std::string> includeList;
cmSystemTools::ExpandListArgument(includes, includeList);
os << "LOCAL_EXPORT_C_INCLUDES := ";
std::string end;
- for (std::vector<std::string>::iterator i = includeList.begin();
- i != includeList.end(); ++i) {
- os << end << *i;
+ for (std::string const& i : includeList) {
+ os << end << i;
end = "\\\n";
}
os << "\n";
} else {
- os << "# " << pi->first << " " << (pi->second) << "\n";
+ os << "# " << property.first << " " << (property.second) << "\n";
}
}
}
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index 6e182b7..bb1dda3 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -45,9 +45,8 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
std::string sep;
std::vector<std::string> targets;
this->GetTargets(targets);
- for (std::vector<std::string>::const_iterator tei = targets.begin();
- tei != targets.end(); ++tei) {
- cmGeneratorTarget* te = this->LG->FindGeneratorTargetToUse(*tei);
+ for (std::string const& tei : targets) {
+ cmGeneratorTarget* te = this->LG->FindGeneratorTargetToUse(tei);
expectedTargets += sep + this->Namespace + te->GetExportName();
sep = " ";
if (this->ExportedTargets.insert(te).second) {
@@ -71,10 +70,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
std::vector<std::string> missingTargets;
// Create all the imported targets.
- for (std::vector<cmGeneratorTarget*>::const_iterator tei =
- this->Exports.begin();
- tei != this->Exports.end(); ++tei) {
- cmGeneratorTarget* gte = *tei;
+ for (cmGeneratorTarget* gte : this->Exports) {
this->GenerateImportTargetCode(os, gte);
gte->Target->AppendBuildInterfaceIncludes();
@@ -115,10 +111,8 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
}
// Generate import file content for each configuration.
- for (std::vector<std::string>::const_iterator ci =
- this->Configurations.begin();
- ci != this->Configurations.end(); ++ci) {
- this->GenerateImportConfig(os, *ci, missingTargets);
+ for (std::string const& c : this->Configurations) {
+ this->GenerateImportConfig(os, c, missingTargets);
}
this->GenerateMissingTargetsCheckCode(os, missingTargets);
@@ -130,11 +124,8 @@ void cmExportBuildFileGenerator::GenerateImportTargetsConfig(
std::ostream& os, const std::string& config, std::string const& suffix,
std::vector<std::string>& missingTargets)
{
- for (std::vector<cmGeneratorTarget*>::const_iterator tei =
- this->Exports.begin();
- tei != this->Exports.end(); ++tei) {
+ for (cmGeneratorTarget* target : this->Exports) {
// Collect import properties for this target.
- cmGeneratorTarget* target = *tei;
ImportPropertyMap properties;
if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
@@ -184,10 +175,8 @@ void cmExportBuildFileGenerator::SetImportLocationProperty(
target->GetObjectSources(objectSources, config);
std::string const obj_dir = target->GetObjectDirectory(config);
std::vector<std::string> objects;
- for (std::vector<cmSourceFile const*>::const_iterator si =
- objectSources.begin();
- si != objectSources.end(); ++si) {
- const std::string& obj = target->GetObjectName(*si);
+ for (cmSourceFile const* sf : objectSources) {
+ const std::string& obj = target->GetObjectName(sf);
objects.push_back(obj_dir + obj);
}
@@ -256,10 +245,8 @@ void cmExportBuildFileGenerator::GetTargets(
std::vector<std::string>& targets) const
{
if (this->ExportSet) {
- for (std::vector<cmTargetExport*>::const_iterator tei =
- this->ExportSet->GetTargetExports()->begin();
- tei != this->ExportSet->GetTargetExports()->end(); ++tei) {
- targets.push_back((*tei)->TargetName);
+ for (cmTargetExport* te : *this->ExportSet->GetTargetExports()) {
+ targets.push_back(te->TargetName);
}
return;
}
@@ -274,10 +261,8 @@ std::vector<std::string> cmExportBuildFileGenerator::FindNamespaces(
std::map<std::string, cmExportBuildFileGenerator*>& exportSets =
gg->GetBuildExportSets();
- for (std::map<std::string, cmExportBuildFileGenerator*>::const_iterator
- expIt = exportSets.begin();
- expIt != exportSets.end(); ++expIt) {
- const cmExportBuildFileGenerator* exportSet = expIt->second;
+ for (auto const& exp : exportSets) {
+ const cmExportBuildFileGenerator* exportSet = exp.second;
std::vector<std::string> targets;
exportSet->GetTargets(targets);
if (std::find(targets.begin(), targets.end(), name) != targets.end()) {
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index 64baa90..9913129 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -136,42 +136,40 @@ bool cmExportCommand::InitialPass(std::vector<std::string> const& args,
}
this->ExportSet = setMap[setName];
} else if (this->Targets.WasFound()) {
- for (std::vector<std::string>::const_iterator currentTarget =
- this->Targets.GetVector().begin();
- currentTarget != this->Targets.GetVector().end(); ++currentTarget) {
- if (this->Makefile->IsAlias(*currentTarget)) {
+ for (std::string const& currentTarget : this->Targets.GetVector()) {
+ if (this->Makefile->IsAlias(currentTarget)) {
std::ostringstream e;
- e << "given ALIAS target \"" << *currentTarget
+ e << "given ALIAS target \"" << currentTarget
<< "\" which may not be exported.";
this->SetError(e.str());
return false;
}
- if (cmTarget* target = gg->FindTarget(*currentTarget)) {
+ if (cmTarget* target = gg->FindTarget(currentTarget)) {
if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
std::string reason;
if (!this->Makefile->GetGlobalGenerator()
->HasKnownObjectFileLocation(&reason)) {
std::ostringstream e;
- e << "given OBJECT library \"" << *currentTarget
+ e << "given OBJECT library \"" << currentTarget
<< "\" which may not be exported" << reason << ".";
this->SetError(e.str());
return false;
}
}
if (target->GetType() == cmStateEnums::UTILITY) {
- this->SetError("given custom target \"" + *currentTarget +
+ this->SetError("given custom target \"" + currentTarget +
"\" which may not be exported.");
return false;
}
} else {
std::ostringstream e;
- e << "given target \"" << *currentTarget
+ e << "given target \"" << currentTarget
<< "\" which is not built by this project.";
this->SetError(e.str());
return false;
}
- targets.push_back(*currentTarget);
+ targets.push_back(currentTarget);
}
if (this->Append.IsEnabled()) {
if (cmExportBuildFileGenerator* ebfg =
@@ -209,10 +207,8 @@ bool cmExportCommand::InitialPass(std::vector<std::string> const& args,
if (configurationTypes.empty()) {
configurationTypes.push_back("");
}
- for (std::vector<std::string>::const_iterator ci =
- configurationTypes.begin();
- ci != configurationTypes.end(); ++ci) {
- ebfg->AddConfiguration(*ci);
+ for (std::string const& ct : configurationTypes) {
+ ebfg->AddConfiguration(ct);
}
if (this->ExportSet) {
gg->AddBuildExportExportSet(ebfg);
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 972f4b9..52f0e27 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -206,9 +206,8 @@ static bool checkInterfaceDirs(const std::string& prepro,
bool hadFatalError = false;
- for (std::vector<std::string>::iterator li = parts.begin();
- li != parts.end(); ++li) {
- size_t genexPos = cmGeneratorExpression::Find(*li);
+ for (std::string const& li : parts) {
+ size_t genexPos = cmGeneratorExpression::Find(li);
if (genexPos == 0) {
continue;
}
@@ -233,20 +232,20 @@ static bool checkInterfaceDirs(const std::string& prepro,
hadFatalError = true;
}
}
- if (cmHasLiteralPrefix(li->c_str(), "${_IMPORT_PREFIX}")) {
+ if (cmHasLiteralPrefix(li.c_str(), "${_IMPORT_PREFIX}")) {
continue;
}
- if (!cmSystemTools::FileIsFullPath(li->c_str())) {
+ if (!cmSystemTools::FileIsFullPath(li.c_str())) {
/* clang-format off */
e << "Target \"" << target->GetName() << "\" " << prop <<
" property contains relative path:\n"
- " \"" << *li << "\"";
+ " \"" << li << "\"";
/* clang-format on */
target->GetLocalGenerator()->IssueMessage(messageType, e.str());
}
- bool inBinary = isSubDirectory(li->c_str(), topBinaryDir);
- bool inSource = isSubDirectory(li->c_str(), topSourceDir);
- if (isSubDirectory(li->c_str(), installDir)) {
+ bool inBinary = isSubDirectory(li.c_str(), topBinaryDir);
+ bool inSource = isSubDirectory(li.c_str(), topSourceDir);
+ if (isSubDirectory(li.c_str(), installDir)) {
// The include directory is inside the install tree. If the
// install tree is not inside the source tree or build tree then
// fall through to the checks below that the include directory is not
@@ -261,7 +260,7 @@ static bool checkInterfaceDirs(const std::string& prepro,
case cmPolicies::WARN: {
std::ostringstream s;
s << cmPolicies::GetPolicyWarning(cmPolicies::CMP0052) << "\n";
- s << "Directory:\n \"" << *li
+ s << "Directory:\n \"" << li
<< "\"\nin "
"INTERFACE_INCLUDE_DIRECTORIES of target \""
<< target->GetName() << "\" is a subdirectory of the install "
@@ -293,7 +292,7 @@ static bool checkInterfaceDirs(const std::string& prepro,
/* clang-format off */
e << "Target \"" << target->GetName() << "\" " << prop <<
" property contains path:\n"
- " \"" << *li << "\"\nwhich is prefixed in the build directory.";
+ " \"" << li << "\"\nwhich is prefixed in the build directory.";
/* clang-format on */
target->GetLocalGenerator()->IssueMessage(messageType, e.str());
}
@@ -302,7 +301,7 @@ static bool checkInterfaceDirs(const std::string& prepro,
e << "Target \"" << target->GetName() << "\" " << prop
<< " property contains path:\n"
" \""
- << *li << "\"\nwhich is prefixed in the source directory.";
+ << li << "\"\nwhich is prefixed in the source directory.";
target->GetLocalGenerator()->IssueMessage(messageType, e.str());
}
}
@@ -316,15 +315,14 @@ static void prefixItems(std::string& exportDirs)
cmGeneratorExpression::Split(exportDirs, entries);
exportDirs = "";
const char* sep = "";
- for (std::vector<std::string>::const_iterator ei = entries.begin();
- ei != entries.end(); ++ei) {
+ for (std::string const& e : entries) {
exportDirs += sep;
sep = ";";
- if (!cmSystemTools::FileIsFullPath(ei->c_str()) &&
- ei->find("${_IMPORT_PREFIX}") == std::string::npos) {
+ if (!cmSystemTools::FileIsFullPath(e.c_str()) &&
+ e.find("${_IMPORT_PREFIX}") == std::string::npos) {
exportDirs += "${_IMPORT_PREFIX}/";
}
- exportDirs += *ei;
+ exportDirs += e;
}
}
@@ -461,18 +459,17 @@ void getCompatibleInterfaceProperties(cmGeneratorTarget* target,
const cmComputeLinkInformation::ItemVector& deps = info->GetItems();
- for (cmComputeLinkInformation::ItemVector::const_iterator li = deps.begin();
- li != deps.end(); ++li) {
- if (!li->Target) {
+ for (auto const& dep : deps) {
+ if (!dep.Target) {
continue;
}
- getPropertyContents(li->Target, "COMPATIBLE_INTERFACE_BOOL",
+ getPropertyContents(dep.Target, "COMPATIBLE_INTERFACE_BOOL",
ifaceProperties);
- getPropertyContents(li->Target, "COMPATIBLE_INTERFACE_STRING",
+ getPropertyContents(dep.Target, "COMPATIBLE_INTERFACE_STRING",
ifaceProperties);
- getPropertyContents(li->Target, "COMPATIBLE_INTERFACE_NUMBER_MIN",
+ getPropertyContents(dep.Target, "COMPATIBLE_INTERFACE_NUMBER_MIN",
ifaceProperties);
- getPropertyContents(li->Target, "COMPATIBLE_INTERFACE_NUMBER_MAX",
+ getPropertyContents(dep.Target, "COMPATIBLE_INTERFACE_NUMBER_MAX",
ifaceProperties);
}
}
@@ -504,15 +501,13 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties(
std::vector<std::string> configNames;
gtarget->Target->GetMakefile()->GetConfigurations(configNames);
- for (std::vector<std::string>::const_iterator ci = configNames.begin();
- ci != configNames.end(); ++ci) {
- getCompatibleInterfaceProperties(gtarget, ifaceProperties, *ci);
+ for (std::string const& cn : configNames) {
+ getCompatibleInterfaceProperties(gtarget, ifaceProperties, cn);
}
}
- for (std::set<std::string>::const_iterator it = ifaceProperties.begin();
- it != ifaceProperties.end(); ++it) {
- this->PopulateInterfaceProperty("INTERFACE_" + *it, gtarget, properties);
+ for (std::string const& ip : ifaceProperties) {
+ this->PopulateInterfaceProperty("INTERFACE_" + ip, gtarget, properties);
}
}
@@ -524,10 +519,9 @@ void cmExportFileGenerator::GenerateInterfaceProperties(
std::string targetName = this->Namespace;
targetName += target->GetExportName();
os << "set_target_properties(" << targetName << " PROPERTIES\n";
- for (ImportPropertyMap::const_iterator pi = properties.begin();
- pi != properties.end(); ++pi) {
- os << " " << pi->first << " " << cmExportFileGeneratorEscape(pi->second)
- << "\n";
+ for (auto const& property : properties) {
+ os << " " << property.first << " "
+ << cmExportFileGeneratorEscape(property.second) << "\n";
}
os << ")\n\n";
}
@@ -572,14 +566,13 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
std::string sep;
input = "";
- for (std::vector<std::string>::iterator li = parts.begin();
- li != parts.end(); ++li) {
- if (cmGeneratorExpression::Find(*li) == std::string::npos) {
- this->AddTargetNamespace(*li, target, missingTargets);
+ for (std::string& li : parts) {
+ if (cmGeneratorExpression::Find(li) == std::string::npos) {
+ this->AddTargetNamespace(li, target, missingTargets);
} else {
- this->ResolveTargetsInGeneratorExpression(*li, target, missingTargets);
+ this->ResolveTargetsInGeneratorExpression(li, target, missingTargets);
}
- input += sep + *li;
+ input += sep + li;
sep = ";";
}
}
@@ -797,13 +790,12 @@ void cmExportFileGenerator::SetImportLinkProperty(
// Construct the property value.
std::string link_entries;
const char* sep = "";
- for (typename std::vector<T>::const_iterator li = entries.begin();
- li != entries.end(); ++li) {
+ for (T const& l : entries) {
// Separate this from the previous entry.
link_entries += sep;
sep = ";";
- std::string temp = *li;
+ std::string temp = l;
this->AddTargetNamespace(temp, target, missingTargets);
link_entries += temp;
}
@@ -988,10 +980,9 @@ void cmExportFileGenerator::GenerateImportPropertyCode(
}
os << ")\n";
os << "set_target_properties(" << targetName << " PROPERTIES\n";
- for (ImportPropertyMap::const_iterator pi = properties.begin();
- pi != properties.end(); ++pi) {
- os << " " << pi->first << " " << cmExportFileGeneratorEscape(pi->second)
- << "\n";
+ for (auto const& property : properties) {
+ os << " " << property.first << " "
+ << cmExportFileGeneratorEscape(property.second) << "\n";
}
os << " )\n"
<< "\n";
@@ -1015,9 +1006,9 @@ void cmExportFileGenerator::GenerateMissingTargetsCheckCode(
"foreach(_target ";
/* clang-format on */
std::set<std::string> emitted;
- for (unsigned int i = 0; i < missingTargets.size(); ++i) {
- if (emitted.insert(missingTargets[i]).second) {
- os << "\"" << missingTargets[i] << "\" ";
+ for (std::string const& missingTarget : missingTargets) {
+ if (emitted.insert(missingTarget).second) {
+ os << "\"" << missingTarget << "\" ";
}
}
/* clang-format off */
@@ -1094,9 +1085,8 @@ void cmExportFileGenerator::GenerateImportedFileChecksCode(
"list(APPEND _IMPORT_CHECK_FILES_FOR_"
<< targetName << " ";
- for (std::set<std::string>::const_iterator li = importedLocations.begin();
- li != importedLocations.end(); ++li) {
- ImportPropertyMap::const_iterator pi = properties.find(*li);
+ for (std::string const& li : importedLocations) {
+ ImportPropertyMap::const_iterator pi = properties.find(li);
if (pi != properties.end()) {
os << cmExportFileGeneratorEscape(pi->second) << " ";
}
diff --git a/Source/cmExportInstallAndroidMKGenerator.cxx b/Source/cmExportInstallAndroidMKGenerator.cxx
index 9a1c647..fe565e6 100644
--- a/Source/cmExportInstallAndroidMKGenerator.cxx
+++ b/Source/cmExportInstallAndroidMKGenerator.cxx
@@ -34,11 +34,8 @@ void cmExportInstallAndroidMKGenerator::GenerateImportHeaderCode(
}
os << "_IMPORT_PREFIX := "
<< "$(LOCAL_PATH)" << path << "\n\n";
- for (std::vector<cmTargetExport*>::const_iterator tei =
- this->IEGen->GetExportSet()->GetTargetExports()->begin();
- tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei) {
+ for (cmTargetExport* te : *this->IEGen->GetExportSet()->GetTargetExports()) {
// Collect import properties for this target.
- cmTargetExport const* te = *tei;
if (te->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 350dc19..9b65e9e 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -4,7 +4,6 @@
#include "cmAlgorithms.h"
#include "cmExportSet.h"
-#include "cmExportSetMap.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
@@ -22,6 +21,8 @@
#include <sstream>
#include <utility>
+class cmExportSetMap;
+
cmExportInstallFileGenerator::cmExportInstallFileGenerator(
cmInstallExportGenerator* iegen)
: IEGen(iegen)
@@ -42,14 +43,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
{
std::string expectedTargets;
std::string sep;
- for (std::vector<cmTargetExport*>::const_iterator tei =
- this->IEGen->GetExportSet()->GetTargetExports()->begin();
- tei != this->IEGen->GetExportSet()->GetTargetExports()->end();
- ++tei) {
- expectedTargets +=
- sep + this->Namespace + (*tei)->Target->GetExportName();
+ for (cmTargetExport* te :
+ *this->IEGen->GetExportSet()->GetTargetExports()) {
+ expectedTargets += sep + this->Namespace + te->Target->GetExportName();
sep = " ";
- cmTargetExport* te = *tei;
if (this->ExportedTargets.insert(te->Target).second) {
allTargets.push_back(te);
} else {
@@ -76,9 +73,8 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
bool require3_1_0 = false;
bool requiresConfigFiles = false;
// Create all the imported targets.
- for (std::vector<cmTargetExport*>::const_iterator tei = allTargets.begin();
- tei != allTargets.end(); ++tei) {
- cmGeneratorTarget* gt = (*tei)->Target;
+ for (cmTargetExport* te : allTargets) {
+ cmGeneratorTarget* gt = te->Target;
requiresConfigFiles =
requiresConfigFiles || gt->GetType() != cmStateEnums::INTERFACE_LIBRARY;
@@ -88,10 +84,8 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
ImportPropertyMap properties;
this->PopulateIncludeDirectoriesInterface(
- *tei, cmGeneratorExpression::InstallInterface, properties,
- missingTargets);
- this->PopulateSourcesInterface(*tei,
- cmGeneratorExpression::InstallInterface,
+ te, cmGeneratorExpression::InstallInterface, properties, missingTargets);
+ this->PopulateSourcesInterface(te, cmGeneratorExpression::InstallInterface,
properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", gt,
cmGeneratorExpression::InstallInterface,
@@ -154,10 +148,8 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
// Generate an import file for each configuration.
// Don't do this if we only export INTERFACE_LIBRARY targets.
if (requiresConfigFiles) {
- for (std::vector<std::string>::const_iterator ci =
- this->Configurations.begin();
- ci != this->Configurations.end(); ++ci) {
- if (!this->GenerateImportFileConfig(*ci, missingTargets)) {
+ for (std::string const& c : this->Configurations) {
+ if (!this->GenerateImportFileConfig(c, missingTargets)) {
result = false;
}
}
@@ -314,11 +306,8 @@ void cmExportInstallFileGenerator::GenerateImportTargetsConfig(
std::vector<std::string>& missingTargets)
{
// Add each target in the set to the export.
- for (std::vector<cmTargetExport*>::const_iterator tei =
- this->IEGen->GetExportSet()->GetTargetExports()->begin();
- tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei) {
+ for (cmTargetExport* te : *this->IEGen->GetExportSet()->GetTargetExports()) {
// Collect import properties for this target.
- cmTargetExport const* te = *tei;
if (te->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
@@ -409,9 +398,8 @@ void cmExportInstallFileGenerator::SetImportLocationProperty(
// IMPORTED_OBJECTS as a list of object files
std::vector<std::string> objects;
itgen->GetInstallObjectNames(config, objects);
- for (std::vector<std::string>::iterator i = objects.begin();
- i != objects.end(); ++i) {
- *i = value + *i;
+ for (std::string& obj : objects) {
+ obj = value + obj;
}
// Store the property.
@@ -465,15 +453,14 @@ std::vector<std::string> cmExportInstallFileGenerator::FindNamespaces(
std::vector<std::string> namespaces;
const cmExportSetMap& exportSets = gg->GetExportSets();
- for (cmExportSetMap::const_iterator expIt = exportSets.begin();
- expIt != exportSets.end(); ++expIt) {
- const cmExportSet* exportSet = expIt->second;
+ for (auto const& expIt : exportSets) {
+ const cmExportSet* exportSet = expIt.second;
std::vector<cmTargetExport*> const* targets =
exportSet->GetTargetExports();
bool containsTarget = false;
- for (unsigned int i = 0; i < targets->size(); i++) {
- if (name == (*targets)[i]->TargetName) {
+ for (cmTargetExport* target : *targets) {
+ if (name == target->TargetName) {
containsTarget = true;
break;
}
@@ -482,8 +469,8 @@ std::vector<std::string> cmExportInstallFileGenerator::FindNamespaces(
if (containsTarget) {
std::vector<cmInstallExportGenerator const*> const* installs =
exportSet->GetInstallations();
- for (unsigned int i = 0; i < installs->size(); i++) {
- namespaces.push_back((*installs)[i]->GetNamespace());
+ for (cmInstallExportGenerator const* install : *installs) {
+ namespaces.push_back(install->GetNamespace());
}
}
}
diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx
index a1fdeae..cf12d33 100644
--- a/Source/cmExportLibraryDependenciesCommand.cxx
+++ b/Source/cmExportLibraryDependenciesCommand.cxx
@@ -4,7 +4,6 @@
#include "cmsys/FStream.hxx"
#include <map>
-#include <unordered_map>
#include <utility>
#include "cmGeneratedFileStream.h"
@@ -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";
diff --git a/Source/cmExportSet.cxx b/Source/cmExportSet.cxx
index a936679..a6fa186 100644
--- a/Source/cmExportSet.cxx
+++ b/Source/cmExportSet.cxx
@@ -13,9 +13,8 @@ cmExportSet::~cmExportSet()
void cmExportSet::Compute(cmLocalGenerator* lg)
{
- for (std::vector<cmTargetExport*>::iterator it = this->TargetExports.begin();
- it != this->TargetExports.end(); ++it) {
- (*it)->Target = lg->FindGeneratorTargetToUse((*it)->TargetName);
+ for (cmTargetExport* tgtExport : this->TargetExports) {
+ tgtExport->Target = lg->FindGeneratorTargetToUse(tgtExport->TargetName);
}
}
diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx
index 54e0e71..3e3fea1 100644
--- a/Source/cmExportTryCompileFileGenerator.cxx
+++ b/Source/cmExportTryCompileFileGenerator.cxx
@@ -77,11 +77,9 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
const std::set<cmGeneratorTarget const*>& allTargets =
cge->GetAllTargetsSeen();
- for (std::set<cmGeneratorTarget const*>::const_iterator li =
- allTargets.begin();
- li != allTargets.end(); ++li) {
- if (emitted.insert(*li).second) {
- this->Exports.push_back(*li);
+ for (cmGeneratorTarget const* target : allTargets) {
+ if (emitted.insert(target).second) {
+ this->Exports.push_back(target);
}
}
return result;
@@ -92,22 +90,20 @@ void cmExportTryCompileFileGenerator::PopulateProperties(
std::set<cmGeneratorTarget const*>& emitted)
{
std::vector<std::string> props = target->GetPropertyKeys();
- for (std::vector<std::string>::const_iterator i = props.begin();
- i != props.end(); ++i) {
+ for (std::string const& p : props) {
- properties[*i] = target->GetProperty(*i);
+ properties[p] = target->GetProperty(p);
- if (i->find("IMPORTED_LINK_INTERFACE_LIBRARIES") == 0 ||
- i->find("IMPORTED_LINK_DEPENDENT_LIBRARIES") == 0 ||
- i->find("INTERFACE_LINK_LIBRARIES") == 0) {
- std::string evalResult = this->FindTargets(*i, target, emitted);
+ if (p.find("IMPORTED_LINK_INTERFACE_LIBRARIES") == 0 ||
+ p.find("IMPORTED_LINK_DEPENDENT_LIBRARIES") == 0 ||
+ p.find("INTERFACE_LINK_LIBRARIES") == 0) {
+ std::string evalResult = this->FindTargets(p, target, emitted);
std::vector<std::string> depends;
cmSystemTools::ExpandListArgument(evalResult, depends);
- for (std::vector<std::string>::const_iterator li = depends.begin();
- li != depends.end(); ++li) {
+ for (std::string const& li : depends) {
cmGeneratorTarget* tgt =
- target->GetLocalGenerator()->FindGeneratorTargetToUse(*li);
+ target->GetLocalGenerator()->FindGeneratorTargetToUse(li);
if (tgt && emitted.insert(tgt).second) {
this->Exports.push_back(tgt);
}
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index 2c77343..48d07ad 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -63,11 +63,9 @@ cmExtraCodeBlocksGenerator::GetFactory()
void cmExtraCodeBlocksGenerator::Generate()
{
// for each sub project in the project create a codeblocks project
- for (std::map<std::string, std::vector<cmLocalGenerator*>>::const_iterator
- it = this->GlobalGenerator->GetProjectMap().begin();
- it != this->GlobalGenerator->GetProjectMap().end(); ++it) {
+ for (auto const& it : this->GlobalGenerator->GetProjectMap()) {
// create a project file
- this->CreateProjectFile(it->second);
+ this->CreateProjectFile(it.second);
}
}
@@ -116,15 +114,14 @@ void Tree::InsertPath(const std::vector<std::string>& splitted,
files.insert(fileName);
return;
}
- for (std::vector<Tree>::iterator it = folders.begin(); it != folders.end();
- ++it) {
- if ((*it).path == splitted[start]) {
+ for (Tree& folder : folders) {
+ if (folder.path == splitted[start]) {
if (start + 1 < splitted.size()) {
- it->InsertPath(splitted, start + 1, fileName);
+ folder.InsertPath(splitted, start + 1, fileName);
return;
}
// last part of splitted
- it->files.insert(fileName);
+ folder.files.insert(fileName);
return;
}
}
@@ -145,9 +142,8 @@ void Tree::BuildVirtualFolder(cmXMLWriter& xml) const
{
xml.StartElement("Option");
std::string virtualFolders = "CMake Files\\;";
- for (std::vector<Tree>::const_iterator it = folders.begin();
- it != folders.end(); ++it) {
- it->BuildVirtualFolderImpl(virtualFolders, "");
+ for (Tree const& folder : folders) {
+ folder.BuildVirtualFolderImpl(virtualFolders, "");
}
xml.Attribute("virtualFolders", virtualFolders);
xml.EndElement();
@@ -157,18 +153,16 @@ void Tree::BuildVirtualFolderImpl(std::string& virtualFolders,
const std::string& prefix) const
{
virtualFolders += "CMake Files\\" + prefix + path + "\\;";
- for (std::vector<Tree>::const_iterator it = folders.begin();
- it != folders.end(); ++it) {
- it->BuildVirtualFolderImpl(virtualFolders, prefix + path + "\\");
+ for (Tree const& folder : folders) {
+ folder.BuildVirtualFolderImpl(virtualFolders, prefix + path + "\\");
}
}
void Tree::BuildUnit(cmXMLWriter& xml, const std::string& fsPath) const
{
- for (std::set<std::string>::const_iterator it = files.begin();
- it != files.end(); ++it) {
+ for (std::string const& f : files) {
xml.StartElement("Unit");
- xml.Attribute("filename", fsPath + *it);
+ xml.Attribute("filename", fsPath + f);
xml.StartElement("Option");
xml.Attribute("virtualFolder", "CMake Files\\");
@@ -176,9 +170,8 @@ void Tree::BuildUnit(cmXMLWriter& xml, const std::string& fsPath) const
xml.EndElement();
}
- for (std::vector<Tree>::const_iterator it = folders.begin();
- it != folders.end(); ++it) {
- it->BuildUnitImpl(xml, "", fsPath);
+ for (Tree const& folder : folders) {
+ folder.BuildUnitImpl(xml, "", fsPath);
}
}
@@ -186,10 +179,9 @@ void Tree::BuildUnitImpl(cmXMLWriter& xml,
const std::string& virtualFolderPath,
const std::string& fsPath) const
{
- for (std::set<std::string>::const_iterator it = files.begin();
- it != files.end(); ++it) {
+ for (std::string const& f : files) {
xml.StartElement("Unit");
- xml.Attribute("filename", fsPath + path + "/" + *it);
+ xml.Attribute("filename", fsPath + path + "/" + f);
xml.StartElement("Option");
xml.Attribute("virtualFolder",
@@ -198,10 +190,9 @@ void Tree::BuildUnitImpl(cmXMLWriter& xml,
xml.EndElement();
}
- for (std::vector<Tree>::const_iterator it = folders.begin();
- it != folders.end(); ++it) {
- it->BuildUnitImpl(xml, virtualFolderPath + path + "\\",
- fsPath + path + "/");
+ for (Tree const& folder : folders) {
+ folder.BuildUnitImpl(xml, virtualFolderPath + path + "\\",
+ fsPath + path + "/");
}
}
@@ -217,29 +208,24 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
Tree tree;
// build tree of virtual folders
- for (std::map<std::string, std::vector<cmLocalGenerator*>>::const_iterator
- it = this->GlobalGenerator->GetProjectMap().begin();
- it != this->GlobalGenerator->GetProjectMap().end(); ++it) {
+ for (auto const& it : this->GlobalGenerator->GetProjectMap()) {
// Collect all files
std::vector<std::string> listFiles;
- for (std::vector<cmLocalGenerator*>::const_iterator jt =
- it->second.begin();
- jt != it->second.end(); ++jt) {
+ for (cmLocalGenerator* lg : it.second) {
const std::vector<std::string>& files =
- (*jt)->GetMakefile()->GetListFiles();
+ lg->GetMakefile()->GetListFiles();
listFiles.insert(listFiles.end(), files.begin(), files.end());
}
// Convert
- for (std::vector<std::string>::const_iterator jt = listFiles.begin();
- jt != listFiles.end(); ++jt) {
+ for (std::string const& listFile : listFiles) {
// don't put cmake's own files into the project (#12110):
- if (jt->find(cmSystemTools::GetCMakeRoot()) == 0) {
+ if (listFile.find(cmSystemTools::GetCMakeRoot()) == 0) {
continue;
}
const std::string& relative = cmSystemTools::RelativePath(
- it->second[0]->GetSourceDirectory(), jt->c_str());
+ it.second[0]->GetSourceDirectory(), listFile.c_str());
std::vector<std::string> splitted;
cmSystemTools::SplitPath(relative, splitted, false);
// Split filename from path
@@ -295,20 +281,17 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
// add all executable and library targets and some of the GLOBAL
// and UTILITY targets
- for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin();
- lg != lgs.end(); lg++) {
- const std::vector<cmGeneratorTarget*>& targets =
- (*lg)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
- ti != targets.end(); ti++) {
- std::string targetName = (*ti)->GetName();
- switch ((*ti)->GetType()) {
+ for (cmLocalGenerator* lg : lgs) {
+ const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
+ for (cmGeneratorTarget* target : targets) {
+ std::string targetName = target->GetName();
+ switch (target->GetType()) {
case cmStateEnums::GLOBAL_TARGET: {
// Only add the global targets from CMAKE_BINARY_DIR,
// not from the subdirs
- if (strcmp((*lg)->GetCurrentBinaryDirectory(),
- (*lg)->GetBinaryDirectory()) == 0) {
- this->AppendTarget(xml, targetName, nullptr, make.c_str(), *lg,
+ if (strcmp(lg->GetCurrentBinaryDirectory(),
+ lg->GetBinaryDirectory()) == 0) {
+ this->AppendTarget(xml, targetName, nullptr, make.c_str(), lg,
compiler.c_str(), makeArgs);
}
} break;
@@ -324,7 +307,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
break;
}
- this->AppendTarget(xml, targetName, nullptr, make.c_str(), *lg,
+ this->AppendTarget(xml, targetName, nullptr, make.c_str(), lg,
compiler.c_str(), makeArgs);
break;
case cmStateEnums::EXECUTABLE:
@@ -332,12 +315,12 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
case cmStateEnums::SHARED_LIBRARY:
case cmStateEnums::MODULE_LIBRARY:
case cmStateEnums::OBJECT_LIBRARY: {
- cmGeneratorTarget* gt = *ti;
- this->AppendTarget(xml, targetName, gt, make.c_str(), *lg,
+ cmGeneratorTarget* gt = target;
+ this->AppendTarget(xml, targetName, gt, make.c_str(), lg,
compiler.c_str(), makeArgs);
std::string fastTarget = targetName;
fastTarget += "/fast";
- this->AppendTarget(xml, fastTarget, gt, make.c_str(), *lg,
+ this->AppendTarget(xml, fastTarget, gt, make.c_str(), lg,
compiler.c_str(), makeArgs);
} break;
default:
@@ -358,14 +341,11 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
std::vector<std::string> const& srcExts =
this->GlobalGenerator->GetCMakeInstance()->GetSourceExtensions();
- for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin();
- lg != lgs.end(); lg++) {
- cmMakefile* makefile = (*lg)->GetMakefile();
- const std::vector<cmGeneratorTarget*>& targets =
- (*lg)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
- ti != targets.end(); ti++) {
- switch ((*ti)->GetType()) {
+ for (cmLocalGenerator* lg : lgs) {
+ cmMakefile* makefile = lg->GetMakefile();
+ const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
+ for (cmGeneratorTarget* target : targets) {
+ switch (target->GetType()) {
case cmStateEnums::EXECUTABLE:
case cmStateEnums::STATIC_LIBRARY:
case cmStateEnums::SHARED_LIBRARY:
@@ -374,41 +354,38 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
case cmStateEnums::UTILITY: // can have sources since 2.6.3
{
std::vector<cmSourceFile*> sources;
- cmGeneratorTarget* gt = *ti;
+ cmGeneratorTarget* gt = target;
gt->GetSourceFiles(sources,
makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
- for (std::vector<cmSourceFile*>::const_iterator si = sources.begin();
- si != sources.end(); si++) {
+ for (cmSourceFile* s : sources) {
// don't add source files from UTILITY target which have the
// GENERATED property set:
if (gt->GetType() == cmStateEnums::UTILITY &&
- (*si)->GetPropertyAsBool("GENERATED")) {
+ s->GetPropertyAsBool("GENERATED")) {
continue;
}
// check whether it is a C/C++ implementation file
bool isCFile = false;
- std::string lang = (*si)->GetLanguage();
+ std::string lang = s->GetLanguage();
if (lang == "C" || lang == "CXX") {
- std::string const& srcext = (*si)->GetExtension();
- for (std::vector<std::string>::const_iterator ext =
- srcExts.begin();
- ext != srcExts.end(); ++ext) {
- if (srcext == *ext) {
+ std::string const& srcext = s->GetExtension();
+ for (std::string const& ext : srcExts) {
+ if (srcext == ext) {
isCFile = true;
break;
}
}
}
- std::string const& fullPath = (*si)->GetFullPath();
+ std::string const& fullPath = s->GetFullPath();
if (isCFile) {
cFiles.push_back(fullPath);
}
CbpUnit& cbpUnit = allFiles[fullPath];
- cbpUnit.Targets.push_back(*ti);
+ cbpUnit.Targets.push_back(target);
}
}
default: // intended fallthrough
@@ -427,19 +404,16 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
// file exists. If it does, it is inserted into the map of files.
// A very similar version of that code exists also in the kdevelop
// project generator.
- for (std::vector<std::string>::const_iterator sit = cFiles.begin();
- sit != cFiles.end(); ++sit) {
- std::string const& fileName = *sit;
+ for (std::string const& fileName : cFiles) {
std::string headerBasename = cmSystemTools::GetFilenamePath(fileName);
headerBasename += "/";
headerBasename += cmSystemTools::GetFilenameWithoutExtension(fileName);
// check if there's a matching header around
- for (std::vector<std::string>::const_iterator ext = headerExts.begin();
- ext != headerExts.end(); ++ext) {
+ for (std::string const& ext : headerExts) {
std::string hname = headerBasename;
hname += ".";
- hname += *ext;
+ hname += ext;
// if it's already in the set, don't check if it exists on disk
if (allFiles.find(hname) != allFiles.end()) {
break;
@@ -453,19 +427,16 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
}
// insert all source files in the CodeBlocks project
- for (all_files_map_t::const_iterator sit = allFiles.begin();
- sit != allFiles.end(); ++sit) {
- std::string const& unitFilename = sit->first;
- CbpUnit const& unit = sit->second;
+ for (auto const& s : allFiles) {
+ std::string const& unitFilename = s.first;
+ CbpUnit const& unit = s.second;
xml.StartElement("Unit");
xml.Attribute("filename", unitFilename);
- for (std::vector<const cmGeneratorTarget*>::const_iterator ti =
- unit.Targets.begin();
- ti != unit.Targets.end(); ++ti) {
+ for (cmGeneratorTarget const* tgt : unit.Targets) {
xml.StartElement("Option");
- xml.Attribute("target", (*ti)->GetName());
+ xml.Attribute("target", tgt->GetName());
xml.EndElement();
}
@@ -575,10 +546,9 @@ void cmExtraCodeBlocksGenerator::AppendTarget(
target->GetCompileDefinitions(cdefs, buildType, "C");
// Expand the list.
- for (std::vector<std::string>::const_iterator di = cdefs.begin();
- di != cdefs.end(); ++di) {
+ for (std::string const& d : cdefs) {
xml.StartElement("Add");
- xml.Attribute("option", "-D" + *di);
+ xml.Attribute("option", "-D" + d);
xml.EndElement();
}
diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx
index 438c854..5a02d54 100644
--- a/Source/cmExtraCodeLiteGenerator.cxx
+++ b/Source/cmExtraCodeLiteGenerator.cxx
@@ -60,20 +60,18 @@ void cmExtraCodeLiteGenerator::Generate()
// loop projects and locate the root project.
// and extract the information for creating the worspace
// root makefile
- for (std::map<std::string, std::vector<cmLocalGenerator*>>::const_iterator
- it = projectMap.begin();
- it != projectMap.end(); ++it) {
- const cmMakefile* mf = it->second[0]->GetMakefile();
+ for (auto const& it : projectMap) {
+ const cmMakefile* mf = it.second[0]->GetMakefile();
this->ConfigName = GetConfigurationName(mf);
- if (strcmp(it->second[0]->GetCurrentBinaryDirectory(),
- it->second[0]->GetBinaryDirectory()) == 0) {
- workspaceOutputDir = it->second[0]->GetCurrentBinaryDirectory();
- workspaceProjectName = it->second[0]->GetProjectName();
- workspaceSourcePath = it->second[0]->GetSourceDirectory();
+ if (strcmp(it.second[0]->GetCurrentBinaryDirectory(),
+ it.second[0]->GetBinaryDirectory()) == 0) {
+ workspaceOutputDir = it.second[0]->GetCurrentBinaryDirectory();
+ workspaceProjectName = it.second[0]->GetProjectName();
+ workspaceSourcePath = it.second[0]->GetSourceDirectory();
workspaceFileName = workspaceOutputDir + "/";
workspaceFileName += workspaceProjectName + ".workspace";
- this->WorkspacePath = it->second[0]->GetCurrentBinaryDirectory();
+ this->WorkspacePath = it.second[0]->GetCurrentBinaryDirectory();
;
break;
}
@@ -101,10 +99,9 @@ void cmExtraCodeLiteGenerator::Generate()
xml.Attribute("Name", this->ConfigName);
xml.Attribute("Selected", "yes");
- for (std::vector<std::string>::iterator it(ProjectNames.begin());
- it != ProjectNames.end(); it++) {
+ for (std::string const& it : ProjectNames) {
xml.StartElement("Project");
- xml.Attribute("Name", *it);
+ xml.Attribute("Name", it);
xml.Attribute("ConfigName", this->ConfigName);
xml.EndElement();
}
@@ -122,14 +119,11 @@ std::vector<std::string> cmExtraCodeLiteGenerator::CreateProjectsByTarget(
// for each target in the workspace create a codelite project
const std::vector<cmLocalGenerator*>& lgs =
this->GlobalGenerator->GetLocalGenerators();
- for (std::vector<cmLocalGenerator*>::const_iterator lg(lgs.begin());
- lg != lgs.end(); lg++) {
- for (std::vector<cmGeneratorTarget*>::const_iterator lt =
- (*lg)->GetGeneratorTargets().begin();
- lt != (*lg)->GetGeneratorTargets().end(); lt++) {
- cmStateEnums::TargetType type = (*lt)->GetType();
- std::string outputDir = (*lg)->GetCurrentBinaryDirectory();
- std::string targetName = (*lt)->GetName();
+ for (cmLocalGenerator* lg : lgs) {
+ for (cmGeneratorTarget* lt : lg->GetGeneratorTargets()) {
+ cmStateEnums::TargetType type = lt->GetType();
+ std::string outputDir = lg->GetCurrentBinaryDirectory();
+ std::string targetName = lt->GetName();
std::string filename = outputDir + "/" + targetName + ".project";
retval.push_back(targetName);
// Make the project file relative to the workspace
@@ -149,7 +143,7 @@ std::vector<std::string> cmExtraCodeLiteGenerator::CreateProjectsByTarget(
xml->Attribute("Active", "No");
xml->EndElement();
- CreateNewProjectFile(*lt, filename);
+ CreateNewProjectFile(lt, filename);
break;
default:
break;
@@ -165,12 +159,10 @@ std::vector<std::string> cmExtraCodeLiteGenerator::CreateProjectsByProjectMaps(
{
std::vector<std::string> retval;
// for each sub project in the workspace create a codelite project
- for (std::map<std::string, std::vector<cmLocalGenerator*>>::const_iterator
- it = this->GlobalGenerator->GetProjectMap().begin();
- it != this->GlobalGenerator->GetProjectMap().end(); it++) {
+ for (auto const& it : this->GlobalGenerator->GetProjectMap()) {
- std::string outputDir = it->second[0]->GetCurrentBinaryDirectory();
- std::string projectName = it->second[0]->GetProjectName();
+ std::string outputDir = it.second[0]->GetCurrentBinaryDirectory();
+ std::string projectName = it.second[0]->GetProjectName();
retval.push_back(projectName);
std::string filename = outputDir + "/" + projectName + ".project";
@@ -179,7 +171,7 @@ std::vector<std::string> cmExtraCodeLiteGenerator::CreateProjectsByProjectMaps(
filename.c_str());
// create a project file
- this->CreateProjectFile(it->second);
+ this->CreateProjectFile(it.second);
xml->StartElement("Project");
xml->Attribute("Name", projectName);
xml->Attribute("Path", filename);
@@ -235,16 +227,14 @@ std::string cmExtraCodeLiteGenerator::CollectSourceFiles(
std::vector<cmSourceFile*> sources;
gt->GetSourceFiles(sources,
makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
- for (std::vector<cmSourceFile*>::const_iterator si = sources.begin();
- si != sources.end(); si++) {
+ for (cmSourceFile* s : sources) {
// check whether it is a C/C++ implementation file
bool isCFile = false;
- std::string lang = (*si)->GetLanguage();
+ std::string lang = s->GetLanguage();
if (lang == "C" || lang == "CXX") {
- std::string const& srcext = (*si)->GetExtension();
- for (std::vector<std::string>::const_iterator ext = srcExts.begin();
- ext != srcExts.end(); ++ext) {
- if (srcext == *ext) {
+ std::string const& srcext = s->GetExtension();
+ for (std::string const& ext : srcExts) {
+ if (srcext == ext) {
isCFile = true;
break;
}
@@ -253,9 +243,9 @@ std::string cmExtraCodeLiteGenerator::CollectSourceFiles(
// then put it accordingly into one of the two containers
if (isCFile) {
- cFiles[(*si)->GetFullPath()] = *si;
+ cFiles[s->GetFullPath()] = s;
} else {
- otherFiles.insert((*si)->GetFullPath());
+ otherFiles.insert(s->GetFullPath());
}
}
}
@@ -289,14 +279,11 @@ void cmExtraCodeLiteGenerator::CreateNewProjectFile(
std::map<std::string, cmSourceFile*> cFiles;
std::set<std::string> otherFiles;
- for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin();
- lg != lgs.end(); lg++) {
- cmMakefile* makefile = (*lg)->GetMakefile();
- const std::vector<cmGeneratorTarget*>& targets =
- (*lg)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
- ti != targets.end(); ti++) {
- projectType = CollectSourceFiles(makefile, *ti, cFiles, otherFiles);
+ for (cmLocalGenerator* lg : lgs) {
+ cmMakefile* makefile = lg->GetMakefile();
+ const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
+ for (cmGeneratorTarget* target : targets) {
+ projectType = CollectSourceFiles(makefile, target, cFiles, otherFiles);
}
}
@@ -324,19 +311,16 @@ void cmExtraCodeLiteGenerator::FindMatchingHeaderfiles(
// file exists. If it does, it is inserted into the map of files.
// A very similar version of that code exists also in the kdevelop
// project generator.
- for (std::map<std::string, cmSourceFile*>::const_iterator sit =
- cFiles.begin();
- sit != cFiles.end(); ++sit) {
- std::string headerBasename = cmSystemTools::GetFilenamePath(sit->first);
+ for (auto const& sit : cFiles) {
+ std::string headerBasename = cmSystemTools::GetFilenamePath(sit.first);
headerBasename += "/";
- headerBasename += cmSystemTools::GetFilenameWithoutExtension(sit->first);
+ headerBasename += cmSystemTools::GetFilenameWithoutExtension(sit.first);
// check if there's a matching header around
- for (std::vector<std::string>::const_iterator ext = headerExts.begin();
- ext != headerExts.end(); ++ext) {
+ for (std::string const& ext : headerExts) {
std::string hname = headerBasename;
hname += ".";
- hname += *ext;
+ hname += ext;
// if it's already in the set, don't check if it exists on disk
std::set<std::string>::const_iterator headerIt = otherFiles.find(hname);
if (headerIt != otherFiles.end()) {
@@ -359,10 +343,9 @@ void cmExtraCodeLiteGenerator::CreateFoldersAndFiles(
std::vector<std::string> components;
size_t numOfEndEl = 0;
- for (std::set<std::string>::const_iterator it = cFiles.begin();
- it != cFiles.end(); ++it) {
+ for (std::string const& cFile : cFiles) {
std::string frelapath =
- cmSystemTools::RelativePath(projectPath.c_str(), it->c_str());
+ cmSystemTools::RelativePath(projectPath.c_str(), cFile.c_str());
cmsys::SystemTools::SplitPath(frelapath, components, false);
components.pop_back(); // erase last member -> it is file, not folder
components.erase(components.begin()); // erase "root"
@@ -424,10 +407,8 @@ void cmExtraCodeLiteGenerator::CreateFoldersAndFiles(
const std::string& projectPath)
{
std::set<std::string> s;
- for (std::map<std::string, cmSourceFile*>::const_iterator it =
- cFiles.begin();
- it != cFiles.end(); ++it) {
- s.insert(it->first);
+ for (auto const& it : cFiles) {
+ s.insert(it.first);
}
this->CreateFoldersAndFiles(s, xml, projectPath);
}
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index bfc490c..b2c1589 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -5,7 +5,6 @@
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
#include <assert.h>
-#include <map>
#include <sstream>
#include <stdio.h>
#include <utility>
@@ -78,16 +77,15 @@ void cmExtraEclipseCDT4Generator::EnableLanguage(
std::vector<std::string> const& languages, cmMakefile* /*unused*/,
bool /*optional*/)
{
- for (std::vector<std::string>::const_iterator lit = languages.begin();
- lit != languages.end(); ++lit) {
- if (*lit == "CXX") {
+ for (std::string const& l : languages) {
+ if (l == "CXX") {
this->Natures.insert("org.eclipse.cdt.core.ccnature");
this->Natures.insert("org.eclipse.cdt.core.cnature");
this->CXXEnabled = true;
- } else if (*lit == "C") {
+ } else if (l == "C") {
this->Natures.insert("org.eclipse.cdt.core.cnature");
this->CEnabled = true;
- } else if (*lit == "Java") {
+ } else if (l == "Java") {
this->Natures.insert("org.eclipse.jdt.core.javanature");
}
}
@@ -382,18 +380,16 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
xml.Element("nature", "org.eclipse.cdt.make.core.ScannerConfigNature");
;
- for (std::set<std::string>::const_iterator nit = this->Natures.begin();
- nit != this->Natures.end(); ++nit) {
- xml.Element("nature", *nit);
+ for (std::string const& n : this->Natures) {
+ xml.Element("nature", n);
}
if (const char* extraNaturesProp =
mf->GetState()->GetGlobalProperty("ECLIPSE_EXTRA_NATURES")) {
std::vector<std::string> extraNatures;
cmSystemTools::ExpandListArgument(extraNaturesProp, extraNatures);
- for (std::vector<std::string>::const_iterator nit = extraNatures.begin();
- nit != extraNatures.end(); ++nit) {
- xml.Element("nature", *nit);
+ for (std::string const& n : extraNatures) {
+ xml.Element("nature", n);
}
}
@@ -435,25 +431,22 @@ void cmExtraEclipseCDT4Generator::WriteGroups(
std::vector<cmSourceGroup> const& sourceGroups, std::string& linkName,
cmXMLWriter& xml)
{
- for (std::vector<cmSourceGroup>::const_iterator sgIt = sourceGroups.begin();
- sgIt != sourceGroups.end(); ++sgIt) {
+ for (cmSourceGroup const& sg : sourceGroups) {
std::string linkName3 = linkName;
linkName3 += "/";
- linkName3 += sgIt->GetFullName();
+ linkName3 += sg.GetFullName();
std::replace(linkName3.begin(), linkName3.end(), '\\', '/');
this->AppendLinkedResource(xml, linkName3, "virtual:/virtual",
VirtualFolder);
- std::vector<cmSourceGroup> const& children = sgIt->GetGroupChildren();
+ std::vector<cmSourceGroup> const& children = sg.GetGroupChildren();
if (!children.empty()) {
this->WriteGroups(children, linkName, xml);
}
- std::vector<const cmSourceFile*> sFiles = sgIt->GetSourceFiles();
- for (std::vector<const cmSourceFile*>::const_iterator fileIt =
- sFiles.begin();
- fileIt != sFiles.end(); ++fileIt) {
- std::string const& fullPath = (*fileIt)->GetFullPath();
+ std::vector<const cmSourceFile*> sFiles = sg.GetSourceFiles();
+ for (cmSourceFile const* file : sFiles) {
+ std::string const& fullPath = file->GetFullPath();
if (!cmSystemTools::FileIsDirectory(fullPath)) {
std::string linkName4 = linkName3;
@@ -471,28 +464,24 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(cmXMLWriter& xml)
std::string linkName = "[Targets]";
this->AppendLinkedResource(xml, linkName, "virtual:/virtual", VirtualFolder);
- for (std::vector<cmLocalGenerator*>::const_iterator lgIt =
- this->GlobalGenerator->GetLocalGenerators().begin();
- lgIt != this->GlobalGenerator->GetLocalGenerators().end(); ++lgIt) {
- cmMakefile* makefile = (*lgIt)->GetMakefile();
- const std::vector<cmGeneratorTarget*>& targets =
- (*lgIt)->GetGeneratorTargets();
+ for (cmLocalGenerator* lg : this->GlobalGenerator->GetLocalGenerators()) {
+ cmMakefile* makefile = lg->GetMakefile();
+ const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
- ti != targets.end(); ++ti) {
+ for (cmGeneratorTarget* target : targets) {
std::string linkName2 = linkName;
linkName2 += "/";
- switch ((*ti)->GetType()) {
+ switch (target->GetType()) {
case cmStateEnums::EXECUTABLE:
case cmStateEnums::STATIC_LIBRARY:
case cmStateEnums::SHARED_LIBRARY:
case cmStateEnums::MODULE_LIBRARY:
case cmStateEnums::OBJECT_LIBRARY: {
const char* prefix =
- ((*ti)->GetType() == cmStateEnums::EXECUTABLE ? "[exe] "
- : "[lib] ");
+ (target->GetType() == cmStateEnums::EXECUTABLE ? "[exe] "
+ : "[lib] ");
linkName2 += prefix;
- linkName2 += (*ti)->GetName();
+ linkName2 += target->GetName();
this->AppendLinkedResource(xml, linkName2, "virtual:/virtual",
VirtualFolder);
if (!this->GenerateLinkedResources) {
@@ -501,17 +490,16 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(cmXMLWriter& xml)
std::vector<cmSourceGroup> sourceGroups =
makefile->GetSourceGroups();
// get the files from the source lists then add them to the groups
- cmGeneratorTarget* gt = const_cast<cmGeneratorTarget*>(*ti);
+ cmGeneratorTarget* gt = const_cast<cmGeneratorTarget*>(target);
std::vector<cmSourceFile*> files;
gt->GetSourceFiles(files,
makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
- for (std::vector<cmSourceFile*>::const_iterator sfIt = files.begin();
- sfIt != files.end(); sfIt++) {
+ for (cmSourceFile* sf : files) {
// Add the file to the list of sources.
- std::string const& source = (*sfIt)->GetFullPath();
+ std::string const& source = sf->GetFullPath();
cmSourceGroup* sourceGroup =
makefile->FindSourceGroup(source.c_str(), sourceGroups);
- sourceGroup->AssignSource(*sfIt);
+ sourceGroup->AssignSource(sf);
}
this->WriteGroups(sourceGroups, linkName2, xml);
@@ -536,17 +524,15 @@ void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects(
this->AppendLinkedResource(xml, "[Subprojects]", "virtual:/virtual",
VirtualFolder);
- for (std::map<std::string, std::vector<cmLocalGenerator*>>::const_iterator
- it = this->GlobalGenerator->GetProjectMap().begin();
- it != this->GlobalGenerator->GetProjectMap().end(); ++it) {
+ for (auto const& it : this->GlobalGenerator->GetProjectMap()) {
std::string linkSourceDirectory =
- this->GetEclipsePath(it->second[0]->GetCurrentSourceDirectory());
+ this->GetEclipsePath(it.second[0]->GetCurrentSourceDirectory());
// a linked resource must not point to a parent directory of .project or
// .project itself
if ((baseDir != linkSourceDirectory) &&
!cmSystemTools::IsSubDirectory(baseDir, linkSourceDirectory)) {
std::string linkName = "[Subprojects]/";
- linkName += it->first;
+ linkName += it.first;
this->AppendLinkedResource(xml, linkName,
this->GetEclipsePath(linkSourceDirectory),
LinkToFolder);
@@ -560,10 +546,9 @@ void cmExtraEclipseCDT4Generator::AppendIncludeDirectories(
cmXMLWriter& xml, const std::vector<std::string>& includeDirs,
std::set<std::string>& emittedDirs)
{
- for (std::vector<std::string>::const_iterator inc = includeDirs.begin();
- inc != includeDirs.end(); ++inc) {
- if (!inc->empty()) {
- std::string dir = cmSystemTools::CollapseFullPath(*inc);
+ for (std::string const& inc : includeDirs) {
+ if (!inc.empty()) {
+ std::string dir = cmSystemTools::CollapseFullPath(inc);
// handle framework include dirs on OSX, the remainder after the
// Frameworks/ part has to be stripped
@@ -712,19 +697,17 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
xml.EndElement();
}
- for (std::vector<std::string>::const_iterator it =
- this->SrcLinkedResources.begin();
- it != this->SrcLinkedResources.end(); ++it) {
+ for (std::string const& p : this->SrcLinkedResources) {
xml.StartElement("pathentry");
xml.Attribute("kind", "src");
- xml.Attribute("path", *it);
+ xml.Attribute("path", p);
xml.EndElement();
// exlude source directory from output search path
// - only if not named the same as an output directory
if (!cmSystemTools::FileIsDirectory(
- std::string(this->HomeOutputDirectory + "/" + *it))) {
- excludeFromOut += *it + "/|";
+ std::string(this->HomeOutputDirectory + "/" + p))) {
+ excludeFromOut += p + "/|";
}
}
@@ -738,34 +721,31 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
// add pre-processor definitions to allow eclipse to gray out sections
emmited.clear();
- for (std::vector<cmLocalGenerator*>::const_iterator it =
- this->GlobalGenerator->GetLocalGenerators().begin();
- it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) {
+ for (cmLocalGenerator* lgen : this->GlobalGenerator->GetLocalGenerators()) {
if (const char* cdefs =
- (*it)->GetMakefile()->GetProperty("COMPILE_DEFINITIONS")) {
+ lgen->GetMakefile()->GetProperty("COMPILE_DEFINITIONS")) {
// Expand the list.
std::vector<std::string> defs;
cmGeneratorExpression::Split(cdefs, defs);
- for (std::vector<std::string>::const_iterator di = defs.begin();
- di != defs.end(); ++di) {
- if (cmGeneratorExpression::Find(*di) != std::string::npos) {
+ for (std::string const& d : defs) {
+ if (cmGeneratorExpression::Find(d) != std::string::npos) {
continue;
}
- std::string::size_type equals = di->find('=', 0);
- std::string::size_type enddef = di->length();
+ std::string::size_type equals = d.find('=', 0);
+ std::string::size_type enddef = d.length();
std::string def;
std::string val;
if (equals != std::string::npos && equals < enddef) {
// we have -DFOO=BAR
- def = di->substr(0, equals);
- val = di->substr(equals + 1, enddef - equals + 1);
+ def = d.substr(0, equals);
+ val = d.substr(equals + 1, enddef - equals + 1);
} else {
// we have -DFOO
- def = *di;
+ def = d;
}
// insert the definition if not already added.
@@ -850,16 +830,13 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
// include dirs
emmited.clear();
- for (std::vector<cmLocalGenerator*>::const_iterator it =
- this->GlobalGenerator->GetLocalGenerators().begin();
- it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) {
+ for (cmLocalGenerator* lgen : this->GlobalGenerator->GetLocalGenerators()) {
const std::vector<cmGeneratorTarget*>& targets =
- (*it)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator l = targets.begin();
- l != targets.end(); ++l) {
+ lgen->GetGeneratorTargets();
+ for (cmGeneratorTarget* target : targets) {
std::vector<std::string> includeDirs;
std::string config = mf->GetSafeDefinition("CMAKE_BUILD_TYPE");
- (*it)->GetIncludeDirectories(includeDirs, *l, "C", config);
+ lgen->GetIncludeDirectories(includeDirs, target, "C", config);
this->AppendIncludeDirectories(xml, includeDirs, emmited);
}
}
@@ -908,21 +885,18 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
// add all executable and library targets and some of the GLOBAL
// and UTILITY targets
- for (std::vector<cmLocalGenerator*>::const_iterator it =
- this->GlobalGenerator->GetLocalGenerators().begin();
- it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) {
+ for (cmLocalGenerator* lgen : this->GlobalGenerator->GetLocalGenerators()) {
const std::vector<cmGeneratorTarget*>& targets =
- (*it)->GetGeneratorTargets();
- std::string subdir = (*it)->ConvertToRelativePath(
- this->HomeOutputDirectory, (*it)->GetCurrentBinaryDirectory());
+ lgen->GetGeneratorTargets();
+ std::string subdir = lgen->ConvertToRelativePath(
+ this->HomeOutputDirectory, lgen->GetCurrentBinaryDirectory());
if (subdir == ".") {
subdir = "";
}
- for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
- ti != targets.end(); ++ti) {
- std::string targetName = (*ti)->GetName();
- switch ((*ti)->GetType()) {
+ for (cmGeneratorTarget* target : targets) {
+ std::string targetName = target->GetName();
+ switch (target->GetType()) {
case cmStateEnums::GLOBAL_TARGET: {
// Only add the global targets from CMAKE_BINARY_DIR,
// not from the subdirs
@@ -950,8 +924,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
case cmStateEnums::MODULE_LIBRARY:
case cmStateEnums::OBJECT_LIBRARY: {
const char* prefix =
- ((*ti)->GetType() == cmStateEnums::EXECUTABLE ? "[exe] "
- : "[lib] ");
+ (target->GetType() == cmStateEnums::EXECUTABLE ? "[exe] "
+ : "[lib] ");
this->AppendTarget(xml, targetName, make, makeArgs, subdir, prefix);
std::string fastTarget = targetName;
fastTarget += "/fast";
@@ -963,19 +937,19 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
virtDir += prefix;
virtDir += targetName;
std::string buildArgs = "-C \"";
- buildArgs += (*it)->GetBinaryDirectory();
+ buildArgs += lgen->GetBinaryDirectory();
buildArgs += "\" ";
buildArgs += makeArgs;
this->AppendTarget(xml, "Build", make, buildArgs, virtDir, "",
targetName.c_str());
std::string cleanArgs = "-E chdir \"";
- cleanArgs += (*it)->GetCurrentBinaryDirectory();
+ cleanArgs += lgen->GetCurrentBinaryDirectory();
cleanArgs += "\" \"";
cleanArgs += cmSystemTools::GetCMakeCommand();
cleanArgs += "\" -P \"";
- cmGeneratorTarget* gt = *ti;
- cleanArgs += (*it)->GetTargetDirectory(gt);
+ cmGeneratorTarget* gt = target;
+ cleanArgs += lgen->GetTargetDirectory(gt);
cleanArgs += "/cmake_clean.cmake\"";
this->AppendTarget(xml, "Clean", cmSystemTools::GetCMakeCommand(),
cleanArgs, virtDir, "", "");
@@ -997,17 +971,15 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
// insert rules for compiling, preprocessing and assembling individual
// files
std::vector<std::string> objectFileTargets;
- (*it)->GetIndividualFileTargets(objectFileTargets);
- for (std::vector<std::string>::const_iterator fit =
- objectFileTargets.begin();
- fit != objectFileTargets.end(); ++fit) {
+ lg->GetIndividualFileTargets(objectFileTargets);
+ for (std::string const& f : objectFileTargets) {
const char* prefix = "[obj] ";
- if ((*fit)[fit->length() - 1] == 's') {
+ if (f[f.length() - 1] == 's') {
prefix = "[to asm] ";
- } else if ((*fit)[fit->length() - 1] == 'i') {
+ } else if (f[f.length() - 1] == 'i') {
prefix = "[pre] ";
}
- this->AppendTarget(xml, *fit, make, makeArgs, subdir, prefix);
+ this->AppendTarget(xml, f, make, makeArgs, subdir, prefix);
}
}
diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx
index a75a400..79cc6ef 100644
--- a/Source/cmExtraKateGenerator.cxx
+++ b/Source/cmExtraKateGenerator.cxx
@@ -112,18 +112,16 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg,
// add all executable and library targets and some of the GLOBAL
// and UTILITY targets
- for (std::vector<cmLocalGenerator*>::const_iterator it =
- this->GlobalGenerator->GetLocalGenerators().begin();
- it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) {
+ for (cmLocalGenerator* localGen :
+ this->GlobalGenerator->GetLocalGenerators()) {
const std::vector<cmGeneratorTarget*>& targets =
- (*it)->GetGeneratorTargets();
- std::string currentDir = (*it)->GetCurrentBinaryDirectory();
- bool topLevel = (currentDir == (*it)->GetBinaryDirectory());
-
- for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
- ti != targets.end(); ++ti) {
- std::string targetName = (*ti)->GetName();
- switch ((*ti)->GetType()) {
+ localGen->GetGeneratorTargets();
+ std::string currentDir = localGen->GetCurrentBinaryDirectory();
+ bool topLevel = (currentDir == localGen->GetBinaryDirectory());
+
+ for (cmGeneratorTarget* target : targets) {
+ std::string const& targetName = target->GetName();
+ switch (target->GetType()) {
case cmStateEnums::GLOBAL_TARGET: {
bool insertTarget = false;
// Only add the global targets from CMAKE_BINARY_DIR,
@@ -134,7 +132,7 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg,
// this will not work within the IDE
if (targetName == "edit_cache") {
const char* editCommand =
- (*it)->GetMakefile()->GetDefinition("CMAKE_EDIT_COMMAND");
+ localGen->GetMakefile()->GetDefinition("CMAKE_EDIT_COMMAND");
if (editCommand == nullptr) {
insertTarget = false;
} else if (strstr(editCommand, "ccmake") != nullptr) {
@@ -183,12 +181,9 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg,
// insert rules for compiling, preprocessing and assembling individual
// files
std::vector<std::string> objectFileTargets;
- (*it)->GetIndividualFileTargets(objectFileTargets);
- for (std::vector<std::string>::const_iterator fit =
- objectFileTargets.begin();
- fit != objectFileTargets.end(); ++fit) {
- this->AppendTarget(fout, *fit, make, makeArgs, currentDir,
- homeOutputDir);
+ localGen->GetIndividualFileTargets(objectFileTargets);
+ for (std::string const& f : objectFileTargets) {
+ this->AppendTarget(fout, f, make, makeArgs, currentDir, homeOutputDir);
}
}
@@ -251,22 +246,18 @@ std::string cmExtraKateGenerator::GenerateFilesString(
const std::vector<cmLocalGenerator*>& lgs =
this->GlobalGenerator->GetLocalGenerators();
- for (std::vector<cmLocalGenerator*>::const_iterator it = lgs.begin();
- it != lgs.end(); it++) {
- cmMakefile* makefile = (*it)->GetMakefile();
+ for (cmLocalGenerator* lgen : lgs) {
+ cmMakefile* makefile = lgen->GetMakefile();
const std::vector<std::string>& listFiles = makefile->GetListFiles();
- for (std::vector<std::string>::const_iterator lt = listFiles.begin();
- lt != listFiles.end(); lt++) {
- tmp = *lt;
+ for (std::string const& listFile : listFiles) {
+ tmp = listFile;
{
files.insert(tmp);
}
}
const std::vector<cmSourceFile*>& sources = makefile->GetSourceFiles();
- for (std::vector<cmSourceFile*>::const_iterator sfIt = sources.begin();
- sfIt != sources.end(); sfIt++) {
- cmSourceFile* sf = *sfIt;
+ for (cmSourceFile* sf : sources) {
if (sf->GetPropertyAsBool("GENERATED")) {
continue;
}
@@ -278,11 +269,10 @@ std::string cmExtraKateGenerator::GenerateFilesString(
const char* sep = "";
tmp = "\"list\": [";
- for (std::set<std::string>::const_iterator it = files.begin();
- it != files.end(); ++it) {
+ for (std::string const& f : files) {
tmp += sep;
tmp += " \"";
- tmp += *it;
+ tmp += f;
tmp += "\"";
sep = ",";
}
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index bd0a261..78cf3ec 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -68,11 +68,9 @@ void cmExtraSublimeTextGenerator::Generate()
"CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS");
// for each sub project in the project create a sublime text 2 project
- for (std::map<std::string, std::vector<cmLocalGenerator*>>::const_iterator
- it = this->GlobalGenerator->GetProjectMap().begin();
- it != this->GlobalGenerator->GetProjectMap().end(); ++it) {
+ for (auto const& it : this->GlobalGenerator->GetProjectMap()) {
// create a project file
- this->CreateProjectFile(it->second);
+ this->CreateProjectFile(it.second);
}
}
@@ -144,20 +142,19 @@ void cmExtraSublimeTextGenerator::CreateNewProjectFile(
fout << "\n\t{";
fout << "\n\t\t" << systemName << ":";
fout << "\n\t\t{";
- for (std::vector<std::string>::iterator i = tokens.begin();
- i != tokens.end(); ++i) {
- size_t const pos = i->find_first_of('=');
+ for (std::string const& t : tokens) {
+ size_t const pos = t.find_first_of('=');
if (pos != std::string::npos) {
- std::string varName = i->substr(0, pos);
- std::string varValue = i->substr(pos + 1);
+ std::string varName = t.substr(0, pos);
+ std::string varValue = t.substr(pos + 1);
fout << "\n\t\t\t\"" << varName << "\":\"" << varValue << "\"";
} else {
std::ostringstream e;
e << "Could not parse Env Vars specified in "
"\"CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS\""
- << ", corrupted string " << *i;
+ << ", corrupted string " << t;
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
}
}
@@ -182,21 +179,18 @@ void cmExtraSublimeTextGenerator::AppendAllTargets(
// add all executable and library targets and some of the GLOBAL
// and UTILITY targets
- for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin();
- lg != lgs.end(); lg++) {
- cmMakefile* makefile = (*lg)->GetMakefile();
- const std::vector<cmGeneratorTarget*>& targets =
- (*lg)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
- ti != targets.end(); ti++) {
- std::string targetName = (*ti)->GetName();
- switch ((*ti)->GetType()) {
+ for (cmLocalGenerator* lg : lgs) {
+ cmMakefile* makefile = lg->GetMakefile();
+ const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
+ for (cmGeneratorTarget* target : targets) {
+ std::string targetName = target->GetName();
+ switch (target->GetType()) {
case cmStateEnums::GLOBAL_TARGET: {
// Only add the global targets from CMAKE_BINARY_DIR,
// not from the subdirs
- if (strcmp((*lg)->GetCurrentBinaryDirectory(),
- (*lg)->GetBinaryDirectory()) == 0) {
- this->AppendTarget(fout, targetName, *lg, nullptr, make.c_str(),
+ if (strcmp(lg->GetCurrentBinaryDirectory(),
+ lg->GetBinaryDirectory()) == 0) {
+ this->AppendTarget(fout, targetName, lg, nullptr, make.c_str(),
makefile, compiler.c_str(), sourceFileFlags,
false);
}
@@ -213,7 +207,7 @@ void cmExtraSublimeTextGenerator::AppendAllTargets(
break;
}
- this->AppendTarget(fout, targetName, *lg, nullptr, make.c_str(),
+ this->AppendTarget(fout, targetName, lg, nullptr, make.c_str(),
makefile, compiler.c_str(), sourceFileFlags,
false);
break;
@@ -222,12 +216,12 @@ void cmExtraSublimeTextGenerator::AppendAllTargets(
case cmStateEnums::SHARED_LIBRARY:
case cmStateEnums::MODULE_LIBRARY:
case cmStateEnums::OBJECT_LIBRARY: {
- this->AppendTarget(fout, targetName, *lg, *ti, make.c_str(),
+ this->AppendTarget(fout, targetName, lg, target, make.c_str(),
makefile, compiler.c_str(), sourceFileFlags,
false);
std::string fastTarget = targetName;
fastTarget += "/fast";
- this->AppendTarget(fout, fastTarget, *lg, *ti, make.c_str(),
+ this->AppendTarget(fout, fastTarget, lg, target, make.c_str(),
makefile, compiler.c_str(), sourceFileFlags,
false);
} break;
@@ -249,11 +243,7 @@ void cmExtraSublimeTextGenerator::AppendTarget(
std::vector<cmSourceFile*> sourceFiles;
target->GetSourceFiles(sourceFiles,
makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
- std::vector<cmSourceFile*>::const_iterator sourceFilesEnd =
- sourceFiles.end();
- for (std::vector<cmSourceFile*>::const_iterator iter = sourceFiles.begin();
- iter != sourceFilesEnd; ++iter) {
- cmSourceFile* sourceFile = *iter;
+ for (cmSourceFile* sourceFile : sourceFiles) {
MapSourceFileFlags::iterator sourceFileFlagsIter =
sourceFileFlags.find(sourceFile->GetFullPath());
if (sourceFileFlagsIter == sourceFileFlags.end()) {
@@ -264,8 +254,9 @@ void cmExtraSublimeTextGenerator::AppendTarget(
.first;
}
std::vector<std::string>& flags = sourceFileFlagsIter->second;
- std::string flagsString = this->ComputeFlagsForObject(*iter, lg, target);
- std::string definesString = this->ComputeDefines(*iter, lg, target);
+ std::string flagsString =
+ this->ComputeFlagsForObject(sourceFile, lg, target);
+ std::string definesString = this->ComputeDefines(sourceFile, lg, target);
flags.clear();
cmsys::RegularExpression flagRegex;
// Regular expression to extract compiler flags from a string
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 3af7484..4eb74cc 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -723,20 +723,18 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
// Encode the result in a CMake list.
const char* sep = "";
std::string output;
- for (std::vector<std::string>::const_iterator si = strings.begin();
- si != strings.end(); ++si) {
+ for (std::string const& sr : strings) {
// Separate the strings in the output to make it a list.
output += sep;
sep = ";";
// Store the string in the output, but escape semicolons to
// make sure it is a list.
- std::string const& sr = *si;
- for (unsigned int i = 0; i < sr.size(); ++i) {
- if (sr[i] == ';') {
+ for (char i : sr) {
+ if (i == ';') {
output += '\\';
}
- output += sr[i];
+ output += i;
}
}
@@ -841,17 +839,16 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
if (!globMessages.empty()) {
bool shouldExit = false;
- for (cmsys::Glob::GlobMessagesIterator it = globMessages.begin();
- it != globMessages.end(); ++it) {
- if (it->type == cmsys::Glob::cyclicRecursion) {
+ for (cmsys::Glob::Message const& globMessage : globMessages) {
+ if (globMessage.type == cmsys::Glob::cyclicRecursion) {
this->Makefile->IssueMessage(
cmake::AUTHOR_WARNING,
"Cyclic recursion detected while globbing for '" + *i + "':\n" +
- it->content);
+ globMessage.content);
} else {
this->Makefile->IssueMessage(
cmake::FATAL_ERROR, "Error has occurred while globbing for '" +
- *i + "' - " + it->content);
+ *i + "' - " + globMessage.content);
shouldExit = true;
}
}
@@ -1060,12 +1057,11 @@ protected:
// Collect properties from all matching rules.
bool matched = false;
MatchProperties result;
- for (std::vector<MatchRule>::iterator mr = this->MatchRules.begin();
- mr != this->MatchRules.end(); ++mr) {
- if (mr->Regex.find(file_to_match)) {
+ for (MatchRule& mr : this->MatchRules) {
+ if (mr.Regex.find(file_to_match)) {
matched = true;
- result.Exclude |= mr->Properties.Exclude;
- result.Permissions |= mr->Properties.Permissions;
+ result.Exclude |= mr.Properties.Exclude;
+ result.Permissions |= mr.Properties.Permissions;
}
}
if (!matched && !this->MatchlessFiles) {
@@ -1421,23 +1417,22 @@ bool cmFileCopier::Run(std::vector<std::string> const& args)
return false;
}
- for (std::vector<std::string>::const_iterator i = this->Files.begin();
- i != this->Files.end(); ++i) {
+ for (std::string const& f : this->Files) {
std::string file;
- if (!i->empty() && !cmSystemTools::FileIsFullPath(*i)) {
+ if (!f.empty() && !cmSystemTools::FileIsFullPath(f)) {
if (!this->FilesFromDir.empty()) {
file = this->FilesFromDir;
} else {
file = this->Makefile->GetCurrentSourceDirectory();
}
file += "/";
- file += *i;
+ file += f;
} else if (!this->FilesFromDir.empty()) {
this->FileCommand->SetError("option FILES_FROM_DIR requires all files "
"to be specified as relative paths.");
return false;
} else {
- file = *i;
+ file = f;
}
// Split the input file into its directory and name components.
@@ -1450,7 +1445,7 @@ bool cmFileCopier::Run(std::vector<std::string> const& args)
// Compute the full path to the destination file.
std::string toFile = this->Destination;
if (!this->FilesFromDir.empty()) {
- std::string dir = cmSystemTools::GetFilenamePath(*i);
+ std::string dir = cmSystemTools::GetFilenamePath(f);
if (!dir.empty()) {
toFile += "/";
toFile += dir;
@@ -2882,9 +2877,8 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
}
struct curl_slist* headers = nullptr;
- for (std::vector<std::string>::const_iterator h = curl_headers.begin();
- h != curl_headers.end(); ++h) {
- headers = ::curl_slist_append(headers, h->c_str());
+ for (std::string const& h : curl_headers) {
+ headers = ::curl_slist_append(headers, h.c_str());
}
::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
@@ -3141,9 +3135,8 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
}
struct curl_slist* headers = nullptr;
- for (std::vector<std::string>::const_iterator h = curl_headers.begin();
- h != curl_headers.end(); ++h) {
- headers = ::curl_slist_append(headers, h->c_str());
+ for (std::string const& h : curl_headers) {
+ headers = ::curl_slist_append(headers, h.c_str());
}
::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
diff --git a/Source/cmFileLockPool.cxx b/Source/cmFileLockPool.cxx
index 7b1564c..5dc9243 100644
--- a/Source/cmFileLockPool.cxx
+++ b/Source/cmFileLockPool.cxx
@@ -75,16 +75,15 @@ cmFileLockResult cmFileLockPool::LockProcessScope(const std::string& filename,
cmFileLockResult cmFileLockPool::Release(const std::string& filename)
{
- for (It i = this->FunctionScopes.begin(); i != this->FunctionScopes.end();
- ++i) {
- const cmFileLockResult result = (*i)->Release(filename);
+ for (auto& funcScope : this->FunctionScopes) {
+ const cmFileLockResult result = funcScope->Release(filename);
if (!result.IsOk()) {
return result;
}
}
- for (It i = this->FileScopes.begin(); i != this->FileScopes.end(); ++i) {
- const cmFileLockResult result = (*i)->Release(filename);
+ for (auto& fileScope : this->FileScopes) {
+ const cmFileLockResult result = fileScope->Release(filename);
if (!result.IsOk()) {
return result;
}
@@ -95,16 +94,15 @@ cmFileLockResult cmFileLockPool::Release(const std::string& filename)
bool cmFileLockPool::IsAlreadyLocked(const std::string& filename) const
{
- for (CIt i = this->FunctionScopes.begin(); i != this->FunctionScopes.end();
- ++i) {
- const bool result = (*i)->IsAlreadyLocked(filename);
+ for (auto const& funcScope : this->FunctionScopes) {
+ const bool result = funcScope->IsAlreadyLocked(filename);
if (result) {
return true;
}
}
- for (CIt i = this->FileScopes.begin(); i != this->FileScopes.end(); ++i) {
- const bool result = (*i)->IsAlreadyLocked(filename);
+ for (auto const& fileScope : this->FileScopes) {
+ const bool result = fileScope->IsAlreadyLocked(filename);
if (result) {
return true;
}
@@ -138,9 +136,9 @@ cmFileLockResult cmFileLockPool::ScopePool::Lock(const std::string& filename,
cmFileLockResult cmFileLockPool::ScopePool::Release(
const std::string& filename)
{
- for (It i = this->Locks.begin(); i != this->Locks.end(); ++i) {
- if ((*i)->IsLocked(filename)) {
- return (*i)->Release();
+ for (auto& lock : this->Locks) {
+ if (lock->IsLocked(filename)) {
+ return lock->Release();
}
}
return cmFileLockResult::MakeOk();
@@ -149,8 +147,8 @@ cmFileLockResult cmFileLockPool::ScopePool::Release(
bool cmFileLockPool::ScopePool::IsAlreadyLocked(
const std::string& filename) const
{
- for (CIt i = this->Locks.begin(); i != this->Locks.end(); ++i) {
- if ((*i)->IsLocked(filename)) {
+ for (auto const& lock : this->Locks) {
+ if (lock->IsLocked(filename)) {
return true;
}
}
diff --git a/Source/cmFileMonitor.cxx b/Source/cmFileMonitor.cxx
index c0401d7..04a3c0e 100644
--- a/Source/cmFileMonitor.cxx
+++ b/Source/cmFileMonitor.cxx
@@ -49,8 +49,8 @@ public:
int status) const final
{
if (pathSegment.empty()) {
- for (const auto& i : this->Children) {
- i.second->Trigger(std::string(), events, status);
+ for (auto const& child : this->Children) {
+ child.second->Trigger(std::string(), events, status);
}
} else {
const auto i = this->Children.find(pathSegment);
@@ -62,24 +62,24 @@ public:
void StartWatching() override
{
- for (const auto& i : this->Children) {
- i.second->StartWatching();
+ for (auto const& child : this->Children) {
+ child.second->StartWatching();
}
}
void StopWatching() override
{
- for (const auto& i : this->Children) {
- i.second->StopWatching();
+ for (auto const& child : this->Children) {
+ child.second->StopWatching();
}
}
std::vector<std::string> WatchedFiles() const final
{
std::vector<std::string> result;
- for (const auto& i : this->Children) {
- for (const auto& j : i.second->WatchedFiles()) {
- result.push_back(j);
+ for (auto const& child : this->Children) {
+ for (std::string const& f : child.second->WatchedFiles()) {
+ result.push_back(f);
}
}
return result;
@@ -88,9 +88,9 @@ public:
std::vector<std::string> WatchedDirectories() const override
{
std::vector<std::string> result;
- for (const auto& i : this->Children) {
- for (const auto& j : i.second->WatchedDirectories()) {
- result.push_back(j);
+ for (auto const& child : this->Children) {
+ for (std::string const& dir : child.second->WatchedDirectories()) {
+ result.push_back(dir);
}
}
return result;
@@ -184,8 +184,9 @@ public:
std::vector<std::string> WatchedDirectories() const override
{
std::vector<std::string> result = { Path() };
- for (const auto& j : cmVirtualDirectoryWatcher::WatchedDirectories()) {
- result.push_back(j);
+ for (std::string const& dir :
+ cmVirtualDirectoryWatcher::WatchedDirectories()) {
+ result.push_back(dir);
}
return result;
}
@@ -267,7 +268,7 @@ public:
static_cast<void>(ps);
const std::string path = this->Path();
- for (const auto& cb : this->CbList) {
+ for (cmFileMonitor::Callback const& cb : this->CbList) {
cb(path, events, status);
}
}
@@ -311,7 +312,7 @@ cmFileMonitor::~cmFileMonitor()
void cmFileMonitor::MonitorPaths(const std::vector<std::string>& paths,
Callback const& cb)
{
- for (const auto& p : paths) {
+ for (std::string const& p : paths) {
std::vector<std::string> pathSegments;
cmsys::SystemTools::SplitPath(p, pathSegments, true);
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index b195d27..417cdd2 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -280,10 +280,8 @@ void cmFindBase::FillUserHintsPath()
{
cmSearchPath& paths = this->LabeledPaths[PathLabel::Hints];
- for (std::vector<std::string>::const_iterator p =
- this->UserHintsArgs.begin();
- p != this->UserHintsArgs.end(); ++p) {
- paths.AddUserPath(*p);
+ for (std::string const& p : this->UserHintsArgs) {
+ paths.AddUserPath(p);
}
paths.AddSuffixes(this->SearchPathSuffixes);
}
@@ -292,10 +290,8 @@ void cmFindBase::FillUserGuessPath()
{
cmSearchPath& paths = this->LabeledPaths[PathLabel::Guess];
- for (std::vector<std::string>::const_iterator p =
- this->UserGuessArgs.begin();
- p != this->UserGuessArgs.end(); ++p) {
- paths.AddUserPath(*p);
+ for (std::string const& p : this->UserGuessArgs) {
+ paths.AddUserPath(p);
}
paths.AddSuffixes(this->SearchPathSuffixes);
}
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx
index 9ebe824..8142962 100644
--- a/Source/cmFindCommon.cxx
+++ b/Source/cmFindCommon.cxx
@@ -155,10 +155,9 @@ void cmFindCommon::SelectDefaultMacMode()
void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
{
#if 0
- for(std::vector<std::string>::const_iterator i = paths.begin();
- i != paths.end(); ++i)
+ for(std::string const& p : paths)
{
- fprintf(stderr, "[%s]\n", i->c_str());
+ fprintf(stderr, "[%s]\n", p.c_str());
}
#endif
// Short-circuit if there is nothing to do.
@@ -194,9 +193,8 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
if (sysroot) {
roots.push_back(sysroot);
}
- for (std::vector<std::string>::iterator ri = roots.begin();
- ri != roots.end(); ++ri) {
- cmSystemTools::ConvertToUnixSlashes(*ri);
+ for (std::string& r : roots) {
+ cmSystemTools::ConvertToUnixSlashes(r);
}
const char* stagePrefix =
@@ -206,24 +204,22 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
std::vector<std::string> unrootedPaths = paths;
paths.clear();
- for (std::vector<std::string>::const_iterator ri = roots.begin();
- ri != roots.end(); ++ri) {
- for (std::vector<std::string>::const_iterator ui = unrootedPaths.begin();
- ui != unrootedPaths.end(); ++ui) {
+ for (std::string const& r : roots) {
+ for (std::string const& up : unrootedPaths) {
// Place the unrooted path under the current root if it is not
// already inside. Skip the unrooted path if it is relative to
// a user home directory or is empty.
std::string rootedDir;
- if (cmSystemTools::IsSubDirectory(*ui, *ri) ||
- (stagePrefix && cmSystemTools::IsSubDirectory(*ui, stagePrefix))) {
- rootedDir = *ui;
- } else if (!ui->empty() && (*ui)[0] != '~') {
+ if (cmSystemTools::IsSubDirectory(up, r) ||
+ (stagePrefix && cmSystemTools::IsSubDirectory(up, stagePrefix))) {
+ rootedDir = up;
+ } else if (!up.empty() && up[0] != '~') {
// Start with the new root.
- rootedDir = *ri;
+ rootedDir = r;
rootedDir += "/";
// Append the original path with its old root removed.
- rootedDir += cmSystemTools::SplitPathRootComponent(*ui);
+ rootedDir += cmSystemTools::SplitPathRootComponent(up);
}
// Store the new path.
@@ -255,9 +251,8 @@ void cmFindCommon::GetIgnoredPaths(std::vector<std::string>& ignore)
cmSystemTools::ExpandListArgument(ignorePath, ignore);
}
- for (std::vector<std::string>::iterator i = ignore.begin();
- i != ignore.end(); ++i) {
- cmSystemTools::ConvertToUnixSlashes(*i);
+ for (std::string& i : ignore) {
+ cmSystemTools::ConvertToUnixSlashes(i);
}
}
@@ -337,9 +332,8 @@ void cmFindCommon::ComputeFinalPaths()
// Combine the seperate path types, filtering out ignores
this->SearchPaths.clear();
std::vector<PathLabel>& allLabels = this->PathGroupLabelMap[PathGroup::All];
- for (std::vector<PathLabel>::const_iterator l = allLabels.begin();
- l != allLabels.end(); ++l) {
- this->LabeledPaths[*l].ExtractWithout(ignored, this->SearchPaths);
+ for (PathLabel const& l : allLabels) {
+ this->LabeledPaths[l].ExtractWithout(ignored, this->SearchPaths);
}
// Expand list of paths inside all search roots.
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index a6b1a21..09a9648 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -87,9 +87,8 @@ void cmFindLibraryCommand::AddArchitecturePaths(const char* suffix)
{
std::vector<std::string> original;
original.swap(this->SearchPaths);
- for (std::vector<std::string>::const_iterator i = original.begin();
- i != original.end(); ++i) {
- this->AddArchitecturePath(*i, 0, suffix);
+ for (std::string const& o : original) {
+ this->AddArchitecturePath(o, 0, suffix);
}
}
@@ -254,8 +253,7 @@ cmFindLibraryHelper::cmFindLibraryHelper(cmMakefile* mf)
void cmFindLibraryHelper::RegexFromLiteral(std::string& out,
std::string const& in)
{
- for (std::string::const_iterator ci = in.begin(); ci != in.end(); ++ci) {
- char ch = *ci;
+ for (char ch : in) {
if (ch == '[' || ch == ']' || ch == '(' || ch == ')' || ch == '\\' ||
ch == '.' || ch == '*' || ch == '+' || ch == '?' || ch == '-' ||
ch == '^' || ch == '$') {
@@ -276,23 +274,20 @@ void cmFindLibraryHelper::RegexFromList(std::string& out,
// else and the result can be checked after matching.
out += "(";
const char* sep = "";
- for (std::vector<std::string>::const_iterator si = in.begin();
- si != in.end(); ++si) {
+ for (std::string const& s : in) {
// Separate from previous item.
out += sep;
sep = "|";
// Append this item.
- this->RegexFromLiteral(out, *si);
+ this->RegexFromLiteral(out, s);
}
out += ")";
}
bool cmFindLibraryHelper::HasValidSuffix(std::string const& name)
{
- for (std::vector<std::string>::const_iterator si = this->Suffixes.begin();
- si != this->Suffixes.end(); ++si) {
- std::string suffix = *si;
+ for (std::string suffix : this->Suffixes) {
if (name.length() <= suffix.length()) {
continue;
}
@@ -339,9 +334,8 @@ void cmFindLibraryHelper::SetName(std::string const& name)
bool cmFindLibraryHelper::CheckDirectory(std::string const& path)
{
- for (std::vector<Name>::iterator i = this->Names.begin();
- i != this->Names.end(); ++i) {
- if (this->CheckDirectoryForName(path, *i)) {
+ for (Name& i : this->Names) {
+ if (this->CheckDirectoryForName(path, i)) {
return true;
}
}
@@ -376,9 +370,7 @@ bool cmFindLibraryHelper::CheckDirectoryForName(std::string const& path,
std::string dir = path;
cmSystemTools::ConvertToUnixSlashes(dir);
std::set<std::string> const& files = this->GG->GetDirectoryContent(dir);
- for (std::set<std::string>::const_iterator fi = files.begin();
- fi != files.end(); ++fi) {
- std::string const& origName = *fi;
+ for (std::string const& origName : files) {
#if defined(_WIN32) || defined(__APPLE__)
std::string testName = cmSystemTools::LowerCase(origName);
#else
@@ -430,14 +422,12 @@ std::string cmFindLibraryCommand::FindNormalLibraryNamesPerDir()
{
// Search for all names in each directory.
cmFindLibraryHelper helper(this->Makefile);
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- helper.AddName(*ni);
+ for (std::string const& n : this->Names) {
+ helper.AddName(n);
}
// Search every directory.
- for (std::vector<std::string>::const_iterator p = this->SearchPaths.begin();
- p != this->SearchPaths.end(); ++p) {
- if (helper.CheckDirectory(*p)) {
+ for (std::string const& sp : this->SearchPaths) {
+ if (helper.CheckDirectory(sp)) {
return helper.BestPath;
}
}
@@ -449,16 +439,13 @@ std::string cmFindLibraryCommand::FindNormalLibraryDirsPerName()
{
// Search the entire path for each name.
cmFindLibraryHelper helper(this->Makefile);
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
+ for (std::string const& n : this->Names) {
// Switch to searching for this name.
- helper.SetName(*ni);
+ helper.SetName(n);
// Search every directory.
- for (std::vector<std::string>::const_iterator p =
- this->SearchPaths.begin();
- p != this->SearchPaths.end(); ++p) {
- if (helper.CheckDirectory(*p)) {
+ for (std::string const& sp : this->SearchPaths) {
+ if (helper.CheckDirectory(sp)) {
return helper.BestPath;
}
}
@@ -479,12 +466,10 @@ std::string cmFindLibraryCommand::FindFrameworkLibraryNamesPerDir()
{
std::string fwPath;
// Search for all names in each search path.
- for (std::vector<std::string>::const_iterator di = this->SearchPaths.begin();
- di != this->SearchPaths.end(); ++di) {
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- fwPath = *di;
- fwPath += *ni;
+ for (std::string const& d : this->SearchPaths) {
+ for (std::string const& n : this->Names) {
+ fwPath = d;
+ fwPath += n;
fwPath += ".framework";
if (cmSystemTools::FileIsDirectory(fwPath)) {
return cmSystemTools::CollapseFullPath(fwPath);
@@ -500,13 +485,10 @@ std::string cmFindLibraryCommand::FindFrameworkLibraryDirsPerName()
{
std::string fwPath;
// Search for each name in all search paths.
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- for (std::vector<std::string>::const_iterator di =
- this->SearchPaths.begin();
- di != this->SearchPaths.end(); ++di) {
- fwPath = *di;
- fwPath += *ni;
+ for (std::string const& n : this->Names) {
+ for (std::string const& d : this->SearchPaths) {
+ fwPath = d;
+ fwPath += n;
fwPath += ".framework";
if (cmSystemTools::FileIsDirectory(fwPath)) {
return cmSystemTools::CollapseFullPath(fwPath);
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index d0cc6ce..9b79931 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -367,14 +367,12 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args,
if (!this->UseFindModules && !this->UseConfigFiles) {
std::ostringstream e;
e << "given options exclusive to Module mode:\n";
- for (std::set<unsigned int>::const_iterator si = moduleArgs.begin();
- si != moduleArgs.end(); ++si) {
- e << " " << args[*si] << "\n";
+ for (unsigned int si : moduleArgs) {
+ e << " " << args[si] << "\n";
}
e << "and options exclusive to Config mode:\n";
- for (std::set<unsigned int>::const_iterator si = configArgs.begin();
- si != configArgs.end(); ++si) {
- e << " " << args[*si] << "\n";
+ for (unsigned int si : configArgs) {
+ e << " " << args[si] << "\n";
}
e << "The options are incompatible.";
this->SetError(e.str());
@@ -518,13 +516,12 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args,
// Add the default configs.
if (this->Configs.empty()) {
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- std::string config = *ni;
+ for (std::string const& n : this->Names) {
+ std::string config = n;
config += "Config.cmake";
this->Configs.push_back(config);
- config = cmSystemTools::LowerCase(*ni);
+ config = cmSystemTools::LowerCase(n);
config += "-config.cmake";
this->Configs.push_back(config);
}
@@ -611,14 +608,12 @@ void cmFindPackageCommand::AddFindDefinition(const std::string& var,
void cmFindPackageCommand::RestoreFindDefinitions()
{
- for (std::map<std::string, OriginalDef>::iterator i =
- this->OriginalDefs.begin();
- i != this->OriginalDefs.end(); ++i) {
- OriginalDef const& od = i->second;
+ for (auto const& i : this->OriginalDefs) {
+ OriginalDef const& od = i.second;
if (od.exists) {
- this->Makefile->AddDefinition(i->first, od.value.c_str());
+ this->Makefile->AddDefinition(i.first, od.value.c_str());
} else {
- this->Makefile->RemoveDefinition(i->first);
+ this->Makefile->RemoveDefinition(i.first);
}
}
}
@@ -874,13 +869,11 @@ bool cmFindPackageCommand::HandlePackageMode()
std::string consideredVersions;
const char* sep = "";
- for (std::vector<ConfigFileInfo>::const_iterator i =
- this->ConsideredConfigs.begin();
- i != this->ConsideredConfigs.end(); ++i) {
+ for (ConfigFileInfo const& i : this->ConsideredConfigs) {
consideredConfigFiles += sep;
consideredVersions += sep;
- consideredConfigFiles += i->filename;
- consideredVersions += i->version;
+ consideredConfigFiles += i.filename;
+ consideredVersions += i.version;
sep = ";";
}
@@ -946,9 +939,8 @@ bool cmFindPackageCommand::FindConfig()
bool cmFindPackageCommand::FindPrefixedConfig()
{
std::vector<std::string> const& prefixes = this->SearchPaths;
- for (std::vector<std::string>::const_iterator pi = prefixes.begin();
- pi != prefixes.end(); ++pi) {
- if (this->SearchPrefix(*pi)) {
+ for (std::string const& p : prefixes) {
+ if (this->SearchPrefix(p)) {
return true;
}
}
@@ -958,9 +950,8 @@ bool cmFindPackageCommand::FindPrefixedConfig()
bool cmFindPackageCommand::FindFrameworkConfig()
{
std::vector<std::string> const& prefixes = this->SearchPaths;
- for (std::vector<std::string>::const_iterator i = prefixes.begin();
- i != prefixes.end(); ++i) {
- if (this->SearchFrameworkPrefix(*i)) {
+ for (std::string const& p : prefixes) {
+ if (this->SearchFrameworkPrefix(p)) {
return true;
}
}
@@ -970,9 +961,8 @@ bool cmFindPackageCommand::FindFrameworkConfig()
bool cmFindPackageCommand::FindAppBundleConfig()
{
std::vector<std::string> const& prefixes = this->SearchPaths;
- for (std::vector<std::string>::const_iterator i = prefixes.begin();
- i != prefixes.end(); ++i) {
- if (this->SearchAppBundlePrefix(*i)) {
+ for (std::string const& p : prefixes) {
+ if (this->SearchAppBundlePrefix(p)) {
return true;
}
}
@@ -1171,14 +1161,12 @@ void cmFindPackageCommand::FillPrefixesSystemEnvironment()
// working directory.
std::vector<std::string> tmp;
cmSystemTools::GetPath(tmp);
- for (std::vector<std::string>::iterator i = tmp.begin(); i != tmp.end();
- ++i) {
+ for (std::string const& i : tmp) {
// If the path is a PREFIX/bin case then add its parent instead.
- if ((cmHasLiteralSuffix(*i, "/bin")) ||
- (cmHasLiteralSuffix(*i, "/sbin"))) {
- paths.AddPath(cmSystemTools::GetFilenamePath(*i));
+ if ((cmHasLiteralSuffix(i, "/bin")) || (cmHasLiteralSuffix(i, "/sbin"))) {
+ paths.AddPath(cmSystemTools::GetFilenamePath(i));
} else {
- paths.AddPath(*i);
+ paths.AddPath(i);
}
}
}
@@ -1296,9 +1284,8 @@ void cmFindPackageCommand::LoadPackageRegistryWin(bool user, unsigned int view,
if (user && !bad.empty() &&
RegOpenKeyExW(HKEY_CURRENT_USER, key.c_str(), 0, KEY_SET_VALUE | view,
&hKey) == ERROR_SUCCESS) {
- for (std::set<std::wstring>::const_iterator vi = bad.begin();
- vi != bad.end(); ++vi) {
- RegDeleteValueW(hKey, vi->c_str());
+ for (std::wstring const& v : bad) {
+ RegDeleteValueW(hKey, v.c_str());
}
RegCloseKey(hKey);
}
@@ -1395,10 +1382,8 @@ void cmFindPackageCommand::FillPrefixesUserGuess()
{
cmSearchPath& paths = this->LabeledPaths[PathLabel::Guess];
- for (std::vector<std::string>::const_iterator p =
- this->UserGuessArgs.begin();
- p != this->UserGuessArgs.end(); ++p) {
- paths.AddUserPath(*p);
+ for (std::string const& p : this->UserGuessArgs) {
+ paths.AddUserPath(p);
}
}
@@ -1406,10 +1391,8 @@ void cmFindPackageCommand::FillPrefixesUserHints()
{
cmSearchPath& paths = this->LabeledPaths[PathLabel::Hints];
- for (std::vector<std::string>::const_iterator p =
- this->UserHintsArgs.begin();
- p != this->UserHintsArgs.end(); ++p) {
- paths.AddUserPath(*p);
+ for (std::string const& p : this->UserHintsArgs) {
+ paths.AddUserPath(p);
}
}
@@ -1418,12 +1401,10 @@ bool cmFindPackageCommand::SearchDirectory(std::string const& dir)
assert(!dir.empty() && dir[dir.size() - 1] == '/');
// Check each path suffix on this directory.
- for (std::vector<std::string>::const_iterator si =
- this->SearchPathSuffixes.begin();
- si != this->SearchPathSuffixes.end(); ++si) {
+ for (std::string const& s : this->SearchPathSuffixes) {
std::string d = dir;
- if (!si->empty()) {
- d += *si;
+ if (!s.empty()) {
+ d += s;
d += "/";
}
if (this->CheckDirectory(d)) {
@@ -1454,11 +1435,10 @@ bool cmFindPackageCommand::FindConfigFile(std::string const& dir,
return false;
}
- for (std::vector<std::string>::const_iterator ci = this->Configs.begin();
- ci != this->Configs.end(); ++ci) {
+ for (std::string const& c : this->Configs) {
file = dir;
file += "/";
- file += *ci;
+ file += c;
if (this->DebugMode) {
fprintf(stderr, "Checking file [%s]\n", file.c_str());
}
@@ -1761,9 +1741,8 @@ private:
std::vector<std::string> const& Vector;
bool Search(std::string const& parent, cmFileList& lister) CM_OVERRIDE
{
- for (std::vector<std::string>::const_iterator i = this->Vector.begin();
- i != this->Vector.end(); ++i) {
- if (this->Consider(parent + *i, lister)) {
+ for (std::string const& i : this->Vector) {
+ if (this->Consider(parent + i, lister)) {
return true;
}
}
@@ -1820,9 +1799,8 @@ private:
if (strcmp(fname, ".") == 0 || strcmp(fname, "..") == 0) {
continue;
}
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- if (cmsysString_strncasecmp(fname, ni->c_str(), ni->length()) == 0) {
+ for (std::string const& n : this->Names) {
+ if (cmsysString_strncasecmp(fname, n.c_str(), n.length()) == 0) {
matches.push_back(fname);
}
}
@@ -1835,9 +1813,8 @@ private:
SortDirection);
}
- for (std::vector<std::string>::const_iterator i = matches.begin();
- i != matches.end(); ++i) {
- if (this->Consider(parent + *i, lister)) {
+ for (std::string const& i : matches) {
+ if (this->Consider(parent + i, lister)) {
return true;
}
}
@@ -1882,9 +1859,7 @@ private:
if (strcmp(fname, ".") == 0 || strcmp(fname, "..") == 0) {
continue;
}
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- std::string name = *ni;
+ for (std::string name : this->Names) {
name += this->Extension;
if (cmsysString_strcasecmp(fname, name.c_str()) == 0) {
matches.push_back(fname);
@@ -1892,9 +1867,8 @@ private:
}
}
- for (std::vector<std::string>::const_iterator i = matches.begin();
- i != matches.end(); ++i) {
- if (this->Consider(parent + *i, lister)) {
+ for (std::string const& i : matches) {
+ if (this->Consider(parent + i, lister)) {
return true;
}
}
@@ -1980,10 +1954,9 @@ private:
std::vector<std::string> const& files = g.GetFiles();
// Look for directories among the matches.
- for (std::vector<std::string>::const_iterator fi = files.begin();
- fi != files.end(); ++fi) {
- if (cmSystemTools::FileIsDirectory(*fi)) {
- if (this->Consider(*fi, lister)) {
+ for (std::string const& f : files) {
+ if (cmSystemTools::FileIsDirectory(f)) {
+ if (this->Consider(f, lister)) {
return true;
}
}
diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx
index d3541ca..35a8a44 100644
--- a/Source/cmFindPathCommand.cxx
+++ b/Source/cmFindPathCommand.cxx
@@ -124,18 +124,15 @@ std::string cmFindPathCommand::FindHeaderInFramework(std::string const& file,
std::string cmFindPathCommand::FindNormalHeader()
{
std::string tryPath;
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- for (std::vector<std::string>::const_iterator p =
- this->SearchPaths.begin();
- p != this->SearchPaths.end(); ++p) {
- tryPath = *p;
- tryPath += *ni;
+ for (std::string const& n : this->Names) {
+ for (std::string const& sp : this->SearchPaths) {
+ tryPath = sp;
+ tryPath += n;
if (cmSystemTools::FileExists(tryPath.c_str())) {
if (this->IncludeFileInPath) {
return tryPath;
}
- return *p;
+ return sp;
}
}
}
@@ -144,12 +141,9 @@ std::string cmFindPathCommand::FindNormalHeader()
std::string cmFindPathCommand::FindFrameworkHeader()
{
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- for (std::vector<std::string>::const_iterator p =
- this->SearchPaths.begin();
- p != this->SearchPaths.end(); ++p) {
- std::string fwPath = this->FindHeaderInFramework(*ni, *p);
+ for (std::string const& n : this->Names) {
+ for (std::string const& sp : this->SearchPaths) {
+ std::string fwPath = this->FindHeaderInFramework(n, sp);
if (!fwPath.empty()) {
return fwPath;
}
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx
index 9327c18..a290229 100644
--- a/Source/cmFindProgramCommand.cxx
+++ b/Source/cmFindProgramCommand.cxx
@@ -45,9 +45,8 @@ struct cmFindProgramHelper
}
bool CheckDirectory(std::string const& path)
{
- for (std::vector<std::string>::iterator i = this->Names.begin();
- i != this->Names.end(); ++i) {
- if (this->CheckDirectoryForName(path, *i)) {
+ for (std::string const& n : this->Names) {
+ if (this->CheckDirectoryForName(path, n)) {
return true;
}
}
@@ -55,14 +54,13 @@ struct cmFindProgramHelper
}
bool CheckDirectoryForName(std::string const& path, std::string const& name)
{
- for (std::vector<std::string>::iterator ext = this->Extensions.begin();
- ext != this->Extensions.end(); ++ext) {
+ for (std::string const& ext : this->Extensions) {
this->TestPath = path;
this->TestPath += name;
- if (!ext->empty() && cmSystemTools::StringEndsWith(name, ext->c_str())) {
+ if (!ext.empty() && cmSystemTools::StringEndsWith(name, ext.c_str())) {
continue;
}
- this->TestPath += *ext;
+ this->TestPath += ext;
if (cmSystemTools::FileExists(this->TestPath, true)) {
this->BestPath = cmSystemTools::CollapseFullPath(this->TestPath);
return true;
@@ -143,9 +141,8 @@ std::string cmFindProgramCommand::FindNormalProgramNamesPerDir()
{
// Search for all names in each directory.
cmFindProgramHelper helper;
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- helper.AddName(*ni);
+ for (std::string const& n : this->Names) {
+ helper.AddName(n);
}
// Check for the names themselves (e.g. absolute paths).
@@ -154,9 +151,8 @@ std::string cmFindProgramCommand::FindNormalProgramNamesPerDir()
}
// Search every directory.
- for (std::vector<std::string>::const_iterator p = this->SearchPaths.begin();
- p != this->SearchPaths.end(); ++p) {
- if (helper.CheckDirectory(*p)) {
+ for (std::string const& sp : this->SearchPaths) {
+ if (helper.CheckDirectory(sp)) {
return helper.BestPath;
}
}
@@ -168,10 +164,9 @@ std::string cmFindProgramCommand::FindNormalProgramDirsPerName()
{
// Search the entire path for each name.
cmFindProgramHelper helper;
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
+ for (std::string const& n : this->Names) {
// Switch to searching for this name.
- helper.SetName(*ni);
+ helper.SetName(n);
// Check for the name by itself (e.g. an absolute path).
if (helper.CheckDirectory(std::string())) {
@@ -179,10 +174,8 @@ std::string cmFindProgramCommand::FindNormalProgramDirsPerName()
}
// Search every directory.
- for (std::vector<std::string>::const_iterator p =
- this->SearchPaths.begin();
- p != this->SearchPaths.end(); ++p) {
- if (helper.CheckDirectory(*p)) {
+ for (std::string const& sp : this->SearchPaths) {
+ if (helper.CheckDirectory(sp)) {
return helper.BestPath;
}
}
@@ -193,10 +186,9 @@ std::string cmFindProgramCommand::FindNormalProgramDirsPerName()
std::string cmFindProgramCommand::FindAppBundle()
{
- for (std::vector<std::string>::const_iterator name = this->Names.begin();
- name != this->Names.end(); ++name) {
+ for (std::string const& name : this->Names) {
- std::string appName = *name + std::string(".app");
+ std::string appName = name + std::string(".app");
std::string appPath =
cmSystemTools::FindDirectory(appName, this->SearchPaths, true);
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index 8346b23..37387b0 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -54,9 +54,9 @@ bool cmForEachFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
mf.AddDefinition(this->Args[0], j->c_str());
// Invoke all the functions that were collected in the block.
cmExecutionStatus status;
- for (unsigned int c = 0; c < this->Functions.size(); ++c) {
+ for (cmListFileFunction const& func : this->Functions) {
status.Clear();
- mf.ExecuteCommand(this->Functions[c], status);
+ mf.ExecuteCommand(func, status);
if (status.GetReturnInvoked()) {
inStatus.SetReturnInvoked();
// restore the variable to its prior value
diff --git a/Source/cmFortranParserImpl.cxx b/Source/cmFortranParserImpl.cxx
index 333b6c1..ce98c6b 100644
--- a/Source/cmFortranParserImpl.cxx
+++ b/Source/cmFortranParserImpl.cxx
@@ -30,9 +30,8 @@ bool cmFortranParser_s::FindIncludeFile(const char* dir,
}
// Search the include path for the file.
- for (std::vector<std::string>::const_iterator i = this->IncludePath.begin();
- i != this->IncludePath.end(); ++i) {
- fullName = *i;
+ for (std::string const& i : this->IncludePath) {
+ fullName = i;
fullName += "/";
fullName += includeName;
if (cmSystemTools::FileExists(fullName.c_str(), true)) {
diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx
index ee52bde..74230b0 100644
--- a/Source/cmFunctionCommand.cxx
+++ b/Source/cmFunctionCommand.cxx
@@ -104,9 +104,9 @@ bool cmFunctionHelperCommand::InvokeInitialPass(
// Invoke all the functions that were collected in the block.
// for each function
- for (unsigned int c = 0; c < this->Functions.size(); ++c) {
+ for (cmListFileFunction const& func : this->Functions) {
cmExecutionStatus status;
- if (!this->Makefile->ExecuteCommand(this->Functions[c], status) ||
+ if (!this->Makefile->ExecuteCommand(func, status) ||
status.GetNestedError()) {
// The error message should have already included the call stack
// so we do not need to report an error here.
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index 3d8b3ba..dd76ad5 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -199,15 +199,14 @@ static void prefixItems(const std::string& content, std::string& result,
std::vector<std::string> entries;
cmGeneratorExpression::Split(content, entries);
const char* sep = "";
- for (std::vector<std::string>::const_iterator ei = entries.begin();
- ei != entries.end(); ++ei) {
+ for (std::string const& e : entries) {
result += sep;
sep = ";";
- if (!cmSystemTools::FileIsFullPath(ei->c_str()) &&
- cmGeneratorExpression::Find(*ei) != 0) {
+ if (!cmSystemTools::FileIsFullPath(e.c_str()) &&
+ cmGeneratorExpression::Find(e) != 0) {
result += prefix;
}
- result += *ei;
+ result += e;
}
}
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx
index a2ff189..ace9609 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.cxx
+++ b/Source/cmGeneratorExpressionEvaluationFile.cxx
@@ -99,10 +99,9 @@ void cmGeneratorExpressionEvaluationFile::CreateOutputFile(
cmGlobalGenerator* gg = lg->GetGlobalGenerator();
gg->GetEnabledLanguages(enabledLanguages);
- for (std::vector<std::string>::const_iterator le = enabledLanguages.begin();
- le != enabledLanguages.end(); ++le) {
+ for (std::string const& le : enabledLanguages) {
std::string name = this->OutputFileExpr->Evaluate(
- lg, config, false, nullptr, nullptr, nullptr, *le);
+ lg, config, false, nullptr, nullptr, nullptr, le);
cmSourceFile* sf = lg->GetMakefile()->GetOrCreateSource(name);
sf->SetProperty("GENERATED", "1");
@@ -161,11 +160,9 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg)
cmGlobalGenerator* gg = lg->GetGlobalGenerator();
gg->GetEnabledLanguages(enabledLanguages);
- for (std::vector<std::string>::const_iterator le = enabledLanguages.begin();
- le != enabledLanguages.end(); ++le) {
- for (std::vector<std::string>::const_iterator li = allConfigs.begin();
- li != allConfigs.end(); ++li) {
- this->Generate(lg, *li, *le, inputExpression.get(), outputFiles, perm);
+ for (std::string const& le : enabledLanguages) {
+ for (std::string const& li : allConfigs) {
+ this->Generate(lg, li, le, inputExpression.get(), outputFiles, perm);
if (cmSystemTools::GetFatalErrorOccured()) {
return;
}
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 44c93ec..0f6170f 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -877,13 +877,12 @@ std::string getLinkedTargetsContent(
std::string linkedTargetsContent;
std::string sep;
std::string depString;
- for (typename std::vector<T>::const_iterator it = libraries.begin();
- it != libraries.end(); ++it) {
+ for (T const& l : libraries) {
// Broken code can have a target in its own link interface.
// Don't follow such link interface entries so as not to create a
// self-referencing loop.
- if (it->Target && it->Target != target) {
- depString += sep + "$<TARGET_PROPERTY:" + it->Target->GetName() + "," +
+ if (l.Target && l.Target != target) {
+ depString += sep + "$<TARGET_PROPERTY:" + l.Target->GetName() + "," +
interfacePropertyName + ">";
sep = ";";
}
@@ -1281,17 +1280,15 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
context->HadContextSensitiveCondition = true;
}
- for (std::vector<std::string>::iterator oi = objects.begin();
- oi != objects.end(); ++oi) {
- *oi = obj_dir + *oi;
+ for (std::string& o : objects) {
+ o = obj_dir + o;
}
}
// Create the cmSourceFile instances in the referencing directory.
cmMakefile* mf = context->LG->GetMakefile();
- for (std::vector<std::string>::iterator oi = objects.begin();
- oi != objects.end(); ++oi) {
- mf->AddTargetObject(tgtName, *oi);
+ for (std::string& o : objects) {
+ mf->AddTargetObject(tgtName, o);
}
return cmJoin(objects, ";");
@@ -1325,16 +1322,15 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
LangMap testedFeatures;
- for (std::vector<std::string>::const_iterator it = parameters.begin();
- it != parameters.end(); ++it) {
+ for (std::string const& p : parameters) {
std::string error;
std::string lang;
if (!context->LG->GetMakefile()->CompileFeatureKnown(
- context->HeadTarget->Target, *it, lang, &error)) {
+ context->HeadTarget->Target, p, lang, &error)) {
reportError(context, content->GetOriginalExpression(), error);
return std::string();
}
- testedFeatures[lang].push_back(*it);
+ testedFeatures[lang].push_back(p);
if (availableFeatures.find(lang) == availableFeatures.end()) {
const char* featuresKnown =
@@ -1350,15 +1346,13 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
bool evalLL = dagChecker && dagChecker->EvaluatingLinkLibraries();
- for (LangMap::const_iterator lit = testedFeatures.begin();
- lit != testedFeatures.end(); ++lit) {
+ for (auto const& lit : testedFeatures) {
std::vector<std::string> const& langAvailable =
- availableFeatures[lit->first];
+ availableFeatures[lit.first];
const char* standardDefault = context->LG->GetMakefile()->GetDefinition(
- "CMAKE_" + lit->first + "_STANDARD_DEFAULT");
- for (std::vector<std::string>::const_iterator it = lit->second.begin();
- it != lit->second.end(); ++it) {
- if (std::find(langAvailable.begin(), langAvailable.end(), *it) ==
+ "CMAKE_" + lit.first + "_STANDARD_DEFAULT");
+ for (std::string const& it : lit.second) {
+ if (std::find(langAvailable.begin(), langAvailable.end(), it) ==
langAvailable.end()) {
return "0";
}
@@ -1368,14 +1362,14 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
continue;
}
if (!context->LG->GetMakefile()->HaveStandardAvailable(
- target->Target, lit->first, *it)) {
+ target->Target, lit.first, it)) {
if (evalLL) {
- const char* l = target->GetProperty(lit->first + "_STANDARD");
+ const char* l = target->GetProperty(lit.first + "_STANDARD");
if (!l) {
l = standardDefault;
}
assert(l);
- context->MaxLanguageStandard[target][lit->first] = l;
+ context->MaxLanguageStandard[target][lit.first] = l;
} else {
return "0";
}
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 74306b0..9946b1e 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -150,11 +150,8 @@ cmGeneratorTarget::~cmGeneratorTarget()
const char* cmGeneratorTarget::GetSourcesProperty() const
{
std::vector<std::string> values;
- for (std::vector<cmGeneratorTarget::TargetPropertyEntry *>::const_iterator
- it = this->SourceEntries.begin(),
- end = this->SourceEntries.end();
- it != end; ++it) {
- values.push_back((*it)->ge->GetInput());
+ for (TargetPropertyEntry* se : this->SourceEntries) {
+ values.push_back(se->ge->GetInput());
}
static std::string value;
value.clear();
@@ -299,9 +296,8 @@ std::string cmGeneratorTarget::GetOutputName(
props.push_back("OUTPUT_NAME");
std::string outName;
- for (std::vector<std::string>::const_iterator it = props.begin();
- it != props.end(); ++it) {
- if (const char* outNameProp = this->GetProperty(*it)) {
+ for (std::string const& p : props) {
+ if (const char* outNameProp = this->GetProperty(p)) {
outName = outNameProp;
break;
}
@@ -414,10 +410,9 @@ static void handleSystemIncludesDep(
#define IMPLEMENT_VISIT(KIND) \
{ \
KindedSources const& kinded = this->GetKindedSources(config); \
- for (std::vector<SourceAndKind>::const_iterator \
- si = kinded.Sources.begin(); si != kinded.Sources.end(); ++si) { \
- if (si->Kind == KIND) { \
- data.push_back(si->Source); \
+ for (SourceAndKind const& s : kinded.Sources) { \
+ if (s.Kind == KIND) { \
+ data.push_back(s.Source); \
} \
} \
}
@@ -432,9 +427,8 @@ void cmGeneratorTarget::GetObjectSources(
return;
}
- for (std::vector<cmSourceFile const*>::const_iterator it = data.begin();
- it != data.end(); ++it) {
- this->Objects[*it];
+ for (cmSourceFile const* it : data) {
+ this->Objects[it];
}
this->LocalGenerator->ComputeObjectFilenames(this->Objects, this);
@@ -451,10 +445,9 @@ void cmGeneratorTarget::ComputeObjectMapping()
if (configs.empty()) {
configs.push_back("");
}
- for (std::vector<std::string>::const_iterator ci = configs.begin();
- ci != configs.end(); ++ci) {
+ for (std::string const& c : configs) {
std::vector<cmSourceFile const*> sourceFiles;
- this->GetObjectSources(sourceFiles, *ci);
+ this->GetObjectSources(sourceFiles, c);
}
}
@@ -655,11 +648,10 @@ std::set<cmLinkItem> const& cmGeneratorTarget::GetUtilityItems() const
if (!this->UtilityItemsDone) {
this->UtilityItemsDone = true;
std::set<std::string> const& utilities = this->GetUtilities();
- for (std::set<std::string>::const_iterator i = utilities.begin();
- i != utilities.end(); ++i) {
+ for (std::string const& i : utilities) {
cmGeneratorTarget* gt =
- this->LocalGenerator->FindGeneratorTargetToUse(*i);
- this->UtilityItems.insert(cmLinkItem(*i, gt));
+ this->LocalGenerator->FindGeneratorTargetToUse(i);
+ this->UtilityItems.insert(cmLinkItem(i, gt));
}
}
return this->UtilityItems;
@@ -760,23 +752,18 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(
bool excludeImported = this->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED");
std::vector<std::string> result;
- for (std::set<std::string>::const_iterator it =
- this->Target->GetSystemIncludeDirectories().begin();
- it != this->Target->GetSystemIncludeDirectories().end(); ++it) {
+ for (std::string const& it : this->Target->GetSystemIncludeDirectories()) {
cmGeneratorExpression ge;
cmSystemTools::ExpandListArgument(
- ge.Parse(*it)->Evaluate(this->LocalGenerator, config, false, this,
- &dagChecker),
+ ge.Parse(it)->Evaluate(this->LocalGenerator, config, false, this,
+ &dagChecker),
result);
}
std::vector<cmGeneratorTarget const*> const& deps =
this->GetLinkImplementationClosure(config);
- for (std::vector<cmGeneratorTarget const *>::const_iterator
- li = deps.begin(),
- le = deps.end();
- li != le; ++li) {
- handleSystemIncludesDep(this->LocalGenerator, *li, config, this,
+ for (cmGeneratorTarget const* dep : deps) {
+ handleSystemIncludesDep(this->LocalGenerator, dep, config, this,
&dagChecker, result, excludeImported);
}
@@ -804,17 +791,14 @@ static void AddInterfaceEntries(
{
if (cmLinkImplementationLibraries const* impl =
thisTarget->GetLinkImplementationLibraries(config)) {
- for (std::vector<cmLinkImplItem>::const_iterator
- it = impl->Libraries.begin(),
- end = impl->Libraries.end();
- it != end; ++it) {
- if (it->Target) {
- std::string genex = "$<TARGET_PROPERTY:" + *it + "," + prop + ">";
- cmGeneratorExpression ge(it->Backtrace);
+ for (cmLinkImplItem const& lib : impl->Libraries) {
+ if (lib.Target) {
+ std::string genex = "$<TARGET_PROPERTY:" + lib + "," + prop + ">";
+ cmGeneratorExpression ge(lib.Backtrace);
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(genex);
cge->SetEvaluateForBuildsystem(true);
entries.push_back(
- new cmGeneratorTarget::TargetPropertyEntry(cge, *it));
+ new cmGeneratorTarget::TargetPropertyEntry(cge, lib));
}
}
}
@@ -831,25 +815,20 @@ static bool processSources(
bool contextDependent = false;
- for (std::vector<cmGeneratorTarget::TargetPropertyEntry *>::const_iterator
- it = entries.begin(),
- end = entries.end();
- it != end; ++it) {
- cmLinkImplItem const& item = (*it)->LinkImplItem;
+ for (cmGeneratorTarget::TargetPropertyEntry* entry : entries) {
+ cmLinkImplItem const& item = entry->LinkImplItem;
std::string const& targetName = item;
std::vector<std::string> entrySources;
cmSystemTools::ExpandListArgument(
- (*it)->ge->Evaluate(tgt->GetLocalGenerator(), config, false, tgt, tgt,
+ entry->ge->Evaluate(tgt->GetLocalGenerator(), config, false, tgt, tgt,
dagChecker),
entrySources);
- if ((*it)->ge->GetHadContextSensitiveCondition()) {
+ if (entry->ge->GetHadContextSensitiveCondition()) {
contextDependent = true;
}
- for (std::vector<std::string>::iterator i = entrySources.begin();
- i != entrySources.end(); ++i) {
- std::string& src = *i;
+ for (std::string& src : entrySources) {
cmSourceFile* sf = mf->GetOrCreateSource(src);
std::string e;
std::string fullPath = sf->GetFullPath(&e);
@@ -880,10 +859,7 @@ static bool processSources(
src = fullPath;
}
std::string usedSources;
- for (std::vector<std::string>::iterator li = entrySources.begin();
- li != entrySources.end(); ++li) {
- std::string src = *li;
-
+ for (std::string const& src : entrySources) {
if (uniqueSrcs.insert(src).second) {
srcs.push_back(src);
if (debugSources) {
@@ -895,7 +871,7 @@ static bool processSources(
tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
cmake::LOG, std::string("Used sources for target ") + tgt->GetName() +
":\n" + usedSources,
- (*it)->ge->GetBacktrace());
+ entry->ge->GetBacktrace());
}
}
return contextDependent;
@@ -914,19 +890,15 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<std::string>& files,
// behavior of CMP0024 and CMP0026 only.
cmStringRange sourceEntries = this->Target->GetSourceEntries();
- for (cmStringRange::const_iterator i = sourceEntries.begin();
- i != sourceEntries.end(); ++i) {
- std::string const& entry = *i;
-
+ for (std::string const& entry : sourceEntries) {
std::vector<std::string> items;
cmSystemTools::ExpandListArgument(entry, items);
- for (std::vector<std::string>::const_iterator li = items.begin();
- li != items.end(); ++li) {
- if (cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") &&
- (*li)[li->size() - 1] == '>') {
+ for (std::string const& item : items) {
+ if (cmHasLiteralPrefix(item, "$<TARGET_OBJECTS:") &&
+ item[item.size() - 1] == '>') {
continue;
}
- files.push_back(*li);
+ files.push_back(item);
}
}
return;
@@ -987,9 +959,8 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*>& files,
std::vector<std::string> srcs;
this->GetSourceFiles(srcs, config);
std::set<cmSourceFile*> emitted;
- for (std::vector<std::string>::const_iterator i = srcs.begin();
- i != srcs.end(); ++i) {
- cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i);
+ for (std::string const& s : srcs) {
+ cmSourceFile* sf = this->Makefile->GetOrCreateSource(s);
if (emitted.insert(sf).second) {
files.push_back(sf);
}
@@ -999,9 +970,8 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*>& files,
KindedSources const& kinded = this->GetKindedSources(config);
files.reserve(kinded.Sources.size());
- for (std::vector<SourceAndKind>::const_iterator si = kinded.Sources.begin();
- si != kinded.Sources.end(); ++si) {
- files.push_back(si->Source);
+ for (SourceAndKind const& si : kinded.Sources) {
+ files.push_back(si.Source);
}
}
@@ -1010,10 +980,9 @@ void cmGeneratorTarget::GetSourceFilesWithoutObjectLibraries(
{
KindedSources const& kinded = this->GetKindedSources(config);
files.reserve(kinded.Sources.size());
- for (std::vector<SourceAndKind>::const_iterator si = kinded.Sources.begin();
- si != kinded.Sources.end(); ++si) {
- if (si->Source->GetObjectLibrary().empty()) {
- files.push_back(si->Source);
+ for (SourceAndKind const& si : kinded.Sources) {
+ if (si.Source->GetObjectLibrary().empty()) {
+ files.push_back(si.Source);
}
}
}
@@ -1062,10 +1031,9 @@ void cmGeneratorTarget::ComputeKindedSources(KindedSources& files,
std::vector<cmSourceFile*> badObjLib;
std::set<cmSourceFile*> emitted;
- for (std::vector<std::string>::const_iterator i = srcs.begin();
- i != srcs.end(); ++i) {
+ for (std::string const& s : srcs) {
// Create each source at most once.
- cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i);
+ cmSourceFile* sf = this->Makefile->GetOrCreateSource(s);
if (!emitted.insert(sf).second) {
continue;
}
@@ -1138,9 +1106,8 @@ void cmGeneratorTarget::ComputeKindedSources(KindedSources& files,
if (!badObjLib.empty()) {
std::ostringstream e;
e << "OBJECT library \"" << this->GetName() << "\" contains:\n";
- for (std::vector<cmSourceFile*>::const_iterator i = badObjLib.begin();
- i != badObjLib.end(); ++i) {
- e << " " << (*i)->GetLocation().GetName() << "\n";
+ for (cmSourceFile* i : badObjLib) {
+ e << " " << i->GetLocation().GetName() << "\n";
}
e << "but may contain only sources that compile, header files, and "
"other files that would not affect linking of a normal library.";
@@ -1167,18 +1134,16 @@ void cmGeneratorTarget::ComputeAllConfigSources() const
for (size_t ci = 0; ci < configs.size(); ++ci) {
KindedSources const& sources = this->GetKindedSources(configs[ci]);
- for (std::vector<cmGeneratorTarget::SourceAndKind>::const_iterator si =
- sources.Sources.begin();
- si != sources.Sources.end(); ++si) {
+ for (SourceAndKind const& src : sources.Sources) {
std::map<cmSourceFile const*, size_t>::iterator mi =
- index.find(si->Source);
+ index.find(src.Source);
if (mi == index.end()) {
AllConfigSource acs;
- acs.Source = si->Source;
- acs.Kind = si->Kind;
+ acs.Source = src.Source;
+ acs.Kind = src.Kind;
this->AllConfigSources.push_back(acs);
std::map<cmSourceFile const*, size_t>::value_type entry(
- si->Source, this->AllConfigSources.size() - 1);
+ src.Source, this->AllConfigSources.size() - 1);
mi = index.insert(entry).first;
}
this->AllConfigSources[mi->second].Configs.push_back(ci);
@@ -1781,15 +1746,12 @@ public:
return;
}
- for (std::vector<std::string>::const_iterator li =
- iface->Languages.begin();
- li != iface->Languages.end(); ++li) {
- this->Languages.insert(*li);
+ for (std::string const& language : iface->Languages) {
+ this->Languages.insert(language);
}
- for (std::vector<cmLinkItem>::const_iterator li = iface->Libraries.begin();
- li != iface->Libraries.end(); ++li) {
- this->Visit(*li);
+ for (cmLinkItem const& lib : iface->Libraries) {
+ this->Visit(lib);
}
}
@@ -1850,9 +1812,8 @@ public:
e << "Target " << this->Target->GetName()
<< " contains multiple languages with the highest linker preference"
<< " (" << this->Preference << "):\n";
- for (std::set<std::string>::const_iterator li = this->Preferred.begin();
- li != this->Preferred.end(); ++li) {
- e << " " << *li << "\n";
+ for (std::string const& li : this->Preferred) {
+ e << " " << li << "\n";
}
e << "Set the LINKER_LANGUAGE property for this target.";
cmake* cm = this->Target->GetLocalGenerator()->GetCMakeInstance();
@@ -1870,23 +1831,19 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config,
std::unordered_set<std::string> languages;
cmLinkImplementation const* impl = this->GetLinkImplementation(config);
assert(impl);
- for (std::vector<std::string>::const_iterator li = impl->Languages.begin();
- li != impl->Languages.end(); ++li) {
- languages.insert(*li);
+ for (std::string const& li : impl->Languages) {
+ languages.insert(li);
}
// Add interface languages from linked targets.
cmTargetCollectLinkLanguages cll(this, config, languages, this);
- for (std::vector<cmLinkImplItem>::const_iterator li =
- impl->Libraries.begin();
- li != impl->Libraries.end(); ++li) {
- cll.Visit(*li);
+ for (cmLinkImplItem const& lib : impl->Libraries) {
+ cll.Visit(lib);
}
// Store the transitive closure of languages.
- for (std::unordered_set<std::string>::const_iterator li = languages.begin();
- li != languages.end(); ++li) {
- lc.Languages.push_back(*li);
+ for (std::string const& lang : languages) {
+ lc.Languages.push_back(lang);
}
// Choose the language whose linker should be used.
@@ -1899,19 +1856,16 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config,
cmTargetSelectLinker tsl(this);
// First select from the languages compiled directly in this target.
- for (std::vector<std::string>::const_iterator li = impl->Languages.begin();
- li != impl->Languages.end(); ++li) {
- tsl.Consider(li->c_str());
+ for (std::string const& l : impl->Languages) {
+ tsl.Consider(l.c_str());
}
// Now consider languages that propagate from linked targets.
- for (std::unordered_set<std::string>::const_iterator sit =
- languages.begin();
- sit != languages.end(); ++sit) {
+ for (std::string const& lang : languages) {
std::string propagates =
- "CMAKE_" + *sit + "_LINKER_PREFERENCE_PROPAGATES";
+ "CMAKE_" + lang + "_LINKER_PREFERENCE_PROPAGATES";
if (this->Makefile->IsOn(propagates)) {
- tsl.Consider(sit->c_str());
+ tsl.Consider(lang.c_str());
}
}
@@ -2083,10 +2037,8 @@ void processILibs(const std::string& config,
tgts.push_back(item.Target);
if (cmLinkInterfaceLibraries const* iface =
item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) {
- for (std::vector<cmLinkItem>::const_iterator it =
- iface->Libraries.begin();
- it != iface->Libraries.end(); ++it) {
- processILibs(config, headTarget, *it, gg, tgts, emitted);
+ for (cmLinkItem const& lib : iface->Libraries) {
+ processILibs(config, headTarget, lib, gg, tgts, emitted);
}
}
}
@@ -2104,10 +2056,8 @@ cmGeneratorTarget::GetLinkImplementationClosure(
cmLinkImplementationLibraries const* impl =
this->GetLinkImplementationLibraries(config);
- for (std::vector<cmLinkImplItem>::const_iterator it =
- impl->Libraries.begin();
- it != impl->Libraries.end(); ++it) {
- processILibs(config, this, *it,
+ for (cmLinkImplItem const& lib : impl->Libraries) {
+ processILibs(config, this, lib,
this->LocalGenerator->GetGlobalGenerator(), tgts, emitted);
}
}
@@ -2161,13 +2111,10 @@ cmTargetTraceDependencies::cmTargetTraceDependencies(cmGeneratorTarget* target)
configs.push_back("");
}
std::set<cmSourceFile*> emitted;
- for (std::vector<std::string>::const_iterator ci = configs.begin();
- ci != configs.end(); ++ci) {
+ for (std::string const& c : configs) {
std::vector<cmSourceFile*> sources;
- this->GeneratorTarget->GetSourceFiles(sources, *ci);
- for (std::vector<cmSourceFile*>::const_iterator si = sources.begin();
- si != sources.end(); ++si) {
- cmSourceFile* sf = *si;
+ this->GeneratorTarget->GetSourceFiles(sources, c);
+ for (cmSourceFile* sf : sources) {
const std::set<cmGeneratorTarget const*> tgts =
this->GlobalGenerator->GetFilenameTargetDepends(sf);
if (tgts.find(this->GeneratorTarget) != tgts.end()) {
@@ -2206,10 +2153,9 @@ void cmTargetTraceDependencies::Trace()
if (const char* additionalDeps = sf->GetProperty("OBJECT_DEPENDS")) {
std::vector<std::string> objDeps;
cmSystemTools::ExpandListArgument(additionalDeps, objDeps);
- for (std::vector<std::string>::iterator odi = objDeps.begin();
- odi != objDeps.end(); ++odi) {
- if (cmSystemTools::FileIsFullPath(*odi)) {
- *odi = cmSystemTools::CollapseFullPath(*odi);
+ for (std::string& objDep : objDeps) {
+ if (cmSystemTools::FileIsFullPath(objDep)) {
+ objDep = cmSystemTools::CollapseFullPath(objDep);
}
}
this->FollowNames(objDeps);
@@ -2262,9 +2208,8 @@ void cmTargetTraceDependencies::FollowName(std::string const& name)
void cmTargetTraceDependencies::FollowNames(
std::vector<std::string> const& names)
{
- for (std::vector<std::string>::const_iterator i = names.begin();
- i != names.end(); ++i) {
- this->FollowName(*i);
+ for (std::string const& name : names) {
+ this->FollowName(name);
}
}
@@ -2324,9 +2269,8 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc)
// Add target-level dependencies referenced by generator expressions.
std::set<cmGeneratorTarget*> targets;
- for (cmCustomCommandLines::const_iterator cit = cc.GetCommandLines().begin();
- cit != cc.GetCommandLines().end(); ++cit) {
- std::string const& command = *cit->begin();
+ for (cmCustomCommandLine const& cCmdLine : cc.GetCommandLines()) {
+ std::string const& command = *cCmdLine.begin();
// Check for a target with this name.
if (cmGeneratorTarget* t =
this->LocalGenerator->FindGeneratorTargetToUse(command)) {
@@ -2340,18 +2284,16 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc)
}
// Check for target references in generator expressions.
- for (cmCustomCommandLine::const_iterator cli = cit->begin();
- cli != cit->end(); ++cli) {
- const CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(*cli);
+ for (std::string const& cl : cCmdLine) {
+ const CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(cl);
cge->Evaluate(this->GeneratorTarget->GetLocalGenerator(), "", true);
std::set<cmGeneratorTarget*> geTargets = cge->GetTargets();
targets.insert(geTargets.begin(), geTargets.end());
}
}
- for (std::set<cmGeneratorTarget*>::iterator ti = targets.begin();
- ti != targets.end(); ++ti) {
- this->GeneratorTarget->Target->AddUtility((*ti)->GetName());
+ for (cmGeneratorTarget* target : targets) {
+ this->GeneratorTarget->Target->AddUtility(target->GetName());
}
// Queue the custom command dependencies.
@@ -2361,9 +2303,8 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc)
if (configs.empty()) {
configs.push_back("");
}
- for (std::vector<std::string>::const_iterator ci = configs.begin();
- ci != configs.end(); ++ci) {
- this->FollowCommandDepends(cc, *ci, emitted);
+ for (std::string const& conf : configs) {
+ this->FollowCommandDepends(cc, conf, emitted);
}
}
@@ -2376,9 +2317,7 @@ void cmTargetTraceDependencies::FollowCommandDepends(
const std::vector<std::string>& depends = ccg.GetDepends();
- for (std::vector<std::string>::const_iterator di = depends.begin();
- di != depends.end(); ++di) {
- std::string const& dep = *di;
+ for (std::string const& dep : depends) {
if (emitted.insert(dep).second) {
if (!this->IsUtility(dep)) {
// The dependency does not name a target and may be a file we
@@ -2392,9 +2331,8 @@ void cmTargetTraceDependencies::FollowCommandDepends(
void cmTargetTraceDependencies::CheckCustomCommands(
const std::vector<cmCustomCommand>& commands)
{
- for (std::vector<cmCustomCommand>::const_iterator cli = commands.begin();
- cli != commands.end(); ++cli) {
- this->CheckCustomCommand(*cli);
+ for (cmCustomCommand const& command : commands) {
+ this->CheckCustomCommand(command);
}
}
@@ -2482,24 +2420,20 @@ static void processIncludeDirectories(
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
bool debugIncludes, const std::string& language)
{
- for (std::vector<cmGeneratorTarget::TargetPropertyEntry *>::const_iterator
- it = entries.begin(),
- end = entries.end();
- it != end; ++it) {
- cmLinkImplItem const& item = (*it)->LinkImplItem;
+ for (cmGeneratorTarget::TargetPropertyEntry* entry : entries) {
+ cmLinkImplItem const& item = entry->LinkImplItem;
std::string const& targetName = item;
bool const fromImported = item.Target && item.Target->IsImported();
bool const checkCMP0027 = item.FromGenex;
std::vector<std::string> entryIncludes;
cmSystemTools::ExpandListArgument(
- (*it)->ge->Evaluate(tgt->GetLocalGenerator(), config, false, tgt,
+ entry->ge->Evaluate(tgt->GetLocalGenerator(), config, false, tgt,
dagChecker, language),
entryIncludes);
std::string usedIncludes;
- for (std::vector<std::string>::iterator li = entryIncludes.begin();
- li != entryIncludes.end(); ++li) {
- if (fromImported && !cmSystemTools::FileExists(li->c_str())) {
+ for (std::string& entryInclude : entryIncludes) {
+ if (fromImported && !cmSystemTools::FileExists(entryInclude.c_str())) {
std::ostringstream e;
cmake::MessageType messageType = cmake::FATAL_ERROR;
if (checkCMP0027) {
@@ -2518,7 +2452,7 @@ static void processIncludeDirectories(
}
/* clang-format off */
e << "Imported target \"" << targetName << "\" includes "
- "non-existent path\n \"" << *li << "\"\nin its "
+ "non-existent path\n \"" << entryInclude << "\"\nin its "
"INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n"
"* The path was deleted, renamed, or moved to another "
"location.\n"
@@ -2531,7 +2465,7 @@ static void processIncludeDirectories(
return;
}
- if (!cmSystemTools::FileIsFullPath(li->c_str())) {
+ if (!cmSystemTools::FileIsFullPath(entryInclude.c_str())) {
std::ostringstream e;
bool noMessage = false;
cmake::MessageType messageType = cmake::FATAL_ERROR;
@@ -2539,7 +2473,7 @@ static void processIncludeDirectories(
/* clang-format off */
e << "Target \"" << targetName << "\" contains relative "
"path in its INTERFACE_INCLUDE_DIRECTORIES:\n"
- " \"" << *li << "\"";
+ " \"" << entryInclude << "\"";
/* clang-format on */
} else {
switch (tgt->GetPolicyStatusCMP0021()) {
@@ -2557,7 +2491,7 @@ static void processIncludeDirectories(
}
e << "Found relative path while evaluating include directories of "
"\""
- << tgt->GetName() << "\":\n \"" << *li << "\"\n";
+ << tgt->GetName() << "\":\n \"" << entryInclude << "\"\n";
}
if (!noMessage) {
tgt->GetLocalGenerator()->IssueMessage(messageType, e.str());
@@ -2567,10 +2501,10 @@ static void processIncludeDirectories(
}
}
- if (!cmSystemTools::IsOff(li->c_str())) {
- cmSystemTools::ConvertToUnixSlashes(*li);
+ if (!cmSystemTools::IsOff(entryInclude.c_str())) {
+ cmSystemTools::ConvertToUnixSlashes(entryInclude);
}
- std::string inc = *li;
+ std::string inc = entryInclude;
if (uniqueIncludes.insert(inc).second) {
includes.push_back(inc);
@@ -2583,7 +2517,7 @@ static void processIncludeDirectories(
tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
cmake::LOG, std::string("Used includes for target ") + tgt->GetName() +
":\n" + usedIncludes,
- (*it)->ge->GetBacktrace());
+ entry->ge->GetBacktrace());
}
}
}
@@ -2624,10 +2558,8 @@ std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories(
if (this->Makefile->IsOn("APPLE")) {
cmLinkImplementationLibraries const* impl =
this->GetLinkImplementationLibraries(config);
- for (std::vector<cmLinkImplItem>::const_iterator it =
- impl->Libraries.begin();
- it != impl->Libraries.end(); ++it) {
- std::string libDir = cmSystemTools::CollapseFullPath(*it);
+ for (cmLinkImplItem const& lib : impl->Libraries) {
+ std::string libDir = cmSystemTools::CollapseFullPath(lib);
static cmsys::RegularExpression frameworkCheck(
"(.*\\.framework)(/Versions/[^/]+)?/[^/]+$");
@@ -2662,20 +2594,14 @@ static void processCompileOptionsInternal(
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
bool debugOptions, const char* logName, std::string const& language)
{
- for (std::vector<cmGeneratorTarget::TargetPropertyEntry *>::const_iterator
- it = entries.begin(),
- end = entries.end();
- it != end; ++it) {
+ for (cmGeneratorTarget::TargetPropertyEntry* entry : entries) {
std::vector<std::string> entryOptions;
cmSystemTools::ExpandListArgument(
- (*it)->ge->Evaluate(tgt->GetLocalGenerator(), config, false, tgt,
+ entry->ge->Evaluate(tgt->GetLocalGenerator(), config, false, tgt,
dagChecker, language),
entryOptions);
std::string usedOptions;
- for (std::vector<std::string>::iterator li = entryOptions.begin();
- li != entryOptions.end(); ++li) {
- std::string const& opt = *li;
-
+ for (std::string const& opt : entryOptions) {
if (uniqueOptions.insert(opt).second) {
options.push_back(opt);
if (debugOptions) {
@@ -2687,7 +2613,7 @@ static void processCompileOptionsInternal(
tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
cmake::LOG, std::string("Used compile ") + logName +
std::string(" for target ") + tgt->GetName() + ":\n" + usedOptions,
- (*it)->ge->GetBacktrace());
+ entry->ge->GetBacktrace());
}
}
}
@@ -2940,9 +2866,8 @@ bool cmGeneratorTarget::ComputeCompileFeatures(std::string const& config) const
{
std::vector<std::string> features;
this->GetCompileFeatures(features, config);
- for (std::vector<std::string>::const_iterator it = features.begin();
- it != features.end(); ++it) {
- if (!this->Makefile->AddRequiredTargetFeature(this->Target, *it)) {
+ for (std::string const& f : features) {
+ if (!this->Makefile->AddRequiredTargetFeature(this->Target, f)) {
return false;
}
}
@@ -3334,9 +3259,8 @@ std::string cmGeneratorTarget::GetPDBName(const std::string& config) const
// PDB_NAME
props.push_back("PDB_NAME");
- for (std::vector<std::string>::const_iterator i = props.begin();
- i != props.end(); ++i) {
- if (const char* outName = this->GetProperty(*i)) {
+ for (std::string const& p : props) {
+ if (const char* outName = this->GetProperty(p)) {
base = outName;
break;
}
@@ -3364,20 +3288,16 @@ void cmGeneratorTarget::GetTargetObjectNames(
this->GetObjectSources(objectSources, config);
std::map<cmSourceFile const*, std::string> mapping;
- for (std::vector<cmSourceFile const*>::const_iterator it =
- objectSources.begin();
- it != objectSources.end(); ++it) {
- mapping[*it];
+ for (cmSourceFile const* sf : objectSources) {
+ mapping[sf];
}
this->LocalGenerator->ComputeObjectFilenames(mapping, this);
- for (std::vector<cmSourceFile const*>::const_iterator it =
- objectSources.begin();
- it != objectSources.end(); ++it) {
+ for (cmSourceFile const* src : objectSources) {
// Find the object file name corresponding to this source file.
std::map<cmSourceFile const*, std::string>::const_iterator map_it =
- mapping.find(*it);
+ mapping.find(src);
// It must exist because we populated the mapping just above.
assert(!map_it->second.empty());
objects.push_back(map_it->second);
@@ -3440,9 +3360,8 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const
if (const char* files = this->GetProperty("PUBLIC_HEADER")) {
std::vector<std::string> relFiles;
cmSystemTools::ExpandListArgument(files, relFiles);
- for (std::vector<std::string>::iterator it = relFiles.begin();
- it != relFiles.end(); ++it) {
- if (cmSourceFile* sf = this->Makefile->GetSource(*it)) {
+ for (std::string const& relFile : relFiles) {
+ if (cmSourceFile* sf = this->Makefile->GetSource(relFile)) {
SourceFileFlags& flags = this->SourceFlagsMap[sf];
flags.MacFolder = "Headers";
flags.Type = cmGeneratorTarget::SourceFileTypePublicHeader;
@@ -3455,9 +3374,8 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const
if (const char* files = this->GetProperty("PRIVATE_HEADER")) {
std::vector<std::string> relFiles;
cmSystemTools::ExpandListArgument(files, relFiles);
- for (std::vector<std::string>::iterator it = relFiles.begin();
- it != relFiles.end(); ++it) {
- if (cmSourceFile* sf = this->Makefile->GetSource(*it)) {
+ for (std::string const& relFile : relFiles) {
+ if (cmSourceFile* sf = this->Makefile->GetSource(relFile)) {
SourceFileFlags& flags = this->SourceFlagsMap[sf];
flags.MacFolder = "PrivateHeaders";
flags.Type = cmGeneratorTarget::SourceFileTypePrivateHeader;
@@ -3469,9 +3387,8 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const
if (const char* files = this->GetProperty("RESOURCE")) {
std::vector<std::string> relFiles;
cmSystemTools::ExpandListArgument(files, relFiles);
- for (std::vector<std::string>::iterator it = relFiles.begin();
- it != relFiles.end(); ++it) {
- if (cmSourceFile* sf = this->Makefile->GetSource(*it)) {
+ for (std::string const& relFile : relFiles) {
+ if (cmSourceFile* sf = this->Makefile->GetSource(relFile)) {
SourceFileFlags& flags = this->SourceFlagsMap[sf];
flags.MacFolder = "";
if (!this->GlobalGenerator->ShouldStripResourcePath(this->Makefile)) {
@@ -3494,11 +3411,9 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const
compat.PropsString.insert("AUTOUIC_OPTIONS");
std::vector<cmGeneratorTarget const*> const& deps =
this->GetLinkImplementationClosure(config);
- for (std::vector<cmGeneratorTarget const*>::const_iterator li =
- deps.begin();
- li != deps.end(); ++li) {
+ for (cmGeneratorTarget const* li : deps) {
#define CM_READ_COMPATIBLE_INTERFACE(X, x) \
- if (const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) { \
+ if (const char* prop = li->GetProperty("COMPATIBLE_INTERFACE_" #X)) { \
std::vector<std::string> props; \
cmSystemTools::ExpandListArgument(prop, props); \
compat.Props##x.insert(props.begin(), props.end()); \
@@ -3618,13 +3533,12 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender,
std::string pdir = cmSystemTools::GetCMakeRoot();
pdir += "/Help/prop_tgt/";
- for (std::vector<std::string>::iterator pi = props.begin();
- pi != props.end(); ++pi) {
- std::string pname = cmSystemTools::HelpFileName(*pi);
+ for (std::string const& p : props) {
+ std::string pname = cmSystemTools::HelpFileName(p);
std::string pfile = pdir + pname + ".rst";
if (cmSystemTools::FileExists(pfile.c_str(), true)) {
std::ostringstream e;
- e << "Target \"" << dependee->GetName() << "\" has property \"" << *pi
+ e << "Target \"" << dependee->GetName() << "\" has property \"" << p
<< "\" listed in its " << propName
<< " property. "
"This is not allowed. Only user-defined properties may appear "
@@ -3633,8 +3547,8 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender,
depender->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
- if (emitted.insert(*pi).second) {
- getLinkInterfaceDependentProperty<PropertyType>(depender, *pi, config, t,
+ if (emitted.insert(p).second) {
+ getLinkInterfaceDependentProperty<PropertyType>(depender, p, config, t,
nullptr);
if (cmSystemTools::GetErrorOccuredFlag()) {
return;
@@ -3706,30 +3620,29 @@ void cmGeneratorTarget::CheckPropertyCompatibility(
std::set<std::string> emittedMaxNumbers;
static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX";
- for (cmComputeLinkInformation::ItemVector::const_iterator li = deps.begin();
- li != deps.end(); ++li) {
- if (!li->Target) {
+ for (auto const& dep : deps) {
+ if (!dep.Target) {
continue;
}
- checkPropertyConsistency<bool>(this, li->Target, strBool, emittedBools,
+ checkPropertyConsistency<bool>(this, dep.Target, strBool, emittedBools,
config, BoolType, nullptr);
if (cmSystemTools::GetErrorOccuredFlag()) {
return;
}
- checkPropertyConsistency<const char*>(this, li->Target, strString,
+ checkPropertyConsistency<const char*>(this, dep.Target, strString,
emittedStrings, config, StringType,
nullptr);
if (cmSystemTools::GetErrorOccuredFlag()) {
return;
}
- checkPropertyConsistency<const char*>(this, li->Target, strNumMin,
+ checkPropertyConsistency<const char*>(this, dep.Target, strNumMin,
emittedMinNumbers, config,
NumberMinType, nullptr);
if (cmSystemTools::GetErrorOccuredFlag()) {
return;
}
- checkPropertyConsistency<const char*>(this, li->Target, strNumMax,
+ checkPropertyConsistency<const char*>(this, dep.Target, strNumMax,
emittedMaxNumbers, config,
NumberMaxType, nullptr);
if (cmSystemTools::GetErrorOccuredFlag()) {
@@ -3961,16 +3874,13 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
}
std::string interfaceProperty = "INTERFACE_" + p;
- for (std::vector<cmGeneratorTarget const*>::const_iterator li = deps.begin();
- li != deps.end(); ++li) {
+ for (cmGeneratorTarget const* theTarget : deps) {
// An error should be reported if one dependency
// has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other
// has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the
// target itself has a POSITION_INDEPENDENT_CODE which disagrees
// with a dependency.
- cmGeneratorTarget const* theTarget = *li;
-
std::vector<std::string> propKeys = theTarget->GetPropertyKeys();
const bool ifaceIsSet = std::find(propKeys.begin(), propKeys.end(),
@@ -4240,9 +4150,8 @@ std::vector<std::string> cmGeneratorTarget::GetPropertyKeys() const
cmPropertyMap const& propsObject = this->Target->GetProperties();
std::vector<std::string> props;
props.reserve(propsObject.size());
- for (cmPropertyMap::const_iterator it = propsObject.begin();
- it != propsObject.end(); ++it) {
- props.push_back(it->first);
+ for (auto const& it : propsObject) {
+ props.push_back(it.first);
}
return props;
}
@@ -4282,9 +4191,8 @@ void cmGeneratorTarget::ReportPropertyOrigin(
void cmGeneratorTarget::LookupLinkItems(std::vector<std::string> const& names,
std::vector<cmLinkItem>& items) const
{
- for (std::vector<std::string>::const_iterator i = names.begin();
- i != names.end(); ++i) {
- std::string name = this->CheckCMP0004(*i);
+ for (std::string const& n : names) {
+ std::string name = this->CheckCMP0004(n);
if (name == this->GetName() || name.empty()) {
continue;
}
@@ -4365,21 +4273,17 @@ void cmGeneratorTarget::ComputeLinkInterface(
// Shared libraries may have runtime implementation dependencies
// on other shared libraries that are not in the interface.
std::unordered_set<std::string> emitted;
- for (std::vector<cmLinkItem>::const_iterator li =
- iface.Libraries.begin();
- li != iface.Libraries.end(); ++li) {
- emitted.insert(*li);
+ for (cmLinkItem const& lib : iface.Libraries) {
+ emitted.insert(lib);
}
if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
cmLinkImplementation const* impl = this->GetLinkImplementation(config);
- for (std::vector<cmLinkImplItem>::const_iterator li =
- impl->Libraries.begin();
- li != impl->Libraries.end(); ++li) {
- if (emitted.insert(*li).second) {
- if (li->Target) {
+ for (cmLinkImplItem const& lib : impl->Libraries) {
+ if (emitted.insert(lib).second) {
+ if (lib.Target) {
// This is a runtime dependency on another shared library.
- if (li->Target->GetType() == cmStateEnums::SHARED_LIBRARY) {
- iface.SharedDeps.push_back(*li);
+ if (lib.Target->GetType() == cmStateEnums::SHARED_LIBRARY) {
+ iface.SharedDeps.push_back(lib);
}
} else {
// TODO: Recognize shared library file names. Perhaps this
@@ -5091,19 +4995,17 @@ bool cmGeneratorTarget::GetConfigCommonSourceFiles(
if (configFiles != files) {
std::string firstConfigFiles;
const char* sep = "";
- for (std::vector<cmSourceFile*>::const_iterator fi = files.begin();
- fi != files.end(); ++fi) {
+ for (cmSourceFile* f : files) {
firstConfigFiles += sep;
- firstConfigFiles += (*fi)->GetFullPath();
+ firstConfigFiles += f->GetFullPath();
sep = "\n ";
}
std::string thisConfigFiles;
sep = "";
- for (std::vector<cmSourceFile*>::const_iterator fi = configFiles.begin();
- fi != configFiles.end(); ++fi) {
+ for (cmSourceFile* f : configFiles) {
thisConfigFiles += sep;
- thisConfigFiles += (*fi)->GetFullPath();
+ thisConfigFiles += f->GetFullPath();
sep = "\n ";
}
std::ostringstream e;
@@ -5134,17 +5036,13 @@ void cmGeneratorTarget::GetObjectLibrariesCMP0026(
// for TARGET_OBJECTS instead for backwards compatibility with OLD
// behavior of CMP0024 and CMP0026 only.
cmStringRange rng = this->Target->GetSourceEntries();
- for (std::vector<std::string>::const_iterator i = rng.begin();
- i != rng.end(); ++i) {
- std::string const& entry = *i;
-
+ for (std::string const& entry : rng) {
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:") &&
- (*li)[li->size() - 1] == '>') {
- std::string objLibName = li->substr(17, li->size() - 18);
+ for (std::string const& li : files) {
+ 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) {
continue;
@@ -5210,9 +5108,8 @@ void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages,
{
std::vector<cmSourceFile*> sourceFiles;
this->GetSourceFiles(sourceFiles, config);
- for (std::vector<cmSourceFile*>::const_iterator i = sourceFiles.begin();
- i != sourceFiles.end(); ++i) {
- const std::string& lang = (*i)->GetLanguage();
+ for (cmSourceFile* src : sourceFiles) {
+ const std::string& lang = src->GetLanguage();
if (!lang.empty()) {
languages.insert(lang);
}
@@ -5224,27 +5121,21 @@ void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages,
std::vector<cmGeneratorTarget*> objectTargets;
this->GetObjectLibrariesCMP0026(objectTargets);
objectLibraries.reserve(objectTargets.size());
- for (std::vector<cmGeneratorTarget*>::const_iterator it =
- objectTargets.begin();
- it != objectTargets.end(); ++it) {
- objectLibraries.push_back(*it);
+ for (cmGeneratorTarget* gt : objectTargets) {
+ objectLibraries.push_back(gt);
}
} else {
this->GetExternalObjects(externalObjects, config);
- for (std::vector<cmSourceFile const*>::const_iterator i =
- externalObjects.begin();
- i != externalObjects.end(); ++i) {
- std::string objLib = (*i)->GetObjectLibrary();
+ for (cmSourceFile const* extObj : externalObjects) {
+ std::string objLib = extObj->GetObjectLibrary();
if (cmGeneratorTarget* tgt =
this->LocalGenerator->FindGeneratorTargetToUse(objLib)) {
objectLibraries.push_back(tgt);
}
}
}
- for (std::vector<cmGeneratorTarget*>::const_iterator i =
- objectLibraries.begin();
- i != objectLibraries.end(); ++i) {
- (*i)->GetLanguages(languages, config);
+ for (cmGeneratorTarget* objLib : objectLibraries) {
+ objLib->GetLanguages(languages, config);
}
}
@@ -5339,10 +5230,9 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
impl.HadHeadSensitiveCondition = true;
}
- for (std::vector<std::string>::const_iterator li = llibs.begin();
- li != llibs.end(); ++li) {
+ for (std::string const& lib : llibs) {
// Skip entries that resolve to the target itself or are empty.
- std::string name = this->CheckCMP0004(*li);
+ std::string name = this->CheckCMP0004(lib);
if (name == this->GetName() || name.empty()) {
if (name == this->GetName()) {
bool noMessage = false;
@@ -5380,10 +5270,9 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
}
std::set<std::string> const& seenProps = cge->GetSeenTargetProperties();
- for (std::set<std::string>::const_iterator it = seenProps.begin();
- it != seenProps.end(); ++it) {
- if (!this->GetProperty(*it)) {
- this->LinkImplicitNullProperties.insert(*it);
+ for (std::string const& sp : seenProps) {
+ if (!this->GetProperty(sp)) {
+ this->LinkImplicitNullProperties.insert(sp);
}
}
cge->GetMaxLanguageStandard(this, this->MaxLanguageStandards);
@@ -5397,10 +5286,9 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
CMP0003_ComputeLinkType(config, debugConfigs);
cmTarget::LinkLibraryVectorType const& oldllibs =
this->Target->GetOriginalLinkLibraries();
- for (cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin();
- li != oldllibs.end(); ++li) {
- if (li->second != GENERAL_LibraryType && li->second != linkType) {
- std::string name = this->CheckCMP0004(li->first);
+ for (cmTarget::LibraryID const& oldllib : oldllibs) {
+ if (oldllib.second != GENERAL_LibraryType && oldllib.second != linkType) {
+ std::string name = this->CheckCMP0004(oldllib.first);
if (name == this->GetName() || name.empty()) {
continue;
}
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 39c181a..958aa05 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -244,10 +244,8 @@ bool cmGlobalGenerator::GenerateImportFile(const std::string& file)
bool result = it->second->GenerateImportFile();
if (!this->ConfigureDoneCMP0026AndCMP0024) {
- for (std::vector<cmMakefile*>::const_iterator mit =
- this->Makefiles.begin();
- mit != this->Makefiles.end(); ++mit) {
- (*mit)->RemoveExportBuildFileGeneratorCMP0024(it->second);
+ for (cmMakefile* m : this->Makefiles) {
+ m->RemoveExportBuildFileGeneratorCMP0024(it->second);
}
}
@@ -383,12 +381,11 @@ void cmGlobalGenerator::EnableLanguage(
}
std::set<std::string> cur_languages(languages.begin(), languages.end());
- for (std::set<std::string>::iterator li = cur_languages.begin();
- li != cur_languages.end(); ++li) {
- if (!this->LanguagesInProgress.insert(*li).second) {
+ for (std::string const& li : cur_languages) {
+ if (!this->LanguagesInProgress.insert(li).second) {
std::ostringstream e;
- e << "Language '" << *li << "' is currently being enabled. "
- "Recursive call not allowed.";
+ e << "Language '" << li << "' is currently being enabled. "
+ "Recursive call not allowed.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
cmSystemTools::SetFatalErrorOccured();
return;
@@ -397,12 +394,11 @@ void cmGlobalGenerator::EnableLanguage(
if (this->TryCompileOuterMakefile) {
// In a try-compile we can only enable languages provided by caller.
- for (std::vector<std::string>::const_iterator li = languages.begin();
- li != languages.end(); ++li) {
- if (*li == "NONE") {
+ for (std::string const& li : languages) {
+ if (li == "NONE") {
this->SetLanguageEnabled("NONE", mf);
} else {
- const char* lang = li->c_str();
+ const char* lang = li.c_str();
if (this->LanguagesReady.find(lang) == this->LanguagesReady.end()) {
std::ostringstream e;
e << "The test project needs language " << lang
@@ -541,11 +537,10 @@ void cmGlobalGenerator::EnableLanguage(
// load the CMakeDetermine(LANG)Compiler.cmake file to find
// the compiler
- for (std::vector<std::string>::const_iterator l = languages.begin();
- l != languages.end(); ++l) {
- const char* lang = l->c_str();
+ for (std::string const& l : languages) {
+ const char* lang = l.c_str();
needSetLanguageEnabledMaps[lang] = false;
- if (*l == "NONE") {
+ if (l == "NONE") {
this->SetLanguageEnabled("NONE", mf);
continue;
}
@@ -647,10 +642,9 @@ void cmGlobalGenerator::EnableLanguage(
}
// loop over languages again loading CMake(LANG)Information.cmake
//
- for (std::vector<std::string>::const_iterator l = languages.begin();
- l != languages.end(); ++l) {
- const char* lang = l->c_str();
- if (*l == "NONE") {
+ for (std::string const& l : languages) {
+ const char* lang = l.c_str();
+ if (l == "NONE") {
this->SetLanguageEnabled("NONE", mf);
continue;
}
@@ -793,9 +787,8 @@ void cmGlobalGenerator::EnableLanguage(
cmSystemTools::SetFatalErrorOccured();
}
- for (std::set<std::string>::iterator li = cur_languages.begin();
- li != cur_languages.end(); ++li) {
- this->LanguagesInProgress.erase(*li);
+ for (std::string const& lang : cur_languages) {
+ this->LanguagesInProgress.erase(lang);
}
}
@@ -1020,9 +1013,8 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const std::string& l,
std::string ignoreExts = mf->GetSafeDefinition(ignoreExtensionsVar);
std::vector<std::string> extensionList;
cmSystemTools::ExpandListArgument(ignoreExts, extensionList);
- for (std::vector<std::string>::iterator i = extensionList.begin();
- i != extensionList.end(); ++i) {
- this->IgnoreExtensions[*i] = true;
+ for (std::string const& i : extensionList) {
+ this->IgnoreExtensions[i] = true;
}
}
@@ -1034,9 +1026,8 @@ void cmGlobalGenerator::FillExtensionToLanguageMap(const std::string& l,
std::string exts = mf->GetSafeDefinition(extensionsVar);
std::vector<std::string> extensionList;
cmSystemTools::ExpandListArgument(exts, extensionList);
- for (std::vector<std::string>::iterator i = extensionList.begin();
- i != extensionList.end(); ++i) {
- this->ExtensionToLanguage[*i] = l;
+ for (std::string const& i : extensionList) {
+ this->ExtensionToLanguage[i] = l;
}
}
@@ -1082,9 +1073,8 @@ void cmGlobalGenerator::CreateLocalGenerators()
cmDeleteAll(this->LocalGenerators);
this->LocalGenerators.clear();
this->LocalGenerators.reserve(this->Makefiles.size());
- for (std::vector<cmMakefile*>::const_iterator it = this->Makefiles.begin();
- it != this->Makefiles.end(); ++it) {
- this->LocalGenerators.push_back(this->CreateLocalGenerator(*it));
+ for (cmMakefile* m : this->Makefiles) {
+ this->LocalGenerators.push_back(this->CreateLocalGenerator(m));
}
}
@@ -1118,13 +1108,11 @@ void cmGlobalGenerator::Configure()
std::vector<GlobalTargetInfo> globalTargets;
this->CreateDefaultGlobalTargets(globalTargets);
- for (unsigned int i = 0; i < this->Makefiles.size(); ++i) {
- cmMakefile* mf = this->Makefiles[i];
+ for (cmMakefile* mf : this->Makefiles) {
cmTargets* targets = &(mf->GetTargets());
- for (std::vector<GlobalTargetInfo>::iterator gti = globalTargets.begin();
- gti != globalTargets.end(); ++gti) {
- targets->insert(
- cmTargets::value_type(gti->Name, this->CreateGlobalTarget(*gti, mf)));
+ for (GlobalTargetInfo const& globalTarget : globalTargets) {
+ targets->insert(cmTargets::value_type(
+ globalTarget.Name, this->CreateGlobalTarget(globalTarget, mf)));
}
}
@@ -1177,9 +1165,8 @@ void cmGlobalGenerator::CreateImportedGenerationObjects(
std::find(this->Makefiles.begin(), this->Makefiles.end(), mf);
cmLocalGenerator* lg =
this->LocalGenerators[std::distance(this->Makefiles.begin(), mfit)];
- for (std::vector<std::string>::const_iterator it = targets.begin();
- it != targets.end(); ++it) {
- cmGeneratorTarget* gt = lg->FindGeneratorTargetToUse(*it);
+ for (std::string const& t : targets) {
+ cmGeneratorTarget* gt = lg->FindGeneratorTargetToUse(t);
if (gt) {
exports.push_back(gt);
}
@@ -1229,10 +1216,8 @@ void cmGlobalGenerator::ComputeBuildFileGenerators()
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
std::vector<cmExportBuildFileGenerator*> gens =
this->Makefiles[i]->GetExportBuildFileGenerators();
- for (std::vector<cmExportBuildFileGenerator*>::const_iterator it =
- gens.begin();
- it != gens.end(); ++it) {
- (*it)->Compute(this->LocalGenerators[i]);
+ for (cmExportBuildFileGenerator* g : gens) {
+ g->Compute(this->LocalGenerators[i]);
}
}
}
@@ -1266,11 +1251,9 @@ bool cmGlobalGenerator::Compute()
cmQtAutoGenDigestUPV autogenDigests = this->CreateQtAutoGeneratorsTargets();
#endif
- unsigned int i;
-
// Add generator specific helper commands
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- this->LocalGenerators[i]->AddHelperCommands();
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ localGen->AddHelperCommands();
}
// Finalize the set of compile features for each target.
@@ -1279,25 +1262,23 @@ bool cmGlobalGenerator::Compute()
// on the original cmTarget instance. It accumulates features
// across all configurations. Some refactoring is needed to
// compute a per-config resulta purely during generation.
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- if (!this->LocalGenerators[i]->ComputeTargetCompileFeatures()) {
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ if (!localGen->ComputeTargetCompileFeatures()) {
return false;
}
}
#ifdef CMAKE_BUILD_WITH_CMAKE
- for (const cmQtAutoGenDigestUP& digest : autogenDigests) {
+ for (cmQtAutoGenDigestUP const& digest : autogenDigests) {
cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(*digest);
}
autogenDigests.clear();
#endif
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- cmMakefile* mf = this->LocalGenerators[i]->GetMakefile();
- std::vector<cmInstallGenerator*>& gens = mf->GetInstallGenerators();
- for (std::vector<cmInstallGenerator*>::const_iterator git = gens.begin();
- git != gens.end(); ++git) {
- (*git)->Compute(this->LocalGenerators[i]);
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ cmMakefile* mf = localGen->GetMakefile();
+ for (cmInstallGenerator* g : mf->GetInstallGenerators()) {
+ g->Compute(localGen);
}
}
@@ -1305,15 +1286,15 @@ bool cmGlobalGenerator::Compute()
// Trace the dependencies, after that no custom commands should be added
// because their dependencies might not be handled correctly
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- this->LocalGenerators[i]->TraceDependencies();
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ localGen->TraceDependencies();
}
this->ForceLinkerLanguages();
// Compute the manifest of main targets generated.
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- this->LocalGenerators[i]->ComputeTargetManifest();
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ localGen->ComputeTargetManifest();
}
// Compute the inter-target dependencies.
@@ -1321,8 +1302,8 @@ bool cmGlobalGenerator::Compute()
return false;
}
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- this->LocalGenerators[i]->ComputeHomeRelativeOutputPath();
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ localGen->ComputeHomeRelativeOutputPath();
}
return true;
@@ -1356,10 +1337,8 @@ void cmGlobalGenerator::Generate()
cmake::FATAL_ERROR, "Could not write CPack properties file.");
}
- for (std::map<std::string, cmExportBuildFileGenerator*>::iterator it =
- this->BuildExportSets.begin();
- it != this->BuildExportSets.end(); ++it) {
- if (!it->second->GenerateImportFile()) {
+ for (auto& buildExpSet : this->BuildExportSets) {
+ if (!buildExpSet.second->GenerateImportFile()) {
if (!cmSystemTools::GetErrorOccuredFlag()) {
this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR,
"Could not write export file.");
@@ -1381,10 +1360,8 @@ void cmGlobalGenerator::Generate()
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0042) << "\n";
w << "MACOSX_RPATH is not specified for"
" the following targets:\n";
- for (std::set<std::string>::iterator iter =
- this->CMP0042WarnTargets.begin();
- iter != this->CMP0042WarnTargets.end(); ++iter) {
- w << " " << *iter << "\n";
+ for (std::string const& t : this->CMP0042WarnTargets) {
+ w << " " << t << "\n";
}
this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str());
}
@@ -1399,10 +1376,8 @@ void cmGlobalGenerator::Generate()
"settings:\n"
;
/* clang-format on */
- for (std::set<std::string>::iterator iter =
- this->CMP0068WarnTargets.begin();
- iter != this->CMP0068WarnTargets.end(); ++iter) {
- w << " " << *iter << "\n";
+ for (std::string const& t : this->CMP0068WarnTargets) {
+ w << " " << t << "\n";
}
this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str());
}
@@ -1417,10 +1392,8 @@ bool cmGlobalGenerator::ComputeTargetDepends()
return false;
}
std::vector<cmGeneratorTarget const*> const& targets = ctd.GetTargets();
- for (std::vector<cmGeneratorTarget const*>::const_iterator ti =
- targets.begin();
- ti != targets.end(); ++ti) {
- ctd.GetTargetDirectDepends(*ti, this->TargetDependencies[*ti]);
+ for (cmGeneratorTarget const* target : targets) {
+ ctd.GetTargetDirectDepends(target, this->TargetDependencies[target]);
}
return true;
}
@@ -1502,17 +1475,15 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
this->CMakeInstance->GetState()->GetEnabledLanguages();
// Construct per-target generator information.
- for (unsigned int i = 0; i < this->Makefiles.size(); ++i) {
- cmMakefile* mf = this->Makefiles[i];
-
+ for (cmMakefile* mf : this->Makefiles) {
const cmStringRange noconfig_compile_definitions =
mf->GetCompileDefinitionsEntries();
const cmBacktraceRange noconfig_compile_definitions_bts =
mf->GetCompileDefinitionsBacktraces();
cmTargets& targets = mf->GetTargets();
- for (cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti) {
- cmTarget* t = &ti->second;
+ for (auto& target : targets) {
+ cmTarget* t = &target.second;
if (t->GetType() == cmStateEnums::GLOBAL_TARGET) {
continue;
}
@@ -1537,10 +1508,9 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
std::vector<std::string> configs;
mf->GetConfigurations(configs);
- for (std::vector<std::string>::const_iterator ci = configs.begin();
- ci != configs.end(); ++ci) {
+ for (std::string const& c : configs) {
std::string defPropName = "COMPILE_DEFINITIONS_";
- defPropName += cmSystemTools::UpperCase(*ci);
+ defPropName += cmSystemTools::UpperCase(c);
t->AppendProperty(defPropName, mf->GetProperty(defPropName));
}
}
@@ -1549,10 +1519,9 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
// The standard include directories for each language
// should be treated as system include directories.
std::set<std::string> standardIncludesSet;
- for (std::vector<std::string>::const_iterator li = langs.begin();
- li != langs.end(); ++li) {
+ for (std::string const& li : langs) {
std::string const standardIncludesVar =
- "CMAKE_" + *li + "_STANDARD_INCLUDE_DIRECTORIES";
+ "CMAKE_" + li + "_STANDARD_INCLUDE_DIRECTORIES";
std::string const standardIncludesStr =
mf->GetSafeDefinition(standardIncludesVar);
std::vector<std::string> standardIncludesVec;
@@ -1571,8 +1540,8 @@ void cmGlobalGenerator::CreateGeneratorTargets(
{
if (targetTypes == AllTargets) {
cmTargets& targets = mf->GetTargets();
- for (cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti) {
- cmTarget* t = &ti->second;
+ for (auto& target : targets) {
+ cmTarget* t = &target.second;
cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg);
lg->AddGeneratorTarget(gt);
}
@@ -1580,9 +1549,8 @@ void cmGlobalGenerator::CreateGeneratorTargets(
std::vector<cmTarget*> itgts = mf->GetImportedTargets();
- for (std::vector<cmTarget*>::const_iterator j = itgts.begin();
- j != itgts.end(); ++j) {
- lg->AddImportedGeneratorTarget(importedMap.find(*j)->second);
+ for (cmTarget* t : itgts) {
+ lg->AddImportedGeneratorTarget(importedMap.find(t)->second);
}
}
@@ -1591,13 +1559,11 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes)
std::map<cmTarget*, cmGeneratorTarget*> importedMap;
for (unsigned int i = 0; i < this->Makefiles.size(); ++i) {
cmMakefile* mf = this->Makefiles[i];
- for (std::vector<cmTarget*>::const_iterator j =
- mf->GetOwnedImportedTargets().begin();
- j != mf->GetOwnedImportedTargets().end(); ++j) {
+ for (cmTarget* ownedImpTgt : mf->GetOwnedImportedTargets()) {
cmLocalGenerator* lg = this->LocalGenerators[i];
- cmGeneratorTarget* gt = new cmGeneratorTarget(*j, lg);
+ cmGeneratorTarget* gt = new cmGeneratorTarget(ownedImpTgt, lg);
lg->AddOwnedImportedGeneratorTarget(gt);
- importedMap[*j] = gt;
+ importedMap[ownedImpTgt] = gt;
}
}
@@ -1644,30 +1610,30 @@ void cmGlobalGenerator::CheckTargetProperties()
for (unsigned int i = 0; i < this->Makefiles.size(); ++i) {
this->Makefiles[i]->ConfigureFinalPass();
cmTargets& targets = this->Makefiles[i]->GetTargets();
- for (cmTargets::iterator l = targets.begin(); l != targets.end(); l++) {
- if (l->second.GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (auto const& target : targets) {
+ if (target.second.GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
const cmTarget::LinkLibraryVectorType& libs =
- l->second.GetOriginalLinkLibraries();
- for (cmTarget::LinkLibraryVectorType::const_iterator lib = libs.begin();
- lib != libs.end(); ++lib) {
- if (lib->first.size() > 9 &&
- cmSystemTools::IsNOTFOUND(lib->first.c_str())) {
- std::string varName = lib->first.substr(0, lib->first.size() - 9);
+ target.second.GetOriginalLinkLibraries();
+ for (auto const& lib : libs) {
+ if (lib.first.size() > 9 &&
+ cmSystemTools::IsNOTFOUND(lib.first.c_str())) {
+ std::string varName = lib.first.substr(0, lib.first.size() - 9);
if (state->GetCacheEntryPropertyAsBool(varName, "ADVANCED")) {
varName += " (ADVANCED)";
}
std::string text = notFoundMap[varName];
text += "\n linked by target \"";
- text += l->second.GetName();
+ text += target.second.GetName();
text += "\" in directory ";
text += this->Makefiles[i]->GetCurrentSourceDirectory();
notFoundMap[varName] = text;
}
}
std::vector<std::string> incs;
- const char* incDirProp = l->second.GetProperty("INCLUDE_DIRECTORIES");
+ const char* incDirProp =
+ target.second.GetProperty("INCLUDE_DIRECTORIES");
if (!incDirProp) {
continue;
}
@@ -1677,10 +1643,9 @@ void cmGlobalGenerator::CheckTargetProperties()
cmSystemTools::ExpandListArgument(incDirs, incs);
- for (std::vector<std::string>::const_iterator incDir = incs.begin();
- incDir != incs.end(); ++incDir) {
- if (incDir->size() > 9 && cmSystemTools::IsNOTFOUND(incDir->c_str())) {
- std::string varName = incDir->substr(0, incDir->size() - 9);
+ for (std::string const& incDir : incs) {
+ if (incDir.size() > 9 && cmSystemTools::IsNOTFOUND(incDir.c_str())) {
+ std::string varName = incDir.substr(0, incDir.size() - 9);
if (state->GetCacheEntryPropertyAsBool(varName, "ADVANCED")) {
varName += " (ADVANCED)";
}
@@ -1699,11 +1664,9 @@ void cmGlobalGenerator::CheckTargetProperties()
if (!notFoundMap.empty()) {
std::string notFoundVars;
- for (std::map<std::string, std::string>::const_iterator ii =
- notFoundMap.begin();
- ii != notFoundMap.end(); ++ii) {
- notFoundVars += ii->first;
- notFoundVars += ii->second;
+ for (auto const& notFound : notFoundMap) {
+ notFoundVars += notFound.first;
+ notFoundVars += notFound.second;
notFoundVars += "\n";
}
cmSystemTools::Error("The following variables are used in this project, "
@@ -2035,16 +1998,15 @@ int cmGlobalGenerator::GetLinkerPreference(const std::string& lang) const
void cmGlobalGenerator::FillProjectMap()
{
this->ProjectMap.clear(); // make sure we start with a clean map
- unsigned int i;
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
// for each local generator add all projects
- cmStateSnapshot snp = this->LocalGenerators[i]->GetStateSnapshot();
+ cmStateSnapshot snp = localGen->GetStateSnapshot();
std::string name;
do {
std::string snpProjName = snp.GetProjectName();
if (name != snpProjName) {
name = snpProjName;
- this->ProjectMap[name].push_back(this->LocalGenerators[i]);
+ this->ProjectMap[name].push_back(localGen);
}
snp = snp.GetBuildsystemDirectoryParent();
} while (snp.IsValid());
@@ -2064,12 +2026,10 @@ cmMakefile* cmGlobalGenerator::FindMakefile(const std::string& start_dir) const
cmLocalGenerator* cmGlobalGenerator::FindLocalGenerator(
const std::string& start_dir) const
{
- for (std::vector<cmLocalGenerator*>::const_iterator it =
- this->LocalGenerators.begin();
- it != this->LocalGenerators.end(); ++it) {
- std::string sd = (*it)->GetCurrentSourceDirectory();
+ for (cmLocalGenerator* lg : this->LocalGenerators) {
+ std::string sd = lg->GetCurrentSourceDirectory();
if (sd == start_dir) {
- return *it;
+ return lg;
}
}
return nullptr;
@@ -2477,9 +2437,8 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(GlobalTargetInfo const& gti,
if (!gti.Message.empty()) {
target.SetProperty("EchoString", gti.Message.c_str());
}
- for (std::vector<std::string>::const_iterator dit = gti.Depends.begin();
- dit != gti.Depends.end(); ++dit) {
- target.AddUtility(*dit);
+ for (std::string const& d : gti.Depends) {
+ target.AddUtility(d);
}
// Organize in the "predefined targets" folder:
@@ -2587,18 +2546,16 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets,
GeneratorVector const& generators)
{
// loop over all local generators
- for (std::vector<cmLocalGenerator*>::const_iterator i = generators.begin();
- i != generators.end(); ++i) {
+ for (cmLocalGenerator* generator : generators) {
// check to make sure generator is not excluded
- if (this->IsExcluded(root, *i)) {
+ if (this->IsExcluded(root, generator)) {
continue;
}
// Get the targets in the makefile
- const std::vector<cmGeneratorTarget*>& tgts = (*i)->GetGeneratorTargets();
+ const std::vector<cmGeneratorTarget*>& tgts =
+ generator->GetGeneratorTargets();
// loop over all the targets
- for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin();
- l != tgts.end(); ++l) {
- cmGeneratorTarget* target = *l;
+ for (cmGeneratorTarget* target : tgts) {
if (this->IsRootOnlyTarget(target) &&
target->GetLocalGenerator() != root) {
continue;
@@ -2625,8 +2582,8 @@ void cmGlobalGenerator::AddTargetDepends(cmGeneratorTarget const* target,
// This is the first time we have encountered the target.
// Recursively follow its dependencies.
TargetDependSet const& ts = this->GetTargetDirectDepends(target);
- for (TargetDependSet::const_iterator i = ts.begin(); i != ts.end(); ++i) {
- this->AddTargetDepends(*i, projectTargets);
+ for (auto const& t : ts) {
+ this->AddTargetDepends(t, projectTargets);
}
}
}
@@ -2771,11 +2728,9 @@ void cmGlobalGenerator::WriteRuleHashes(std::string const& pfile)
} else {
cmGeneratedFileStream fout(pfile.c_str());
fout << "# Hashes of file build rules.\n";
- for (std::map<std::string, RuleHash>::const_iterator rhi =
- this->RuleHashes.begin();
- rhi != this->RuleHashes.end(); ++rhi) {
- fout.write(rhi->second.Data, 32);
- fout << " " << rhi->first << "\n";
+ for (auto const& rh : this->RuleHashes) {
+ fout.write(rh.second.Data, 32);
+ fout << " " << rh.first << "\n";
}
}
}
@@ -2788,16 +2743,14 @@ void cmGlobalGenerator::WriteSummary()
fname += "/TargetDirectories.txt";
cmGeneratedFileStream fout(fname.c_str());
- for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
- const std::vector<cmGeneratorTarget*>& tgts =
- this->LocalGenerators[i]->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator it = tgts.begin();
- it != tgts.end(); ++it) {
- if ((*it)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (cmLocalGenerator* lg : this->LocalGenerators) {
+ const std::vector<cmGeneratorTarget*>& tgts = lg->GetGeneratorTargets();
+ for (cmGeneratorTarget* tgt : tgts) {
+ if (tgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- this->WriteSummary(*it);
- fout << (*it)->GetSupportDirectory() << "\n";
+ this->WriteSummary(tgt);
+ fout << tgt->GetSupportDirectory() << "\n";
}
}
}
@@ -2835,10 +2788,9 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
cmSystemTools::ExpandListArgument(targetLabels, labels);
if (!labels.empty()) {
fout << "# Target labels\n";
- for (std::vector<std::string>::const_iterator li = labels.begin();
- li != labels.end(); ++li) {
- fout << " " << *li << "\n";
- lj_target_labels.append(*li);
+ for (std::string const& l : labels) {
+ fout << " " << l << "\n";
+ lj_target_labels.append(l);
}
}
}
@@ -2860,18 +2812,14 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
fout << "# Directory labels\n";
}
- for (std::vector<std::string>::const_iterator li =
- directoryLabelsList.begin();
- li != directoryLabelsList.end(); ++li) {
- fout << " " << *li << "\n";
- lj_target_labels.append(*li);
+ for (std::string const& li : directoryLabelsList) {
+ fout << " " << li << "\n";
+ lj_target_labels.append(li);
}
- for (std::vector<std::string>::const_iterator li =
- cmakeDirectoryLabelsList.begin();
- li != cmakeDirectoryLabelsList.end(); ++li) {
- fout << " " << *li << "\n";
- lj_target_labels.append(*li);
+ for (std::string const& li : cmakeDirectoryLabelsList) {
+ fout << " " << li << "\n";
+ lj_target_labels.append(li);
}
// List the source files with any per-source labels.
@@ -2882,9 +2830,8 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
if (configs.empty()) {
configs.push_back("");
}
- for (std::vector<std::string>::const_iterator ci = configs.begin();
- ci != configs.end(); ++ci) {
- target->GetSourceFiles(sources, *ci);
+ for (std::string const& c : configs) {
+ target->GetSourceFiles(sources, c);
}
std::vector<cmSourceFile*>::const_iterator sourcesEnd =
cmRemoveDuplicates(sources);
@@ -2899,10 +2846,9 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
labels.clear();
Json::Value& lj_source_labels = lj_source["labels"] = Json::arrayValue;
cmSystemTools::ExpandListArgument(svalue, labels);
- for (std::vector<std::string>::const_iterator li = labels.begin();
- li != labels.end(); ++li) {
- fout << " " << *li << "\n";
- lj_source_labels.append(*li);
+ for (std::string const& label : labels) {
+ fout << " " << label << "\n";
+ lj_source_labels.append(label);
}
}
}
@@ -2920,11 +2866,11 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
std::string cmGlobalGenerator::EscapeJSON(const std::string& s)
{
std::string result;
- for (std::string::size_type i = 0; i < s.size(); ++i) {
- if (s[i] == '"' || s[i] == '\\') {
+ for (char i : s) {
+ if (i == '"' || i == '\\') {
result += '\\';
}
- result += s[i];
+ result += i;
}
return result;
}
@@ -2944,18 +2890,16 @@ cmGlobalGenerator::GetFilenameTargetDepends(cmSourceFile* sf) const
void cmGlobalGenerator::CreateEvaluationSourceFiles(
std::string const& config) const
{
- unsigned int i;
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- this->LocalGenerators[i]->CreateEvaluationFileOutputs(config);
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ localGen->CreateEvaluationFileOutputs(config);
}
}
void cmGlobalGenerator::ProcessEvaluationFiles()
{
std::vector<std::string> generatedFiles;
- unsigned int i;
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- this->LocalGenerators[i]->ProcessEvaluationFiles(generatedFiles);
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ localGen->ProcessEvaluationFiles(generatedFiles);
}
}
@@ -2986,9 +2930,8 @@ bool cmGlobalGenerator::GenerateCPackPropertiesFile()
cmGeneratedFileStream file(path.c_str());
file << "# CPack properties\n";
- for (cmake::InstalledFilesMap::const_iterator i = installedFiles.begin();
- i != installedFiles.end(); ++i) {
- cmInstalledFile const& installedFile = i->second;
+ for (auto const& i : installedFiles) {
+ cmInstalledFile const& installedFile = i.second;
cmCPackPropertiesGenerator cpackPropertiesGenerator(lg, installedFile,
configs);
diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx
index c337ab0..b1e630e 100644
--- a/Source/cmGlobalKdevelopGenerator.cxx
+++ b/Source/cmGlobalKdevelopGenerator.cxx
@@ -16,7 +16,6 @@
#include "cmsys/Directory.hxx"
#include "cmsys/FStream.hxx"
-#include <map>
#include <set>
#include <string.h>
#include <utility>
@@ -49,15 +48,13 @@ void cmGlobalKdevelopGenerator::Generate()
{
// for each sub project in the project create
// a kdevelop project
- for (std::map<std::string, std::vector<cmLocalGenerator*>>::const_iterator
- it = this->GlobalGenerator->GetProjectMap().begin();
- it != this->GlobalGenerator->GetProjectMap().end(); ++it) {
- std::string outputDir = it->second[0]->GetCurrentBinaryDirectory();
- std::string projectDir = it->second[0]->GetSourceDirectory();
- std::string projectName = it->second[0]->GetProjectName();
+ for (auto const& it : this->GlobalGenerator->GetProjectMap()) {
+ std::string outputDir = it.second[0]->GetCurrentBinaryDirectory();
+ std::string projectDir = it.second[0]->GetSourceDirectory();
+ std::string projectName = it.second[0]->GetProjectName();
std::string cmakeFilePattern("CMakeLists.txt;*.cmake;");
std::string fileToOpen;
- const std::vector<cmLocalGenerator*>& lgs = it->second;
+ const std::vector<cmLocalGenerator*>& lgs = it.second;
// create the project.kdevelop.filelist file
if (!this->CreateFilelistFile(lgs, outputDir, projectDir, projectName,
cmakeFilePattern, fileToOpen)) {
@@ -67,15 +64,12 @@ void cmGlobalKdevelopGenerator::Generate()
// try to find the name of an executable so we have something to
// run from kdevelop for now just pick the first executable found
std::string executable;
- for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin();
- lg != lgs.end(); lg++) {
+ for (cmLocalGenerator* lg : lgs) {
std::vector<cmGeneratorTarget*> const& targets =
- (*lg)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator ti =
- targets.begin();
- ti != targets.end(); ti++) {
- if ((*ti)->GetType() == cmStateEnums::EXECUTABLE) {
- executable = (*ti)->GetLocation("");
+ lg->GetGeneratorTargets();
+ for (cmGeneratorTarget* target : targets) {
+ if (target->GetType() == cmStateEnums::EXECUTABLE) {
+ executable = target->GetLocation("");
break;
}
}
@@ -104,13 +98,11 @@ bool cmGlobalKdevelopGenerator::CreateFilelistFile(
std::vector<std::string> const& hdrExts =
this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions();
- for (std::vector<cmLocalGenerator*>::const_iterator it = lgs.begin();
- it != lgs.end(); it++) {
- cmMakefile* makefile = (*it)->GetMakefile();
+ for (cmLocalGenerator* lg : lgs) {
+ cmMakefile* makefile = lg->GetMakefile();
const std::vector<std::string>& listFiles = makefile->GetListFiles();
- for (std::vector<std::string>::const_iterator lt = listFiles.begin();
- lt != listFiles.end(); lt++) {
- tmp = *lt;
+ for (std::string const& listFile : listFiles) {
+ tmp = listFile;
cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
// make sure the file is part of this source tree
if ((tmp[0] != '/') &&
@@ -128,17 +120,13 @@ bool cmGlobalKdevelopGenerator::CreateFilelistFile(
}
// get all sources
- const std::vector<cmGeneratorTarget*>& targets =
- (*it)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
- ti != targets.end(); ti++) {
+ const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
+ for (cmGeneratorTarget* gt : targets) {
std::vector<cmSourceFile*> sources;
- cmGeneratorTarget* gt = *ti;
gt->GetSourceFiles(sources, gt->Target->GetMakefile()->GetSafeDefinition(
"CMAKE_BUILD_TYPE"));
- for (std::vector<cmSourceFile*>::const_iterator si = sources.begin();
- si != sources.end(); si++) {
- tmp = (*si)->GetFullPath();
+ for (cmSourceFile* sf : sources) {
+ tmp = sf->GetFullPath();
std::string headerBasename = cmSystemTools::GetFilenamePath(tmp);
headerBasename += "/";
headerBasename += cmSystemTools::GetFilenameWithoutExtension(tmp);
@@ -152,11 +140,10 @@ bool cmGlobalKdevelopGenerator::CreateFilelistFile(
files.insert(tmp);
// check if there's a matching header around
- for (std::vector<std::string>::const_iterator ext = hdrExts.begin();
- ext != hdrExts.end(); ++ext) {
+ for (std::string const& hdrExt : hdrExts) {
std::string hname = headerBasename;
hname += ".";
- hname += *ext;
+ hname += hdrExt;
if (cmSystemTools::FileExists(hname.c_str())) {
cmSystemTools::ReplaceString(hname, projectDir.c_str(), "");
files.insert(hname);
@@ -165,9 +152,8 @@ bool cmGlobalKdevelopGenerator::CreateFilelistFile(
}
}
}
- for (std::vector<std::string>::const_iterator lt = listFiles.begin();
- lt != listFiles.end(); lt++) {
- tmp = *lt;
+ for (std::string const& listFile : listFiles) {
+ tmp = listFile;
cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
if ((tmp[0] != '/') &&
(strstr(tmp.c_str(), cmake::GetCMakeFilesDirectoryPostSlash()) ==
@@ -201,10 +187,9 @@ bool cmGlobalKdevelopGenerator::CreateFilelistFile(
}
fileToOpen = "";
- for (std::set<std::string>::const_iterator it = files.begin();
- it != files.end(); it++) {
+ for (std::string const& file : files) {
// get the full path to the file
- tmp = cmSystemTools::CollapseFullPath(*it, projectDir.c_str());
+ tmp = cmSystemTools::CollapseFullPath(file, projectDir.c_str());
// just select the first source file
if (fileToOpen.empty()) {
std::string ext = cmSystemTools::GetFilenameExtension(tmp);
@@ -297,9 +282,8 @@ void cmGlobalKdevelopGenerator::MergeProjectFiles(
return;
}
- for (std::vector<std::string>::const_iterator it = lines.begin();
- it != lines.end(); it++) {
- const char* line = (*it).c_str();
+ for (std::string const& l : lines) {
+ const char* line = l.c_str();
// skip these tags as they are always replaced
if ((strstr(line, "<projectdirectory>") != nullptr) ||
(strstr(line, "<projectmanagement>") != nullptr) ||
@@ -311,7 +295,7 @@ void cmGlobalKdevelopGenerator::MergeProjectFiles(
}
// output the line from the file if it is not one of the above tags
- fout << *it << "\n";
+ fout << l << "\n";
// if this is the <general> tag output the stuff that goes in the
// general tag
if (strstr(line, "<general>")) {
@@ -434,10 +418,8 @@ void cmGlobalKdevelopGenerator::CreateNewProjectFile(
xml.EndElement(); // make
xml.StartElement("blacklist");
- for (std::vector<std::string>::const_iterator dirIt =
- this->Blacklist.begin();
- dirIt != this->Blacklist.end(); ++dirIt) {
- xml.Element("path", *dirIt);
+ for (std::string const& dir : this->Blacklist) {
+ xml.Element("path", dir);
}
xml.EndElement();
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index c9cd0fd..eee63c9 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -90,12 +90,12 @@ std::string cmGlobalNinjaGenerator::EncodeRuleName(std::string const& name)
// Ninja rule names must match "[a-zA-Z0-9_.-]+". Use ".xx" to encode
// "." and all invalid characters as hexadecimal.
std::string encoded;
- for (std::string::const_iterator i = name.begin(); i != name.end(); ++i) {
- if (isalnum(*i) || *i == '_' || *i == '-') {
- encoded += *i;
+ for (char i : name) {
+ if (isalnum(i) || i == '_' || i == '-') {
+ encoded += i;
} else {
char buf[16];
- sprintf(buf, ".%02x", static_cast<unsigned int>(*i));
+ sprintf(buf, ".%02x", static_cast<unsigned int>(i));
encoded += buf;
}
}
@@ -177,26 +177,23 @@ void cmGlobalNinjaGenerator::WriteBuild(
// TODO: Better formatting for when there are multiple input/output files.
// Write explicit dependencies.
- for (cmNinjaDeps::const_iterator i = explicitDeps.begin();
- i != explicitDeps.end(); ++i) {
- arguments += " " + EncodeIdent(EncodePath(*i), os);
+ for (std::string const& explicitDep : explicitDeps) {
+ arguments += " " + EncodeIdent(EncodePath(explicitDep), os);
}
// Write implicit dependencies.
if (!implicitDeps.empty()) {
arguments += " |";
- for (cmNinjaDeps::const_iterator i = implicitDeps.begin();
- i != implicitDeps.end(); ++i) {
- arguments += " " + EncodeIdent(EncodePath(*i), os);
+ for (std::string const& implicitDep : implicitDeps) {
+ arguments += " " + EncodeIdent(EncodePath(implicitDep), os);
}
}
// Write order-only dependencies.
if (!orderOnlyDeps.empty()) {
arguments += " ||";
- for (cmNinjaDeps::const_iterator i = orderOnlyDeps.begin();
- i != orderOnlyDeps.end(); ++i) {
- arguments += " " + EncodeIdent(EncodePath(*i), os);
+ for (std::string const& orderOnlyDep : orderOnlyDeps) {
+ arguments += " " + EncodeIdent(EncodePath(orderOnlyDep), os);
}
}
@@ -206,18 +203,16 @@ void cmGlobalNinjaGenerator::WriteBuild(
// Write outputs files.
build += "build";
- for (cmNinjaDeps::const_iterator i = outputs.begin(); i != outputs.end();
- ++i) {
- build += " " + EncodeIdent(EncodePath(*i), os);
+ for (std::string const& output : outputs) {
+ build += " " + EncodeIdent(EncodePath(output), os);
if (this->ComputingUnknownDependencies) {
- this->CombinedBuildOutputs.insert(*i);
+ this->CombinedBuildOutputs.insert(output);
}
}
if (!implicitOuts.empty()) {
build += " |";
- for (cmNinjaDeps::const_iterator i = implicitOuts.begin();
- i != implicitOuts.end(); ++i) {
- build += " " + EncodeIdent(EncodePath(*i), os);
+ for (std::string const& implicitOut : implicitOuts) {
+ build += " " + EncodeIdent(EncodePath(implicitOut), os);
}
}
build += ":";
@@ -227,20 +222,18 @@ void cmGlobalNinjaGenerator::WriteBuild(
// Write the variables bound to this build statement.
std::ostringstream variable_assignments;
- for (cmNinjaVars::const_iterator i = variables.begin(); i != variables.end();
- ++i) {
- cmGlobalNinjaGenerator::WriteVariable(variable_assignments, i->first,
- i->second, "", 1);
+ for (auto const& variable : variables) {
+ cmGlobalNinjaGenerator::WriteVariable(variable_assignments, variable.first,
+ variable.second, "", 1);
}
// check if a response file rule should be used
std::string buildstr = build;
std::string assignments = variable_assignments.str();
- const std::string& args = arguments;
bool useResponseFile = false;
if (cmdLineLimit < 0 ||
(cmdLineLimit > 0 &&
- (args.size() + buildstr.size() + assignments.size() + 1000) >
+ (arguments.size() + buildstr.size() + assignments.size() + 1000) >
static_cast<size_t>(cmdLineLimit))) {
variable_assignments.str(std::string());
cmGlobalNinjaGenerator::WriteVariable(variable_assignments, "RSP_FILE",
@@ -252,7 +245,7 @@ void cmGlobalNinjaGenerator::WriteBuild(
*usedResponseFile = useResponseFile;
}
- os << buildstr << args << assignments;
+ os << buildstr << arguments << assignments;
}
void cmGlobalNinjaGenerator::WritePhonyBuild(
@@ -311,8 +304,8 @@ void cmGlobalNinjaGenerator::WriteCustomCommandBuild(
if (this->ComputingUnknownDependencies) {
// we need to track every dependency that comes in, since we are trying
// to find dependencies that are side effects of build commands
- for (cmNinjaDeps::const_iterator i = deps.begin(); i != deps.end(); ++i) {
- this->CombinedCustomCommandExplicitDependencies.insert(*i);
+ for (std::string const& dep : deps) {
+ this->CombinedCustomCommandExplicitDependencies.insert(dep);
}
}
}
@@ -465,9 +458,8 @@ void cmGlobalNinjaGenerator::WriteDefault(std::ostream& os,
{
cmGlobalNinjaGenerator::WriteComment(os, comment);
os << "default";
- for (cmNinjaDeps::const_iterator i = targets.begin(); i != targets.end();
- ++i) {
- os << " " << *i;
+ for (std::string const& target : targets) {
+ os << " " << target;
}
os << "\n";
}
@@ -670,12 +662,11 @@ void cmGlobalNinjaGenerator::EnableLanguage(
std::vector<std::string> const& langs, cmMakefile* mf, bool optional)
{
this->cmGlobalGenerator::EnableLanguage(langs, mf, optional);
- for (std::vector<std::string>::const_iterator l = langs.begin();
- l != langs.end(); ++l) {
- if (*l == "NONE") {
+ for (std::string const& l : langs) {
+ if (l == "NONE") {
continue;
}
- this->ResolveLanguageCompiler(*l, mf, optional);
+ this->ResolveLanguageCompiler(l, mf, optional);
}
#ifdef _WIN32
if (strcmp(mf->GetSafeDefinition("CMAKE_C_SIMULATE_ID"), "MSVC") != 0 &&
@@ -952,15 +943,13 @@ void cmGlobalNinjaGenerator::AddDependencyToAll(const std::string& input)
void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies()
{
- for (std::map<std::string, std::set<std::string>>::iterator i =
- this->AssumedSourceDependencies.begin();
- i != this->AssumedSourceDependencies.end(); ++i) {
+ for (auto const& asd : this->AssumedSourceDependencies) {
cmNinjaDeps deps;
- std::copy(i->second.begin(), i->second.end(), std::back_inserter(deps));
+ std::copy(asd.second.begin(), asd.second.end(), std::back_inserter(deps));
WriteCustomCommandBuild(/*command=*/"", /*description=*/"",
"Assume dependencies for generated source file.",
/*depfile*/ "", /*uses_terminal*/ false,
- /*restat*/ true, cmNinjaDeps(1, i->first), deps);
+ /*restat*/ true, cmNinjaDeps(1, asd.first), deps);
}
}
@@ -1025,22 +1014,20 @@ void cmGlobalNinjaGenerator::AppendTargetDepends(
if (target->GetType() == cmStateEnums::GLOBAL_TARGET) {
// These depend only on other CMake-provided targets, e.g. "all".
std::set<std::string> const& utils = target->GetUtilities();
- for (std::set<std::string>::const_iterator i = utils.begin();
- i != utils.end(); ++i) {
+ for (std::string const& util : utils) {
std::string d =
target->GetLocalGenerator()->GetCurrentBinaryDirectory() +
- std::string("/") + *i;
+ std::string("/") + util;
outputs.push_back(this->ConvertToNinjaPath(d));
}
} else {
cmNinjaDeps outs;
cmTargetDependSet const& targetDeps = this->GetTargetDirectDepends(target);
- for (cmTargetDependSet::const_iterator i = targetDeps.begin();
- i != targetDeps.end(); ++i) {
- if ((*i)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (cmTargetDepend const& targetDep : targetDeps) {
+ if (targetDep->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- this->AppendTargetOutputs(*i, outs, depends);
+ this->AppendTargetOutputs(targetDep, outs, depends);
}
std::sort(outs.begin(), outs.end());
outputs.insert(outputs.end(), outs.begin(), outs.end());
@@ -1060,9 +1047,8 @@ void cmGlobalNinjaGenerator::AppendTargetDependsClosure(
}
std::set<cmGeneratorTarget const*> const& targets = i->second;
cmNinjaDeps outs;
- for (std::set<cmGeneratorTarget const*>::const_iterator ti = targets.begin();
- ti != targets.end(); ++ti) {
- this->AppendTargetOutputs(*ti, outs);
+ for (auto tgt : targets) {
+ this->AppendTargetOutputs(tgt, outs);
}
std::sort(outs.begin(), outs.end());
outputs.insert(outputs.end(), outs.begin(), outs.end());
@@ -1072,13 +1058,12 @@ void cmGlobalNinjaGenerator::ComputeTargetDependsClosure(
cmGeneratorTarget const* target, std::set<cmGeneratorTarget const*>& depends)
{
cmTargetDependSet const& targetDeps = this->GetTargetDirectDepends(target);
- for (cmTargetDependSet::const_iterator i = targetDeps.begin();
- i != targetDeps.end(); ++i) {
- if ((*i)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (auto targetDep : targetDeps) {
+ if (targetDep->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- if (depends.insert(*i).second) {
- this->ComputeTargetDependsClosure(*i, depends);
+ if (depends.insert(targetDep).second) {
+ this->ComputeTargetDependsClosure(targetDep, depends);
}
}
}
@@ -1091,8 +1076,8 @@ void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias,
this->AppendTargetOutputs(target, outputs);
// Mark the target's outputs as ambiguous to ensure that no other target uses
// the output as an alias.
- for (cmNinjaDeps::iterator i = outputs.begin(); i != outputs.end(); ++i) {
- TargetAliases[*i] = nullptr;
+ for (std::string const& output : outputs) {
+ TargetAliases[output] = nullptr;
}
// Insert the alias into the map. If the alias was already present in the
@@ -1109,17 +1094,16 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os)
cmGlobalNinjaGenerator::WriteDivider(os);
os << "# Target aliases.\n\n";
- for (TargetAliasMap::const_iterator i = TargetAliases.begin();
- i != TargetAliases.end(); ++i) {
+ for (auto const& ta : TargetAliases) {
// Don't write ambiguous aliases.
- if (!i->second) {
+ if (!ta.second) {
continue;
}
cmNinjaDeps deps;
- this->AppendTargetOutputs(i->second, deps);
+ this->AppendTargetOutputs(ta.second, deps);
- this->WritePhonyBuild(os, "", cmNinjaDeps(1, i->first), deps);
+ this->WritePhonyBuild(os, "", cmNinjaDeps(1, ta.first), deps);
}
}
@@ -1129,19 +1113,13 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os)
os << "# Folder targets.\n\n";
std::map<std::string, cmNinjaDeps> targetsPerFolder;
- for (std::vector<cmLocalGenerator*>::const_iterator lgi =
- this->LocalGenerators.begin();
- lgi != this->LocalGenerators.end(); ++lgi) {
- cmLocalGenerator const* lg = *lgi;
+ for (cmLocalGenerator const* lg : this->LocalGenerators) {
const std::string currentBinaryFolder(
lg->GetStateSnapshot().GetDirectory().GetCurrentBinary());
// The directory-level rule should depend on the target-level rules
// for all targets in the directory.
targetsPerFolder[currentBinaryFolder] = cmNinjaDeps();
- for (std::vector<cmGeneratorTarget*>::const_iterator ti =
- lg->GetGeneratorTargets().begin();
- ti != lg->GetGeneratorTargets().end(); ++ti) {
- cmGeneratorTarget const* gt = *ti;
+ for (auto gt : lg->GetGeneratorTargets()) {
cmStateEnums::TargetType const type = gt->GetType();
if ((type == cmStateEnums::EXECUTABLE ||
type == cmStateEnums::STATIC_LIBRARY ||
@@ -1158,11 +1136,9 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os)
// rules of the subdirectories.
std::vector<cmStateSnapshot> const& children =
lg->GetStateSnapshot().GetChildren();
- for (std::vector<cmStateSnapshot>::const_iterator stateIt =
- children.begin();
- stateIt != children.end(); ++stateIt) {
+ for (cmStateSnapshot const& state : children) {
std::string const currentBinaryDir =
- stateIt->GetDirectory().GetCurrentBinary();
+ state.GetDirectory().GetCurrentBinary();
targetsPerFolder[currentBinaryFolder].push_back(
this->ConvertToNinjaPath(currentBinaryDir + "/all"));
@@ -1171,11 +1147,9 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os)
std::string const rootBinaryDir =
this->LocalGenerators[0]->GetBinaryDirectory();
- for (std::map<std::string, cmNinjaDeps>::const_iterator it =
- targetsPerFolder.begin();
- it != targetsPerFolder.end(); ++it) {
+ for (auto const& it : targetsPerFolder) {
cmGlobalNinjaGenerator::WriteDivider(os);
- std::string const& currentBinaryDir = it->first;
+ std::string const& currentBinaryDir = it.first;
// Do not generate a rule for the root binary dir.
if (rootBinaryDir.length() >= currentBinaryDir.length()) {
@@ -1186,7 +1160,7 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os)
cmNinjaDeps output(1);
output.push_back(this->ConvertToNinjaPath(currentBinaryDir + "/all"));
- this->WritePhonyBuild(os, comment, output, it->second);
+ this->WritePhonyBuild(os, comment, output, it.second);
}
}
@@ -1220,50 +1194,40 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
// get the list of files that cmake itself has generated as a
// product of configuration.
- for (std::vector<cmLocalGenerator*>::const_iterator i =
- this->LocalGenerators.begin();
- i != this->LocalGenerators.end(); ++i) {
+ for (cmLocalGenerator* lg : this->LocalGenerators) {
// get the vector of files created by this makefile and convert them
// to ninja paths, which are all relative in respect to the build directory
const std::vector<std::string>& files =
- (*i)->GetMakefile()->GetOutputFiles();
- typedef std::vector<std::string>::const_iterator vect_it;
- for (vect_it j = files.begin(); j != files.end(); ++j) {
- knownDependencies.insert(this->ConvertToNinjaPath(*j));
+ lg->GetMakefile()->GetOutputFiles();
+ for (std::string const& file : files) {
+ knownDependencies.insert(this->ConvertToNinjaPath(file));
}
// get list files which are implicit dependencies as well and will be phony
// for rebuild manifest
- std::vector<std::string> const& lf = (*i)->GetMakefile()->GetListFiles();
- typedef std::vector<std::string>::const_iterator vect_it;
- for (vect_it j = lf.begin(); j != lf.end(); ++j) {
- knownDependencies.insert(this->ConvertToNinjaPath(*j));
+ std::vector<std::string> const& lf = lg->GetMakefile()->GetListFiles();
+ for (std::string const& j : lf) {
+ knownDependencies.insert(this->ConvertToNinjaPath(j));
}
std::vector<cmGeneratorExpressionEvaluationFile*> const& ef =
- (*i)->GetMakefile()->GetEvaluationFiles();
- for (std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator li =
- ef.begin();
- li != ef.end(); ++li) {
+ lg->GetMakefile()->GetEvaluationFiles();
+ for (cmGeneratorExpressionEvaluationFile* li : ef) {
// get all the files created by generator expressions and convert them
// to ninja paths
- std::vector<std::string> evaluationFiles = (*li)->GetFiles();
- for (vect_it j = evaluationFiles.begin(); j != evaluationFiles.end();
- ++j) {
- knownDependencies.insert(this->ConvertToNinjaPath(*j));
+ std::vector<std::string> evaluationFiles = li->GetFiles();
+ for (std::string const& evaluationFile : evaluationFiles) {
+ knownDependencies.insert(this->ConvertToNinjaPath(evaluationFile));
}
}
}
knownDependencies.insert(this->CMakeCacheFile);
- for (TargetAliasMap::const_iterator i = this->TargetAliases.begin();
- i != this->TargetAliases.end(); ++i) {
- knownDependencies.insert(this->ConvertToNinjaPath(i->first));
+ for (auto const& ta : this->TargetAliases) {
+ knownDependencies.insert(this->ConvertToNinjaPath(ta.first));
}
// remove all source files we know will exist.
- typedef std::map<std::string, std::set<std::string>>::const_iterator map_it;
- for (map_it i = this->AssumedSourceDependencies.begin();
- i != this->AssumedSourceDependencies.end(); ++i) {
- knownDependencies.insert(this->ConvertToNinjaPath(i->first));
+ for (auto const& i : this->AssumedSourceDependencies) {
+ knownDependencies.insert(this->ConvertToNinjaPath(i.first));
}
// now we difference with CombinedCustomCommandExplicitDependencies to find
@@ -1285,20 +1249,18 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
bool const inSourceBuild =
(rootBuildDirectory == this->GetCMakeInstance()->GetHomeDirectory());
std::vector<std::string> warnExplicitDepends;
- for (std::vector<std::string>::const_iterator i =
- unknownExplicitDepends.begin();
- i != unknownExplicitDepends.end(); ++i) {
+ for (std::string const& i : unknownExplicitDepends) {
// verify the file is in the build directory
std::string const absDepPath =
- cmSystemTools::CollapseFullPath(*i, rootBuildDirectory.c_str());
+ cmSystemTools::CollapseFullPath(i, rootBuildDirectory.c_str());
bool const inBuildDir =
cmSystemTools::IsSubDirectory(absDepPath, rootBuildDirectory);
if (inBuildDir) {
- cmNinjaDeps deps(1, *i);
+ cmNinjaDeps deps(1, i);
this->WritePhonyBuild(os, "", deps, cmNinjaDeps());
if (this->PolicyCMP0058 == cmPolicies::WARN && !inSourceBuild &&
warnExplicitDepends.size() < 10) {
- warnExplicitDepends.push_back(*i);
+ warnExplicitDepends.push_back(i);
}
}
}
@@ -1373,13 +1335,11 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
/*generator=*/true);
cmNinjaDeps implicitDeps;
- for (std::vector<cmLocalGenerator*>::const_iterator i =
- this->LocalGenerators.begin();
- i != this->LocalGenerators.end(); ++i) {
- std::vector<std::string> const& lf = (*i)->GetMakefile()->GetListFiles();
- for (std::vector<std::string>::const_iterator fi = lf.begin();
- fi != lf.end(); ++fi) {
- implicitDeps.push_back(this->ConvertToNinjaPath(*fi));
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ std::vector<std::string> const& lf =
+ localGen->GetMakefile()->GetListFiles();
+ for (std::string const& fi : lf) {
+ implicitDeps.push_back(this->ConvertToNinjaPath(fi));
}
}
implicitDeps.push_back(this->CMakeCacheFile);
@@ -1636,9 +1596,8 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
Json::Value const& tdi_include_dirs = tdi["include-dirs"];
if (tdi_include_dirs.isArray()) {
- for (Json::Value::const_iterator i = tdi_include_dirs.begin();
- i != tdi_include_dirs.end(); ++i) {
- includes.push_back(i->asString());
+ for (auto const& tdi_include_dir : tdi_include_dirs) {
+ includes.push_back(tdi_include_dir.asString());
}
}
}
@@ -1659,9 +1618,8 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
{
cmGeneratedFileStream depfile(arg_dep.c_str());
depfile << cmSystemTools::ConvertToUnixOutputPath(arg_pp) << ":";
- for (std::set<std::string>::iterator i = info.Includes.begin();
- i != info.Includes.end(); ++i) {
- depfile << " \\\n " << cmSystemTools::ConvertToUnixOutputPath(*i);
+ for (std::string const& include : info.Includes) {
+ depfile << " \\\n " << cmSystemTools::ConvertToUnixOutputPath(include);
}
depfile << "\n";
}
@@ -1670,16 +1628,14 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
ddi["object"] = arg_obj;
Json::Value& ddi_provides = ddi["provides"] = Json::arrayValue;
- for (std::set<std::string>::iterator i = info.Provides.begin();
- i != info.Provides.end(); ++i) {
- ddi_provides.append(*i);
+ for (std::string const& provide : info.Provides) {
+ ddi_provides.append(provide);
}
Json::Value& ddi_requires = ddi["requires"] = Json::arrayValue;
- for (std::set<std::string>::iterator i = info.Requires.begin();
- i != info.Requires.end(); ++i) {
+ for (std::string const& r : info.Requires) {
// Require modules not provided in the same source.
- if (!info.Provides.count(*i)) {
- ddi_requires.append(*i);
+ if (!info.Provides.count(r)) {
+ ddi_requires.append(r);
}
}
@@ -1722,16 +1678,15 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
}
std::vector<cmFortranObjectInfo> objects;
- for (std::vector<std::string>::const_iterator ddii = arg_ddis.begin();
- ddii != arg_ddis.end(); ++ddii) {
+ for (std::string const& arg_ddi : arg_ddis) {
// Load the ddi file and compute the module file paths it provides.
Json::Value ddio;
Json::Value const& ddi = ddio;
- cmsys::ifstream ddif(ddii->c_str(), std::ios::in | std::ios::binary);
+ cmsys::ifstream ddif(arg_ddi.c_str(), std::ios::in | std::ios::binary);
Json::Reader reader;
if (!reader.parse(ddif, ddio, false)) {
cmSystemTools::Error("-E cmake_ninja_dyndep failed to parse ",
- ddii->c_str(),
+ arg_ddi.c_str(),
reader.getFormattedErrorMessages().c_str());
return false;
}
@@ -1740,16 +1695,14 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
info.Object = ddi["object"].asString();
Json::Value const& ddi_provides = ddi["provides"];
if (ddi_provides.isArray()) {
- for (Json::Value::const_iterator i = ddi_provides.begin();
- i != ddi_provides.end(); ++i) {
- info.Provides.push_back(i->asString());
+ for (auto const& ddi_provide : ddi_provides) {
+ info.Provides.push_back(ddi_provide.asString());
}
}
Json::Value const& ddi_requires = ddi["requires"];
if (ddi_requires.isArray()) {
- for (Json::Value::const_iterator i = ddi_requires.begin();
- i != ddi_requires.end(); ++i) {
- info.Requires.push_back(i->asString());
+ for (auto const& ddi_require : ddi_requires) {
+ info.Requires.push_back(ddi_require.asString());
}
}
objects.push_back(info);
@@ -1759,16 +1712,14 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
std::map<std::string, std::string> mod_files;
// Populate the module map with those provided by linked targets first.
- for (std::vector<std::string>::const_iterator di =
- linked_target_dirs.begin();
- di != linked_target_dirs.end(); ++di) {
- std::string const ltmn = *di + "/FortranModules.json";
+ for (std::string const& linked_target_dir : linked_target_dirs) {
+ std::string const ltmn = linked_target_dir + "/FortranModules.json";
Json::Value ltm;
cmsys::ifstream ltmf(ltmn.c_str(), std::ios::in | std::ios::binary);
Json::Reader reader;
if (ltmf && !reader.parse(ltmf, ltm, false)) {
cmSystemTools::Error("-E cmake_ninja_dyndep failed to parse ",
- di->c_str(),
+ linked_target_dir.c_str(),
reader.getFormattedErrorMessages().c_str());
return false;
}
@@ -1783,21 +1734,18 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
// We do this after loading the modules provided by linked targets
// in case we have one of the same name that must be preferred.
Json::Value tm = Json::objectValue;
- for (std::vector<cmFortranObjectInfo>::iterator oi = objects.begin();
- oi != objects.end(); ++oi) {
- for (std::vector<std::string>::iterator i = oi->Provides.begin();
- i != oi->Provides.end(); ++i) {
- std::string const mod = module_dir + *i + ".mod";
- mod_files[*i] = mod;
- tm[*i] = mod;
+ for (cmFortranObjectInfo const& object : objects) {
+ for (std::string const& p : object.Provides) {
+ std::string const mod = module_dir + p + ".mod";
+ mod_files[p] = mod;
+ tm[p] = mod;
}
}
cmGeneratedFileStream ddf(arg_dd.c_str());
ddf << "ninja_dyndep_version = 1.0\n";
- for (std::vector<cmFortranObjectInfo>::iterator oi = objects.begin();
- oi != objects.end(); ++oi) {
+ for (cmFortranObjectInfo const& object : objects) {
std::string const ddComment;
std::string const ddRule = "dyndep";
cmNinjaDeps ddOutputs;
@@ -1807,19 +1755,17 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
cmNinjaDeps ddOrderOnlyDeps;
cmNinjaVars ddVars;
- ddOutputs.push_back(oi->Object);
- for (std::vector<std::string>::iterator i = oi->Provides.begin();
- i != oi->Provides.end(); ++i) {
- ddImplicitOuts.push_back(this->ConvertToNinjaPath(mod_files[*i]));
+ ddOutputs.push_back(object.Object);
+ for (std::string const& p : object.Provides) {
+ ddImplicitOuts.push_back(this->ConvertToNinjaPath(mod_files[p]));
}
- for (std::vector<std::string>::iterator i = oi->Requires.begin();
- i != oi->Requires.end(); ++i) {
- std::map<std::string, std::string>::iterator m = mod_files.find(*i);
+ for (std::string const& r : object.Requires) {
+ std::map<std::string, std::string>::iterator m = mod_files.find(r);
if (m != mod_files.end()) {
ddImplicitDeps.push_back(this->ConvertToNinjaPath(m->second));
}
}
- if (!oi->Provides.empty()) {
+ if (!object.Provides.empty()) {
ddVars["restat"] = "1";
}
@@ -1846,9 +1792,7 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg,
std::string arg_dd;
std::string arg_tdi;
std::vector<std::string> arg_ddis;
- for (std::vector<std::string>::const_iterator a = arg_full.begin();
- a != arg_full.end(); ++a) {
- std::string const& arg = *a;
+ for (std::string const& arg : arg_full) {
if (cmHasLiteralPrefix(arg, "--tdi=")) {
arg_tdi = arg.substr(6);
} else if (cmHasLiteralPrefix(arg, "--dd=")) {
@@ -1895,9 +1839,8 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg,
std::vector<std::string> linked_target_dirs;
Json::Value const& tdi_linked_target_dirs = tdi["linked-target-dirs"];
if (tdi_linked_target_dirs.isArray()) {
- for (Json::Value::const_iterator i = tdi_linked_target_dirs.begin();
- i != tdi_linked_target_dirs.end(); ++i) {
- linked_target_dirs.push_back(i->asString());
+ for (auto const& tdi_linked_target_dir : tdi_linked_target_dirs) {
+ linked_target_dirs.push_back(tdi_linked_target_dir.asString());
}
}
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 05c9ce0..15ddeff 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -50,12 +50,11 @@ void cmGlobalUnixMakefileGenerator3::EnableLanguage(
std::vector<std::string> const& languages, cmMakefile* mf, bool optional)
{
this->cmGlobalGenerator::EnableLanguage(languages, mf, optional);
- for (std::vector<std::string>::const_iterator l = languages.begin();
- l != languages.end(); ++l) {
- if (*l == "NONE") {
+ for (std::string const& language : languages) {
+ if (language == "NONE") {
continue;
}
- this->ResolveLanguageCompiler(*l, mf, optional);
+ this->ResolveLanguageCompiler(language, mf, optional);
}
}
@@ -130,9 +129,8 @@ void cmGlobalUnixMakefileGenerator3::Generate()
// initialize progress
unsigned long total = 0;
- for (ProgressMapType::const_iterator pmi = this->ProgressMap.begin();
- pmi != this->ProgressMap.end(); ++pmi) {
- total += pmi->second.NumberOfActions;
+ for (auto const& pmi : this->ProgressMap) {
+ total += pmi.second.NumberOfActions;
}
// write each target's progress.make this loop is done twice. Bascially the
@@ -143,12 +141,10 @@ void cmGlobalUnixMakefileGenerator3::Generate()
// well. This is because the all targets require more information that is
// computed in the first loop.
unsigned long current = 0;
- for (ProgressMapType::iterator pmi = this->ProgressMap.begin();
- pmi != this->ProgressMap.end(); ++pmi) {
- pmi->second.WriteProgressVariables(total, current);
+ for (auto& pmi : this->ProgressMap) {
+ pmi.second.WriteProgressVariables(total, current);
}
- for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
- cmLocalGenerator* lg = this->LocalGenerators[i];
+ for (cmLocalGenerator* lg : this->LocalGenerators) {
std::string markFileName = lg->GetCurrentBinaryDirectory();
markFileName += "/";
markFileName += cmake::GetCMakeFilesDirectory();
@@ -250,9 +246,8 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2()
lg->WriteSpecialTargetsTop(makefileStream);
// write the target convenience rules
- unsigned int i;
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ lg = static_cast<cmLocalUnixMakefileGenerator3*>(localGen);
this->WriteConvenienceRules2(makefileStream, lg);
}
@@ -292,8 +287,8 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
// for each cmMakefile get its list of dependencies
std::vector<std::string> lfiles;
- for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
- lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ lg = static_cast<cmLocalUnixMakefileGenerator3*>(localGen);
// Get the list of files contributing to this generation step.
lfiles.insert(lfiles.end(), lg->GetMakefile()->GetListFiles().begin(),
@@ -316,9 +311,8 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
<< "# The top level Makefile was generated from the following files:\n"
<< "set(CMAKE_MAKEFILE_DEPENDS\n"
<< " \"CMakeCache.txt\"\n";
- for (std::vector<std::string>::const_iterator i = lfiles.begin();
- i != lfiles.end(); ++i) {
- cmakefileStream << " \"" << lg->ConvertToRelativePath(currentBinDir, *i)
+ for (std::string const& f : lfiles) {
+ cmakefileStream << " \"" << lg->ConvertToRelativePath(currentBinDir, f)
<< "\"\n";
}
cmakefileStream << " )\n\n";
@@ -346,17 +340,15 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
<< "set(CMAKE_MAKEFILE_PRODUCTS\n";
const std::vector<std::string>& outfiles =
lg->GetMakefile()->GetOutputFiles();
- for (std::vector<std::string>::const_iterator k = outfiles.begin();
- k != outfiles.end(); ++k) {
- cmakefileStream << " \"" << lg->ConvertToRelativePath(binDir, *k)
+ for (std::string const& outfile : outfiles) {
+ cmakefileStream << " \"" << lg->ConvertToRelativePath(binDir, outfile)
<< "\"\n";
}
// add in all the directory information files
std::string tmpStr;
- for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
- lg =
- static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ lg = static_cast<cmLocalUnixMakefileGenerator3*>(localGen);
tmpStr = lg->GetCurrentBinaryDirectory();
tmpStr += cmake::GetCMakeFilesDirectory();
tmpStr += "/CMakeDirectoryInformation.cmake";
@@ -379,19 +371,18 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefileLanguageRules(
// now list all the target info files
cmakefileStream << "# Dependency information for all targets:\n";
cmakefileStream << "set(CMAKE_DEPEND_INFO_FILES\n";
- for (unsigned int i = 0; i < lGenerators.size(); ++i) {
- lg = static_cast<cmLocalUnixMakefileGenerator3*>(lGenerators[i]);
+ for (cmLocalGenerator* lGenerator : lGenerators) {
+ lg = static_cast<cmLocalUnixMakefileGenerator3*>(lGenerator);
// for all of out targets
const std::vector<cmGeneratorTarget*>& tgts = lg->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin();
- l != tgts.end(); l++) {
- if (((*l)->GetType() == cmStateEnums::EXECUTABLE) ||
- ((*l)->GetType() == cmStateEnums::STATIC_LIBRARY) ||
- ((*l)->GetType() == cmStateEnums::SHARED_LIBRARY) ||
- ((*l)->GetType() == cmStateEnums::MODULE_LIBRARY) ||
- ((*l)->GetType() == cmStateEnums::OBJECT_LIBRARY) ||
- ((*l)->GetType() == cmStateEnums::UTILITY)) {
- cmGeneratorTarget* gt = *l;
+ for (cmGeneratorTarget* tgt : tgts) {
+ if ((tgt->GetType() == cmStateEnums::EXECUTABLE) ||
+ (tgt->GetType() == cmStateEnums::STATIC_LIBRARY) ||
+ (tgt->GetType() == cmStateEnums::SHARED_LIBRARY) ||
+ (tgt->GetType() == cmStateEnums::MODULE_LIBRARY) ||
+ (tgt->GetType() == cmStateEnums::OBJECT_LIBRARY) ||
+ (tgt->GetType() == cmStateEnums::UTILITY)) {
+ cmGeneratorTarget* gt = tgt;
std::string tname = lg->GetRelativeTargetDirectory(gt);
tname += "/DependInfo.cmake";
cmSystemTools::ConvertToUnixSlashes(tname);
@@ -415,9 +406,7 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRule2(
// for all targets in the directory.
std::vector<std::string> depends;
const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator l = targets.begin();
- l != targets.end(); ++l) {
- cmGeneratorTarget* gtarget = *l;
+ for (cmGeneratorTarget* gtarget : targets) {
int type = gtarget->GetType();
if ((type == cmStateEnums::EXECUTABLE) ||
(type == cmStateEnums::STATIC_LIBRARY) ||
@@ -440,9 +429,8 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRule2(
// The directory-level rule should depend on the directory-level
// rules of the subdirectories.
std::vector<cmStateSnapshot> children = lg->GetStateSnapshot().GetChildren();
- for (std::vector<cmStateSnapshot>::const_iterator ci = children.begin();
- ci != children.end(); ++ci) {
- std::string subdir = ci->GetDirectory().GetCurrentBinary();
+ for (cmStateSnapshot const& c : children) {
+ std::string subdir = c.GetDirectory().GetCurrentBinary();
subdir += "/";
subdir += pass;
depends.push_back(subdir);
@@ -542,15 +530,12 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules(
depends.push_back("cmake_check_build_system");
// write the target convenience rules
- unsigned int i;
- cmLocalUnixMakefileGenerator3* lg;
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ cmLocalUnixMakefileGenerator3* lg =
+ static_cast<cmLocalUnixMakefileGenerator3*>(localGen);
// for each target Generate the rule files for each target.
const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin();
- t != targets.end(); ++t) {
- cmGeneratorTarget* gtarget = *t;
+ for (cmGeneratorTarget* gtarget : targets) {
// Don't emit the same rule twice (e.g. two targets with the same
// simple name)
int type = gtarget->GetType();
@@ -630,9 +615,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
// for each target Generate the rule files for each target.
const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin();
- t != targets.end(); ++t) {
- cmGeneratorTarget* gtarget = *t;
+ for (cmGeneratorTarget* gtarget : targets) {
int type = gtarget->GetType();
std::string name = gtarget->GetName();
if (!name.empty() && ((type == cmStateEnums::EXECUTABLE) ||
@@ -680,11 +663,10 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
{
std::ostringstream progressArg;
const char* sep = "";
- std::vector<unsigned long>& progFiles =
+ std::vector<unsigned long> const& progFiles =
this->ProgressMap[gtarget].Marks;
- for (std::vector<unsigned long>::iterator i = progFiles.begin();
- i != progFiles.end(); ++i) {
- progressArg << sep << *i;
+ for (unsigned long progFile : progFiles) {
+ progressArg << sep << progFile;
sep = ",";
}
progress.Arg = progressArg.str();
@@ -803,15 +785,9 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks()
{
this->DirectoryTargetsMap.clear();
// Loop over all targets in all local generators.
- for (std::vector<cmLocalGenerator*>::const_iterator lgi =
- this->LocalGenerators.begin();
- lgi != this->LocalGenerators.end(); ++lgi) {
- cmLocalGenerator* lg = *lgi;
+ for (cmLocalGenerator* lg : this->LocalGenerators) {
const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin();
- t != targets.end(); ++t) {
- cmGeneratorTarget* gt = *t;
-
+ for (cmGeneratorTarget* gt : targets) {
cmLocalGenerator* tlg = gt->GetLocalGenerator();
if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
@@ -835,9 +811,8 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks()
// target may still be included if it is a dependency of a
// non-excluded target.
TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(gt);
- for (TargetDependSet::const_iterator ti = tgtdeps.begin();
- ti != tgtdeps.end(); ++ti) {
- targetSet.insert(*ti);
+ for (cmTargetDepend const& tgtdep : tgtdeps) {
+ targetSet.insert(tgtdep);
}
}
}
@@ -851,12 +826,11 @@ size_t cmGlobalUnixMakefileGenerator3::CountProgressMarksInTarget(
if (emitted.insert(target).second) {
count = this->ProgressMap[target].Marks.size();
TargetDependSet const& depends = this->GetTargetDirectDepends(target);
- for (TargetDependSet::const_iterator di = depends.begin();
- di != depends.end(); ++di) {
- if ((*di)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (cmTargetDepend const& depend : depends) {
+ if (depend->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- count += this->CountProgressMarksInTarget(*di, emitted);
+ count += this->CountProgressMarksInTarget(depend, emitted);
}
}
return count;
@@ -869,9 +843,8 @@ size_t cmGlobalUnixMakefileGenerator3::CountProgressMarksInAll(
std::set<cmGeneratorTarget const*> emitted;
std::set<cmGeneratorTarget const*> const& targets =
this->DirectoryTargetsMap[lg->GetStateSnapshot()];
- for (std::set<cmGeneratorTarget const*>::const_iterator t = targets.begin();
- t != targets.end(); ++t) {
- count += this->CountProgressMarksInTarget(*t, emitted);
+ for (cmGeneratorTarget const* target : targets) {
+ count += this->CountProgressMarksInTarget(target, emitted);
}
return count;
}
@@ -910,10 +883,9 @@ void cmGlobalUnixMakefileGenerator3::AppendGlobalTargetDepends(
std::vector<std::string>& depends, cmGeneratorTarget* target)
{
TargetDependSet const& depends_set = this->GetTargetDirectDepends(target);
- for (TargetDependSet::const_iterator i = depends_set.begin();
- i != depends_set.end(); ++i) {
+ for (cmTargetDepend const& i : depends_set) {
// Create the target-level dependency.
- cmGeneratorTarget const* dep = *i;
+ cmGeneratorTarget const* dep = i;
if (dep->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
@@ -943,20 +915,16 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule(
std::set<std::string> emittedTargets;
// for each local generator
- unsigned int i;
- cmLocalUnixMakefileGenerator3* lg2;
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- lg2 =
- static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ cmLocalUnixMakefileGenerator3* lg2 =
+ static_cast<cmLocalUnixMakefileGenerator3*>(localGen);
// for the passed in makefile or if this is the top Makefile wripte out
// the targets
if (lg2 == lg || lg->IsRootMakefile()) {
// for each target Generate the rule files for each target.
const std::vector<cmGeneratorTarget*>& targets =
lg2->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin();
- t != targets.end(); ++t) {
- cmGeneratorTarget* target = *t;
+ for (cmGeneratorTarget* target : targets) {
cmStateEnums::TargetType type = target->GetType();
if ((type == cmStateEnums::EXECUTABLE) ||
(type == cmStateEnums::STATIC_LIBRARY) ||
@@ -975,11 +943,9 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule(
}
}
}
- std::vector<std::string> const& localHelp = lg->GetLocalHelp();
- for (std::vector<std::string>::const_iterator o = localHelp.begin();
- o != localHelp.end(); ++o) {
+ for (std::string const& o : lg->GetLocalHelp()) {
path = "... ";
- path += *o;
+ path += o;
lg->AppendEcho(commands, path);
}
lg->WriteMakeRule(ruleFileStream, "Help Target", "help", no_depends,
@@ -994,10 +960,9 @@ bool cmGlobalUnixMakefileGenerator3::NeedRequiresStep(
target->GetLanguages(
languages,
target->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
- for (std::set<std::string>::const_iterator l = languages.begin();
- l != languages.end(); ++l) {
+ for (std::string const& l : languages) {
std::string var = "CMAKE_NEEDS_REQUIRES_STEP_";
- var += *l;
+ var += l;
var += "_FLAG";
if (target->Target->GetMakefile()->GetDefinition(var)) {
return true;
diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx
index b334f41..967fd2e 100644
--- a/Source/cmGraphVizWriter.cxx
+++ b/Source/cmGraphVizWriter.cxx
@@ -122,10 +122,7 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
std::vector<std::string> ignoreTargetsRegExVector;
cmSystemTools::ExpandListArgument(ignoreTargetsRegexes,
ignoreTargetsRegExVector);
- for (std::vector<std::string>::const_iterator itvIt =
- ignoreTargetsRegExVector.begin();
- itvIt != ignoreTargetsRegExVector.end(); ++itvIt) {
- std::string currentRegexString(*itvIt);
+ for (std::string const& currentRegexString : ignoreTargetsRegExVector) {
cmsys::RegularExpression currentRegex;
if (!currentRegex.compile(currentRegexString.c_str())) {
std::cerr << "Could not compile bad regex \"" << currentRegexString
@@ -146,20 +143,18 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName)
this->CollectTargetsAndLibs();
- for (std::map<std::string, const cmGeneratorTarget*>::const_iterator ptrIt =
- this->TargetPtrs.begin();
- ptrIt != this->TargetPtrs.end(); ++ptrIt) {
- if (ptrIt->second == nullptr) {
+ for (auto const& ptr : this->TargetPtrs) {
+ if (ptr.second == nullptr) {
continue;
}
- if (!this->GenerateForTargetType(ptrIt->second->GetType())) {
+ if (!this->GenerateForTargetType(ptr.second->GetType())) {
continue;
}
std::string currentFilename = fileName;
currentFilename += ".";
- currentFilename += ptrIt->first;
+ currentFilename += ptr.first;
currentFilename += ".dependers";
cmGeneratedFileStream str(currentFilename.c_str());
@@ -173,7 +168,7 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName)
std::cout << "Writing " << currentFilename << "..." << std::endl;
this->WriteHeader(str);
- this->WriteDependerConnections(ptrIt->first, insertedNodes,
+ this->WriteDependerConnections(ptr.first, insertedNodes,
insertedConnections, str);
this->WriteFooter(str);
@@ -190,14 +185,12 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName)
this->CollectTargetsAndLibs();
- for (std::map<std::string, const cmGeneratorTarget*>::const_iterator ptrIt =
- this->TargetPtrs.begin();
- ptrIt != this->TargetPtrs.end(); ++ptrIt) {
- if (ptrIt->second == nullptr) {
+ for (auto const& ptr : this->TargetPtrs) {
+ if (ptr.second == nullptr) {
continue;
}
- if (!this->GenerateForTargetType(ptrIt->second->GetType())) {
+ if (!this->GenerateForTargetType(ptr.second->GetType())) {
continue;
}
@@ -206,7 +199,7 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName)
std::string currentFilename = fileName;
currentFilename += ".";
- currentFilename += ptrIt->first;
+ currentFilename += ptr.first;
cmGeneratedFileStream str(currentFilename.c_str());
if (!str) {
return;
@@ -215,8 +208,7 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName)
std::cout << "Writing " << currentFilename << "..." << std::endl;
this->WriteHeader(str);
- this->WriteConnections(ptrIt->first, insertedNodes, insertedConnections,
- str);
+ this->WriteConnections(ptr.first, insertedNodes, insertedConnections, str);
this->WriteFooter(str);
}
}
@@ -236,19 +228,16 @@ void cmGraphVizWriter::WriteGlobalFile(const char* fileName)
std::set<std::string> insertedConnections;
std::set<std::string> insertedNodes;
- for (std::map<std::string, const cmGeneratorTarget*>::const_iterator ptrIt =
- this->TargetPtrs.begin();
- ptrIt != this->TargetPtrs.end(); ++ptrIt) {
- if (ptrIt->second == nullptr) {
+ for (auto const& ptr : this->TargetPtrs) {
+ if (ptr.second == nullptr) {
continue;
}
- if (!this->GenerateForTargetType(ptrIt->second->GetType())) {
+ if (!this->GenerateForTargetType(ptr.second->GetType())) {
continue;
}
- this->WriteConnections(ptrIt->first, insertedNodes, insertedConnections,
- str);
+ this->WriteConnections(ptr.first, insertedNodes, insertedConnections, str);
}
this->WriteFooter(str);
}
@@ -288,9 +277,8 @@ void cmGraphVizWriter::WriteConnections(
const cmTarget::LinkLibraryVectorType* ll =
&(targetPtrIt->second->Target->GetOriginalLinkLibraries());
- for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin();
- llit != ll->end(); ++llit) {
- const char* libName = llit->first.c_str();
+ for (auto const& llit : *ll) {
+ const char* libName = llit.first.c_str();
std::map<std::string, std::string>::const_iterator libNameIt =
this->TargetNamesNodes.find(libName);
@@ -337,29 +325,26 @@ void cmGraphVizWriter::WriteDependerConnections(
std::string myNodeName = this->TargetNamesNodes.find(targetName)->second;
// now search who links against me
- for (std::map<std::string, const cmGeneratorTarget*>::const_iterator
- dependerIt = this->TargetPtrs.begin();
- dependerIt != this->TargetPtrs.end(); ++dependerIt) {
- if (dependerIt->second == nullptr) {
+ for (auto const& tptr : this->TargetPtrs) {
+ if (tptr.second == nullptr) {
continue;
}
- if (!this->GenerateForTargetType(dependerIt->second->GetType())) {
+ if (!this->GenerateForTargetType(tptr.second->GetType())) {
continue;
}
// Now we have a target, check whether it links against targetName.
// If so, draw a connection, and then continue with dependers on that one.
const cmTarget::LinkLibraryVectorType* ll =
- &(dependerIt->second->Target->GetOriginalLinkLibraries());
+ &(tptr.second->Target->GetOriginalLinkLibraries());
- for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin();
- llit != ll->end(); ++llit) {
- std::string libName = llit->first;
+ for (auto const& llit : *ll) {
+ std::string libName = llit.first;
if (libName == targetName) {
// So this target links against targetName.
std::map<std::string, std::string>::const_iterator dependerNodeNameIt =
- this->TargetNamesNodes.find(dependerIt->first);
+ this->TargetNamesNodes.find(tptr.first);
if (dependerNodeNameIt != this->TargetNamesNodes.end()) {
std::string connectionName = dependerNodeNameIt->second;
@@ -369,14 +354,12 @@ void cmGraphVizWriter::WriteDependerConnections(
if (insertedConnections.find(connectionName) ==
insertedConnections.end()) {
insertedConnections.insert(connectionName);
- this->WriteNode(dependerIt->first, dependerIt->second,
- insertedNodes, str);
+ this->WriteNode(tptr.first, tptr.second, insertedNodes, str);
str << " \"" << dependerNodeNameIt->second << "\" -> \""
<< myNodeName << "\"";
- str << " // " << targetName << " -> " << dependerIt->first
- << std::endl;
- this->WriteDependerConnections(dependerIt->first, insertedNodes,
+ str << " // " << targetName << " -> " << tptr.first << std::endl;
+ this->WriteDependerConnections(tptr.first, insertedNodes,
insertedConnections, str);
}
}
@@ -416,14 +399,10 @@ int cmGraphVizWriter::CollectAllTargets()
{
int cnt = 0;
// First pass get the list of all cmake targets
- for (std::vector<cmLocalGenerator*>::const_iterator lit =
- this->LocalGenerators.begin();
- lit != this->LocalGenerators.end(); ++lit) {
- const std::vector<cmGeneratorTarget*>& targets =
- (*lit)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator it = targets.begin();
- it != targets.end(); ++it) {
- const char* realTargetName = (*it)->GetName().c_str();
+ for (cmLocalGenerator* lg : this->LocalGenerators) {
+ const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
+ for (cmGeneratorTarget* target : targets) {
+ const char* realTargetName = target->GetName().c_str();
if (this->IgnoreThisTarget(realTargetName)) {
// Skip ignored targets
continue;
@@ -432,7 +411,7 @@ int cmGraphVizWriter::CollectAllTargets()
std::ostringstream ostr;
ostr << this->GraphNodePrefix << cnt++;
this->TargetNamesNodes[realTargetName] = ostr.str();
- this->TargetPtrs[realTargetName] = *it;
+ this->TargetPtrs[realTargetName] = target;
}
}
@@ -442,23 +421,18 @@ int cmGraphVizWriter::CollectAllTargets()
int cmGraphVizWriter::CollectAllExternalLibs(int cnt)
{
// Ok, now find all the stuff we link to that is not in cmake
- for (std::vector<cmLocalGenerator*>::const_iterator lit =
- this->LocalGenerators.begin();
- lit != this->LocalGenerators.end(); ++lit) {
- const std::vector<cmGeneratorTarget*>& targets =
- (*lit)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator it = targets.begin();
- it != targets.end(); ++it) {
- const char* realTargetName = (*it)->GetName().c_str();
+ for (cmLocalGenerator* lg : this->LocalGenerators) {
+ const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
+ for (cmGeneratorTarget* target : targets) {
+ const char* realTargetName = target->GetName().c_str();
if (this->IgnoreThisTarget(realTargetName)) {
// Skip ignored targets
continue;
}
const cmTarget::LinkLibraryVectorType* ll =
- &((*it)->Target->GetOriginalLinkLibraries());
- for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin();
- llit != ll->end(); ++llit) {
- const char* libName = llit->first.c_str();
+ &(target->Target->GetOriginalLinkLibraries());
+ for (auto const& llit : *ll) {
+ const char* libName = llit.first.c_str();
if (this->IgnoreThisTarget(libName)) {
// Skip ignored targets
continue;
@@ -482,10 +456,7 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt)
bool cmGraphVizWriter::IgnoreThisTarget(const std::string& name)
{
- for (std::vector<cmsys::RegularExpression>::iterator itvIt =
- this->TargetsToIgnoreRegex.begin();
- itvIt != this->TargetsToIgnoreRegex.end(); ++itvIt) {
- cmsys::RegularExpression& regEx = *itvIt;
+ for (cmsys::RegularExpression& regEx : this->TargetsToIgnoreRegex) {
if (regEx.is_valid()) {
if (regEx.find(name)) {
return true;
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index 0972664..1a01854 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -15,10 +15,9 @@ static std::string cmIfCommandError(
std::vector<cmExpandedCommandArgument> const& args)
{
std::string err = "given arguments:\n ";
- for (std::vector<cmExpandedCommandArgument>::const_iterator i = args.begin();
- i != args.end(); ++i) {
+ for (cmExpandedCommandArgument const& i : args) {
err += " ";
- err += cmOutputConverter::EscapeForCMake(i->GetValue());
+ err += cmOutputConverter::EscapeForCMake(i.GetValue());
}
err += "\n";
return err;
@@ -45,21 +44,20 @@ bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
// execute the functions for the true parts of the if statement
cmExecutionStatus status;
int scopeDepth = 0;
- for (unsigned int c = 0; c < this->Functions.size(); ++c) {
+ for (cmListFileFunction const& func : this->Functions) {
// keep track of scope depth
- if (!cmSystemTools::Strucmp(this->Functions[c].Name.c_str(), "if")) {
+ if (!cmSystemTools::Strucmp(func.Name.c_str(), "if")) {
scopeDepth++;
}
- if (!cmSystemTools::Strucmp(this->Functions[c].Name.c_str(),
- "endif")) {
+ if (!cmSystemTools::Strucmp(func.Name.c_str(), "endif")) {
scopeDepth--;
}
// watch for our state change
if (scopeDepth == 0 &&
- !cmSystemTools::Strucmp(this->Functions[c].Name.c_str(), "else")) {
+ !cmSystemTools::Strucmp(func.Name.c_str(), "else")) {
if (this->ElseSeen) {
- cmListFileBacktrace bt = mf.GetBacktrace(this->Functions[c]);
+ cmListFileBacktrace bt = mf.GetBacktrace(func);
mf.GetCMakeInstance()->IssueMessage(
cmake::FATAL_ERROR,
"A duplicate ELSE command was found inside an IF block.", bt);
@@ -74,13 +72,12 @@ bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
// if trace is enabled, print a (trivially) evaluated "else"
// statement
if (!this->IsBlocking && mf.GetCMakeInstance()->GetTrace()) {
- mf.PrintCommandTrace(this->Functions[c]);
+ mf.PrintCommandTrace(func);
}
} else if (scopeDepth == 0 &&
- !cmSystemTools::Strucmp(this->Functions[c].Name.c_str(),
- "elseif")) {
+ !cmSystemTools::Strucmp(func.Name.c_str(), "elseif")) {
if (this->ElseSeen) {
- cmListFileBacktrace bt = mf.GetBacktrace(this->Functions[c]);
+ cmListFileBacktrace bt = mf.GetBacktrace(func);
mf.GetCMakeInstance()->IssueMessage(
cmake::FATAL_ERROR,
"An ELSEIF command was found after an ELSE command.", bt);
@@ -93,23 +90,22 @@ bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
} else {
// if trace is enabled, print the evaluated "elseif" statement
if (mf.GetCMakeInstance()->GetTrace()) {
- mf.PrintCommandTrace(this->Functions[c]);
+ mf.PrintCommandTrace(func);
}
std::string errorString;
std::vector<cmExpandedCommandArgument> expandedArguments;
- mf.ExpandArguments(this->Functions[c].Arguments,
- expandedArguments);
+ mf.ExpandArguments(func.Arguments, expandedArguments);
cmake::MessageType messType;
cmListFileContext conditionContext =
cmListFileContext::FromCommandContext(
- this->Functions[c], this->GetStartingContext().FilePath);
+ func, this->GetStartingContext().FilePath);
- cmConditionEvaluator conditionEvaluator(
- mf, conditionContext, mf.GetBacktrace(this->Functions[c]));
+ cmConditionEvaluator conditionEvaluator(mf, conditionContext,
+ mf.GetBacktrace(func));
bool isTrue = conditionEvaluator.IsTrue(expandedArguments,
errorString, messType);
@@ -117,7 +113,7 @@ bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
if (!errorString.empty()) {
std::string err = cmIfCommandError(expandedArguments);
err += errorString;
- cmListFileBacktrace bt = mf.GetBacktrace(this->Functions[c]);
+ cmListFileBacktrace bt = mf.GetBacktrace(func);
mf.GetCMakeInstance()->IssueMessage(messType, err, bt);
if (messType == cmake::FATAL_ERROR) {
cmSystemTools::SetFatalErrorOccured();
@@ -135,7 +131,7 @@ bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
// should we execute?
else if (!this->IsBlocking) {
status.Clear();
- mf.ExecuteCommand(this->Functions[c], status);
+ mf.ExecuteCommand(func, status);
if (status.GetReturnInvoked()) {
inStatus.SetReturnInvoked();
return true;
diff --git a/Source/cmIncludeExternalMSProjectCommand.cxx b/Source/cmIncludeExternalMSProjectCommand.cxx
index 03388c7..bd16b1d 100644
--- a/Source/cmIncludeExternalMSProjectCommand.cxx
+++ b/Source/cmIncludeExternalMSProjectCommand.cxx
@@ -91,9 +91,8 @@ bool cmIncludeExternalMSProjectCommand::InitialPass(
if (!platformMapping.empty())
target->SetProperty("VS_PLATFORM_MAPPING", platformMapping.c_str());
- for (std::vector<std::string>::const_iterator it = depends.begin();
- it != depends.end(); ++it) {
- target->AddUtility(it->c_str());
+ for (std::string const& d : depends) {
+ target->AddUtility(d.c_str());
}
}
#endif
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 7402105..685fc67 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -141,23 +141,23 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args)
// Scan the args again, this time adding install generators each time we
// encounter a SCRIPT or CODE arg:
//
- for (size_t i = 0; i < args.size(); ++i) {
- if (args[i] == "SCRIPT") {
+ for (std::string const& arg : args) {
+ if (arg == "SCRIPT") {
doing_script = true;
doing_code = false;
- } else if (args[i] == "CODE") {
+ } else if (arg == "CODE") {
doing_script = false;
doing_code = true;
- } else if (args[i] == "COMPONENT") {
+ } else if (arg == "COMPONENT") {
doing_script = false;
doing_code = false;
} else if (doing_script) {
doing_script = false;
- std::string script = args[i];
+ std::string script = arg;
if (!cmSystemTools::FileIsFullPath(script.c_str())) {
script = this->Makefile->GetCurrentSourceDirectory();
script += "/";
- script += args[i];
+ script += arg;
}
if (cmSystemTools::FileIsDirectory(script)) {
this->SetError("given a directory as value of SCRIPT argument.");
@@ -167,7 +167,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args)
script.c_str(), false, component.c_str(), exclude_from_all));
} else if (doing_code) {
doing_code = false;
- std::string const& code = args[i];
+ std::string const& code = arg;
this->Makefile->AddInstallGenerator(new cmInstallScriptGenerator(
code.c_str(), true, component.c_str(), exclude_from_all));
}
@@ -336,19 +336,16 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
(this->Makefile->IsOn("WIN32") || this->Makefile->IsOn("CYGWIN") ||
this->Makefile->IsOn("MINGW"));
- for (std::vector<std::string>::const_iterator targetIt =
- targetList.GetVector().begin();
- targetIt != targetList.GetVector().end(); ++targetIt) {
+ for (std::string const& tgt : targetList.GetVector()) {
- if (this->Makefile->IsAlias(*targetIt)) {
+ if (this->Makefile->IsAlias(tgt)) {
std::ostringstream e;
- e << "TARGETS given target \"" << (*targetIt) << "\" which is an alias.";
+ e << "TARGETS given target \"" << tgt << "\" which is an alias.";
this->SetError(e.str());
return false;
}
// Lookup this target in the current directory.
- if (cmTarget* target =
- this->Makefile->FindLocalNonAliasTarget(*targetIt)) {
+ if (cmTarget* target = this->Makefile->FindLocalNonAliasTarget(tgt)) {
// Found the target. Check its type.
if (target->GetType() != cmStateEnums::EXECUTABLE &&
target->GetType() != cmStateEnums::STATIC_LIBRARY &&
@@ -357,7 +354,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
target->GetType() != cmStateEnums::OBJECT_LIBRARY &&
target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
std::ostringstream e;
- e << "TARGETS given target \"" << (*targetIt)
+ e << "TARGETS given target \"" << tgt
<< "\" which is not an executable, library, or module.";
this->SetError(e.str());
return false;
@@ -367,7 +364,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
if (!this->Makefile->GetGlobalGenerator()->HasKnownObjectFileLocation(
&reason)) {
std::ostringstream e;
- e << "TARGETS given OBJECT library \"" << (*targetIt)
+ e << "TARGETS given OBJECT library \"" << tgt
<< "\" which may not be installed" << reason << ".";
this->SetError(e.str());
return false;
@@ -378,7 +375,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
} else {
// Did not find the target.
std::ostringstream e;
- e << "TARGETS given target \"" << (*targetIt)
+ e << "TARGETS given target \"" << tgt
<< "\" which does not exist in this directory.";
this->SetError(e.str());
return false;
@@ -398,10 +395,9 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
bool installsResource = false;
// Generate install script code to install the given targets.
- for (std::vector<cmTarget*>::iterator ti = targets.begin();
- ti != targets.end(); ++ti) {
+ for (cmTarget* ti : targets) {
// Handle each target type.
- cmTarget& target = *(*ti);
+ cmTarget& target = *ti;
cmInstallTargetGenerator* archiveGenerator = nullptr;
cmInstallTargetGenerator* libraryGenerator = nullptr;
cmInstallTargetGenerator* runtimeGenerator = nullptr;
@@ -815,9 +811,8 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
this->Makefile->GetPolicyStatus(cmPolicies::CMP0062);
cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
- for (std::vector<std::string>::const_iterator fileIt = filesVector.begin();
- fileIt != filesVector.end(); ++fileIt) {
- if (gg->IsExportedTargetsFile(*fileIt)) {
+ for (std::string const& file : filesVector) {
+ if (gg->IsExportedTargetsFile(file)) {
const char* modal = nullptr;
std::ostringstream e;
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
@@ -835,8 +830,8 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
messageType = cmake::FATAL_ERROR;
}
if (modal) {
- e << "The file\n " << *fileIt << "\nwas generated by the export() "
- "command. It "
+ e << "The file\n " << file << "\nwas generated by the export() "
+ "command. It "
<< modal << " not be installed with the "
"install() command. Use the install(EXPORT) mechanism "
"instead. See the cmake-packages(7) manual for more.\n";
@@ -1339,10 +1334,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
cmExportSet* exportSet =
this->Makefile->GetGlobalGenerator()->GetExportSets()[exp.GetString()];
if (exportOld.IsEnabled()) {
- for (std::vector<cmTargetExport*>::const_iterator tei =
- exportSet->GetTargetExports()->begin();
- tei != exportSet->GetTargetExports()->end(); ++tei) {
- cmTargetExport const* te = *tei;
+ for (cmTargetExport* te : *exportSet->GetTargetExports()) {
cmTarget* tgt =
this->Makefile->GetGlobalGenerator()->FindTarget(te->TargetName);
const bool newCMP0022Behavior =
@@ -1379,20 +1371,19 @@ bool cmInstallCommand::MakeFilesFullPath(
const char* modeName, const std::vector<std::string>& relFiles,
std::vector<std::string>& absFiles)
{
- for (std::vector<std::string>::const_iterator fileIt = relFiles.begin();
- fileIt != relFiles.end(); ++fileIt) {
- std::string file = (*fileIt);
+ for (std::string const& relFile : relFiles) {
+ std::string file = relFile;
std::string::size_type gpos = cmGeneratorExpression::Find(file);
if (gpos != 0 && !cmSystemTools::FileIsFullPath(file.c_str())) {
file = this->Makefile->GetCurrentSourceDirectory();
file += "/";
- file += *fileIt;
+ file += relFile;
}
// Make sure the file is not a directory.
if (gpos == std::string::npos && cmSystemTools::FileIsDirectory(file)) {
std::ostringstream e;
- e << modeName << " given directory \"" << (*fileIt) << "\" to install.";
+ e << modeName << " given directory \"" << relFile << "\" to install.";
this->SetError(e.str());
return false;
}
diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx
index 072d2a5..179521e 100644
--- a/Source/cmInstallCommandArguments.cxx
+++ b/Source/cmInstallCommandArguments.cxx
@@ -154,10 +154,8 @@ void cmInstallCommandArguments::Parse(const std::vector<std::string>* args,
bool cmInstallCommandArguments::CheckPermissions()
{
this->PermissionsString = "";
- for (std::vector<std::string>::const_iterator permIt =
- this->Permissions.GetVector().begin();
- permIt != this->Permissions.GetVector().end(); ++permIt) {
- if (!this->CheckPermissions(*permIt, this->PermissionsString)) {
+ for (std::string const& perm : this->Permissions.GetVector()) {
+ if (!this->CheckPermissions(perm, this->PermissionsString)) {
return false;
}
}
diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx
index 1ca9893..49e57b1 100644
--- a/Source/cmInstallDirectoryGenerator.cxx
+++ b/Source/cmInstallDirectoryGenerator.cxx
@@ -62,19 +62,17 @@ void cmInstallDirectoryGenerator::GenerateScriptForConfig(
{
std::vector<std::string> dirs;
cmGeneratorExpression ge;
- for (std::vector<std::string>::const_iterator i = this->Directories.begin();
- i != this->Directories.end(); ++i) {
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(*i);
+ for (std::string const& d : this->Directories) {
+ CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(d);
cmSystemTools::ExpandListArgument(
cge->Evaluate(this->LocalGenerator, config), dirs);
}
// Make sure all dirs have absolute paths.
cmMakefile const& mf = *this->LocalGenerator->GetMakefile();
- for (std::vector<std::string>::iterator i = dirs.begin(); i != dirs.end();
- ++i) {
- if (!cmSystemTools::FileIsFullPath(i->c_str())) {
- *i = std::string(mf.GetCurrentSourceDirectory()) + "/" + *i;
+ for (std::string& d : dirs) {
+ if (!cmSystemTools::FileIsFullPath(d.c_str())) {
+ d = std::string(mf.GetCurrentSourceDirectory()) + "/" + d;
}
}
diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx
index ec1b210..fdd231c 100644
--- a/Source/cmInstallExportGenerator.cxx
+++ b/Source/cmInstallExportGenerator.cxx
@@ -3,7 +3,6 @@
#include "cmInstallExportGenerator.h"
#include <algorithm>
-#include <map>
#include <sstream>
#include <utility>
@@ -111,11 +110,9 @@ size_t cmInstallExportGenerator::GetMaxConfigLength() const
len = this->ConfigurationName.size();
}
} else {
- for (std::vector<std::string>::const_iterator ci =
- this->ConfigurationTypes->begin();
- ci != this->ConfigurationTypes->end(); ++ci) {
- if (ci->size() > len) {
- len = ci->size();
+ for (std::string const& c : *this->ConfigurationTypes) {
+ if (c.size() > len) {
+ len = c.size();
}
}
}
@@ -153,10 +150,8 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os)
this->EFGen->AddConfiguration("");
}
} else {
- for (std::vector<std::string>::const_iterator ci =
- this->ConfigurationTypes->begin();
- ci != this->ConfigurationTypes->end(); ++ci) {
- this->EFGen->AddConfiguration(*ci);
+ for (std::string const& c : *this->ConfigurationTypes) {
+ this->EFGen->AddConfiguration(c);
}
}
this->EFGen->GenerateImportFile();
@@ -174,11 +169,9 @@ void cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os,
// Now create a configuration-specific install rule for the import
// file of each configuration.
std::vector<std::string> files;
- for (std::map<std::string, std::string>::const_iterator i =
- this->EFGen->GetConfigImportFiles().begin();
- i != this->EFGen->GetConfigImportFiles().end(); ++i) {
- files.push_back(i->second);
- std::string config_test = this->CreateConfigTest(i->first);
+ for (auto const& i : this->EFGen->GetConfigImportFiles()) {
+ files.push_back(i.second);
+ std::string config_test = this->CreateConfigTest(i.first);
os << indent << "if(" << config_test << ")\n";
this->AddInstallRule(os, this->Destination, cmInstallType_FILES, files,
false, this->FilePermissions.c_str(), nullptr,
diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx
index 4fcff4f..0e79563 100644
--- a/Source/cmInstallFilesGenerator.cxx
+++ b/Source/cmInstallFilesGenerator.cxx
@@ -81,9 +81,8 @@ void cmInstallFilesGenerator::GenerateScriptForConfig(
{
std::vector<std::string> files;
cmGeneratorExpression ge;
- for (std::vector<std::string>::const_iterator i = this->Files.begin();
- i != this->Files.end(); ++i) {
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(*i);
+ for (std::string const& f : this->Files) {
+ CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(f);
cmSystemTools::ExpandListArgument(
cge->Evaluate(this->LocalGenerator, config), files);
}
diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx
index 3fbb3af..4d01978 100644
--- a/Source/cmInstallGenerator.cxx
+++ b/Source/cmInstallGenerator.cxx
@@ -113,9 +113,8 @@ void cmInstallGenerator::AddInstallRule(
if (files.size() == 1) {
os << " \"" << files[0] << "\"";
} else {
- for (std::vector<std::string>::const_iterator fi = files.begin();
- fi != files.end(); ++fi) {
- os << "\n" << indent << " \"" << *fi << "\"";
+ for (std::string const& f : files) {
+ os << "\n" << indent << " \"" << f << "\"";
}
os << "\n" << indent << " ";
if (!(literal_args && *literal_args)) {
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index 2b15aeb..b964794 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -362,9 +362,8 @@ void cmInstallTargetGenerator::GetInstallObjectNames(
std::string const& config, std::vector<std::string>& objects) const
{
this->Target->GetTargetObjectNames(config, objects);
- for (std::vector<std::string>::iterator i = objects.begin();
- i != objects.end(); ++i) {
- *i = computeInstallObjectDir(this->Target, config) + "/" + *i;
+ for (std::string& o : objects) {
+ o = computeInstallObjectDir(this->Target, config) + "/" + o;
}
}
@@ -476,9 +475,8 @@ void cmInstallTargetGenerator::AddTweak(std::ostream& os, Indent indent,
if (!tws.empty()) {
Indent indent2 = indent.Next().Next();
os << indent << "foreach(file\n";
- for (std::vector<std::string>::const_iterator i = files.begin();
- i != files.end(); ++i) {
- os << indent2 << "\"" << this->GetDestDirPath(*i) << "\"\n";
+ for (std::string const& f : files) {
+ os << indent2 << "\"" << this->GetDestDirPath(f) << "\"\n";
}
os << indent2 << ")\n";
os << tws;
@@ -546,11 +544,7 @@ void cmInstallTargetGenerator::AddInstallNamePatchRule(
this->Target->GetLinkInformation(config)) {
std::set<cmGeneratorTarget const*> const& sharedLibs =
cli->GetSharedLibrariesLinked();
- for (std::set<cmGeneratorTarget const*>::const_iterator j =
- sharedLibs.begin();
- j != sharedLibs.end(); ++j) {
- cmGeneratorTarget const* tgt = *j;
-
+ for (cmGeneratorTarget const* tgt : sharedLibs) {
// The install_name of an imported target does not change.
if (tgt->IsImported()) {
continue;
@@ -609,12 +603,9 @@ void cmInstallTargetGenerator::AddInstallNamePatchRule(
if (!new_id.empty()) {
os << "\n" << indent << " -id \"" << new_id << "\"";
}
- for (std::map<std::string, std::string>::const_iterator i =
- install_name_remap.begin();
- i != install_name_remap.end(); ++i) {
+ for (auto const& i : install_name_remap) {
os << "\n"
- << indent << " -change \"" << i->first << "\" \"" << i->second
- << "\"";
+ << indent << " -change \"" << i.first << "\" \"" << i.second << "\"";
}
os << "\n" << indent << " \"" << toDestDirPath << "\")\n";
}
@@ -702,10 +693,9 @@ void cmInstallTargetGenerator::AddChrpathPatchRule(
// Note: These paths are kept unique to avoid
// install_name_tool corruption.
std::set<std::string> runpaths;
- for (std::vector<std::string>::const_iterator i = oldRuntimeDirs.begin();
- i != oldRuntimeDirs.end(); ++i) {
+ for (std::string const& i : oldRuntimeDirs) {
std::string runpath =
- mf->GetGlobalGenerator()->ExpandCFGIntDir(*i, config);
+ mf->GetGlobalGenerator()->ExpandCFGIntDir(i, config);
if (runpaths.find(runpath) == runpaths.end()) {
runpaths.insert(runpath);
@@ -717,10 +707,9 @@ void cmInstallTargetGenerator::AddChrpathPatchRule(
}
runpaths.clear();
- for (std::vector<std::string>::const_iterator i = newRuntimeDirs.begin();
- i != newRuntimeDirs.end(); ++i) {
+ for (std::string const& i : newRuntimeDirs) {
std::string runpath =
- mf->GetGlobalGenerator()->ExpandCFGIntDir(*i, config);
+ mf->GetGlobalGenerator()->ExpandCFGIntDir(i, config);
if (runpaths.find(runpath) == runpaths.end()) {
os << indent << "execute_process(COMMAND " << installNameTool
diff --git a/Source/cmInstalledFile.cxx b/Source/cmInstalledFile.cxx
index 035c900..c8144aa 100644
--- a/Source/cmInstalledFile.cxx
+++ b/Source/cmInstalledFile.cxx
@@ -90,11 +90,9 @@ bool cmInstalledFile::GetProperty(const std::string& prop,
std::string output;
std::string separator;
- for (ExpressionVectorType::const_iterator j =
- property.ValueExpressions.begin();
- j != property.ValueExpressions.end(); ++j) {
+ for (auto ve : property.ValueExpressions) {
output += separator;
- output += (*j)->GetInput();
+ output += ve->GetInput();
separator = ";";
}
diff --git a/Source/cmLinkDirectoriesCommand.cxx b/Source/cmLinkDirectoriesCommand.cxx
index 9b0c288..98ab7e7 100644
--- a/Source/cmLinkDirectoriesCommand.cxx
+++ b/Source/cmLinkDirectoriesCommand.cxx
@@ -19,9 +19,8 @@ bool cmLinkDirectoriesCommand::InitialPass(
return true;
}
- for (std::vector<std::string>::const_iterator i = args.begin();
- i != args.end(); ++i) {
- this->AddLinkDir(*i);
+ for (std::string const& i : args) {
+ this->AddLinkDir(i);
}
return true;
}
diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx
index c0f702e..7511fd2 100644
--- a/Source/cmLinkLineComputer.cxx
+++ b/Source/cmLinkLineComputer.cxx
@@ -59,17 +59,16 @@ std::string cmLinkLineComputer::ComputeLinkLibs(cmComputeLinkInformation& cli)
std::string linkLibs;
typedef cmComputeLinkInformation::ItemVector ItemVector;
ItemVector const& items = cli.GetItems();
- for (ItemVector::const_iterator li = items.begin(); li != items.end();
- ++li) {
- if (li->Target &&
- li->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (auto const& item : items) {
+ if (item.Target &&
+ item.Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- if (li->IsPath) {
+ if (item.IsPath) {
linkLibs +=
- this->ConvertToOutputFormat(this->ConvertToLinkReference(li->Value));
+ this->ConvertToOutputFormat(this->ConvertToLinkReference(item.Value));
} else {
- linkLibs += li->Value;
+ linkLibs += item.Value;
}
linkLibs += " ";
}
@@ -103,9 +102,8 @@ std::string cmLinkLineComputer::ComputeLinkPath(
{
std::string linkPath;
std::vector<std::string> const& libDirs = cli.GetDirectories();
- for (std::vector<std::string>::const_iterator libDir = libDirs.begin();
- libDir != libDirs.end(); ++libDir) {
- std::string libpath = this->ConvertToOutputForExisting(*libDir);
+ for (std::string const& libDir : libDirs) {
+ std::string libpath = this->ConvertToOutputForExisting(libDir);
linkPath += " " + libPathFlag;
linkPath += libpath;
linkPath += libPathTerminator;
@@ -123,10 +121,9 @@ std::string cmLinkLineComputer::ComputeRPath(cmComputeLinkInformation& cli)
std::vector<std::string> runtimeDirs;
cli.GetRPath(runtimeDirs, this->Relink);
- for (std::vector<std::string>::iterator ri = runtimeDirs.begin();
- ri != runtimeDirs.end(); ++ri) {
+ for (std::string const& rd : runtimeDirs) {
rpath += cli.GetRuntimeFlag();
- rpath += this->ConvertToOutputFormat(*ri);
+ rpath += this->ConvertToOutputFormat(rd);
rpath += " ";
}
} else {
@@ -150,10 +147,9 @@ std::string cmLinkLineComputer::ComputeFrameworkPath(
std::string frameworkPath;
if (!fwSearchFlag.empty()) {
std::vector<std::string> const& fwDirs = cli.GetFrameworkPaths();
- for (std::vector<std::string>::const_iterator fdi = fwDirs.begin();
- fdi != fwDirs.end(); ++fdi) {
+ for (std::string const& fd : fwDirs) {
frameworkPath += fwSearchFlag;
- frameworkPath += this->ConvertToOutputFormat(*fdi);
+ frameworkPath += this->ConvertToOutputFormat(fd);
frameworkPath += " ";
}
}
diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx
index 942e9b9..3beeae3 100644
--- a/Source/cmLinkLineDeviceComputer.cxx
+++ b/Source/cmLinkLineDeviceComputer.cxx
@@ -5,7 +5,6 @@
#include <set>
#include <sstream>
-#include <vector>
#include "cmComputeLinkInformation.h"
#include "cmGeneratorTarget.h"
@@ -32,14 +31,13 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries(
typedef cmComputeLinkInformation::ItemVector ItemVector;
ItemVector const& items = cli.GetItems();
std::string config = cli.GetConfig();
- for (ItemVector::const_iterator li = items.begin(); li != items.end();
- ++li) {
- if (!li->Target) {
+ for (auto const& item : items) {
+ if (!item.Target) {
continue;
}
bool skippable = false;
- switch (li->Target->GetType()) {
+ switch (item.Target->GetType()) {
case cmStateEnums::SHARED_LIBRARY:
case cmStateEnums::MODULE_LIBRARY:
case cmStateEnums::INTERFACE_LIBRARY:
@@ -49,7 +47,7 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries(
// If a static library is resolving its device linking, it should
// be removed for other device linking
skippable =
- li->Target->GetPropertyAsBool("CUDA_RESOLVE_DEVICE_SYMBOLS");
+ item.Target->GetPropertyAsBool("CUDA_RESOLVE_DEVICE_SYMBOLS");
break;
default:
break;
@@ -60,16 +58,16 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries(
}
std::set<std::string> langs;
- li->Target->GetLanguages(langs, config);
+ item.Target->GetLanguages(langs, config);
if (langs.count("CUDA") == 0) {
continue;
}
- if (li->IsPath) {
+ if (item.IsPath) {
fout << this->ConvertToOutputFormat(
- this->ConvertToLinkReference(li->Value));
+ this->ConvertToLinkReference(item.Value));
} else {
- fout << li->Value;
+ fout << item.Value;
}
fout << " ";
}
diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx
index 00a30bf..419b2e4 100644
--- a/Source/cmLoadCacheCommand.cxx
+++ b/Source/cmLoadCacheCommand.cxx
@@ -27,17 +27,16 @@ bool cmLoadCacheCommand::InitialPass(std::vector<std::string> const& args,
// If this set is empty, all cache entries are brought in
// and they can not be overridden.
bool excludeFiles = false;
- unsigned int i;
std::set<std::string> excludes;
- for (i = 0; i < args.size(); i++) {
+ for (std::string const& arg : args) {
if (excludeFiles) {
- excludes.insert(args[i]);
+ excludes.insert(arg);
}
- if (args[i] == "EXCLUDE") {
+ if (arg == "EXCLUDE") {
excludeFiles = true;
}
- if (excludeFiles && (args[i] == "INCLUDE_INTERNALS")) {
+ if (excludeFiles && (arg == "INCLUDE_INTERNALS")) {
break;
}
}
@@ -48,25 +47,25 @@ bool cmLoadCacheCommand::InitialPass(std::vector<std::string> const& args,
bool includeFiles = false;
std::set<std::string> includes;
- for (i = 0; i < args.size(); i++) {
+ for (std::string const& arg : args) {
if (includeFiles) {
- includes.insert(args[i]);
+ includes.insert(arg);
}
- if (args[i] == "INCLUDE_INTERNALS") {
+ if (arg == "INCLUDE_INTERNALS") {
includeFiles = true;
}
- if (includeFiles && (args[i] == "EXCLUDE")) {
+ if (includeFiles && (arg == "EXCLUDE")) {
break;
}
}
// Loop over each build directory listed in the arguments. Each
// directory has a cache file.
- for (i = 0; i < args.size(); i++) {
- if ((args[i] == "EXCLUDE") || (args[i] == "INCLUDE_INTERNALS")) {
+ for (std::string const& arg : args) {
+ if ((arg == "EXCLUDE") || (arg == "INCLUDE_INTERNALS")) {
break;
}
- this->Makefile->GetCMakeInstance()->LoadCache(args[i], false, excludes,
+ this->Makefile->GetCMakeInstance()->LoadCache(arg, false, excludes,
includes);
}
diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx
index 6524db4..d255173 100644
--- a/Source/cmLocalCommonGenerator.cxx
+++ b/Source/cmLocalCommonGenerator.cxx
@@ -67,10 +67,9 @@ std::string cmLocalCommonGenerator::GetTargetFortranFlags(
this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG")) {
std::vector<std::string> includes;
this->GetIncludeDirectories(includes, target, "C", config);
- for (std::vector<std::string>::const_iterator idi = includes.begin();
- idi != includes.end(); ++idi) {
+ for (std::string const& id : includes) {
std::string flg = modpath_flag;
- flg += this->ConvertToOutputFormat(*idi, cmOutputConverter::SHELL);
+ flg += this->ConvertToOutputFormat(id, cmOutputConverter::SHELL);
this->AppendFlags(flags, flg);
}
}
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 1e5cd39..e1662ac 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -102,9 +102,7 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile)
this->LinkerSysroot = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT");
}
- for (std::vector<std::string>::iterator i = enabledLanguages.begin();
- i != enabledLanguages.end(); ++i) {
- std::string const& lang = *i;
+ for (std::string const& lang : enabledLanguages) {
if (lang == "NONE") {
continue;
}
@@ -209,18 +207,16 @@ void cmLocalGenerator::TraceDependencies()
if (configs.empty()) {
configs.push_back("");
}
- for (std::vector<std::string>::const_iterator ci = configs.begin();
- ci != configs.end(); ++ci) {
- this->GlobalGenerator->CreateEvaluationSourceFiles(*ci);
+ for (std::string const& c : configs) {
+ this->GlobalGenerator->CreateEvaluationSourceFiles(c);
}
// Generate the rule files for each target.
const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin();
- t != targets.end(); ++t) {
- if ((*t)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (cmGeneratorTarget* target : targets) {
+ if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- (*t)->TraceDependencies();
+ target->TraceDependencies();
}
}
@@ -264,26 +260,24 @@ void cmLocalGenerator::GenerateTestFiles()
if (testIncludeFiles) {
std::vector<std::string> includesList;
cmSystemTools::ExpandListArgument(testIncludeFiles, includesList);
- for (std::vector<std::string>::const_iterator i = includesList.begin();
- i != includesList.end(); ++i) {
- fout << "include(\"" << *i << "\")" << std::endl;
+ for (std::string const& i : includesList) {
+ fout << "include(\"" << i << "\")" << std::endl;
}
}
// Ask each test generator to write its code.
std::vector<cmTestGenerator*> const& testers =
this->Makefile->GetTestGenerators();
- for (std::vector<cmTestGenerator*>::const_iterator gi = testers.begin();
- gi != testers.end(); ++gi) {
- (*gi)->Compute(this);
- (*gi)->Generate(fout, config, configurationTypes);
+ for (cmTestGenerator* tester : testers) {
+ tester->Compute(this);
+ tester->Generate(fout, config, configurationTypes);
}
typedef std::vector<cmStateSnapshot> vec_t;
vec_t const& children = this->Makefile->GetStateSnapshot().GetChildren();
std::string parentBinDir = this->GetCurrentBinaryDirectory();
- for (vec_t::const_iterator i = children.begin(); i != children.end(); ++i) {
+ for (cmStateSnapshot const& i : children) {
// TODO: Use add_subdirectory instead?
- std::string outP = i->GetDirectory().GetCurrentBinary();
+ std::string outP = i.GetDirectory().GetCurrentBinary();
outP = this->ConvertToRelativePath(parentBinDir, outP);
outP = cmOutputConverter::EscapeForCMake(outP);
fout << "subdirs(" << outP << ")" << std::endl;
@@ -313,10 +307,8 @@ void cmLocalGenerator::CreateEvaluationFileOutputs(std::string const& config)
{
std::vector<cmGeneratorExpressionEvaluationFile*> ef =
this->Makefile->GetEvaluationFiles();
- for (std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator li =
- ef.begin();
- li != ef.end(); ++li) {
- (*li)->CreateOutputFile(this, config);
+ for (cmGeneratorExpressionEvaluationFile* geef : ef) {
+ geef->CreateOutputFile(this, config);
}
}
@@ -325,14 +317,12 @@ void cmLocalGenerator::ProcessEvaluationFiles(
{
std::vector<cmGeneratorExpressionEvaluationFile*> ef =
this->Makefile->GetEvaluationFiles();
- for (std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator li =
- ef.begin();
- li != ef.end(); ++li) {
- (*li)->Generate(this);
+ for (cmGeneratorExpressionEvaluationFile* geef : ef) {
+ geef->Generate(this);
if (cmSystemTools::GetFatalErrorOccured()) {
return;
}
- std::vector<std::string> files = (*li)->GetFiles();
+ std::vector<std::string> files = geef->GetFiles();
std::sort(files.begin(), files.end());
std::vector<std::string> intersection;
@@ -403,10 +393,9 @@ void cmLocalGenerator::GenerateInstallRules()
const char* default_order[] = { "RELEASE", "MINSIZEREL", "RELWITHDEBINFO",
"DEBUG", nullptr };
for (const char** c = default_order; *c && default_config.empty(); ++c) {
- for (std::vector<std::string>::iterator i = configurationTypes.begin();
- i != configurationTypes.end(); ++i) {
- if (cmSystemTools::UpperCase(*i) == *c) {
- default_config = *i;
+ for (std::string const& configurationType : configurationTypes) {
+ if (cmSystemTools::UpperCase(configurationType) == *c) {
+ default_config = configurationType;
}
}
}
@@ -498,10 +487,8 @@ void cmLocalGenerator::GenerateInstallRules()
// Ask each install generator to write its code.
std::vector<cmInstallGenerator*> const& installers =
this->Makefile->GetInstallGenerators();
- for (std::vector<cmInstallGenerator*>::const_iterator gi =
- installers.begin();
- gi != installers.end(); ++gi) {
- (*gi)->Generate(fout, config, configurationTypes);
+ for (cmInstallGenerator* installer : installers) {
+ installer->Generate(fout, config, configurationTypes);
}
// Write rules from old-style specification stored in targets.
@@ -513,10 +500,9 @@ void cmLocalGenerator::GenerateInstallRules()
if (!children.empty()) {
fout << "if(NOT CMAKE_INSTALL_LOCAL_ONLY)\n";
fout << " # Include the install script for each subdirectory.\n";
- for (std::vector<cmStateSnapshot>::const_iterator ci = children.begin();
- ci != children.end(); ++ci) {
- if (!ci->GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
- std::string odir = ci->GetDirectory().GetCurrentBinary();
+ for (cmStateSnapshot const& c : children) {
+ if (!c.GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
+ std::string odir = c.GetDirectory().GetCurrentBinary();
cmSystemTools::ConvertToUnixSlashes(odir);
fout << " include(\"" << odir << "/cmake_install.cmake\")"
<< std::endl;
@@ -602,16 +588,12 @@ void cmLocalGenerator::ComputeTargetManifest()
// Add our targets to the manifest for each configuration.
const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin();
- t != targets.end(); ++t) {
- cmGeneratorTarget* target = *t;
+ for (cmGeneratorTarget* target : targets) {
if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- for (std::vector<std::string>::iterator ci = configNames.begin();
- ci != configNames.end(); ++ci) {
- const char* config = ci->c_str();
- target->ComputeTargetManifest(config);
+ for (std::string const& c : configNames) {
+ target->ComputeTargetManifest(c);
}
}
}
@@ -627,12 +609,9 @@ bool cmLocalGenerator::ComputeTargetCompileFeatures()
// Process compile features of all targets.
const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin();
- t != targets.end(); ++t) {
- cmGeneratorTarget* target = *t;
- for (std::vector<std::string>::iterator ci = configNames.begin();
- ci != configNames.end(); ++ci) {
- if (!target->ComputeCompileFeatures(*ci)) {
+ for (cmGeneratorTarget* target : targets) {
+ for (std::string const& c : configNames) {
+ if (!target->ComputeCompileFeatures(c)) {
return false;
}
}
@@ -729,16 +708,15 @@ std::string cmLocalGenerator::GetIncludeFlags(
#ifdef __APPLE__
emitted.insert("/System/Library/Frameworks");
#endif
- std::vector<std::string>::const_iterator i;
- for (i = includes.begin(); i != includes.end(); ++i) {
+ for (std::string const& i : includes) {
if (fwSearchFlag && *fwSearchFlag && this->Makefile->IsOn("APPLE") &&
- cmSystemTools::IsPathToFramework(i->c_str())) {
- std::string frameworkDir = *i;
+ cmSystemTools::IsPathToFramework(i.c_str())) {
+ std::string frameworkDir = i;
frameworkDir += "/../";
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
if (emitted.insert(frameworkDir).second) {
if (sysFwSearchFlag && target &&
- target->IsSystemIncludeDirectory(*i, config)) {
+ target->IsSystemIncludeDirectory(i, config)) {
includeFlags << sysFwSearchFlag;
} else {
includeFlags << fwSearchFlag;
@@ -751,7 +729,7 @@ std::string cmLocalGenerator::GetIncludeFlags(
if (!flagUsed || repeatFlag) {
if (sysIncludeFlag && target &&
- target->IsSystemIncludeDirectory(*i, config)) {
+ target->IsSystemIncludeDirectory(i, config)) {
includeFlags << sysIncludeFlag;
} else {
includeFlags << includeFlag;
@@ -759,7 +737,7 @@ std::string cmLocalGenerator::GetIncludeFlags(
flagUsed = true;
}
std::string includePath =
- this->ConvertToIncludeReference(*i, shellFormat, forceFullPaths);
+ this->ConvertToIncludeReference(i, shellFormat, forceFullPaths);
if (quotePaths && !includePath.empty() && includePath[0] != '\"') {
includeFlags << "\"";
}
@@ -803,12 +781,11 @@ void cmLocalGenerator::AddCompileOptions(std::string& flags,
cmSystemTools::ParseWindowsCommandLine(targetFlags, opts);
}
target->GetCompileOptions(opts, config, lang);
- for (std::vector<std::string>::const_iterator i = opts.begin();
- i != opts.end(); ++i) {
- if (r.find(i->c_str())) {
+ for (std::string const& opt : opts) {
+ if (r.find(opt.c_str())) {
// (Re-)Escape this flag. COMPILE_FLAGS were already parsed
// as a command line above, and COMPILE_OPTIONS are escaped.
- this->AppendFlagEscape(flags, *i);
+ this->AppendFlagEscape(flags, opt);
}
}
} else {
@@ -819,30 +796,27 @@ void cmLocalGenerator::AddCompileOptions(std::string& flags,
}
std::vector<std::string> opts;
target->GetCompileOptions(opts, config, lang);
- for (std::vector<std::string>::const_iterator i = opts.begin();
- i != opts.end(); ++i) {
+ for (std::string const& opt : opts) {
// COMPILE_OPTIONS are escaped.
- this->AppendFlagEscape(flags, *i);
+ this->AppendFlagEscape(flags, opt);
}
}
- for (std::map<std::string, std::string>::const_iterator it =
- target->GetMaxLanguageStandards().begin();
- it != target->GetMaxLanguageStandards().end(); ++it) {
- const char* standard = target->GetProperty(it->first + "_STANDARD");
+ for (auto const& it : target->GetMaxLanguageStandards()) {
+ const char* standard = target->GetProperty(it.first + "_STANDARD");
if (!standard) {
continue;
}
- if (this->Makefile->IsLaterStandard(it->first, standard, it->second)) {
+ if (this->Makefile->IsLaterStandard(it.first, standard, it.second)) {
std::ostringstream e;
e << "The COMPILE_FEATURES property of target \"" << target->GetName()
<< "\" was evaluated when computing the link "
"implementation, and the \""
- << it->first << "_STANDARD\" was \"" << it->second
+ << it.first << "_STANDARD\" was \"" << it.second
<< "\" for that computation. Computing the "
"COMPILE_FEATURES based on the link implementation resulted in a "
"higher \""
- << it->first << "_STANDARD\" \"" << standard
+ << it.first << "_STANDARD\" \"" << standard
<< "\". "
"This is not permitted. The COMPILE_FEATURES may not both depend "
"on "
@@ -917,13 +891,12 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
if (const char* value = this->Makefile->GetDefinition(impDirVar)) {
std::vector<std::string> impDirVec;
cmSystemTools::ExpandListArgument(value, impDirVec);
- for (std::vector<std::string>::const_iterator i = impDirVec.begin();
- i != impDirVec.end(); ++i) {
- std::string d = rootPath + *i;
+ for (std::string const& i : impDirVec) {
+ std::string d = rootPath + i;
cmSystemTools::ConvertToUnixSlashes(d);
emitted.insert(d);
if (!stripImplicitInclDirs) {
- implicitDirs.push_back(*i);
+ implicitDirs.push_back(i);
}
}
}
@@ -938,26 +911,24 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
if (this->Makefile->IsOn("CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE")) {
const char* topSourceDir = this->GetState()->GetSourceDirectory();
const char* topBinaryDir = this->GetState()->GetBinaryDirectory();
- for (std::vector<std::string>::const_iterator i = includes.begin();
- i != includes.end(); ++i) {
+ for (std::string const& i : includes) {
// Emit this directory only if it is a subdirectory of the
// top-level source or binary tree.
- if (cmSystemTools::ComparePath(*i, topSourceDir) ||
- cmSystemTools::ComparePath(*i, topBinaryDir) ||
- cmSystemTools::IsSubDirectory(*i, topSourceDir) ||
- cmSystemTools::IsSubDirectory(*i, topBinaryDir)) {
- if (emitted.insert(*i).second) {
- dirs.push_back(*i);
+ if (cmSystemTools::ComparePath(i, topSourceDir) ||
+ cmSystemTools::ComparePath(i, topBinaryDir) ||
+ cmSystemTools::IsSubDirectory(i, topSourceDir) ||
+ cmSystemTools::IsSubDirectory(i, topBinaryDir)) {
+ if (emitted.insert(i).second) {
+ dirs.push_back(i);
}
}
}
}
// Construct the final ordered include directory list.
- for (std::vector<std::string>::const_iterator i = includes.begin();
- i != includes.end(); ++i) {
- if (emitted.insert(*i).second) {
- dirs.push_back(*i);
+ for (std::string const& i : includes) {
+ if (emitted.insert(i).second) {
+ dirs.push_back(i);
}
}
@@ -975,10 +946,9 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
dirs.push_back(*i);
}
- for (std::vector<std::string>::const_iterator i = implicitDirs.begin();
- i != implicitDirs.end(); ++i) {
- if (std::find(includes.begin(), includes.end(), *i) != includes.end()) {
- dirs.push_back(*i);
+ for (std::string const& i : implicitDirs) {
+ if (std::find(includes.begin(), includes.end(), i) != includes.end()) {
+ dirs.push_back(i);
}
}
}
@@ -1036,9 +1006,7 @@ void cmLocalGenerator::GetTargetFlags(
target->GetSourceFiles(sources, buildType);
std::string defFlag =
this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
- for (std::vector<cmSourceFile*>::const_iterator i = sources.begin();
- i != sources.end(); ++i) {
- cmSourceFile* sf = *i;
+ for (cmSourceFile* sf : sources) {
if (sf->GetExtension() == "def") {
linkFlags += defFlag;
linkFlags += this->ConvertToOutputFormat(
@@ -1189,10 +1157,9 @@ static std::string GetFrameworkFlags(const std::string& lang,
lg->GetIncludeDirectories(includes, target, "C", config);
// check all include directories for frameworks as this
// will already have added a -F for the framework
- for (std::vector<std::string>::iterator i = includes.begin();
- i != includes.end(); ++i) {
- if (lg->GetGlobalGenerator()->NameResolvesToFramework(*i)) {
- std::string frameworkDir = *i;
+ for (std::string const& include : includes) {
+ if (lg->GetGlobalGenerator()->NameResolvesToFramework(include)) {
+ std::string frameworkDir = include;
frameworkDir += "/../";
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
emitted.insert(frameworkDir);
@@ -1202,11 +1169,11 @@ static std::string GetFrameworkFlags(const std::string& lang,
std::string flags;
if (cmComputeLinkInformation* cli = target->GetLinkInformation(config)) {
std::vector<std::string> const& frameworks = cli->GetFrameworkPaths();
- for (std::vector<std::string>::const_iterator i = frameworks.begin();
- i != frameworks.end(); ++i) {
- if (emitted.insert(*i).second) {
+ for (std::string const& framework : frameworks) {
+ if (emitted.insert(framework).second) {
flags += fwSearchFlag;
- flags += lg->ConvertToOutputFormat(*i, cmOutputConverter::SHELL);
+ flags +=
+ lg->ConvertToOutputFormat(framework, cmOutputConverter::SHELL);
flags += " ";
}
}
@@ -1359,10 +1326,9 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
this->Makefile->GetDefinition(deploymentTargetFlagVar);
if (!archs.empty() && !lang.empty() &&
(lang[0] == 'C' || lang[0] == 'F')) {
- for (std::vector<std::string>::iterator i = archs.begin();
- i != archs.end(); ++i) {
+ for (std::string const& arch : archs) {
flags += " -arch ";
- flags += *i;
+ flags += arch;
}
}
@@ -1566,8 +1532,8 @@ void cmLocalGenerator::AddCompilerRequirementFlag(
target->Target->GetMakefile()->GetDefinition(option_flag)) {
std::vector<std::string> optVec;
cmSystemTools::ExpandListArgument(opt, optVec);
- for (size_t i = 0; i < optVec.size(); ++i) {
- this->AppendFlagEscape(flags, optVec[i]);
+ for (std::string const& i : optVec) {
+ this->AppendFlagEscape(flags, i);
}
}
}
@@ -1594,8 +1560,8 @@ void cmLocalGenerator::AddCompilerRequirementFlag(
} else {
std::vector<std::string> optVec;
cmSystemTools::ExpandListArgument(opt, optVec);
- for (size_t i = 0; i < optVec.size(); ++i) {
- this->AppendFlagEscape(flags, optVec[i]);
+ for (std::string const& i : optVec) {
+ this->AppendFlagEscape(flags, i);
}
}
return;
@@ -1654,8 +1620,8 @@ void cmLocalGenerator::AddCompilerRequirementFlag(
target->Target->GetMakefile()->GetRequiredDefinition(option_flag);
std::vector<std::string> optVec;
cmSystemTools::ExpandListArgument(opt, optVec);
- for (size_t i = 0; i < optVec.size(); ++i) {
- this->AppendFlagEscape(flags, optVec[i]);
+ for (std::string const& i : optVec) {
+ this->AppendFlagEscape(flags, i);
}
return;
}
@@ -1671,8 +1637,8 @@ void cmLocalGenerator::AddCompilerRequirementFlag(
target->Target->GetMakefile()->GetDefinition(option_flag)) {
std::vector<std::string> optVec;
cmSystemTools::ExpandListArgument(opt, optVec);
- for (size_t i = 0; i < optVec.size(); ++i) {
- this->AppendFlagEscape(flags, optVec[i]);
+ for (std::string const& i : optVec) {
+ this->AppendFlagEscape(flags, i);
}
return;
}
@@ -1871,9 +1837,8 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags,
if (picFlags) {
std::vector<std::string> options;
cmSystemTools::ExpandListArgument(picFlags, options);
- for (std::vector<std::string>::const_iterator oi = options.begin();
- oi != options.end(); ++oi) {
- this->AppendFlagEscape(flags, *oi);
+ for (std::string const& o : options) {
+ this->AppendFlagEscape(flags, o);
}
}
}
@@ -1943,9 +1908,8 @@ void cmLocalGenerator::AppendIPOLinkerFlags(std::string& flags,
std::vector<std::string> flagsList;
cmSystemTools::ExpandListArgument(rawFlagsList, flagsList);
- for (std::vector<std::string>::const_iterator oi = flagsList.begin();
- oi != flagsList.end(); ++oi) {
- this->AppendFlagEscape(flags, *oi);
+ for (std::string const& o : flagsList) {
+ this->AppendFlagEscape(flags, o);
}
}
@@ -1967,13 +1931,12 @@ void cmLocalGenerator::AppendDefines(
std::set<std::string>& defines,
const std::vector<std::string>& defines_vec) const
{
- for (std::vector<std::string>::const_iterator di = defines_vec.begin();
- di != defines_vec.end(); ++di) {
+ for (std::string const& d : defines_vec) {
// Skip unsupported definitions.
- if (!this->CheckDefinition(*di)) {
+ if (!this->CheckDefinition(d)) {
continue;
}
- defines.insert(*di);
+ defines.insert(d);
}
}
@@ -2043,9 +2006,8 @@ void cmLocalGenerator::AppendFeatureOptions(std::string& flags,
if (const char* optionList = this->Makefile->GetDefinition(optVar)) {
std::vector<std::string> options;
cmSystemTools::ExpandListArgument(optionList, options);
- for (std::vector<std::string>::const_iterator oi = options.begin();
- oi != options.end(); ++oi) {
- this->AppendFlagEscape(flags, *oi);
+ for (std::string const& o : options) {
+ this->AppendFlagEscape(flags, o);
}
}
}
@@ -2089,10 +2051,9 @@ std::string cmLocalGenerator::ConstructComment(
comment = "Generating ";
const char* sep = "";
std::string currentBinaryDir = this->GetCurrentBinaryDirectory();
- for (std::vector<std::string>::const_iterator o = ccg.GetOutputs().begin();
- o != ccg.GetOutputs().end(); ++o) {
+ for (std::string const& o : ccg.GetOutputs()) {
comment += sep;
- comment += this->ConvertToRelativePath(currentBinaryDir, *o);
+ comment += this->ConvertToRelativePath(currentBinaryDir, o);
sep = ", ";
}
return comment;
@@ -2123,36 +2084,35 @@ void cmLocalGenerator::GenerateTargetInstallRules(
// Convert the old-style install specification from each target to
// an install generator and run it.
const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin();
- l != tgts.end(); ++l) {
- if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (cmGeneratorTarget* l : tgts) {
+ if (l->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
// Include the user-specified pre-install script for this target.
- if (const char* preinstall = (*l)->GetProperty("PRE_INSTALL_SCRIPT")) {
+ if (const char* preinstall = l->GetProperty("PRE_INSTALL_SCRIPT")) {
cmInstallScriptGenerator g(preinstall, false, nullptr, false);
g.Generate(os, config, configurationTypes);
}
// Install this target if a destination is given.
- if ((*l)->Target->GetInstallPath() != "") {
+ if (l->Target->GetInstallPath() != "") {
// Compute the full install destination. Note that converting
// to unix slashes also removes any trailing slash.
// We also skip over the leading slash given by the user.
- std::string destination = (*l)->Target->GetInstallPath().substr(1);
+ std::string destination = l->Target->GetInstallPath().substr(1);
cmSystemTools::ConvertToUnixSlashes(destination);
if (destination.empty()) {
destination = ".";
}
// Generate the proper install generator for this target type.
- switch ((*l)->GetType()) {
+ switch (l->GetType()) {
case cmStateEnums::EXECUTABLE:
case cmStateEnums::STATIC_LIBRARY:
case cmStateEnums::MODULE_LIBRARY: {
// Use a target install generator.
- cmInstallTargetGeneratorLocal g(this, (*l)->GetName(),
+ cmInstallTargetGeneratorLocal g(this, l->GetName(),
destination.c_str(), false);
g.Generate(os, config, configurationTypes);
} break;
@@ -2161,18 +2121,18 @@ void cmLocalGenerator::GenerateTargetInstallRules(
// Special code to handle DLL. Install the import library
// to the normal destination and the DLL to the runtime
// destination.
- cmInstallTargetGeneratorLocal g1(this, (*l)->GetName(),
+ cmInstallTargetGeneratorLocal g1(this, l->GetName(),
destination.c_str(), true);
g1.Generate(os, config, configurationTypes);
// We also skip over the leading slash given by the user.
- destination = (*l)->Target->GetRuntimeInstallPath().substr(1);
+ destination = l->Target->GetRuntimeInstallPath().substr(1);
cmSystemTools::ConvertToUnixSlashes(destination);
- cmInstallTargetGeneratorLocal g2(this, (*l)->GetName(),
+ cmInstallTargetGeneratorLocal g2(this, l->GetName(),
destination.c_str(), false);
g2.Generate(os, config, configurationTypes);
#else
// Use a target install generator.
- cmInstallTargetGeneratorLocal g(this, (*l)->GetName(),
+ cmInstallTargetGeneratorLocal g(this, l->GetName(),
destination.c_str(), false);
g.Generate(os, config, configurationTypes);
#endif
@@ -2183,7 +2143,7 @@ void cmLocalGenerator::GenerateTargetInstallRules(
}
// Include the user-specified post-install script for this target.
- if (const char* postinstall = (*l)->GetProperty("POST_INSTALL_SCRIPT")) {
+ if (const char* postinstall = l->GetProperty("POST_INSTALL_SCRIPT")) {
cmInstallScriptGenerator g(postinstall, false, nullptr, false);
g.Generate(os, config, configurationTypes);
}
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index 9fa3ca5..8a7f455 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -80,18 +80,18 @@ void cmLocalNinjaGenerator::Generate()
}
const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin();
- t != targets.end(); ++t) {
- if ((*t)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (cmGeneratorTarget* target : targets) {
+ if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- cmNinjaTargetGenerator* tg = cmNinjaTargetGenerator::New(*t);
+ cmNinjaTargetGenerator* tg = cmNinjaTargetGenerator::New(target);
if (tg) {
tg->Generate();
// Add the target to "all" if required.
if (!this->GetGlobalNinjaGenerator()->IsExcluded(
- this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], *t)) {
- this->GetGlobalNinjaGenerator()->AddDependencyToAll(*t);
+ this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0],
+ target)) {
+ this->GetGlobalNinjaGenerator()->AddDependencyToAll(target);
}
delete tg;
}
@@ -212,8 +212,7 @@ void cmLocalNinjaGenerator::WritePools(std::ostream& os)
os, "Pools defined by global property JOB_POOLS");
std::vector<std::string> pools;
cmSystemTools::ExpandListArgument(jobpools, pools);
- for (size_t i = 0; i < pools.size(); ++i) {
- std::string const& pool = pools[i];
+ for (std::string const& pool : pools) {
const std::string::size_type eq = pool.find('=');
unsigned int jobs;
if (eq != std::string::npos &&
@@ -250,12 +249,10 @@ void cmLocalNinjaGenerator::ComputeObjectFilenames(
{
// Determine if these object files should use a custom extension
char const* custom_ext = gt->GetCustomObjectExtension();
- for (std::map<cmSourceFile const*, std::string>::iterator si =
- mapping.begin();
- si != mapping.end(); ++si) {
- cmSourceFile const* sf = si->first;
+ for (auto& si : mapping) {
+ cmSourceFile const* sf = si.first;
bool keptSourceExtension;
- si->second = this->GetObjectFileNameWithoutTarget(
+ si.second = this->GetObjectFileNameWithoutTarget(
*sf, gt->ObjectDirectory, &keptSourceExtension, custom_ext);
}
}
@@ -291,10 +288,9 @@ void cmLocalNinjaGenerator::AppendCustomCommandDeps(
cmCustomCommandGenerator const& ccg, cmNinjaDeps& ninjaDeps)
{
const std::vector<std::string>& deps = ccg.GetDepends();
- for (std::vector<std::string>::const_iterator i = deps.begin();
- i != deps.end(); ++i) {
+ for (std::string const& i : deps) {
std::string dep;
- if (this->GetRealDependency(*i, this->GetConfigName(), dep)) {
+ if (this->GetRealDependency(i, this->GetConfigName(), dep)) {
ninjaDeps.push_back(
this->GetGlobalNinjaGenerator()->ConvertToNinjaPath(dep));
}
@@ -408,9 +404,8 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
this->GetGlobalNinjaGenerator()->MapToNinjaPath());
this->AppendCustomCommandDeps(ccg, ninjaDeps);
- for (cmNinjaDeps::iterator i = ninjaOutputs.begin(); i != ninjaOutputs.end();
- ++i) {
- this->GetGlobalNinjaGenerator()->SeenCustomCommandOutput(*i);
+ for (std::string const& ninjaOutput : ninjaOutputs) {
+ this->GetGlobalNinjaGenerator()->SeenCustomCommandOutput(ninjaOutput);
}
std::vector<std::string> cmdLines;
@@ -445,10 +440,9 @@ void cmLocalNinjaGenerator::AddCustomCommandTarget(cmCustomCommand const* cc,
void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements()
{
- for (std::vector<cmCustomCommand const*>::iterator vi =
- this->CustomCommands.begin();
- vi != this->CustomCommands.end(); ++vi) {
- CustomCommandTargetMap::iterator i = this->CustomCommandTargets.find(*vi);
+ for (cmCustomCommand const* customCommand : this->CustomCommands) {
+ CustomCommandTargetMap::iterator i =
+ this->CustomCommandTargets.find(customCommand);
assert(i != this->CustomCommandTargets.end());
// A custom command may appear on multiple targets. However, some build
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index cde2621..7f7ec4f 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -11,7 +11,6 @@
#include <utility>
#include "cmAlgorithms.h"
-#include "cmCustomCommand.h"
#include "cmCustomCommandGenerator.h"
#include "cmFileTimeComparison.h"
#include "cmGeneratedFileStream.h"
@@ -119,13 +118,12 @@ void cmLocalUnixMakefileGenerator3::Generate()
const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
cmGlobalUnixMakefileGenerator3* gg =
static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
- for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin();
- t != targets.end(); ++t) {
- if ((*t)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (cmGeneratorTarget* target : targets) {
+ if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
CM_AUTO_PTR<cmMakefileTargetGenerator> tg(
- cmMakefileTargetGenerator::New(*t));
+ cmMakefileTargetGenerator::New(target));
if (tg.get()) {
tg->WriteRuleFiles();
gg->RecordTargetProgress(tg.get());
@@ -159,12 +157,10 @@ void cmLocalUnixMakefileGenerator3::ComputeObjectFilenames(
{
// Determine if these object files should use a custom extension
char const* custom_ext = gt->GetCustomObjectExtension();
- for (std::map<cmSourceFile const*, std::string>::iterator si =
- mapping.begin();
- si != mapping.end(); ++si) {
- cmSourceFile const* sf = si->first;
+ for (auto& si : mapping) {
+ cmSourceFile const* sf = si.first;
bool keptSourceExtension;
- si->second = this->GetObjectFileNameWithoutTarget(
+ si.second = this->GetObjectFileNameWithoutTarget(
*sf, gt->ObjectDirectory, &keptSourceExtension, custom_ext);
}
}
@@ -173,9 +169,7 @@ void cmLocalUnixMakefileGenerator3::GetLocalObjectFiles(
std::map<std::string, LocalObjectInfo>& localObjectFiles)
{
const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
- ti != targets.end(); ++ti) {
- cmGeneratorTarget* gt = *ti;
+ for (cmGeneratorTarget* gt : targets) {
if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
@@ -189,9 +183,7 @@ void cmLocalUnixMakefileGenerator3::GetLocalObjectFiles(
dir += this->GetTargetDirectory(gt);
dir += "/";
// Compute the name of each object file.
- for (std::vector<cmSourceFile const*>::iterator si = objectSources.begin();
- si != objectSources.end(); ++si) {
- cmSourceFile const* sf = *si;
+ for (cmSourceFile const* sf : objectSources) {
bool hasSourceExtension = true;
std::string objectName =
this->GetObjectFileNameWithoutTarget(*sf, dir, &hasSourceExtension);
@@ -210,18 +202,16 @@ void cmLocalUnixMakefileGenerator3::GetIndividualFileTargets(
{
std::map<std::string, LocalObjectInfo> localObjectFiles;
this->GetLocalObjectFiles(localObjectFiles);
- for (std::map<std::string, LocalObjectInfo>::iterator lo =
- localObjectFiles.begin();
- lo != localObjectFiles.end(); ++lo) {
- targets.push_back(lo->first);
-
- std::string::size_type dot_pos = lo->first.rfind(".");
- std::string base = lo->first.substr(0, dot_pos);
- if (lo->second.HasPreprocessRule) {
+ for (auto const& localObjectFile : localObjectFiles) {
+ targets.push_back(localObjectFile.first);
+
+ std::string::size_type dot_pos = localObjectFile.first.rfind(".");
+ std::string base = localObjectFile.first.substr(0, dot_pos);
+ if (localObjectFile.second.HasPreprocessRule) {
targets.push_back(base + ".i");
}
- if (lo->second.HasAssembleRule) {
+ if (localObjectFile.second.HasAssembleRule) {
targets.push_back(base + ".s");
}
}
@@ -270,23 +260,20 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
// now write out the object rules
// for each object file name
- for (std::map<std::string, LocalObjectInfo>::iterator lo =
- localObjectFiles.begin();
- lo != localObjectFiles.end(); ++lo) {
+ for (auto& localObjectFile : localObjectFiles) {
// Add a convenience rule for building the object file.
- this->WriteObjectConvenienceRule(ruleFileStream,
- "target to build an object file",
- lo->first.c_str(), lo->second);
+ this->WriteObjectConvenienceRule(
+ ruleFileStream, "target to build an object file",
+ localObjectFile.first.c_str(), localObjectFile.second);
// Check whether preprocessing and assembly rules make sense.
// They make sense only for C and C++ sources.
bool lang_has_preprocessor = false;
bool lang_has_assembly = false;
- for (std::vector<LocalObjectEntry>::const_iterator ei = lo->second.begin();
- ei != lo->second.end(); ++ei) {
- if (ei->Language == "C" || ei->Language == "CXX" ||
- ei->Language == "CUDA" || ei->Language == "Fortran") {
+ for (LocalObjectEntry const& entry : localObjectFile.second) {
+ if (entry.Language == "C" || entry.Language == "CXX" ||
+ entry.Language == "CUDA" || entry.Language == "Fortran") {
// Right now, C, C++, Fortran and CUDA have both a preprocessor and the
// ability to generate assembly code
lang_has_preprocessor = true;
@@ -297,21 +284,21 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
// Add convenience rules for preprocessed and assembly files.
if (lang_has_preprocessor && do_preprocess_rules) {
- std::string::size_type dot_pos = lo->first.rfind(".");
- std::string base = lo->first.substr(0, dot_pos);
- this->WriteObjectConvenienceRule(ruleFileStream,
- "target to preprocess a source file",
- (base + ".i").c_str(), lo->second);
- lo->second.HasPreprocessRule = true;
+ std::string::size_type dot_pos = localObjectFile.first.rfind(".");
+ std::string base = localObjectFile.first.substr(0, dot_pos);
+ this->WriteObjectConvenienceRule(
+ ruleFileStream, "target to preprocess a source file",
+ (base + ".i").c_str(), localObjectFile.second);
+ localObjectFile.second.HasPreprocessRule = true;
}
if (lang_has_assembly && do_assembly_rules) {
- std::string::size_type dot_pos = lo->first.rfind(".");
- std::string base = lo->first.substr(0, dot_pos);
+ std::string::size_type dot_pos = localObjectFile.first.rfind(".");
+ std::string base = localObjectFile.first.substr(0, dot_pos);
this->WriteObjectConvenienceRule(
ruleFileStream, "target to generate assembly for a file",
- (base + ".s").c_str(), lo->second);
- lo->second.HasAssembleRule = true;
+ (base + ".s").c_str(), localObjectFile.second);
+ localObjectFile.second.HasAssembleRule = true;
}
}
@@ -355,9 +342,8 @@ void cmLocalUnixMakefileGenerator3::WriteObjectConvenienceRule(
// Recursively make the rule for each target using the object file.
std::vector<std::string> commands;
- for (std::vector<LocalObjectEntry>::const_iterator t = info.begin();
- t != info.end(); ++t) {
- std::string tgtMakefileName = this->GetRelativeTargetDirectory(t->Target);
+ for (LocalObjectEntry const& t : info) {
+ std::string tgtMakefileName = this->GetRelativeTargetDirectory(t.Target);
std::string targetName = tgtMakefileName;
tgtMakefileName += "/build.make";
targetName += "/";
@@ -384,18 +370,17 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets(
// on the target
const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
std::string localName;
- for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin();
- t != targets.end(); ++t) {
- if (((*t)->GetType() == cmStateEnums::EXECUTABLE) ||
- ((*t)->GetType() == cmStateEnums::STATIC_LIBRARY) ||
- ((*t)->GetType() == cmStateEnums::SHARED_LIBRARY) ||
- ((*t)->GetType() == cmStateEnums::MODULE_LIBRARY) ||
- ((*t)->GetType() == cmStateEnums::OBJECT_LIBRARY) ||
- ((*t)->GetType() == cmStateEnums::UTILITY)) {
- emitted.insert((*t)->GetName());
+ for (cmGeneratorTarget* target : targets) {
+ if ((target->GetType() == cmStateEnums::EXECUTABLE) ||
+ (target->GetType() == cmStateEnums::STATIC_LIBRARY) ||
+ (target->GetType() == cmStateEnums::SHARED_LIBRARY) ||
+ (target->GetType() == cmStateEnums::MODULE_LIBRARY) ||
+ (target->GetType() == cmStateEnums::OBJECT_LIBRARY) ||
+ (target->GetType() == cmStateEnums::UTILITY)) {
+ emitted.insert(target->GetName());
// for subdirs add a rule to build this specific target by name.
- localName = this->GetRelativeTargetDirectory(*t);
+ localName = this->GetRelativeTargetDirectory(target);
localName += "/rule";
commands.clear();
depends.clear();
@@ -411,20 +396,20 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets(
localName, depends, commands, true);
// Add a target with the canonical name (no prefix, suffix or path).
- if (localName != (*t)->GetName()) {
+ if (localName != target->GetName()) {
commands.clear();
depends.push_back(localName);
this->WriteMakeRule(ruleFileStream, "Convenience name for target.",
- (*t)->GetName(), depends, commands, true);
+ target->GetName(), depends, commands, true);
}
// Add a fast rule to build the target
- std::string makefileName = this->GetRelativeTargetDirectory(*t);
+ std::string makefileName = this->GetRelativeTargetDirectory(target);
makefileName += "/build.make";
// make sure the makefile name is suitable for a makefile
- std::string makeTargetName = this->GetRelativeTargetDirectory(*t);
+ std::string makeTargetName = this->GetRelativeTargetDirectory(target);
makeTargetName += "/build";
- localName = (*t)->GetName();
+ localName = target->GetName();
localName += "/fast";
depends.clear();
commands.clear();
@@ -437,10 +422,10 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets(
// Add a local name for the rule to relink the target before
// installation.
- if ((*t)->NeedRelinkBeforeInstall(this->ConfigName)) {
- makeTargetName = this->GetRelativeTargetDirectory(*t);
+ if (target->NeedRelinkBeforeInstall(this->ConfigName)) {
+ makeTargetName = this->GetRelativeTargetDirectory(target);
makeTargetName += "/preinstall";
- localName = (*t)->GetName();
+ localName = target->GetName();
localName += "/preinstall";
depends.clear();
commands.clear();
@@ -581,9 +566,8 @@ void cmLocalUnixMakefileGenerator3::WriteMakeRule(
// Split dependencies into multiple rule lines. This allows for
// very long dependency lists even on older make implementations.
std::string binDir = this->GetBinaryDirectory();
- for (std::vector<std::string>::const_iterator dep = depends.begin();
- dep != depends.end(); ++dep) {
- replace = *dep;
+ for (std::string const& depend : depends) {
+ replace = depend;
replace = cmSystemTools::ConvertToOutputPath(
this->MaybeConvertToRelativePath(binDir, replace).c_str());
os << cmMakeSafe(tgt) << space << ": " << cmMakeSafe(replace) << "\n";
@@ -892,9 +876,8 @@ void cmLocalUnixMakefileGenerator3::AppendRuleDepends(
void cmLocalUnixMakefileGenerator3::AppendCustomDepends(
std::vector<std::string>& depends, const std::vector<cmCustomCommand>& ccs)
{
- for (std::vector<cmCustomCommand>::const_iterator i = ccs.begin();
- i != ccs.end(); ++i) {
- cmCustomCommandGenerator ccg(*i, this->ConfigName, this);
+ for (cmCustomCommand const& cc : ccs) {
+ cmCustomCommandGenerator ccg(cc, this->ConfigName, this);
this->AppendCustomDepend(depends, ccg);
}
}
@@ -902,11 +885,10 @@ void cmLocalUnixMakefileGenerator3::AppendCustomDepends(
void cmLocalUnixMakefileGenerator3::AppendCustomDepend(
std::vector<std::string>& depends, cmCustomCommandGenerator const& ccg)
{
- for (std::vector<std::string>::const_iterator d = ccg.GetDepends().begin();
- d != ccg.GetDepends().end(); ++d) {
+ for (std::string const& d : ccg.GetDepends()) {
// Lookup the real name of the dependency in case it is a CMake target.
std::string dep;
- if (this->GetRealDependency(*d, this->ConfigName, dep)) {
+ if (this->GetRealDependency(d, this->ConfigName, dep)) {
depends.push_back(dep);
}
}
@@ -916,9 +898,8 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommands(
std::vector<std::string>& commands, const std::vector<cmCustomCommand>& ccs,
cmGeneratorTarget* target, std::string const& relative)
{
- for (std::vector<cmCustomCommand>::const_iterator i = ccs.begin();
- i != ccs.end(); ++i) {
- cmCustomCommandGenerator ccg(*i, this->ConfigName, this);
+ for (cmCustomCommand const& cc : ccs) {
+ cmCustomCommandGenerator ccg(cc, this->ConfigName, this);
this->AppendCustomCommand(commands, ccg, target, relative, true);
}
}
@@ -1089,9 +1070,8 @@ void cmLocalUnixMakefileGenerator3::AppendCleanCommand(
}
if (!files.empty()) {
fout << "file(REMOVE_RECURSE\n";
- for (std::vector<std::string>::const_iterator f = files.begin();
- f != files.end(); ++f) {
- std::string fc = this->MaybeConvertToRelativePath(currentBinDir, *f);
+ for (std::string const& file : files) {
+ std::string fc = this->MaybeConvertToRelativePath(currentBinDir, file);
fout << " " << cmOutputConverter::EscapeForCMake(fc) << "\n";
}
fout << ")\n";
@@ -1454,11 +1434,8 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
const char* langStr = mf->GetSafeDefinition("CMAKE_DEPENDS_LANGUAGES");
std::vector<std::string> langs;
cmSystemTools::ExpandListArgument(langStr, langs);
- for (std::vector<std::string>::iterator li = langs.begin();
- li != langs.end(); ++li) {
+ for (std::string const& lang : langs) {
// construct the checker
- std::string lang = *li;
-
// Create the scanner for this language
cmDepends* scanner = nullptr;
if (lang == "C" || lang == "CXX" || lang == "RC" || lang == "ASM" ||
@@ -1563,25 +1540,22 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
ruleFileStream << "# Targets provided globally by CMake.\n"
<< "\n";
const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
- std::vector<cmGeneratorTarget*>::const_iterator glIt;
- for (glIt = targets.begin(); glIt != targets.end(); ++glIt) {
- if ((*glIt)->GetType() == cmStateEnums::GLOBAL_TARGET) {
+ for (cmGeneratorTarget* gt : targets) {
+ if (gt->GetType() == cmStateEnums::GLOBAL_TARGET) {
std::string targetString =
- "Special rule for the target " + (*glIt)->GetName();
+ "Special rule for the target " + gt->GetName();
std::vector<std::string> commands;
std::vector<std::string> depends;
- const char* text = (*glIt)->GetProperty("EchoString");
+ const char* text = gt->GetProperty("EchoString");
if (!text) {
text = "Running external command ...";
}
- depends.insert(depends.end(), (*glIt)->GetUtilities().begin(),
- (*glIt)->GetUtilities().end());
+ depends.insert(depends.end(), gt->GetUtilities().begin(),
+ gt->GetUtilities().end());
this->AppendEcho(commands, text,
cmLocalUnixMakefileGenerator3::EchoGlobal);
- cmGeneratorTarget* gt = *glIt;
-
// Global targets store their rules in pre- and post-build commands.
this->AppendCustomDepends(depends, gt->GetPreBuildCommands());
this->AppendCustomDepends(depends, gt->GetPostBuildCommands());
@@ -1728,9 +1702,8 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf,
// dependencies for that target.
cmDepends clearer;
clearer.SetVerbose(verbose);
- for (std::vector<std::string>::iterator l = files.begin(); l != files.end();
- ++l) {
- std::string dir = cmSystemTools::GetFilenamePath(*l);
+ for (std::string const& file : files) {
+ std::string dir = cmSystemTools::GetFilenamePath(file);
// Clear the implicit dependency makefile.
std::string dependFile = dir + "/depend.make";
@@ -1802,54 +1775,51 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo(
cmakefileStream
<< "# The set of languages for which implicit dependencies are needed:\n";
cmakefileStream << "set(CMAKE_DEPENDS_LANGUAGES\n";
- for (ImplicitDependLanguageMap::const_iterator l = implicitLangs.begin();
- l != implicitLangs.end(); ++l) {
- cmakefileStream << " \"" << l->first << "\"\n";
+ for (auto const& implicitLang : implicitLangs) {
+ cmakefileStream << " \"" << implicitLang.first << "\"\n";
}
cmakefileStream << " )\n";
// now list the files for each language
cmakefileStream
<< "# The set of files for implicit dependencies of each language:\n";
- for (ImplicitDependLanguageMap::const_iterator l = implicitLangs.begin();
- l != implicitLangs.end(); ++l) {
- cmakefileStream << "set(CMAKE_DEPENDS_CHECK_" << l->first << "\n";
- ImplicitDependFileMap const& implicitPairs = l->second;
+ for (auto const& implicitLang : implicitLangs) {
+ cmakefileStream << "set(CMAKE_DEPENDS_CHECK_" << implicitLang.first
+ << "\n";
+ ImplicitDependFileMap const& implicitPairs = implicitLang.second;
// for each file pair
- for (ImplicitDependFileMap::const_iterator pi = implicitPairs.begin();
- pi != implicitPairs.end(); ++pi) {
- for (cmDepends::DependencyVector::const_iterator di = pi->second.begin();
- di != pi->second.end(); ++di) {
- cmakefileStream << " \"" << *di << "\" ";
- cmakefileStream << "\"" << pi->first << "\"\n";
+ for (auto const& implicitPair : implicitPairs) {
+ for (auto const& di : implicitPair.second) {
+ cmakefileStream << " \"" << di << "\" ";
+ cmakefileStream << "\"" << implicitPair.first << "\"\n";
}
}
cmakefileStream << " )\n";
// Tell the dependency scanner what compiler is used.
std::string cidVar = "CMAKE_";
- cidVar += l->first;
+ cidVar += implicitLang.first;
cidVar += "_COMPILER_ID";
const char* cid = this->Makefile->GetDefinition(cidVar);
if (cid && *cid) {
- cmakefileStream << "set(CMAKE_" << l->first << "_COMPILER_ID \"" << cid
- << "\")\n";
+ cmakefileStream << "set(CMAKE_" << implicitLang.first
+ << "_COMPILER_ID \"" << cid << "\")\n";
}
// Build a list of preprocessor definitions for the target.
std::set<std::string> defines;
- this->AddCompileDefinitions(defines, target, this->ConfigName, l->first);
+ this->AddCompileDefinitions(defines, target, this->ConfigName,
+ implicitLang.first);
if (!defines.empty()) {
/* clang-format off */
cmakefileStream
<< "\n"
<< "# Preprocessor definitions for this target.\n"
- << "set(CMAKE_TARGET_DEFINITIONS_" << l->first << "\n";
+ << "set(CMAKE_TARGET_DEFINITIONS_" << implicitLang.first << "\n";
/* clang-format on */
- for (std::set<std::string>::const_iterator di = defines.begin();
- di != defines.end(); ++di) {
- cmakefileStream << " " << cmOutputConverter::EscapeForCMake(*di)
+ for (std::string const& define : defines) {
+ cmakefileStream << " " << cmOutputConverter::EscapeForCMake(define)
<< "\n";
}
cmakefileStream << " )\n";
@@ -1858,21 +1828,21 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo(
// Target-specific include directories:
cmakefileStream << "\n"
<< "# The include file search paths:\n";
- cmakefileStream << "set(CMAKE_" << l->first << "_TARGET_INCLUDE_PATH\n";
+ cmakefileStream << "set(CMAKE_" << implicitLang.first
+ << "_TARGET_INCLUDE_PATH\n";
std::vector<std::string> includes;
const std::string& config =
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
- this->GetIncludeDirectories(includes, target, l->first, config);
+ this->GetIncludeDirectories(includes, target, implicitLang.first, config);
std::string binaryDir = this->GetState()->GetBinaryDirectory();
if (this->Makefile->IsOn("CMAKE_DEPENDS_IN_PROJECT_ONLY")) {
const char* sourceDir = this->GetState()->GetSourceDirectory();
cmEraseIf(includes, ::NotInProjectDir(sourceDir, binaryDir));
}
- for (std::vector<std::string>::iterator i = includes.begin();
- i != includes.end(); ++i) {
+ for (std::string const& include : includes) {
cmakefileStream << " \""
- << this->MaybeConvertToRelativePath(binaryDir, *i)
+ << this->MaybeConvertToRelativePath(binaryDir, include)
<< "\"\n";
}
cmakefileStream << " )\n";
@@ -1891,10 +1861,8 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo(
}
if (!transformRules.empty()) {
cmakefileStream << "set(CMAKE_INCLUDE_TRANSFORMS\n";
- for (std::vector<std::string>::const_iterator tri = transformRules.begin();
- tri != transformRules.end(); ++tri) {
- cmakefileStream << " " << cmOutputConverter::EscapeForCMake(*tri)
- << "\n";
+ for (std::string const& tr : transformRules) {
+ cmakefileStream << " " << cmOutputConverter::EscapeForCMake(tr) << "\n";
}
cmakefileStream << " )\n";
}
@@ -2004,10 +1972,9 @@ std::string cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(
#if defined(_WIN32) && !defined(__CYGWIN__)
if (!cmSystemTools::GetForceUnixPaths()) {
slash = "\\";
- for (std::string::iterator i = components[0].begin();
- i != components[0].end(); ++i) {
- if (*i == '/') {
- *i = '\\';
+ for (char& i : components[0]) {
+ if (i == '/') {
+ i = '\\';
}
}
}
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index a6a9ea3..003c443 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -98,20 +98,18 @@ bool cmMacroHelperCommand::InvokeInitialPass(
// Invoke all the functions that were collected in the block.
cmListFileFunction newLFF;
// for each function
- for (unsigned int c = 0; c < this->Functions.size(); ++c) {
+ for (cmListFileFunction const& func : this->Functions) {
// Replace the formal arguments and then invoke the command.
newLFF.Arguments.clear();
- newLFF.Arguments.reserve(this->Functions[c].Arguments.size());
- newLFF.Name = this->Functions[c].Name;
- newLFF.Line = this->Functions[c].Line;
+ newLFF.Arguments.reserve(func.Arguments.size());
+ newLFF.Name = func.Name;
+ newLFF.Line = func.Line;
// for each argument of the current function
- for (std::vector<cmListFileArgument>::iterator k =
- this->Functions[c].Arguments.begin();
- k != this->Functions[c].Arguments.end(); ++k) {
+ for (cmListFileArgument const& k : func.Arguments) {
cmListFileArgument arg;
- arg.Value = k->Value;
- if (k->Delim != cmListFileArgument::Bracket) {
+ arg.Value = k.Value;
+ if (k.Delim != cmListFileArgument::Bracket) {
// replace formal arguments
for (unsigned int j = 0; j < variables.size(); ++j) {
cmSystemTools::ReplaceString(arg.Value, variables[j],
@@ -131,8 +129,8 @@ bool cmMacroHelperCommand::InvokeInitialPass(
}
}
}
- arg.Delim = k->Delim;
- arg.Line = k->Line;
+ arg.Delim = k.Delim;
+ arg.Line = k.Line;
newLFF.Arguments.push_back(arg);
}
cmExecutionStatus status;
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 230c210..efab81f 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -206,15 +206,13 @@ void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
msg << lff.Name << "(";
bool expand = this->GetCMakeInstance()->GetTraceExpand();
std::string temp;
- for (std::vector<cmListFileArgument>::const_iterator i =
- lff.Arguments.begin();
- i != lff.Arguments.end(); ++i) {
+ for (cmListFileArgument const& arg : lff.Arguments) {
if (expand) {
- temp = i->Value;
+ temp = arg.Value;
this->ExpandVariablesInString(temp);
msg << temp;
} else {
- msg << i->Value;
+ msg << arg.Value;
}
msg << " ";
}
@@ -640,9 +638,8 @@ void cmMakefile::FinalPass()
// give all the commands a chance to do something
// after the file has been parsed before generation
- for (std::vector<cmCommand*>::iterator i = this->FinalPassCommands.begin();
- i != this->FinalPassCommands.end(); ++i) {
- (*i)->FinalPass();
+ for (cmCommand* fpCommand : this->FinalPassCommands) {
+ fpCommand->FinalPass();
}
// go through all configured files and see which ones still exist.
@@ -739,9 +736,8 @@ void cmMakefile::AddCustomCommandToTarget(
}
// Always create the byproduct sources and mark them generated.
- for (std::vector<std::string>::const_iterator o = byproducts.begin();
- o != byproducts.end(); ++o) {
- if (cmSourceFile* out = this->GetOrCreateSource(*o, true)) {
+ for (std::string const& o : byproducts) {
+ if (cmSourceFile* out = this->GetOrCreateSource(o, true)) {
out->SetProperty("GENERATED", "1");
}
}
@@ -783,9 +779,7 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput(
}
// Validate custom commands. TODO: More strict?
- for (cmCustomCommandLines::const_iterator i = commandLines.begin();
- i != commandLines.end(); ++i) {
- cmCustomCommandLine const& cl = *i;
+ for (cmCustomCommandLine const& cl : commandLines) {
if (!cl.empty() && !cl[0].empty() && cl[0][0] == '"') {
std::ostringstream e;
e << "COMMAND may not contain literal quotes:\n " << cl[0] << "\n";
@@ -842,15 +836,13 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput(
}
// Always create the output sources and mark them generated.
- for (std::vector<std::string>::const_iterator o = outputs.begin();
- o != outputs.end(); ++o) {
- if (cmSourceFile* out = this->GetOrCreateSource(*o, true)) {
+ for (std::string const& o : outputs) {
+ if (cmSourceFile* out = this->GetOrCreateSource(o, true)) {
out->SetProperty("GENERATED", "1");
}
}
- for (std::vector<std::string>::const_iterator o = byproducts.begin();
- o != byproducts.end(); ++o) {
- if (cmSourceFile* out = this->GetOrCreateSource(*o, true)) {
+ for (std::string const& o : byproducts) {
+ if (cmSourceFile* out = this->GetOrCreateSource(o, true)) {
out->SetProperty("GENERATED", "1");
}
}
@@ -879,9 +871,8 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput(
void cmMakefile::UpdateOutputToSourceMap(
std::vector<std::string> const& outputs, cmSourceFile* source)
{
- for (std::vector<std::string>::const_iterator o = outputs.begin();
- o != outputs.end(); ++o) {
- this->UpdateOutputToSourceMap(*o, source);
+ for (std::string const& o : outputs) {
+ this->UpdateOutputToSourceMap(o, source);
}
}
@@ -941,10 +932,9 @@ void cmMakefile::AddCustomCommandOldStyle(
cmsys::RegularExpression sourceFiles("\\.(C|M|c|c\\+\\+|cc|cpp|cxx|m|mm|"
"rc|def|r|odl|idl|hpj|bat|h|h\\+\\+|"
"hm|hpp|hxx|in|txx|inl)$");
- for (std::vector<std::string>::const_iterator oi = outputs.begin();
- oi != outputs.end(); ++oi) {
+ for (std::string const& oi : outputs) {
// Get the name of this output.
- const char* output = oi->c_str();
+ const char* output = oi.c_str();
cmSourceFile* sf;
// Choose whether to use a main dependency.
@@ -1062,9 +1052,8 @@ cmTarget* cmMakefile::AddUtilityCommand(
}
// Always create the byproduct sources and mark them generated.
- for (std::vector<std::string>::const_iterator o = byproducts.begin();
- o != byproducts.end(); ++o) {
- if (cmSourceFile* out = this->GetOrCreateSource(*o, true)) {
+ for (std::string const& byproduct : byproducts) {
+ if (cmSourceFile* out = this->GetOrCreateSource(byproduct, true)) {
out->SetProperty("GENERATED", "1");
}
}
@@ -1226,10 +1215,9 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent)
parent->GetProperty("COMPILE_DEFINITIONS"));
std::vector<std::string> configs;
this->GetConfigurations(configs);
- for (std::vector<std::string>::const_iterator ci = configs.begin();
- ci != configs.end(); ++ci) {
+ for (std::string const& config : configs) {
std::string defPropName = "COMPILE_DEFINITIONS_";
- defPropName += cmSystemTools::UpperCase(*ci);
+ defPropName += cmSystemTools::UpperCase(config);
const char* prop = parent->GetProperty(defPropName);
this->SetProperty(defPropName, prop);
}
@@ -1391,10 +1379,8 @@ void cmMakefile::Configure()
if (this->IsRootMakefile()) {
bool hasVersion = false;
// search for the right policy command
- for (std::vector<cmListFileFunction>::iterator i =
- listFile.Functions.begin();
- i != listFile.Functions.end(); ++i) {
- if (cmSystemTools::LowerCase(i->Name) == "cmake_minimum_required") {
+ for (cmListFileFunction const& func : listFile.Functions) {
+ if (cmSystemTools::LowerCase(func.Name) == "cmake_minimum_required") {
hasVersion = true;
break;
}
@@ -1420,10 +1406,8 @@ void cmMakefile::Configure()
allowedCommands.insert("option");
allowedCommands.insert("message");
isProblem = false;
- for (std::vector<cmListFileFunction>::iterator i =
- listFile.Functions.begin();
- i != listFile.Functions.end(); ++i) {
- std::string name = cmSystemTools::LowerCase(i->Name);
+ for (cmListFileFunction const& func : listFile.Functions) {
+ std::string name = cmSystemTools::LowerCase(func.Name);
if (allowedCommands.find(name) == allowedCommands.end()) {
isProblem = true;
break;
@@ -1442,10 +1426,8 @@ void cmMakefile::Configure()
}
bool hasProject = false;
// search for a project command
- for (std::vector<cmListFileFunction>::iterator i =
- listFile.Functions.begin();
- i != listFile.Functions.end(); ++i) {
- if (cmSystemTools::LowerCase(i->Name) == "project") {
+ for (cmListFileFunction const& func : listFile.Functions) {
+ if (cmSystemTools::LowerCase(func.Name) == "project") {
hasProject = true;
break;
}
@@ -1577,9 +1559,8 @@ std::vector<cmTarget*> cmMakefile::GetImportedTargets() const
{
std::vector<cmTarget*> tgts;
tgts.reserve(this->ImportedTargets.size());
- for (TargetMap::const_iterator it = this->ImportedTargets.begin();
- it != this->ImportedTargets.end(); ++it) {
- tgts.push_back(it->second);
+ for (auto const& impTarget : this->ImportedTargets) {
+ tgts.push_back(impTarget.second);
}
return tgts;
}
@@ -1602,9 +1583,8 @@ void cmMakefile::AddIncludeDirectories(const std::vector<std::string>& incs,
}
// Property on each target:
- for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end();
- ++l) {
- cmTarget& t = l->second;
+ for (auto& target : this->Targets) {
+ cmTarget& t = target.second;
t.InsertInclude(entryString, lfbt, before);
}
}
@@ -1617,9 +1597,8 @@ void cmMakefile::AddSystemIncludeDirectories(const std::set<std::string>& incs)
this->SystemIncludeDirectories.insert(incs.begin(), incs.end());
- for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end();
- ++l) {
- cmTarget& t = l->second;
+ for (auto& target : this->Targets) {
+ cmTarget& t = target.second;
t.AddSystemIncludeDirectories(incs);
}
}
@@ -1788,14 +1767,13 @@ void cmMakefile::AddGlobalLinkInformation(cmTarget& target)
std::vector<std::string> linkDirs;
cmSystemTools::ExpandListArgument(linkDirsProp, linkDirs);
- for (std::vector<std::string>::iterator j = linkDirs.begin();
- j != linkDirs.end(); ++j) {
- std::string newdir = *j;
+ for (std::string const& linkDir : linkDirs) {
+ std::string newdir = linkDir;
// remove trailing slashes
- if (*j->rbegin() == '/') {
- newdir = j->substr(0, j->size() - 1);
+ if (*linkDir.rbegin() == '/') {
+ newdir = linkDir.substr(0, linkDir.size() - 1);
}
- target.AddLinkDirectory(*j);
+ target.AddLinkDirectory(linkDir);
}
}
@@ -1888,22 +1866,19 @@ cmSourceFile* cmMakefile::LinearGetSourceFileWithOutput(
// look through all the source files that have custom commands
// and see if the custom command has the passed source file as an output
- for (std::vector<cmSourceFile*>::const_iterator i =
- this->SourceFiles.begin();
- i != this->SourceFiles.end(); ++i) {
+ for (cmSourceFile* src : this->SourceFiles) {
// does this source file have a custom command?
- if ((*i)->GetCustomCommand()) {
+ if (src->GetCustomCommand()) {
// Does the output of the custom command match the source file name?
const std::vector<std::string>& outputs =
- (*i)->GetCustomCommand()->GetOutputs();
- for (std::vector<std::string>::const_iterator o = outputs.begin();
- o != outputs.end(); ++o) {
- out = *o;
+ src->GetCustomCommand()->GetOutputs();
+ for (std::string const& output : outputs) {
+ out = output;
std::string::size_type pos = out.rfind(name);
// If the output matches exactly
if (pos != std::string::npos && pos == out.size() - name.size() &&
(pos == 0 || out[pos - 1] == '/')) {
- return *i;
+ return src;
}
}
}
@@ -1936,12 +1911,10 @@ cmSourceGroup* cmMakefile::GetSourceGroup(
cmSourceGroup* sg = nullptr;
// first look for source group starting with the same as the one we want
- for (std::vector<cmSourceGroup>::const_iterator sgIt =
- this->SourceGroups.begin();
- sgIt != this->SourceGroups.end(); ++sgIt) {
- std::string sgName = sgIt->GetName();
+ for (cmSourceGroup const& srcGroup : this->SourceGroups) {
+ std::string sgName = srcGroup.GetName();
if (sgName == name[0]) {
- sg = const_cast<cmSourceGroup*>(&(*sgIt));
+ sg = const_cast<cmSourceGroup*>(&srcGroup);
break;
}
}
@@ -2042,9 +2015,8 @@ void cmMakefile::ExpandVariablesCMP0019()
}
// Also for each target's INCLUDE_DIRECTORIES property:
- for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end();
- ++l) {
- cmTarget& t = l->second;
+ for (auto& target : this->Targets) {
+ cmTarget& t = target.second;
if (t.GetType() == cmStateEnums::INTERFACE_LIBRARY ||
t.GetType() == cmStateEnums::GLOBAL_TARGET) {
continue;
@@ -2191,9 +2163,9 @@ bool cmMakefile::PlatformIsAppleIos() const
"iphonesimulator", "watchos", "watchsimulator",
};
- for (size_t i = 0; i < sizeof(embedded) / sizeof(embedded[0]); ++i) {
- if (sdkRoot.find(embedded[i]) == 0 ||
- sdkRoot.find(std::string("/") + embedded[i]) != std::string::npos) {
+ for (std::string const& i : embedded) {
+ if (sdkRoot.find(i) == 0 ||
+ sdkRoot.find(std::string("/") + i) != std::string::npos) {
return true;
}
}
@@ -2949,23 +2921,22 @@ bool cmMakefile::ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
if (!filename) {
filename = efp.c_str();
}
- std::vector<cmListFileArgument>::const_iterator i;
std::string value;
outArgs.reserve(inArgs.size());
- for (i = inArgs.begin(); i != inArgs.end(); ++i) {
+ for (cmListFileArgument const& i : inArgs) {
// No expansion in a bracket argument.
- if (i->Delim == cmListFileArgument::Bracket) {
- outArgs.push_back(i->Value);
+ if (i.Delim == cmListFileArgument::Bracket) {
+ outArgs.push_back(i.Value);
continue;
}
// Expand the variables in the argument.
- value = i->Value;
- this->ExpandVariablesInString(value, false, false, false, filename,
- i->Line, false, false);
+ value = i.Value;
+ this->ExpandVariablesInString(value, false, false, false, filename, i.Line,
+ false, false);
// If the argument is quoted, it should be one argument.
// Otherwise, it may be a list of arguments.
- if (i->Delim == cmListFileArgument::Quoted) {
+ if (i.Delim == cmListFileArgument::Quoted) {
outArgs.push_back(value);
} else {
cmSystemTools::ExpandListArgument(value, outArgs);
@@ -2982,29 +2953,28 @@ bool cmMakefile::ExpandArguments(
if (!filename) {
filename = efp.c_str();
}
- std::vector<cmListFileArgument>::const_iterator i;
std::string value;
outArgs.reserve(inArgs.size());
- for (i = inArgs.begin(); i != inArgs.end(); ++i) {
+ for (cmListFileArgument const& i : inArgs) {
// No expansion in a bracket argument.
- if (i->Delim == cmListFileArgument::Bracket) {
- outArgs.push_back(cmExpandedCommandArgument(i->Value, true));
+ if (i.Delim == cmListFileArgument::Bracket) {
+ outArgs.push_back(cmExpandedCommandArgument(i.Value, true));
continue;
}
// Expand the variables in the argument.
- value = i->Value;
- this->ExpandVariablesInString(value, false, false, false, filename,
- i->Line, false, false);
+ value = i.Value;
+ this->ExpandVariablesInString(value, false, false, false, filename, i.Line,
+ false, false);
// If the argument is quoted, it should be one argument.
// Otherwise, it may be a list of arguments.
- if (i->Delim == cmListFileArgument::Quoted) {
+ if (i.Delim == cmListFileArgument::Quoted) {
outArgs.push_back(cmExpandedCommandArgument(value, true));
} else {
std::vector<std::string> stringArgs;
cmSystemTools::ExpandListArgument(value, stringArgs);
- for (size_t j = 0; j < stringArgs.size(); ++j) {
- outArgs.push_back(cmExpandedCommandArgument(stringArgs[j], false));
+ for (std::string const& stringArg : stringArgs) {
+ outArgs.push_back(cmExpandedCommandArgument(stringArg, false));
}
}
}
@@ -3094,10 +3064,7 @@ void cmMakefile::SetArgcArgv(const std::vector<std::string>& args)
cmSourceFile* cmMakefile::GetSource(const std::string& sourceName) const
{
cmSourceFileLocation sfl(this, sourceName);
- for (std::vector<cmSourceFile*>::const_iterator sfi =
- this->SourceFiles.begin();
- sfi != this->SourceFiles.end(); ++sfi) {
- cmSourceFile* sf = *sfi;
+ for (cmSourceFile* sf : this->SourceFiles) {
if (sf->Matches(sfl)) {
return sf;
}
@@ -3148,12 +3115,11 @@ void cmMakefile::EnableLanguage(std::vector<std::string> const& lang,
std::vector<std::string> langs;
std::vector<std::string> langsRC;
langs.reserve(lang.size());
- for (std::vector<std::string>::const_iterator i = lang.begin();
- i != lang.end(); ++i) {
- if (*i == "RC") {
- langsRC.push_back(*i);
+ for (std::string const& i : lang) {
+ if (i == "RC") {
+ langsRC.push_back(i);
} else {
- langs.push_back(*i);
+ langs.push_back(i);
}
}
if (!langs.empty()) {
@@ -3347,9 +3313,7 @@ std::string cmMakefile::GetModulesFile(const char* filename) const
cmSystemTools::ExpandListArgument(cmakeModulePath, modulePath);
// Look through the possible module directories.
- for (std::vector<std::string>::iterator i = modulePath.begin();
- i != modulePath.end(); ++i) {
- std::string itempl = *i;
+ for (std::string itempl : modulePath) {
cmSystemTools::ConvertToUnixSlashes(itempl);
itempl += "/";
itempl += filename;
@@ -3639,14 +3603,13 @@ void cmMakefile::AddCMakeDependFilesFromUser()
if (const char* deps_str = this->GetProperty("CMAKE_CONFIGURE_DEPENDS")) {
cmSystemTools::ExpandListArgument(deps_str, deps);
}
- for (std::vector<std::string>::iterator i = deps.begin(); i != deps.end();
- ++i) {
- if (cmSystemTools::FileIsFullPath(i->c_str())) {
- this->AddCMakeDependFile(*i);
+ for (std::string const& dep : deps) {
+ if (cmSystemTools::FileIsFullPath(dep.c_str())) {
+ this->AddCMakeDependFile(dep);
} else {
std::string f = this->GetCurrentSourceDirectory();
f += "/";
- f += *i;
+ f += dep;
this->AddCMakeDependFile(f);
}
}
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index b9b3c2f..e1745bd 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -256,11 +256,10 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
// Expand placeholders in the commands.
rulePlaceholderExpander->SetTargetImpLib(targetOutputReal);
- for (std::vector<std::string>::iterator i = real_link_commands.begin();
- i != real_link_commands.end(); ++i) {
- *i = launcher + *i;
- rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, *i,
- vars);
+ for (std::string& real_link_command : real_link_commands) {
+ real_link_command = launcher + real_link_command;
+ rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator,
+ real_link_command, vars);
}
// Restore path conversion to normal shells.
@@ -638,11 +637,10 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Expand placeholders in the commands.
rulePlaceholderExpander->SetTargetImpLib(targetOutPathImport);
- for (std::vector<std::string>::iterator i = real_link_commands.begin();
- i != real_link_commands.end(); ++i) {
- *i = launcher + *i;
- rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, *i,
- vars);
+ for (std::string& real_link_command : real_link_commands) {
+ real_link_command = launcher + real_link_command;
+ rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator,
+ real_link_command, vars);
}
// Restore path conversion to normal shells.
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 2faef67..34c285c 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -419,11 +419,10 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules(
cmSystemTools::ExpandListArgument(linkRule, real_link_commands);
// Expand placeholders.
- for (std::vector<std::string>::iterator i = real_link_commands.begin();
- i != real_link_commands.end(); ++i) {
- *i = launcher + *i;
- rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, *i,
- vars);
+ for (std::string& real_link_command : real_link_commands) {
+ real_link_command = launcher + real_link_command;
+ rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator,
+ real_link_command, vars);
}
// Restore path conversion to normal shells.
this->LocalGenerator->SetLinkScriptShell(false);
@@ -897,10 +896,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
std::vector<std::string>::iterator osi = object_strings.begin();
{
vars.Objects = osi->c_str();
- for (std::vector<std::string>::const_iterator i =
- archiveCreateCommands.begin();
- i != archiveCreateCommands.end(); ++i) {
- std::string cmd = launcher + *i;
+ for (std::string const& acc : archiveCreateCommands) {
+ std::string cmd = launcher + acc;
rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator,
cmd, vars);
real_link_commands.push_back(cmd);
@@ -909,10 +906,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
// Append to the archive with the other object sets.
for (++osi; osi != object_strings.end(); ++osi) {
vars.Objects = osi->c_str();
- for (std::vector<std::string>::const_iterator i =
- archiveAppendCommands.begin();
- i != archiveAppendCommands.end(); ++i) {
- std::string cmd = launcher + *i;
+ for (std::string const& aac : archiveAppendCommands) {
+ std::string cmd = launcher + aac;
rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator,
cmd, vars);
real_link_commands.push_back(cmd);
@@ -920,10 +915,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
}
// Finish the archive.
vars.Objects = "";
- for (std::vector<std::string>::const_iterator i =
- archiveFinishCommands.begin();
- i != archiveFinishCommands.end(); ++i) {
- std::string cmd = launcher + *i;
+ for (std::string const& afc : archiveFinishCommands) {
+ std::string cmd = launcher + afc;
rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, cmd,
vars);
// If there is no ranlib the command will be ":". Skip it.
@@ -945,11 +938,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
}
// Expand placeholders.
- for (std::vector<std::string>::iterator i = real_link_commands.begin();
- i != real_link_commands.end(); ++i) {
- *i = launcher + *i;
- rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, *i,
- vars);
+ for (std::string& real_link_command : real_link_commands) {
+ real_link_command = launcher + real_link_command;
+ rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator,
+ real_link_command, vars);
}
}
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index c1cf103..2acd57a 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -153,18 +153,16 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
this->GeneratorTarget->GetCustomCommands(customCommands, config);
std::string currentBinDir =
this->LocalGenerator->GetCurrentBinaryDirectory();
- for (std::vector<cmSourceFile const*>::const_iterator si =
- customCommands.begin();
- si != customCommands.end(); ++si) {
- cmCustomCommandGenerator ccg(*(*si)->GetCustomCommand(), this->ConfigName,
+ for (cmSourceFile const* sf : customCommands) {
+ cmCustomCommandGenerator ccg(*sf->GetCustomCommand(), this->ConfigName,
this->LocalGenerator);
this->GenerateCustomRuleFile(ccg);
if (clean) {
const std::vector<std::string>& outputs = ccg.GetOutputs();
- for (std::vector<std::string>::const_iterator o = outputs.begin();
- o != outputs.end(); ++o) {
+ for (std::string const& output : outputs) {
this->CleanFiles.push_back(
- this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir, *o));
+ this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir,
+ output));
}
}
}
@@ -178,18 +176,14 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
extraSources, this->MacOSXContentGenerator);
std::vector<cmSourceFile const*> externalObjects;
this->GeneratorTarget->GetExternalObjects(externalObjects, config);
- for (std::vector<cmSourceFile const*>::const_iterator si =
- externalObjects.begin();
- si != externalObjects.end(); ++si) {
- this->ExternalObjects.push_back((*si)->GetFullPath());
+ for (cmSourceFile const* sf : externalObjects) {
+ this->ExternalObjects.push_back(sf->GetFullPath());
}
std::vector<cmSourceFile const*> objectSources;
this->GeneratorTarget->GetObjectSources(objectSources, config);
- for (std::vector<cmSourceFile const*>::const_iterator si =
- objectSources.begin();
- si != objectSources.end(); ++si) {
+ for (cmSourceFile const* sf : objectSources) {
// Generate this object file's rule file.
- this->WriteObjectRuleFiles(**si);
+ this->WriteObjectRuleFiles(*sf);
}
}
@@ -272,28 +266,26 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
// put the compiler in the rules.make file so that if it changes
// things rebuild
- for (std::set<std::string>::const_iterator l = languages.begin();
- l != languages.end(); ++l) {
+ for (std::string const& language : languages) {
std::string compiler = "CMAKE_";
- compiler += *l;
+ compiler += language;
compiler += "_COMPILER";
- *this->FlagFileStream << "# compile " << *l << " with "
+ *this->FlagFileStream << "# compile " << language << " with "
<< this->Makefile->GetSafeDefinition(compiler)
<< "\n";
}
- for (std::set<std::string>::const_iterator l = languages.begin();
- l != languages.end(); ++l) {
- std::string flags = this->GetFlags(*l);
- std::string defines = this->GetDefines(*l);
- std::string includes = this->GetIncludes(*l);
+ for (std::string const& language : languages) {
+ std::string flags = this->GetFlags(language);
+ std::string defines = this->GetDefines(language);
+ std::string includes = this->GetIncludes(language);
// Escape comment characters so they do not terminate assignment.
cmSystemTools::ReplaceString(flags, "#", "\\#");
cmSystemTools::ReplaceString(defines, "#", "\\#");
cmSystemTools::ReplaceString(includes, "#", "\\#");
- *this->FlagFileStream << *l << "_FLAGS = " << flags << "\n\n";
- *this->FlagFileStream << *l << "_DEFINES = " << defines << "\n\n";
- *this->FlagFileStream << *l << "_INCLUDES = " << includes << "\n\n";
+ *this->FlagFileStream << language << "_FLAGS = " << flags << "\n\n";
+ *this->FlagFileStream << language << "_DEFINES = " << defines << "\n\n";
+ *this->FlagFileStream << language << "_INCLUDES = " << includes << "\n\n";
}
}
@@ -673,10 +665,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
if (clauncher && *clauncher) {
std::vector<std::string> launcher_cmd;
cmSystemTools::ExpandListArgument(clauncher, launcher_cmd, true);
- for (std::vector<std::string>::iterator i = launcher_cmd.begin(),
- e = launcher_cmd.end();
- i != e; ++i) {
- *i = this->LocalGenerator->EscapeForShell(*i);
+ for (std::string& i : launcher_cmd) {
+ i = this->LocalGenerator->EscapeForShell(i);
}
std::string const& run_launcher = cmJoin(launcher_cmd, " ") + " ";
compileCommands.front().insert(0, run_launcher);
@@ -694,11 +684,10 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
}
// Expand placeholders in the commands.
- for (std::vector<std::string>::iterator i = compileCommands.begin();
- i != compileCommands.end(); ++i) {
- *i = launcher + *i;
- rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, *i,
- vars);
+ for (std::string& compileCommand : compileCommands) {
+ compileCommand = launcher + compileCommand;
+ rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator,
+ compileCommand, vars);
}
// Change the command working directory to the local build tree.
@@ -759,11 +748,10 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
vars.PreprocessedSource = shellObjI.c_str();
// Expand placeholders in the commands.
- for (std::vector<std::string>::iterator i = preprocessCommands.begin();
- i != preprocessCommands.end(); ++i) {
+ for (std::string& preprocessCommand : preprocessCommands) {
// no launcher for preprocessor commands
- rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator,
- *i, vars);
+ rulePlaceholderExpander->ExpandRuleVariables(
+ this->LocalGenerator, preprocessCommand, vars);
}
this->LocalGenerator->CreateCDCommand(
@@ -808,11 +796,10 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
vars.AssemblySource = shellObjS.c_str();
// Expand placeholders in the commands.
- for (std::vector<std::string>::iterator i = assemblyCommands.begin();
- i != assemblyCommands.end(); ++i) {
+ for (std::string& assemblyCommand : assemblyCommands) {
// no launcher for assembly commands
rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator,
- *i, vars);
+ assemblyCommand, vars);
}
this->LocalGenerator->CreateCDCommand(
@@ -880,10 +867,9 @@ void cmMakefileTargetGenerator::WriteTargetRequiresRules()
// This target drives dependency generation for all object files.
std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath();
std::string objTarget;
- for (std::vector<std::string>::const_iterator obj = this->Objects.begin();
- obj != this->Objects.end(); ++obj) {
+ for (std::string const& obj : this->Objects) {
objTarget = relPath;
- objTarget += *obj;
+ objTarget += obj;
objTarget += ".requires";
depends.push_back(objTarget);
}
@@ -1007,12 +993,10 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
<< "# Pairs of files generated by the same build rule.\n"
<< "set(CMAKE_MULTIPLE_OUTPUT_PAIRS\n";
/* clang-format on */
- for (MultipleOutputPairsType::const_iterator pi =
- this->MultipleOutputPairs.begin();
- pi != this->MultipleOutputPairs.end(); ++pi) {
+ for (auto const& pi : this->MultipleOutputPairs) {
*this->InfoFileStream
- << " " << cmOutputConverter::EscapeForCMake(pi->first) << " "
- << cmOutputConverter::EscapeForCMake(pi->second) << "\n";
+ << " " << cmOutputConverter::EscapeForCMake(pi.first) << " "
+ << cmOutputConverter::EscapeForCMake(pi.second) << "\n";
}
*this->InfoFileStream << " )\n\n";
}
@@ -1026,9 +1010,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
<< "set(CMAKE_TARGET_LINKED_INFO_FILES\n";
/* clang-format on */
std::vector<std::string> dirs = this->GetLinkedTargetDirectories();
- for (std::vector<std::string>::iterator i = dirs.begin(); i != dirs.end();
- ++i) {
- *this->InfoFileStream << " \"" << *i << "/DependInfo.cmake\"\n";
+ for (std::string const& d : dirs) {
+ *this->InfoFileStream << " \"" << d << "/DependInfo.cmake\"\n";
}
*this->InfoFileStream << " )\n";
}
@@ -1126,9 +1109,8 @@ void cmMakefileTargetGenerator::DriveCustomCommands(
std::vector<cmSourceFile*> sources;
this->GeneratorTarget->GetSourceFiles(
sources, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
- for (std::vector<cmSourceFile*>::const_iterator source = sources.begin();
- source != sources.end(); ++source) {
- if (cmCustomCommand* cc = (*source)->GetCustomCommand()) {
+ for (cmSourceFile* source : sources) {
+ if (cmCustomCommand* cc = source->GetCustomCommand()) {
cmCustomCommandGenerator ccg(*cc, this->ConfigName,
this->LocalGenerator);
const std::vector<std::string>& outputs = ccg.GetOutputs();
@@ -1187,12 +1169,10 @@ void cmMakefileTargetGenerator::GenerateCustomRuleFile(
}
// Setup implicit dependency scanning.
- for (cmCustomCommand::ImplicitDependsList::const_iterator idi =
- ccg.GetCC().GetImplicitDepends().begin();
- idi != ccg.GetCC().GetImplicitDepends().end(); ++idi) {
+ for (auto const& idi : ccg.GetCC().GetImplicitDepends()) {
std::string objFullPath = cmSystemTools::CollapseFullPath(outputs[0]);
- std::string srcFullPath = cmSystemTools::CollapseFullPath(idi->second);
- this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, idi->first,
+ std::string srcFullPath = cmSystemTools::CollapseFullPath(idi.second);
+ this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, idi.first,
objFullPath.c_str(),
srcFullPath.c_str());
}
@@ -1225,11 +1205,10 @@ void cmMakefileTargetGenerator::WriteObjectsVariable(
if (!lineContinue) {
lineContinue = "\\";
}
- for (std::vector<std::string>::const_iterator i = this->Objects.begin();
- i != this->Objects.end(); ++i) {
+ for (std::string const& obj : this->Objects) {
*this->BuildFileStream << " " << lineContinue << "\n";
*this->BuildFileStream << this->LocalGenerator->ConvertToQuotedOutputPath(
- i->c_str(), useWatcomQuote);
+ obj.c_str(), useWatcomQuote);
}
*this->BuildFileStream << "\n";
@@ -1246,14 +1225,12 @@ void cmMakefileTargetGenerator::WriteObjectsVariable(
/* clang-format on */
std::string currentBinDir =
this->LocalGenerator->GetCurrentBinaryDirectory();
- for (std::vector<std::string>::const_iterator i =
- this->ExternalObjects.begin();
- i != this->ExternalObjects.end(); ++i) {
+ for (std::string const& obj : this->ExternalObjects) {
object =
- this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir, *i);
+ this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir, obj);
*this->BuildFileStream << " " << lineContinue << "\n";
*this->BuildFileStream << this->LocalGenerator->ConvertToQuotedOutputPath(
- i->c_str(), useWatcomQuote);
+ obj.c_str(), useWatcomQuote);
}
*this->BuildFileStream << "\n"
<< "\n";
@@ -1323,14 +1300,11 @@ void cmMakefileTargetGenerator::WriteObjectsStrings(
cmMakefileTargetGeneratorObjectStrings helper(
objStrings, this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory(), limit);
- for (std::vector<std::string>::const_iterator i = this->Objects.begin();
- i != this->Objects.end(); ++i) {
- helper.Feed(*i);
+ for (std::string const& obj : this->Objects) {
+ helper.Feed(obj);
}
- for (std::vector<std::string>::const_iterator i =
- this->ExternalObjects.begin();
- i != this->ExternalObjects.end(); ++i) {
- helper.Feed(*i);
+ for (std::string const& obj : this->ExternalObjects) {
+ helper.Feed(obj);
}
helper.Done();
}
@@ -1398,10 +1372,9 @@ void cmMakefileTargetGenerator::AppendObjectDepends(
// Add dependencies on the compiled object files.
std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath();
std::string objTarget;
- for (std::vector<std::string>::const_iterator obj = this->Objects.begin();
- obj != this->Objects.end(); ++obj) {
+ for (std::string const& obj : this->Objects) {
objTarget = relPath;
- objTarget += *obj;
+ objTarget += obj;
depends.push_back(objTarget);
}
@@ -1426,19 +1399,16 @@ void cmMakefileTargetGenerator::AppendLinkDepends(
if (cmGeneratorTarget::ModuleDefinitionInfo const* mdi =
this->GeneratorTarget->GetModuleDefinitionInfo(
this->GetConfigName())) {
- for (std::vector<cmSourceFile const*>::const_iterator i =
- mdi->Sources.begin();
- i != mdi->Sources.end(); ++i) {
- depends.push_back((*i)->GetFullPath());
+ for (cmSourceFile const* src : mdi->Sources) {
+ depends.push_back(src->GetFullPath());
}
}
// Add a dependency on user-specified manifest files, if any.
std::vector<cmSourceFile const*> manifest_srcs;
this->GeneratorTarget->GetManifests(manifest_srcs, this->ConfigName);
- for (std::vector<cmSourceFile const*>::iterator mi = manifest_srcs.begin();
- mi != manifest_srcs.end(); ++mi) {
- depends.push_back((*mi)->GetFullPath());
+ for (cmSourceFile const* manifest_src : manifest_srcs) {
+ depends.push_back(manifest_src->GetFullPath());
}
// Add user-specified dependencies.
@@ -1481,12 +1451,11 @@ void cmMakefileTargetGenerator::CreateLinkScript(
linkScriptName += name;
cmGeneratedFileStream linkScriptStream(linkScriptName.c_str());
linkScriptStream.SetCopyIfDifferent(true);
- for (std::vector<std::string>::const_iterator cmd = link_commands.begin();
- cmd != link_commands.end(); ++cmd) {
+ for (std::string const& link_command : link_commands) {
// Do not write out empty commands or commands beginning in the
// shell no-op ":".
- if (!cmd->empty() && (*cmd)[0] != ':') {
- linkScriptStream << *cmd << "\n";
+ if (!link_command.empty() && link_command[0] != ':') {
+ linkScriptStream << link_command << "\n";
}
}
@@ -1521,14 +1490,11 @@ bool cmMakefileTargetGenerator::CheckUseResponseFileForObjects(
// actual list will likely be much shorter than this. However, in the
// worst case all objects will remain as absolute paths.
size_t length = 0;
- for (std::vector<std::string>::const_iterator i = this->Objects.begin();
- i != this->Objects.end(); ++i) {
- length += i->size() + 3;
+ for (std::string const& obj : this->Objects) {
+ length += obj.size() + 3;
}
- for (std::vector<std::string>::const_iterator i =
- this->ExternalObjects.begin();
- i != this->ExternalObjects.end(); ++i) {
- length += i->size() + 3;
+ for (std::string const& ext_obj : this->ExternalObjects) {
+ length += ext_obj.size() + 3;
}
// We need to guarantee room for both objects and libraries, so
@@ -1751,22 +1717,17 @@ void cmMakefileTargetGenerator::GenDefFile(
cmGeneratedFileStream fout(objlist_file.c_str());
if (mdi->WindowsExportAllSymbols) {
- for (std::vector<std::string>::const_iterator i = this->Objects.begin();
- i != this->Objects.end(); ++i) {
- if (cmHasLiteralSuffix(*i, ".obj")) {
- fout << *i << "\n";
+ for (std::string const& obj : this->Objects) {
+ if (cmHasLiteralSuffix(obj, ".obj")) {
+ fout << obj << "\n";
}
}
- for (std::vector<std::string>::const_iterator i =
- this->ExternalObjects.begin();
- i != this->ExternalObjects.end(); ++i) {
- fout << *i << "\n";
+ for (std::string const& obj : this->ExternalObjects) {
+ fout << obj << "\n";
}
}
- for (std::vector<cmSourceFile const*>::const_iterator i =
- mdi->Sources.begin();
- i != mdi->Sources.end(); ++i) {
- fout << (*i)->GetFullPath() << "\n";
+ for (cmSourceFile const* src : mdi->Sources) {
+ fout << src->GetFullPath() << "\n";
}
}
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index ddac20e..32377f8 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -10,7 +10,6 @@
#include <sstream>
#include "cmAlgorithms.h"
-#include "cmCustomCommand.h"
#include "cmCustomCommandGenerator.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
@@ -33,6 +32,8 @@
#include "cm_auto_ptr.hxx"
#include "cmake.h"
+class cmCustomCommand;
+
cmNinjaNormalTargetGenerator::cmNinjaNormalTargetGenerator(
cmGeneratorTarget* target)
: cmNinjaTargetGenerator(target)
@@ -112,17 +113,14 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules()
std::vector<cmSourceFile const*> sourceFiles;
this->GetGeneratorTarget()->GetObjectSources(
sourceFiles, this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
- for (std::vector<cmSourceFile const*>::const_iterator i =
- sourceFiles.begin();
- i != sourceFiles.end(); ++i) {
- const std::string& lang = (*i)->GetLanguage();
+ for (cmSourceFile const* sf : sourceFiles) {
+ std::string const lang = sf->GetLanguage();
if (!lang.empty()) {
languages.insert(lang);
}
}
- for (std::set<std::string>::const_iterator l = languages.begin();
- l != languages.end(); ++l) {
- this->WriteLanguageRules(*l);
+ for (std::string const& language : languages) {
+ this->WriteLanguageRules(language);
}
}
@@ -248,11 +246,10 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRule(bool useResponseFile)
// Rule for linking library/executable.
std::vector<std::string> linkCmds = this->ComputeDeviceLinkCmd();
- for (std::vector<std::string>::iterator i = linkCmds.begin();
- i != linkCmds.end(); ++i) {
- *i = launcher + *i;
+ for (std::string& linkCmd : linkCmds) {
+ linkCmd = launcher + linkCmd;
rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(),
- *i, vars);
+ linkCmd, vars);
}
// If there is no ranlib the command will be ":". Skip it.
@@ -373,11 +370,10 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
// Rule for linking library/executable.
std::vector<std::string> linkCmds = this->ComputeLinkCmd();
- for (std::vector<std::string>::iterator i = linkCmds.begin();
- i != linkCmds.end(); ++i) {
- *i = launcher + *i;
+ for (std::string& linkCmd : linkCmds) {
+ linkCmd = launcher + linkCmd;
rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(),
- *i, vars);
+ linkCmd, vars);
}
// If there is no ranlib the command will be ":". Skip it.
@@ -731,10 +727,8 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement()
&postBuildCmdLines };
for (unsigned i = 0; i != 3; ++i) {
- for (std::vector<cmCustomCommand>::const_iterator ci =
- cmdLists[i]->begin();
- ci != cmdLists[i]->end(); ++ci) {
- cmCustomCommandGenerator ccg(*ci, cfgName, this->GetLocalGenerator());
+ for (cmCustomCommand const& cc : *cmdLists[i]) {
+ cmCustomCommandGenerator ccg(cc, cfgName, this->GetLocalGenerator());
localGen.AppendCustomCommandLines(ccg, *cmdLineLists[i]);
std::vector<std::string> const& ccByproducts = ccg.GetByproducts();
std::transform(ccByproducts.begin(), ccByproducts.end(),
@@ -960,10 +954,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
&postBuildCmdLines };
for (unsigned i = 0; i != 3; ++i) {
- for (std::vector<cmCustomCommand>::const_iterator ci =
- cmdLists[i]->begin();
- ci != cmdLists[i]->end(); ++ci) {
- cmCustomCommandGenerator ccg(*ci, cfgName, this->GetLocalGenerator());
+ for (cmCustomCommand const& cc : *cmdLists[i]) {
+ cmCustomCommandGenerator ccg(cc, cfgName, this->GetLocalGenerator());
localGen.AppendCustomCommandLines(ccg, *cmdLineLists[i]);
std::vector<std::string> const& ccByproducts = ccg.GetByproducts();
std::transform(ccByproducts.begin(), ccByproducts.end(),
@@ -993,17 +985,15 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
if (mdi->WindowsExportAllSymbols) {
cmNinjaDeps objs = this->GetObjects();
- for (cmNinjaDeps::iterator i = objs.begin(); i != objs.end(); ++i) {
- if (cmHasLiteralSuffix(*i, ".obj")) {
- fout << *i << "\n";
+ for (std::string const& obj : objs) {
+ if (cmHasLiteralSuffix(obj, ".obj")) {
+ fout << obj << "\n";
}
}
}
- for (std::vector<cmSourceFile const*>::const_iterator i =
- mdi->Sources.begin();
- i != mdi->Sources.end(); ++i) {
- fout << (*i)->GetFullPath() << "\n";
+ for (cmSourceFile const* src : mdi->Sources) {
+ fout << src->GetFullPath() << "\n";
}
}
// If we have any PRE_LINK commands, we need to go back to CMAKE_BINARY_DIR
@@ -1050,11 +1040,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
// Ninja should restat after linking if and only if there are byproducts.
vars["RESTAT"] = byproducts.empty() ? "" : "1";
- for (cmNinjaDeps::const_iterator oi = byproducts.begin(),
- oe = byproducts.end();
- oi != oe; ++oi) {
- this->GetGlobalGenerator()->SeenCustomCommandOutput(*oi);
- outputs.push_back(*oi);
+ for (std::string const& o : byproducts) {
+ this->GetGlobalGenerator()->SeenCustomCommandOutput(o);
+ outputs.push_back(o);
}
// Write the build statement for this target.
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index b08c19b..3760fc1 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -215,19 +215,16 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const
if (cmGeneratorTarget::ModuleDefinitionInfo const* mdi =
this->GeneratorTarget->GetModuleDefinitionInfo(
this->GetConfigName())) {
- for (std::vector<cmSourceFile const*>::const_iterator i =
- mdi->Sources.begin();
- i != mdi->Sources.end(); ++i) {
- result.push_back(this->ConvertToNinjaPath((*i)->GetFullPath()));
+ for (cmSourceFile const* src : mdi->Sources) {
+ result.push_back(this->ConvertToNinjaPath(src->GetFullPath()));
}
}
// Add a dependency on user-specified manifest files, if any.
std::vector<cmSourceFile const*> manifest_srcs;
this->GeneratorTarget->GetManifests(manifest_srcs, this->ConfigName);
- for (std::vector<cmSourceFile const*>::iterator mi = manifest_srcs.begin();
- mi != manifest_srcs.end(); ++mi) {
- result.push_back(this->ConvertToNinjaPath((*mi)->GetFullPath()));
+ for (cmSourceFile const* manifest_src : manifest_srcs) {
+ result.push_back(this->ConvertToNinjaPath(manifest_src->GetFullPath()));
}
// Add user-specified dependencies.
@@ -519,11 +516,10 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
std::vector<std::string> ppCmds;
cmSystemTools::ExpandListArgument(ppCmd, ppCmds);
- for (std::vector<std::string>::iterator i = ppCmds.begin();
- i != ppCmds.end(); ++i) {
- *i = launcher + *i;
+ for (std::string& i : ppCmds) {
+ i = launcher + i;
rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(),
- *i, ppVars);
+ i, ppVars);
}
// Run CMake dependency scanner on preprocessed output.
@@ -657,10 +653,8 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
if (clauncher && *clauncher) {
std::vector<std::string> launcher_cmd;
cmSystemTools::ExpandListArgument(clauncher, launcher_cmd, true);
- for (std::vector<std::string>::iterator i = launcher_cmd.begin(),
- e = launcher_cmd.end();
- i != e; ++i) {
- *i = this->LocalGenerator->EscapeForShell(*i);
+ for (std::string& i : launcher_cmd) {
+ i = this->LocalGenerator->EscapeForShell(i);
}
std::string const& run_launcher = cmJoin(launcher_cmd, " ") + " ";
compileCmds.front().insert(0, run_launcher);
@@ -671,10 +665,9 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
compileCmds.front().insert(0, cldeps);
}
- for (std::vector<std::string>::iterator i = compileCmds.begin();
- i != compileCmds.end(); ++i) {
- *i = launcher + *i;
- rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), *i,
+ for (std::string& i : compileCmds) {
+ i = launcher + i;
+ rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), i,
vars);
}
@@ -705,10 +698,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements()
std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
std::vector<cmSourceFile const*> customCommands;
this->GeneratorTarget->GetCustomCommands(customCommands, config);
- for (std::vector<cmSourceFile const*>::const_iterator si =
- customCommands.begin();
- si != customCommands.end(); ++si) {
- cmCustomCommand const* cc = (*si)->GetCustomCommand();
+ for (cmSourceFile const* sf : customCommands) {
+ cmCustomCommand const* cc = sf->GetCustomCommand();
this->GetLocalGenerator()->AddCustomCommandTarget(
cc, this->GetGeneratorTarget());
// Record the custom commands for this target. The container is used
@@ -725,10 +716,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements()
extraSources, this->MacOSXContentGenerator);
std::vector<cmSourceFile const*> externalObjects;
this->GeneratorTarget->GetExternalObjects(externalObjects, config);
- for (std::vector<cmSourceFile const*>::const_iterator si =
- externalObjects.begin();
- si != externalObjects.end(); ++si) {
- this->Objects.push_back(this->GetSourceFilePath(*si));
+ for (cmSourceFile const* sf : externalObjects) {
+ this->Objects.push_back(this->GetSourceFilePath(sf));
}
cmNinjaDeps orderOnlyDeps;
@@ -740,10 +729,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements()
this->ExtraFiles.end());
// Add order-only dependencies on custom command outputs.
- for (std::vector<cmCustomCommand const*>::const_iterator cci =
- this->CustomCommands.begin();
- cci != this->CustomCommands.end(); ++cci) {
- cmCustomCommand const* cc = *cci;
+ for (cmCustomCommand const* cc : this->CustomCommands) {
cmCustomCommandGenerator ccg(*cc, this->GetConfigName(),
this->GetLocalGenerator());
const std::vector<std::string>& ccoutputs = ccg.GetOutputs();
@@ -768,10 +754,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements()
}
std::vector<cmSourceFile const*> objectSources;
this->GeneratorTarget->GetObjectSources(objectSources, config);
- for (std::vector<cmSourceFile const*>::const_iterator si =
- objectSources.begin();
- si != objectSources.end(); ++si) {
- this->WriteObjectBuildStatement(*si);
+ for (cmSourceFile const* sf : objectSources) {
+ this->WriteObjectBuildStatement(sf);
}
if (!this->DDIFiles.empty()) {
@@ -848,10 +832,9 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
if (const char* objectDeps = source->GetProperty("OBJECT_DEPENDS")) {
std::vector<std::string> depList;
cmSystemTools::ExpandListArgument(objectDeps, depList);
- for (std::vector<std::string>::iterator odi = depList.begin();
- odi != depList.end(); ++odi) {
- if (cmSystemTools::FileIsFullPath(*odi)) {
- *odi = cmSystemTools::CollapseFullPath(*odi);
+ for (std::string& odi : depList) {
+ if (cmSystemTools::FileIsFullPath(odi)) {
+ odi = cmSystemTools::CollapseFullPath(odi);
}
}
std::transform(depList.begin(), depList.end(),
@@ -1019,19 +1002,17 @@ void cmNinjaTargetGenerator::WriteTargetDependInfo(std::string const& lang)
std::vector<std::string> includes;
this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget,
lang, this->GetConfigName());
- for (std::vector<std::string>::iterator i = includes.begin();
- i != includes.end(); ++i) {
+ for (std::string const& i : includes) {
// Convert the include directories the same way we do for -I flags.
// See upstream ninja issue 1251.
- tdi_include_dirs.append(this->ConvertToNinjaPath(*i));
+ tdi_include_dirs.append(this->ConvertToNinjaPath(i));
}
Json::Value& tdi_linked_target_dirs = tdi["linked-target-dirs"] =
Json::arrayValue;
std::vector<std::string> linked = this->GetLinkedTargetDirectories();
- for (std::vector<std::string>::iterator i = linked.begin();
- i != linked.end(); ++i) {
- tdi_linked_target_dirs.append(*i);
+ for (std::string const& l : linked) {
+ tdi_linked_target_dirs.append(l);
}
std::string const tdin = this->GetTargetDependInfoPath(lang);
@@ -1099,10 +1080,9 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand(
CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->GetLocalGenerator()->CreateRulePlaceholderExpander());
- for (std::vector<std::string>::iterator i = compileCmds.begin();
- i != compileCmds.end(); ++i) {
+ for (std::string& i : compileCmds) {
// no launcher for CMAKE_EXPORT_COMPILE_COMMANDS
- rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), *i,
+ rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), i,
compileObjectVars);
}
diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx
index 500ff4a..7adeb8e 100644
--- a/Source/cmNinjaUtilityTargetGenerator.cxx
+++ b/Source/cmNinjaUtilityTargetGenerator.cxx
@@ -51,17 +51,15 @@ void cmNinjaUtilityTargetGenerator::Generate()
bool uses_terminal = false;
for (unsigned i = 0; i != 2; ++i) {
- for (std::vector<cmCustomCommand>::const_iterator ci =
- cmdLists[i]->begin();
- ci != cmdLists[i]->end(); ++ci) {
- cmCustomCommandGenerator ccg(*ci, this->GetConfigName(),
+ for (cmCustomCommand const& ci : *cmdLists[i]) {
+ cmCustomCommandGenerator ccg(ci, this->GetConfigName(),
this->GetLocalGenerator());
this->GetLocalGenerator()->AppendCustomCommandDeps(ccg, deps);
this->GetLocalGenerator()->AppendCustomCommandLines(ccg, commands);
std::vector<std::string> const& ccByproducts = ccg.GetByproducts();
std::transform(ccByproducts.begin(), ccByproducts.end(),
std::back_inserter(util_outputs), MapToNinjaPath());
- if (ci->GetUsesTerminal()) {
+ if (ci.GetUsesTerminal()) {
uses_terminal = true;
}
}
@@ -71,9 +69,8 @@ void cmNinjaUtilityTargetGenerator::Generate()
std::string config =
this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
this->GetGeneratorTarget()->GetSourceFiles(sources, config);
- for (std::vector<cmSourceFile*>::const_iterator source = sources.begin();
- source != sources.end(); ++source) {
- if (cmCustomCommand* cc = (*source)->GetCustomCommand()) {
+ for (cmSourceFile const* source : sources) {
+ if (cmCustomCommand const* cc = source->GetCustomCommand()) {
cmCustomCommandGenerator ccg(*cc, this->GetConfigName(),
this->GetLocalGenerator());
this->GetLocalGenerator()->AddCustomCommandTarget(
@@ -132,10 +129,8 @@ void cmNinjaUtilityTargetGenerator::Generate()
return;
}
- for (cmNinjaDeps::const_iterator oi = util_outputs.begin(),
- oe = util_outputs.end();
- oi != oe; ++oi) {
- this->GetGlobalGenerator()->SeenCustomCommandOutput(*oi);
+ for (std::string const& util_output : util_outputs) {
+ this->GetGlobalGenerator()->SeenCustomCommandOutput(util_output);
}
this->GetGlobalGenerator()->WriteCustomCommandBuild(
diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx
index 847e3f2..c85c82d 100644
--- a/Source/cmOSXBundleGenerator.cxx
+++ b/Source/cmOSXBundleGenerator.cxx
@@ -195,12 +195,11 @@ void cmOSXBundleGenerator::GenerateMacOSXContentStatements(
return;
}
- for (std::vector<cmSourceFile const*>::const_iterator si = sources.begin();
- si != sources.end(); ++si) {
+ for (cmSourceFile const* source : sources) {
cmGeneratorTarget::SourceFileFlags tsFlags =
- this->GT->GetTargetSourceFileFlags(*si);
+ this->GT->GetTargetSourceFileFlags(source);
if (tsFlags.Type != cmGeneratorTarget::SourceFileTypeNormal) {
- (*generator)(**si, tsFlags.MacFolder);
+ (*generator)(*source, tsFlags.MacFolder);
}
}
}
diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx
index 333e313..1ee0578 100644
--- a/Source/cmOrderDirectories.cxx
+++ b/Source/cmOrderDirectories.cxx
@@ -75,9 +75,8 @@ public:
void FindImplicitConflicts(std::ostringstream& w)
{
bool first = true;
- for (unsigned int i = 0; i < this->OD->OriginalDirectories.size(); ++i) {
+ for (std::string const& dir : this->OD->OriginalDirectories) {
// Check if this directory conflicts with the entry.
- std::string const& dir = this->OD->OriginalDirectories[i];
if (dir != this->Directory &&
cmSystemTools::GetRealPath(dir) !=
cmSystemTools::GetRealPath(this->Directory) &&
@@ -226,12 +225,10 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir)
this->OD->RemoveLibraryExtension.find(this->FileName)) {
std::string lib = this->OD->RemoveLibraryExtension.match(1);
std::string ext = this->OD->RemoveLibraryExtension.match(2);
- for (std::vector<std::string>::iterator i =
- this->OD->LinkExtensions.begin();
- i != this->OD->LinkExtensions.end(); ++i) {
- if (*i != ext) {
+ for (std::string const& LinkExtension : this->OD->LinkExtensions) {
+ if (LinkExtension != ext) {
std::string fname = lib;
- fname += *i;
+ fname += LinkExtension;
if (this->FileMayConflict(dir, fname)) {
return true;
}
@@ -346,9 +343,8 @@ void cmOrderDirectories::SetImplicitDirectories(
std::set<std::string> const& implicitDirs)
{
this->ImplicitDirectories.clear();
- for (std::set<std::string>::const_iterator i = implicitDirs.begin();
- i != implicitDirs.end(); ++i) {
- this->ImplicitDirectories.insert(this->GetRealPath(*i));
+ for (std::string const& implicitDir : implicitDirs) {
+ this->ImplicitDirectories.insert(this->GetRealPath(implicitDir));
}
}
@@ -375,8 +371,8 @@ void cmOrderDirectories::CollectOriginalDirectories()
this->AddOriginalDirectories(this->UserDirectories);
// Add directories containing constraints.
- for (unsigned int i = 0; i < this->ConstraintEntries.size(); ++i) {
- this->ConstraintEntries[i]->AddDirectory();
+ for (cmOrderDirectoriesConstraint* entry : this->ConstraintEntries) {
+ entry->AddDirectory();
}
// Add language runtime directories last.
@@ -400,20 +396,19 @@ int cmOrderDirectories::AddOriginalDirectory(std::string const& dir)
void cmOrderDirectories::AddOriginalDirectories(
std::vector<std::string> const& dirs)
{
- for (std::vector<std::string>::const_iterator di = dirs.begin();
- di != dirs.end(); ++di) {
+ for (std::string const& dir : dirs) {
// We never explicitly specify implicit link directories.
- if (this->IsImplicitDirectory(*di)) {
+ if (this->IsImplicitDirectory(dir)) {
continue;
}
// Skip the empty string.
- if (di->empty()) {
+ if (dir.empty()) {
continue;
}
// Add this directory.
- this->AddOriginalDirectory(*di);
+ this->AddOriginalDirectory(dir);
}
}
@@ -442,16 +437,15 @@ void cmOrderDirectories::FindConflicts()
}
// Clean up the conflict graph representation.
- for (std::vector<ConflictList>::iterator i = this->ConflictGraph.begin();
- i != this->ConflictGraph.end(); ++i) {
+ for (ConflictList& cl : this->ConflictGraph) {
// Sort the outgoing edges for each graph node so that the
// original order will be preserved as much as possible.
- std::sort(i->begin(), i->end());
+ std::sort(cl.begin(), cl.end());
// Make the edge list unique so cycle detection will be reliable.
ConflictList::iterator last =
- std::unique(i->begin(), i->end(), cmOrderDirectoriesCompare());
- i->erase(last, i->end());
+ std::unique(cl.begin(), cl.end(), cmOrderDirectoriesCompare());
+ cl.erase(last, cl.end());
}
// Check items in implicit link directories.
@@ -463,12 +457,12 @@ void cmOrderDirectories::FindImplicitConflicts()
// Check for items in implicit link directories that have conflicts
// in the explicit directories.
std::ostringstream conflicts;
- for (unsigned int i = 0; i < this->ImplicitDirEntries.size(); ++i) {
- this->ImplicitDirEntries[i]->FindImplicitConflicts(conflicts);
+ for (cmOrderDirectoriesConstraint* entry : this->ImplicitDirEntries) {
+ entry->FindImplicitConflicts(conflicts);
}
// Skip warning if there were no conflicts.
- std::string text = conflicts.str();
+ std::string const text = conflicts.str();
if (text.empty()) {
return;
}
@@ -515,8 +509,8 @@ void cmOrderDirectories::VisitDirectory(unsigned int i)
// Visit the neighbors of the node first.
ConflictList const& clist = this->ConflictGraph[i];
- for (ConflictList::const_iterator j = clist.begin(); j != clist.end(); ++j) {
- this->VisitDirectory(j->first);
+ for (ConflictPair const& j : clist) {
+ this->VisitDirectory(j.first);
}
// Now that all directories required to come before this one have
@@ -542,10 +536,9 @@ void cmOrderDirectories::DiagnoseCycle()
for (unsigned int i = 0; i < this->ConflictGraph.size(); ++i) {
ConflictList const& clist = this->ConflictGraph[i];
e << " dir " << i << " is [" << this->OriginalDirectories[i] << "]\n";
- for (ConflictList::const_iterator j = clist.begin(); j != clist.end();
- ++j) {
- e << " dir " << j->first << " must precede it due to ";
- this->ConstraintEntries[j->second]->Report(e);
+ for (ConflictPair const& j : clist) {
+ e << " dir " << j.first << " must precede it due to ";
+ this->ConstraintEntries[j.second]->Report(e);
e << "\n";
}
}
diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx
index f56d212..dac6569 100644
--- a/Source/cmOutputConverter.cxx
+++ b/Source/cmOutputConverter.cxx
@@ -285,12 +285,11 @@ cmOutputConverter::FortranFormat cmOutputConverter::GetFortranFormat(
if (value && *value) {
std::vector<std::string> fmt;
cmSystemTools::ExpandListArgument(value, fmt);
- for (std::vector<std::string>::iterator fi = fmt.begin(); fi != fmt.end();
- ++fi) {
- if (*fi == "FIXED") {
+ for (std::string const& fi : fmt) {
+ if (fi == "FIXED") {
format = FortranFormatFixed;
}
- if (*fi == "FREE") {
+ if (fi == "FREE") {
format = FortranFormatFree;
}
}
diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx
index 2fd266a..26816cb 100644
--- a/Source/cmOutputRequiredFilesCommand.cxx
+++ b/Source/cmOutputRequiredFilesCommand.cxx
@@ -5,7 +5,6 @@
#include "cmsys/FStream.hxx"
#include "cmsys/RegularExpression.hxx"
#include <map>
-#include <unordered_map>
#include <utility>
#include "cmAlgorithms.h"
@@ -114,8 +113,9 @@ public:
std::set<std::string> uniqueIncludes;
std::vector<std::string> orderedAndUniqueIncludes;
cmTargets& targets = this->Makefile->GetTargets();
- for (cmTargets::iterator l = targets.begin(); l != targets.end(); ++l) {
- const char* incDirProp = l->second.GetProperty("INCLUDE_DIRECTORIES");
+ for (auto const& target : targets) {
+ const char* incDirProp =
+ target.second.GetProperty("INCLUDE_DIRECTORIES");
if (!incDirProp) {
continue;
}
@@ -126,9 +126,7 @@ public:
std::vector<std::string> includes;
cmSystemTools::ExpandListArgument(incDirs, includes);
- for (std::vector<std::string>::const_iterator j = includes.begin();
- j != includes.end(); ++j) {
- std::string path = *j;
+ for (std::string& path : includes) {
this->Makefile->ExpandVariablesInString(path);
if (uniqueIncludes.insert(path).second) {
orderedAndUniqueIncludes.push_back(path);
@@ -136,10 +134,8 @@ public:
}
}
- for (std::vector<std::string>::const_iterator it =
- orderedAndUniqueIncludes.begin();
- it != orderedAndUniqueIncludes.end(); ++it) {
- this->AddSearchPath(*it);
+ for (std::string const& inc : orderedAndUniqueIncludes) {
+ this->AddSearchPath(inc);
}
}
@@ -220,10 +216,7 @@ protected:
if (cmSystemTools::FileExists(cxxFile.c_str())) {
found = true;
}
- for (std::vector<std::string>::iterator i =
- this->IncludeDirectories.begin();
- i != this->IncludeDirectories.end(); ++i) {
- std::string path = *i;
+ for (std::string path : this->IncludeDirectories) {
path = path + "/";
path = path + cxxFile;
if (cmSystemTools::FileExists(path.c_str())) {
@@ -235,10 +228,7 @@ protected:
if (cmSystemTools::FileExists(cxxFile.c_str())) {
found = true;
}
- for (std::vector<std::string>::iterator i =
- this->IncludeDirectories.begin();
- i != this->IncludeDirectories.end(); ++i) {
- std::string path = *i;
+ for (std::string path : this->IncludeDirectories) {
path = path + "/";
path = path + cxxFile;
if (cmSystemTools::FileExists(path.c_str())) {
@@ -251,10 +241,7 @@ protected:
if (cmSystemTools::FileExists(cxxFile.c_str())) {
found = true;
}
- for (std::vector<std::string>::iterator i =
- this->IncludeDirectories.begin();
- i != this->IncludeDirectories.end(); ++i) {
- std::string path = *i;
+ for (std::string path : this->IncludeDirectories) {
path = path + "/";
path = path + cxxFile;
if (cmSystemTools::FileExists(path.c_str())) {
@@ -267,10 +254,7 @@ protected:
if (cmSystemTools::FileExists(cxxFile.c_str())) {
found = true;
}
- for (std::vector<std::string>::iterator i =
- this->IncludeDirectories.begin();
- i != this->IncludeDirectories.end(); ++i) {
- std::string path = *i;
+ for (std::string path : this->IncludeDirectories) {
path = path + "/";
path = path + cxxFile;
if (cmSystemTools::FileExists(path.c_str())) {
@@ -337,10 +321,8 @@ protected:
if (!cFile.GetDepends().empty()) {
// Dependency hints have been given. Use them to begin the
// recursion.
- for (std::vector<std::string>::const_iterator file =
- cFile.GetDepends().begin();
- file != cFile.GetDepends().end(); ++file) {
- this->AddDependency(info, file->c_str());
+ for (std::string const& file : cFile.GetDepends()) {
+ this->AddDependency(info, file.c_str());
}
// Found dependency information. We are done.
@@ -357,10 +339,7 @@ protected:
found = true;
} else {
// try to guess which include path to use
- for (std::vector<std::string>::iterator t =
- this->IncludeDirectories.begin();
- t != this->IncludeDirectories.end(); ++t) {
- std::string incpath = *t;
+ for (std::string incpath : this->IncludeDirectories) {
if (!incpath.empty() && incpath[incpath.size() - 1] != '/') {
incpath = incpath + "/";
}
@@ -442,10 +421,7 @@ protected:
return fp;
}
- for (std::vector<std::string>::iterator i =
- this->IncludeDirectories.begin();
- i != this->IncludeDirectories.end(); ++i) {
- std::string path = *i;
+ for (std::string path : this->IncludeDirectories) {
if (!path.empty() && path[path.size() - 1] != '/') {
path = path + "/";
}
@@ -532,19 +508,17 @@ void cmOutputRequiredFilesCommand::ListDependencies(
// add info to the visited set
visited->insert(info);
// now recurse with info's dependencies
- for (cmDependInformation::DependencySetType::const_iterator d =
- info->DependencySet.begin();
- d != info->DependencySet.end(); ++d) {
- if (visited->find(*d) == visited->end()) {
+ for (cmDependInformation* d : info->DependencySet) {
+ if (visited->find(d) == visited->end()) {
if (info->FullPath != "") {
- std::string tmp = (*d)->FullPath;
+ std::string tmp = d->FullPath;
std::string::size_type pos = tmp.rfind('.');
if (pos != std::string::npos && (tmp.substr(pos) != ".h")) {
tmp = tmp.substr(0, pos);
- fprintf(fout, "%s\n", (*d)->FullPath.c_str());
+ fprintf(fout, "%s\n", d->FullPath.c_str());
}
}
- this->ListDependencies(*d, fout, visited);
+ this->ListDependencies(d, fout, visited);
}
}
}
diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx
index 52acd35..0922e6e 100644
--- a/Source/cmParseArgumentsCommand.cxx
+++ b/Source/cmParseArgumentsCommand.cxx
@@ -5,7 +5,6 @@
#include <map>
#include <set>
#include <sstream>
-#include <stddef.h>
#include <utility>
#include "cmAlgorithms.h"
@@ -19,11 +18,11 @@ static std::string escape_arg(const std::string& arg)
{
// replace ";" with "\;" so output argument lists will split correctly
std::string escapedArg;
- for (size_t i = 0; i < arg.size(); ++i) {
- if (arg[i] == ';') {
+ for (char i : arg) {
+ if (i == ';') {
escapedArg += '\\';
}
- escapedArg += arg[i];
+ escapedArg += i;
}
return escapedArg;
}
@@ -85,37 +84,31 @@ bool cmParseArgumentsCommand::InitialPass(std::vector<std::string> const& args,
// the second argument is a (cmake) list of options without argument
std::vector<std::string> list;
cmSystemTools::ExpandListArgument(*argIter++, list);
- for (std::vector<std::string>::const_iterator iter = list.begin(),
- end = list.end();
- iter != end; ++iter) {
- if (!used_keywords.insert(*iter).second) {
- this->GetMakefile()->IssueMessage(cmake::WARNING, dup_warning + *iter);
+ for (std::string const& iter : list) {
+ if (!used_keywords.insert(iter).second) {
+ this->GetMakefile()->IssueMessage(cmake::WARNING, dup_warning + iter);
}
- options[*iter]; // default initialize
+ options[iter]; // default initialize
}
// the third argument is a (cmake) list of single argument options
list.clear();
cmSystemTools::ExpandListArgument(*argIter++, list);
- for (std::vector<std::string>::const_iterator iter = list.begin(),
- end = list.end();
- iter != end; ++iter) {
- if (!used_keywords.insert(*iter).second) {
- this->GetMakefile()->IssueMessage(cmake::WARNING, dup_warning + *iter);
+ for (std::string const& iter : list) {
+ if (!used_keywords.insert(iter).second) {
+ this->GetMakefile()->IssueMessage(cmake::WARNING, dup_warning + iter);
}
- single[*iter]; // default initialize
+ single[iter]; // default initialize
}
// the fourth argument is a (cmake) list of multi argument options
list.clear();
cmSystemTools::ExpandListArgument(*argIter++, list);
- for (std::vector<std::string>::const_iterator iter = list.begin(),
- end = list.end();
- iter != end; ++iter) {
- if (!used_keywords.insert(*iter).second) {
- this->GetMakefile()->IssueMessage(cmake::WARNING, dup_warning + *iter);
+ for (std::string const& iter : list) {
+ if (!used_keywords.insert(iter).second) {
+ this->GetMakefile()->IssueMessage(cmake::WARNING, dup_warning + iter);
}
- multi[*iter]; // default initialize
+ multi[iter]; // default initialize
}
enum insideValues
@@ -160,46 +153,45 @@ bool cmParseArgumentsCommand::InitialPass(std::vector<std::string> const& args,
}
// iterate over the arguments list and fill in the values where applicable
- for (argIter = list.begin(), argEnd = list.end(); argIter != argEnd;
- ++argIter) {
- const options_map::iterator optIter = options.find(*argIter);
+ for (std::string const& arg : list) {
+ const options_map::iterator optIter = options.find(arg);
if (optIter != options.end()) {
insideValues = NONE;
optIter->second = true;
continue;
}
- const single_map::iterator singleIter = single.find(*argIter);
+ const single_map::iterator singleIter = single.find(arg);
if (singleIter != single.end()) {
insideValues = SINGLE;
- currentArgName = *argIter;
+ currentArgName = arg;
continue;
}
- const multi_map::iterator multiIter = multi.find(*argIter);
+ const multi_map::iterator multiIter = multi.find(arg);
if (multiIter != multi.end()) {
insideValues = MULTI;
- currentArgName = *argIter;
+ currentArgName = arg;
continue;
}
switch (insideValues) {
case SINGLE:
- single[currentArgName] = *argIter;
+ single[currentArgName] = arg;
insideValues = NONE;
break;
case MULTI:
if (parseFromArgV) {
- multi[currentArgName].push_back(escape_arg(*argIter));
+ multi[currentArgName].push_back(escape_arg(arg));
} else {
- multi[currentArgName].push_back(*argIter);
+ multi[currentArgName].push_back(arg);
}
break;
default:
if (parseFromArgV) {
- unparsed.push_back(escape_arg(*argIter));
+ unparsed.push_back(escape_arg(arg));
} else {
- unparsed.push_back(*argIter);
+ unparsed.push_back(arg);
}
break;
}
@@ -208,28 +200,24 @@ bool cmParseArgumentsCommand::InitialPass(std::vector<std::string> const& args,
// now iterate over the collected values and update their definition
// within the current scope. undefine if necessary.
- for (options_map::const_iterator iter = options.begin(), end = options.end();
- iter != end; ++iter) {
- this->Makefile->AddDefinition(prefix + iter->first,
- iter->second ? "TRUE" : "FALSE");
+ for (auto const& iter : options) {
+ this->Makefile->AddDefinition(prefix + iter.first,
+ iter.second ? "TRUE" : "FALSE");
}
- for (single_map::const_iterator iter = single.begin(), end = single.end();
- iter != end; ++iter) {
- if (!iter->second.empty()) {
- this->Makefile->AddDefinition(prefix + iter->first,
- iter->second.c_str());
+ for (auto const& iter : single) {
+ if (!iter.second.empty()) {
+ this->Makefile->AddDefinition(prefix + iter.first, iter.second.c_str());
} else {
- this->Makefile->RemoveDefinition(prefix + iter->first);
+ this->Makefile->RemoveDefinition(prefix + iter.first);
}
}
- for (multi_map::const_iterator iter = multi.begin(), end = multi.end();
- iter != end; ++iter) {
- if (!iter->second.empty()) {
+ for (auto const& iter : multi) {
+ if (!iter.second.empty()) {
this->Makefile->AddDefinition(
- prefix + iter->first, cmJoin(cmMakeRange(iter->second), ";").c_str());
+ prefix + iter.first, cmJoin(cmMakeRange(iter.second), ";").c_str());
} else {
- this->Makefile->RemoveDefinition(prefix + iter->first);
+ this->Makefile->RemoveDefinition(prefix + iter.first);
}
}
diff --git a/Source/cmPathLabel.cxx b/Source/cmPathLabel.cxx
index 30ba081..4793206 100644
--- a/Source/cmPathLabel.cxx
+++ b/Source/cmPathLabel.cxx
@@ -2,15 +2,13 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmPathLabel.h"
-#include <stddef.h>
-
cmPathLabel::cmPathLabel(const std::string& label)
: Label(label)
, Hash(0)
{
// Use a Jenkins one-at-a-time hash with under/over-flow protection
- for (size_t i = 0; i < this->Label.size(); ++i) {
- this->Hash += this->Label[i];
+ for (char i : this->Label) {
+ this->Hash += i;
this->Hash += ((this->Hash & 0x003FFFFF) << 10);
this->Hash ^= ((this->Hash & 0xFFFFFFC0) >> 6);
}
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 910f6fb..a1f346a 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -120,9 +120,8 @@ static void DiagnoseAncientPolicies(
e << "The project requests behavior compatible with CMake version \""
<< majorVer << "." << minorVer << "." << patchVer
<< "\", which requires the OLD behavior for some policies:\n";
- for (std::vector<cmPolicies::PolicyID>::const_iterator i = ancient.begin();
- i != ancient.end(); ++i) {
- e << " " << idToString(*i) << ": " << idToShortDescription(*i) << "\n";
+ for (cmPolicies::PolicyID i : ancient) {
+ e << " " << idToString(i) << ": " << idToShortDescription(i) << "\n";
}
e << "However, this version of CMake no longer supports the OLD "
<< "behavior for these policies. "
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx
index d72c790..fea8a9d 100644
--- a/Source/cmProjectCommand.cxx
+++ b/Source/cmProjectCommand.cxx
@@ -195,15 +195,14 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
vv.push_back(projectName + "_VERSION_PATCH");
vv.push_back(projectName + "_VERSION_TWEAK");
std::string vw;
- for (std::vector<std::string>::iterator i = vv.begin(); i != vv.end();
- ++i) {
- const char* v = this->Makefile->GetDefinition(*i);
+ for (std::string const& i : vv) {
+ const char* v = this->Makefile->GetDefinition(i);
if (v && *v) {
if (cmp0048 == cmPolicies::WARN) {
vw += "\n ";
- vw += *i;
+ vw += i;
} else {
- this->Makefile->AddDefinition(*i, "");
+ this->Makefile->AddDefinition(i, "");
}
}
}
diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx
index 4905c24..3f6d7c8 100644
--- a/Source/cmPropertyMap.cxx
+++ b/Source/cmPropertyMap.cxx
@@ -21,9 +21,8 @@ cmProperty* cmPropertyMap::GetOrCreateProperty(const std::string& name)
std::vector<std::string> cmPropertyMap::GetPropertyList() const
{
std::vector<std::string> keyList;
- for (cmPropertyMap::const_iterator i = this->begin(), e = this->end();
- i != e; ++i) {
- keyList.push_back(i->first);
+ for (auto const& i : *this) {
+ keyList.push_back(i.first);
}
std::sort(keyList.begin(), keyList.end());
return keyList;
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index 22ac9d2..5d81f25 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -387,7 +387,7 @@ static void SetupAutoTargetMoc(const cmQtAutoGenDigest& digest,
AddDefinitionEscaped(makefile, "_moc_compile_defs", compileDefs);
// Configuration specific settings
- for (const std::string& cfg : configs) {
+ for (std::string const& cfg : configs) {
std::string configIncs;
std::string configCompileDefs;
GetCompileDefinitionsAndDirectories(cfg, configIncs, configCompileDefs);
@@ -470,7 +470,7 @@ static void SetupAutoTargetUic(const cmQtAutoGenDigest& digest,
AddDefinitionEscaped(makefile, "_uic_target_options", uicOpts);
// Configuration specific settings
- for (const std::string& cfg : configs) {
+ for (std::string const& cfg : configs) {
const std::string configUicOpts = UicGetOpts(cfg);
if (configUicOpts != uicOpts) {
setup.ConfigUicOptions[cfg] = configUicOpts;
@@ -579,7 +579,7 @@ static void SetupAutoTargetRcc(const cmQtAutoGenDigest& digest)
std::vector<std::vector<std::string>> rccOptions;
std::vector<std::vector<std::string>> rccInputs;
- for (const cmQtAutoGenDigestQrc& qrcDigest : digest.Qrcs) {
+ for (cmQtAutoGenDigestQrc const& qrcDigest : digest.Qrcs) {
rccFiles.push_back(qrcDigest.QrcFile);
rccBuilds.push_back(qrcDigest.RccFile);
rccOptions.push_back(qrcDigest.Options);
@@ -621,7 +621,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
{
std::string base = GetAutogenTargetFilesDir(target);
base += "/AutogenOldSettings";
- for (const std::string& suffix : suffixes) {
+ for (std::string const& suffix : suffixes) {
AddCleanFile(makefile, (base + suffix).append(".cmake"));
}
}
@@ -773,11 +773,11 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
if (policyAccept) {
// Accept GENERATED sources
- for (const std::string& absFile : generatedHeaders) {
+ for (std::string const& absFile : generatedHeaders) {
digest.Headers.push_back(absFile);
autogenDependFiles.insert(absFile);
}
- for (const std::string& absFile : generatedSources) {
+ for (std::string const& absFile : generatedSources) {
digest.Sources.push_back(absFile);
autogenDependFiles.insert(absFile);
}
@@ -828,7 +828,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
// Check if file name is unique
for (cmQtAutoGenDigestQrc& qrcDigest : digest.Qrcs) {
qrcDigest.Unique = true;
- for (const cmQtAutoGenDigestQrc& qrcDig2 : digest.Qrcs) {
+ for (cmQtAutoGenDigestQrc const& qrcDig2 : digest.Qrcs) {
if ((&qrcDigest != &qrcDig2) &&
(qrcDigest.QrcName == qrcDig2.QrcName)) {
qrcDigest.Unique = false;
@@ -887,7 +887,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
if (cmQtAutoGen::RccListInputs(digest.QtVersionMajor, rcc,
qrcDigest.QrcFile,
qrcDigest.Resources, &error)) {
- for (const std::string& fileName : qrcDigest.Resources) {
+ for (std::string const& fileName : qrcDigest.Resources) {
autogenDependFiles.insert(fileName);
}
} else {
@@ -906,7 +906,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
if (!deps.empty()) {
std::vector<std::string> extraDeps;
cmSystemTools::ExpandListArgument(deps, extraDeps);
- for (const std::string& depName : extraDeps) {
+ for (std::string const& depName : extraDeps) {
// Allow target and file dependencies
auto* depTarget = makefile->FindTargetToUse(depName);
if (depTarget != nullptr) {
@@ -1023,7 +1023,7 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(
// Configuration suffixes
std::map<std::string, std::string> configSuffix;
if (AutogenMultiConfig(target->GetGlobalGenerator())) {
- for (const std::string& cfg : configs) {
+ for (std::string const& cfg : configs) {
configSuffix[cfg] = "_" + cfg;
}
}
@@ -1083,7 +1083,7 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(
if (ofs) {
auto OfsWriteMap = [&ofs](
const char* key, const std::map<std::string, std::string>& map) {
- for (const auto& item : map) {
+ for (auto const& item : map) {
ofs << "set(" << key << "_" << item.first << " "
<< cmOutputConverter::EscapeForCMake(item.second) << ")\n";
}
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 5ede9d5..8c03045 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -38,7 +38,7 @@ static const char* SettingsKeyRcc = "AM_RCC_SETTINGS_HASH";
static std::string QuotedCommand(const std::vector<std::string>& command)
{
std::string res;
- for (const std::string& item : command) {
+ for (std::string const& item : command) {
if (!res.empty()) {
res.push_back(' ');
}
@@ -335,7 +335,7 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
{
const std::vector<std::string> MocMacroNames =
InfoGetList("AM_MOC_MACRO_NAMES");
- for (const std::string& item : MocMacroNames) {
+ for (std::string const& item : MocMacroNames) {
this->MocMacroFilters.emplace_back(
item, ("[^a-zA-Z0-9_]" + item).append("[^a-zA-Z0-9_]"));
}
@@ -628,7 +628,7 @@ void cmQtAutoGenerators::Init(cmMakefile* makefile)
// Compose moc includes list
{
std::set<std::string> frameworkPaths;
- for (const std::string& path : this->MocIncludePaths) {
+ for (std::string const& path : this->MocIncludePaths) {
this->MocIncludes.push_back("-I" + path);
// Extract framework path
if (cmHasLiteralSuffix(path, ".framework/Headers")) {
@@ -641,7 +641,7 @@ void cmQtAutoGenerators::Init(cmMakefile* makefile)
}
}
// Append framework includes
- for (const std::string& path : frameworkPaths) {
+ for (std::string const& path : frameworkPaths) {
this->MocIncludes.push_back("-F");
this->MocIncludes.push_back(path);
}
@@ -679,7 +679,7 @@ bool cmQtAutoGenerators::RunAutogen()
std::set<std::string> uicHeaderFiles;
// Parse sources
- for (const std::string& src : this->Sources) {
+ for (std::string const& src : this->Sources) {
// Parse source file for MOC/UIC
if (!this->ParseSourceFile(src, mocsIncluded, mocDepends, uisIncluded,
this->MocRelaxedMode)) {
@@ -690,7 +690,7 @@ bool cmQtAutoGenerators::RunAutogen()
}
// Parse headers
- for (const std::string& hdr : this->Headers) {
+ for (std::string const& hdr : this->Headers) {
if (!this->MocSkip(hdr)) {
mocHeaderFiles.insert(hdr);
}
@@ -1155,7 +1155,7 @@ bool cmQtAutoGenerators::ParseHeaders(
headerFiles.insert(mocHeaderFiles.begin(), mocHeaderFiles.end());
headerFiles.insert(uicHeaderFiles.begin(), uicHeaderFiles.end());
- for (const std::string& headerName : headerFiles) {
+ for (std::string const& headerName : headerFiles) {
std::string contentText;
if (ReadAll(contentText, headerName)) {
// Parse header content for MOC
@@ -1220,7 +1220,7 @@ bool cmQtAutoGenerators::MocGenerateAll(
cmd.insert(cmd.end(), this->MocIncludes.begin(),
this->MocIncludes.end());
// Add definitions
- for (const std::string& def : this->MocDefinitions) {
+ for (std::string const& def : this->MocDefinitions) {
cmd.push_back("-D" + def);
}
// Add options
@@ -1254,10 +1254,8 @@ bool cmQtAutoGenerators::MocGenerateAll(
}
// Generate moc files that are included by source files.
- for (std::map<std::string, std::string>::const_iterator it =
- mocsIncluded.begin();
- it != mocsIncluded.end(); ++it) {
- if (!this->MocGenerateFile(it->first, it->second, mocDepends, true)) {
+ for (auto const& it : mocsIncluded) {
+ if (!this->MocGenerateFile(it.first, it.second, mocDepends, true)) {
if (this->MocRunFailed) {
return false;
}
@@ -1266,10 +1264,8 @@ bool cmQtAutoGenerators::MocGenerateAll(
// Generate moc files that are _not_ included by source files.
bool mocCompFileGenerated = false;
- for (std::map<std::string, std::string>::const_iterator it =
- mocsNotIncluded.begin();
- it != mocsNotIncluded.end(); ++it) {
- if (this->MocGenerateFile(it->first, it->second, mocDepends, false)) {
+ for (auto const& it : mocsNotIncluded) {
+ if (this->MocGenerateFile(it.first, it.second, mocDepends, false)) {
mocCompFileGenerated = true;
} else {
if (this->MocRunFailed) {
@@ -1288,10 +1284,8 @@ bool cmQtAutoGenerators::MocGenerateAll(
ost << "enum some_compilers { need_more_than_nothing };\n";
} else {
// Valid content
- for (std::map<std::string, std::string>::const_iterator it =
- mocsNotIncluded.begin();
- it != mocsNotIncluded.end(); ++it) {
- ost << "#include \"" << it->second << "\"\n";
+ for (auto const& it : mocsNotIncluded) {
+ ost << "#include \"" << it.second << "\"\n";
}
}
automocSource = ost.str();
@@ -1342,9 +1336,8 @@ bool cmQtAutoGenerators::MocGenerateFile(
std::map<std::string, std::set<std::string>>::const_iterator dit =
mocDepends.find(sourceFile);
if (dit != mocDepends.end()) {
- for (std::set<std::string>::const_iterator fit = dit->second.begin();
- fit != dit->second.end(); ++fit) {
- if (FileAbsentOrOlder(mocFileAbs, *fit)) {
+ for (std::string const& fit : dit->second) {
+ if (FileAbsentOrOlder(mocFileAbs, fit)) {
generateMoc = true;
break;
}
@@ -1367,7 +1360,7 @@ bool cmQtAutoGenerators::MocGenerateFile(
cmd.insert(cmd.end(), this->MocIncludes.begin(),
this->MocIncludes.end());
// Add definitions
- for (const std::string& def : this->MocDefinitions) {
+ for (std::string const& def : this->MocDefinitions) {
cmd.push_back("-D" + def);
}
// Add options
@@ -1425,11 +1418,11 @@ bool cmQtAutoGenerators::UicFindIncludedFile(std::string& absFile,
}
// AUTOUIC search paths
if (!this->UicSearchPaths.empty()) {
- for (const std::string& sPath : this->UicSearchPaths) {
+ for (std::string const& sPath : this->UicSearchPaths) {
testFiles.push_back((sPath + "/").append(searchFile));
}
if (!searchPath.empty()) {
- for (const std::string& sPath : this->UicSearchPaths) {
+ for (std::string const& sPath : this->UicSearchPaths) {
testFiles.push_back((sPath + "/").append(searchFileFull));
}
}
@@ -1437,7 +1430,7 @@ bool cmQtAutoGenerators::UicFindIncludedFile(std::string& absFile,
}
// Search for the .ui file!
- for (const std::string& testFile : testFiles) {
+ for (std::string const& testFile : testFiles) {
if (cmSystemTools::FileExists(testFile.c_str())) {
absFile = cmSystemTools::GetRealPath(testFile);
success = true;
@@ -1449,7 +1442,7 @@ bool cmQtAutoGenerators::UicFindIncludedFile(std::string& absFile,
if (!success) {
std::ostringstream ost;
ost << "Could not find " << cmQtAutoGen::Quoted(searchFile) << " in\n";
- for (const std::string& testFile : testFiles) {
+ for (std::string const& testFile : testFiles) {
ost << " " << cmQtAutoGen::Quoted(testFile) << "\n";
}
this->LogFileError(cmQtAutoGen::UIC, sourceFile, ost.str());
@@ -1471,14 +1464,12 @@ bool cmQtAutoGenerators::UicGenerateAll(
// Collision lookup map
std::map<std::string, std::string> testMap;
// Compile maps
- for (std::map<std::string, std::vector<std::string>>::const_iterator sit =
- uisIncluded.begin();
- sit != uisIncluded.end(); ++sit) {
- const std::string& source(sit->first);
- const std::vector<std::string>& sourceIncs(sit->second);
+ for (auto const& sit : uisIncluded) {
+ const std::string& source(sit.first);
+ const std::vector<std::string>& sourceIncs(sit.second);
// insert new source/destination map
std::map<std::string, std::string>& uiGenMap = sourceGenMap[source];
- for (const std::string& inc : sourceIncs) {
+ for (std::string const& inc : sourceIncs) {
// Remove ui_ from the begin filename by substr()
const std::string uiBasePath = SubDirPrefix(inc);
const std::string uiBaseName =
@@ -1512,8 +1503,8 @@ bool cmQtAutoGenerators::UicGenerateAll(
}
// generate ui files
- for (const auto& srcItem : sourceGenMap) {
- for (const auto& item : srcItem.second) {
+ for (auto const& srcItem : sourceGenMap) {
+ for (auto const& item : srcItem.second) {
if (!this->UicGenerateFile(srcItem.first, item.first, item.second)) {
if (this->UicRunFailed) {
return false;
@@ -1599,7 +1590,7 @@ bool cmQtAutoGenerators::RccGenerateAll()
}
// Generate qrc files
- for (const RccJob& rccJob : this->RccJobs) {
+ for (RccJob const& rccJob : this->RccJobs) {
if (!this->RccGenerateFile(rccJob)) {
if (this->RccRunFailed) {
return false;
@@ -1653,7 +1644,7 @@ bool cmQtAutoGenerators::RccGenerateFile(const RccJob& rccJob)
}
// Test if any input file is newer than the build file
if (files != nullptr) {
- for (const std::string& file : *files) {
+ for (std::string const& file : *files) {
if (FileAbsentOrOlder(rccFileAbs, file)) {
generateRcc = true;
break;
@@ -1831,7 +1822,7 @@ void cmQtAutoGenerators::LogNameCollisionError(
}
}
// Append collision list
- for (const auto& item : collisions) {
+ for (auto const& item : collisions) {
emsg += " ";
emsg += item.first;
emsg += " -> ";
@@ -2003,7 +1994,7 @@ bool cmQtAutoGenerators::RunCommand(const std::vector<std::string>& command,
bool cmQtAutoGenerators::FindHeader(std::string& header,
const std::string& testBasePath) const
{
- for (const std::string& ext : this->HeaderExtensions) {
+ for (std::string const& ext : this->HeaderExtensions) {
std::string testFilePath(testBasePath);
testFilePath.push_back('.');
testFilePath += ext;
@@ -2022,7 +2013,7 @@ std::string cmQtAutoGenerators::MocFindHeader(
// Search in vicinity of the source
if (!this->FindHeader(header, sourcePath + includeBase)) {
// Search in include directories
- for (const std::string& path : this->MocIncludePaths) {
+ for (std::string const& path : this->MocIncludePaths) {
std::string fullPath = path;
fullPath.push_back('/');
fullPath += includeBase;
@@ -2054,7 +2045,7 @@ bool cmQtAutoGenerators::MocFindIncludedFile(
}
// Search in include directories
if (!success) {
- for (const std::string& path : this->MocIncludePaths) {
+ for (std::string const& path : this->MocIncludePaths) {
std::string fullPath = path;
fullPath.push_back('/');
fullPath += includeString;
diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx
index 5364f76..783e308 100644
--- a/Source/cmRST.cxx
+++ b/Source/cmRST.cxx
@@ -292,9 +292,7 @@ std::string cmRST::ReplaceSubstitutions(std::string const& line)
void cmRST::OutputMarkupLines(bool inlineMarkup)
{
- for (std::vector<std::string>::iterator i = this->MarkupLines.begin();
- i != this->MarkupLines.end(); ++i) {
- std::string line = *i;
+ for (auto line : this->MarkupLines) {
if (!line.empty()) {
line = " " + line;
}
@@ -353,9 +351,7 @@ void cmRST::ProcessDirectiveReplace()
void cmRST::ProcessDirectiveTocTree()
{
// Process documents referenced by toctree directive.
- for (std::vector<std::string>::iterator i = this->MarkupLines.begin();
- i != this->MarkupLines.end(); ++i) {
- std::string const& line = *i;
+ for (std::string const& line : this->MarkupLines) {
if (!line.empty() && line[0] != ':') {
if (this->TocTreeLink.find(line)) {
std::string const& link = this->TocTreeLink.match(1);
diff --git a/Source/cmRemoveCommand.cxx b/Source/cmRemoveCommand.cxx
index 1db8441..bb14e68 100644
--- a/Source/cmRemoveCommand.cxx
+++ b/Source/cmRemoveCommand.cxx
@@ -37,10 +37,10 @@ bool cmRemoveCommand::InitialPass(std::vector<std::string> const& args,
// now create the new value
std::string value;
- for (unsigned int j = 0; j < varArgsExpanded.size(); ++j) {
+ for (std::string const& varArgExpanded : varArgsExpanded) {
int found = 0;
- for (unsigned int k = 0; k < argsExpanded.size(); ++k) {
- if (varArgsExpanded[j] == argsExpanded[k]) {
+ for (std::string const& argExpanded : argsExpanded) {
+ if (varArgExpanded == argExpanded) {
found = 1;
break;
}
@@ -49,7 +49,7 @@ bool cmRemoveCommand::InitialPass(std::vector<std::string> const& args,
if (!value.empty()) {
value += ";";
}
- value += varArgsExpanded[j];
+ value += varArgExpanded;
}
}
diff --git a/Source/cmRemoveDefinitionsCommand.cxx b/Source/cmRemoveDefinitionsCommand.cxx
index f5fe2df..8311b4b 100644
--- a/Source/cmRemoveDefinitionsCommand.cxx
+++ b/Source/cmRemoveDefinitionsCommand.cxx
@@ -15,9 +15,8 @@ bool cmRemoveDefinitionsCommand::InitialPass(
return true;
}
- for (std::vector<std::string>::const_iterator i = args.begin();
- i != args.end(); ++i) {
- this->Makefile->RemoveDefineFlag(i->c_str());
+ for (std::string const& i : args) {
+ this->Makefile->RemoveDefineFlag(i.c_str());
}
return true;
}
diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx
index 768e15a..5346b77 100644
--- a/Source/cmScriptGenerator.cxx
+++ b/Source/cmScriptGenerator.cxx
@@ -69,11 +69,10 @@ std::string cmScriptGenerator::CreateConfigTest(
result += this->RuntimeConfigVariable;
result += "}\" MATCHES \"^(";
const char* sep = "";
- for (std::vector<std::string>::const_iterator ci = configs.begin();
- ci != configs.end(); ++ci) {
+ for (std::string const& config : configs) {
result += sep;
sep = "|";
- cmScriptGeneratorEncodeConfig(*ci, result);
+ cmScriptGeneratorEncodeConfig(config, result);
}
result += ")$\"";
return result;
@@ -123,10 +122,8 @@ bool cmScriptGenerator::GeneratesForConfig(const std::string& config)
// This is a configuration-specific rule. Check if the config
// matches this rule.
std::string config_upper = cmSystemTools::UpperCase(config);
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- if (cmSystemTools::UpperCase(*i) == config_upper) {
+ for (std::string const& cfg : this->Configurations) {
+ if (cmSystemTools::UpperCase(cfg) == config_upper) {
return true;
}
}
@@ -163,15 +160,12 @@ void cmScriptGenerator::GenerateScriptActionsPerConfig(std::ostream& os,
// in a block for each configuration that is built. We restrict
// the list of configurations to those to which this rule applies.
bool first = true;
- for (std::vector<std::string>::const_iterator i =
- this->ConfigurationTypes->begin();
- i != this->ConfigurationTypes->end(); ++i) {
- const char* config = i->c_str();
- if (this->GeneratesForConfig(config)) {
+ for (std::string const& cfgType : *this->ConfigurationTypes) {
+ if (this->GeneratesForConfig(cfgType)) {
// Generate a per-configuration block.
- std::string config_test = this->CreateConfigTest(config);
+ std::string config_test = this->CreateConfigTest(cfgType);
os << indent << (first ? "if(" : "elseif(") << config_test << ")\n";
- this->GenerateScriptForConfig(os, config, indent.Next());
+ this->GenerateScriptForConfig(os, cfgType, indent.Next());
first = false;
}
}
diff --git a/Source/cmSearchPath.cxx b/Source/cmSearchPath.cxx
index 0f2ef6e..26c0de2 100644
--- a/Source/cmSearchPath.cxx
+++ b/Source/cmSearchPath.cxx
@@ -27,10 +27,9 @@ void cmSearchPath::ExtractWithout(const std::set<std::string>& ignore,
if (clear) {
outPaths.clear();
}
- for (std::vector<std::string>::const_iterator p = this->Paths.begin();
- p != this->Paths.end(); ++p) {
- if (ignore.count(*p) == 0) {
- outPaths.push_back(*p);
+ for (std::string const& path : this->Paths) {
+ if (ignore.count(path) == 0) {
+ outPaths.push_back(path);
}
}
}
@@ -69,9 +68,8 @@ void cmSearchPath::AddUserPath(const std::string& path)
}
// Process them all from the current directory
- for (std::vector<std::string>::const_iterator p = outPaths.begin();
- p != outPaths.end(); ++p) {
- this->AddPathInternal(*p, this->FC->Makefile->GetCurrentSourceDirectory());
+ for (std::string const& p : outPaths) {
+ this->AddPathInternal(p, this->FC->Makefile->GetCurrentSourceDirectory());
}
}
@@ -84,9 +82,8 @@ void cmSearchPath::AddCMakePath(const std::string& variable)
std::vector<std::string> expanded;
cmSystemTools::ExpandListArgument(value, expanded);
- for (std::vector<std::string>::const_iterator p = expanded.begin();
- p != expanded.end(); ++p) {
- this->AddPathInternal(*p,
+ for (std::string const& p : expanded) {
+ this->AddPathInternal(p,
this->FC->Makefile->GetCurrentSourceDirectory());
}
}
@@ -96,9 +93,8 @@ void cmSearchPath::AddEnvPath(const std::string& variable)
{
std::vector<std::string> expanded;
cmSystemTools::GetPath(expanded, variable.c_str());
- for (std::vector<std::string>::const_iterator p = expanded.begin();
- p != expanded.end(); ++p) {
- this->AddPathInternal(*p);
+ for (std::string const& p : expanded) {
+ this->AddPathInternal(p);
}
}
@@ -142,26 +138,24 @@ void cmSearchPath::AddSuffixes(const std::vector<std::string>& suffixes)
inPaths.swap(this->Paths);
this->Paths.reserve(inPaths.size() * (suffixes.size() + 1));
- for (std::vector<std::string>::iterator ip = inPaths.begin();
- ip != inPaths.end(); ++ip) {
- cmSystemTools::ConvertToUnixSlashes(*ip);
+ for (std::string& inPath : inPaths) {
+ cmSystemTools::ConvertToUnixSlashes(inPath);
// if *i is only / then do not add a //
// this will get incorrectly considered a network
// path on windows and cause huge delays.
- std::string p = *ip;
+ std::string p = inPath;
if (!p.empty() && *p.rbegin() != '/') {
p += "/";
}
// Combine with all the suffixes
- for (std::vector<std::string>::const_iterator s = suffixes.begin();
- s != suffixes.end(); ++s) {
- this->Paths.push_back(p + *s);
+ for (std::string const& suffix : suffixes) {
+ this->Paths.push_back(p + suffix);
}
// And now the original w/o any suffix
- this->Paths.push_back(*ip);
+ this->Paths.push_back(inPath);
}
}
@@ -181,9 +175,8 @@ void cmSearchPath::AddPrefixPaths(const std::vector<std::string>& paths,
subdir = ""; // ? what to do for frameworks ?
}
- for (std::vector<std::string>::const_iterator p = paths.begin();
- p != paths.end(); ++p) {
- std::string dir = *p;
+ for (std::string const& path : paths) {
+ std::string dir = path;
if (!subdir.empty() && !dir.empty() && *dir.rbegin() != '/') {
dir += "/";
}
@@ -201,8 +194,8 @@ void cmSearchPath::AddPrefixPaths(const std::vector<std::string>& paths,
if (subdir == "bin") {
this->AddPathInternal(dir + "sbin", base);
}
- if (!subdir.empty() && *p != "/") {
- this->AddPathInternal(*p, base);
+ if (!subdir.empty() && path != "/") {
+ this->AddPathInternal(path, base);
}
}
}
diff --git a/Source/cmSeparateArgumentsCommand.cxx b/Source/cmSeparateArgumentsCommand.cxx
index 7b222a0..28cbdc0 100644
--- a/Source/cmSeparateArgumentsCommand.cxx
+++ b/Source/cmSeparateArgumentsCommand.cxx
@@ -36,29 +36,29 @@ bool cmSeparateArgumentsCommand::InitialPass(
DoingCommand
};
Doing doing = DoingVariable;
- for (unsigned int i = 0; i < args.size(); ++i) {
+ for (std::string const& arg : args) {
if (doing == DoingVariable) {
- var = args[i];
+ var = arg;
doing = DoingMode;
- } else if (doing == DoingMode && args[i] == "NATIVE_COMMAND") {
+ } else if (doing == DoingMode && arg == "NATIVE_COMMAND") {
#ifdef _WIN32
mode = ModeWindows;
#else
mode = ModeUnix;
#endif
doing = DoingCommand;
- } else if (doing == DoingMode && args[i] == "UNIX_COMMAND") {
+ } else if (doing == DoingMode && arg == "UNIX_COMMAND") {
mode = ModeUnix;
doing = DoingCommand;
- } else if (doing == DoingMode && args[i] == "WINDOWS_COMMAND") {
+ } else if (doing == DoingMode && arg == "WINDOWS_COMMAND") {
mode = ModeWindows;
doing = DoingCommand;
} else if (doing == DoingCommand) {
- command = args[i];
+ command = arg;
doing = DoingNone;
} else {
std::ostringstream e;
- e << "given unknown argument " << args[i];
+ e << "given unknown argument " << arg;
this->SetError(e.str());
return false;
}
@@ -84,19 +84,17 @@ bool cmSeparateArgumentsCommand::InitialPass(
// Construct the result list value.
std::string value;
const char* sep = "";
- for (std::vector<std::string>::const_iterator vi = vec.begin();
- vi != vec.end(); ++vi) {
+ for (std::string const& vi : vec) {
// Separate from the previous argument.
value += sep;
sep = ";";
// Preserve semicolons.
- for (std::string::const_iterator si = vi->begin(); si != vi->end();
- ++si) {
- if (*si == ';') {
+ for (char si : vi) {
+ if (si == ';') {
value += '\\';
}
- value += *si;
+ value += si;
}
}
this->Makefile->AddDefinition(var, value.c_str());
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index 2b0a826..1b47608 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -66,7 +66,7 @@ template <class T>
Json::Value fromStringList(const T& in)
{
Json::Value result = Json::arrayValue;
- for (const std::string& i : in) {
+ for (std::string const& i : in) {
result.append(i);
}
return result;
@@ -75,7 +75,7 @@ Json::Value fromStringList(const T& in)
std::vector<std::string> toStringList(const Json::Value& in)
{
std::vector<std::string> result;
- for (const auto& it : in) {
+ for (auto const& it : in) {
result.push_back(it.asString());
}
return result;
@@ -89,19 +89,17 @@ void getCMakeInputs(const cmGlobalGenerator* gg, const std::string& sourceDir,
{
const std::string cmakeRootDir = cmSystemTools::GetCMakeRoot() + '/';
std::vector<cmMakefile*> const& makefiles = gg->GetMakefiles();
- for (auto it = makefiles.begin(); it != makefiles.end(); ++it) {
- const std::vector<std::string> listFiles = (*it)->GetListFiles();
+ for (cmMakefile const* mf : makefiles) {
+ for (std::string const& lf : mf->GetListFiles()) {
- for (auto jt = listFiles.begin(); jt != listFiles.end(); ++jt) {
-
- const std::string startOfFile = jt->substr(0, cmakeRootDir.size());
+ const std::string startOfFile = lf.substr(0, cmakeRootDir.size());
const bool isInternal = (startOfFile == cmakeRootDir);
- const bool isTemporary = !isInternal && (jt->find(buildDir + '/') == 0);
+ const bool isTemporary = !isInternal && (lf.find(buildDir + '/') == 0);
- std::string toAdd = *jt;
+ std::string toAdd = lf;
if (!sourceDir.empty()) {
const std::string& relative =
- cmSystemTools::RelativePath(sourceDir.c_str(), jt->c_str());
+ cmSystemTools::RelativePath(sourceDir.c_str(), lf.c_str());
if (toAdd.size() > relative.size()) {
toAdd = relative;
}
@@ -501,14 +499,14 @@ cmServerResponse cmServerProtocol1::ProcessCache(
if (keys.empty()) {
keys = allKeys;
} else {
- for (const auto& i : keys) {
+ for (auto const& i : keys) {
if (std::find(allKeys.begin(), allKeys.end(), i) == allKeys.end()) {
return request.ReportError("Key \"" + i + "\" not found in cache.");
}
}
}
std::sort(keys.begin(), keys.end());
- for (const auto& key : keys) {
+ for (auto const& key : keys) {
Json::Value entry = Json::objectValue;
entry[kKEY_KEY] = key;
entry[kTYPE_KEY] =
@@ -517,7 +515,7 @@ cmServerResponse cmServerProtocol1::ProcessCache(
Json::Value props = Json::objectValue;
bool haveProperties = false;
- for (const auto& prop : state->GetCacheEntryPropertyList(key)) {
+ for (auto const& prop : state->GetCacheEntryPropertyList(key)) {
haveProperties = true;
props[prop] = state->GetCacheEntryProperty(key, prop);
}
@@ -604,7 +602,7 @@ bool LanguageData::operator==(const LanguageData& other) const
void LanguageData::SetDefines(const std::set<std::string>& defines)
{
std::vector<std::string> result;
- for (const auto& i : defines) {
+ for (std::string const& i : defines) {
result.push_back(i);
}
std::sort(result.begin(), result.end());
@@ -621,11 +619,11 @@ struct hash<LanguageData>
using std::hash;
size_t result =
hash<std::string>()(in.Language) ^ hash<std::string>()(in.Flags);
- for (const auto& i : in.IncludePathList) {
+ for (auto const& i : in.IncludePathList) {
result = result ^ (hash<std::string>()(i.first) ^
(i.second ? std::numeric_limits<size_t>::max() : 0));
}
- for (const auto& i : in.Defines) {
+ for (auto const& i : in.Defines) {
result = result ^ hash<std::string>()(i);
}
result =
@@ -649,7 +647,7 @@ static Json::Value DumpSourceFileGroup(const LanguageData& data,
}
if (!data.IncludePathList.empty()) {
Json::Value includes = Json::arrayValue;
- for (const auto& i : data.IncludePathList) {
+ for (auto const& i : data.IncludePathList) {
Json::Value tmp = Json::objectValue;
tmp[kPATH_KEY] = i.first;
if (i.second) {
@@ -667,7 +665,7 @@ static Json::Value DumpSourceFileGroup(const LanguageData& data,
result[kIS_GENERATED_KEY] = data.IsGenerated;
Json::Value sourcesValue = Json::arrayValue;
- for (const auto& i : files) {
+ for (auto const& i : files) {
const std::string relPath =
cmSystemTools::RelativePath(baseDir.c_str(), i.c_str());
sourcesValue.append(relPath.size() < i.size() ? relPath : i);
@@ -723,8 +721,8 @@ static Json::Value DumpSourceFilesList(
const std::string baseDir = target->Makefile->GetCurrentSourceDirectory();
Json::Value result = Json::arrayValue;
- for (auto it = fileGroups.begin(); it != fileGroups.end(); ++it) {
- Json::Value group = DumpSourceFileGroup(it->first, it->second, baseDir);
+ for (auto const& it : fileGroups) {
+ Json::Value group = DumpSourceFileGroup(it.first, it.second, baseDir);
if (!group.isNull()) {
result.append(group);
}
@@ -756,7 +754,7 @@ static Json::Value DumpBacktrace(const cmListFileBacktrace& backtrace)
static void DumpBacktraceRange(Json::Value& result, const std::string& type,
cmBacktraceRange range)
{
- for (const auto& bt : range) {
+ for (auto const& bt : range) {
Json::Value obj = Json::objectValue;
obj[kTYPE_KEY] = type;
obj[kBACKTRACE_KEY] = DumpBacktrace(bt);
@@ -872,7 +870,7 @@ static Json::Value DumpTarget(cmGeneratorTarget* target,
std::set<std::string> languages;
target->GetLanguages(languages, config);
std::map<std::string, LanguageData> languageDataMap;
- for (const auto& lang : languages) {
+ for (std::string const& lang : languages) {
LanguageData& ld = languageDataMap[lang];
ld.Language = lang;
lg->GetTargetCompileFlags(target, config, lang, ld.Flags);
@@ -881,7 +879,7 @@ static Json::Value DumpTarget(cmGeneratorTarget* target,
ld.SetDefines(defines);
std::vector<std::string> includePathList;
lg->GetIncludeDirectories(includePathList, target, lang, config, true);
- for (auto i : includePathList) {
+ for (std::string const& i : includePathList) {
ld.IncludePathList.push_back(
std::make_pair(i, target->IsSystemIncludeDirectory(i, config)));
}
@@ -902,7 +900,7 @@ static Json::Value DumpTargetsList(
Json::Value result = Json::arrayValue;
std::vector<cmGeneratorTarget*> targetList;
- for (const auto& lgIt : generators) {
+ for (auto const& lgIt : generators) {
const auto& list = lgIt->GetGeneratorTargets();
targetList.insert(targetList.end(), list.begin(), list.end());
}
@@ -924,7 +922,7 @@ static Json::Value DumpProjectList(const cmake* cm, std::string const& config)
auto globalGen = cm->GetGlobalGenerator();
- for (const auto& projectIt : globalGen->GetProjectMap()) {
+ for (auto const& projectIt : globalGen->GetProjectMap()) {
Json::Value pObj = Json::objectValue;
pObj[kNAME_KEY] = projectIt.first;
@@ -959,7 +957,7 @@ static Json::Value DumpConfigurationsList(const cmake* cm)
{
Json::Value result = Json::arrayValue;
- for (const std::string& c : getConfigurations(cm)) {
+ for (std::string const& c : getConfigurations(cm)) {
result.append(DumpConfiguration(cm, c));
}
@@ -1022,12 +1020,12 @@ cmServerResponse cmServerProtocol1::ProcessConfigure(
if (passedArgs.isString()) {
cacheArgs.push_back(passedArgs.asString());
} else if (passedArgs.isArray()) {
- for (auto i = passedArgs.begin(); i != passedArgs.end(); ++i) {
- if (!i->isString()) {
+ for (auto const& arg : passedArgs) {
+ if (!arg.isString()) {
cacheArgumentsError = true;
break;
}
- cacheArgs.push_back(i->asString());
+ cacheArgs.push_back(arg.asString());
}
} else {
cacheArgumentsError = true;
@@ -1148,7 +1146,7 @@ cmServerResponse cmServerProtocol1::ProcessSetGlobalSettings(
kWARN_UNINITIALIZED_KEY, kWARN_UNUSED_KEY, kWARN_UNUSED_CLI_KEY,
kCHECK_SYSTEM_VARS_KEY
};
- for (const auto& i : boolValues) {
+ for (std::string const& i : boolValues) {
if (!request.Data[i].isNull() && !request.Data[i].isBool()) {
return request.ReportError("\"" + i +
"\" must be unset or a bool value.");
@@ -1178,11 +1176,11 @@ cmServerResponse cmServerProtocol1::ProcessFileSystemWatchers(
const cmFileMonitor* const fm = FileMonitor();
Json::Value result = Json::objectValue;
Json::Value files = Json::arrayValue;
- for (const auto& f : fm->WatchedFiles()) {
+ for (auto const& f : fm->WatchedFiles()) {
files.append(f);
}
Json::Value directories = Json::arrayValue;
- for (const auto& d : fm->WatchedDirectories()) {
+ for (auto const& d : fm->WatchedDirectories()) {
directories.append(d);
}
result[kWATCHED_FILES_KEY] = files;
diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx
index 338fcea..7efcc04 100644
--- a/Source/cmSetPropertyCommand.cxx
+++ b/Source/cmSetPropertyCommand.cxx
@@ -204,20 +204,19 @@ bool cmSetPropertyCommand::HandleDirectoryMode()
bool cmSetPropertyCommand::HandleTargetMode()
{
- for (std::set<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- if (this->Makefile->IsAlias(*ni)) {
+ for (std::string const& name : this->Names) {
+ if (this->Makefile->IsAlias(name)) {
this->SetError("can not be used on an ALIAS target.");
return false;
}
- if (cmTarget* target = this->Makefile->FindTargetToUse(*ni)) {
+ if (cmTarget* target = this->Makefile->FindTargetToUse(name)) {
// Handle the current target.
if (!this->HandleTarget(target)) {
return false;
}
} else {
std::ostringstream e;
- e << "could not find TARGET " << *ni
+ e << "could not find TARGET " << name
<< ". Perhaps it has not yet been created.";
this->SetError(e.str());
return false;
@@ -248,16 +247,15 @@ bool cmSetPropertyCommand::HandleTarget(cmTarget* target)
bool cmSetPropertyCommand::HandleSourceMode()
{
- for (std::set<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
+ for (std::string const& name : this->Names) {
// Get the source file.
- if (cmSourceFile* sf = this->Makefile->GetOrCreateSource(*ni)) {
+ if (cmSourceFile* sf = this->Makefile->GetOrCreateSource(name)) {
if (!this->HandleSource(sf)) {
return false;
}
} else {
std::ostringstream e;
- e << "given SOURCE name that could not be found or created: " << *ni;
+ e << "given SOURCE name that could not be found or created: " << name;
this->SetError(e.str());
return false;
}
@@ -303,9 +301,8 @@ bool cmSetPropertyCommand::HandleTestMode()
if (!this->Names.empty()) {
std::ostringstream e;
e << "given TEST names that do not exist:\n";
- for (std::set<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- e << " " << *ni << "\n";
+ for (std::string const& name : this->Names) {
+ e << " " << name << "\n";
}
this->SetError(e.str());
return false;
@@ -359,19 +356,18 @@ bool cmSetPropertyCommand::HandleCacheMode()
return false;
}
- for (std::set<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
+ for (std::string const& name : this->Names) {
// Get the source file.
cmMakefile* mf = this->GetMakefile();
cmake* cm = mf->GetCMakeInstance();
- const char* existingValue = cm->GetState()->GetCacheEntryValue(*ni);
+ const char* existingValue = cm->GetState()->GetCacheEntryValue(name);
if (existingValue) {
- if (!this->HandleCacheEntry(*ni)) {
+ if (!this->HandleCacheEntry(name)) {
return false;
}
} else {
std::ostringstream e;
- e << "could not find CACHE variable " << *ni
+ e << "could not find CACHE variable " << name
<< ". Perhaps it has not yet been created.";
this->SetError(e.str());
return false;
@@ -403,16 +399,15 @@ bool cmSetPropertyCommand::HandleInstallMode()
{
cmake* cm = this->Makefile->GetCMakeInstance();
- for (std::set<std::string>::const_iterator i = this->Names.begin();
- i != this->Names.end(); ++i) {
+ for (std::string const& name : this->Names) {
if (cmInstalledFile* file =
- cm->GetOrCreateInstalledFile(this->Makefile, *i)) {
+ cm->GetOrCreateInstalledFile(this->Makefile, name)) {
if (!this->HandleInstall(file)) {
return false;
}
} else {
std::ostringstream e;
- e << "given INSTALL name that could not be found or created: " << *i;
+ e << "given INSTALL name that could not be found or created: " << name;
this->SetError(e.str());
return false;
}
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index 6d2b98d..0964bea 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -150,15 +150,13 @@ bool cmSourceFile::FindFullPath(std::string* error)
if (this->TryFullPath(tryPath, "")) {
return true;
}
- for (std::vector<std::string>::const_iterator ei = srcExts.begin();
- ei != srcExts.end(); ++ei) {
- if (this->TryFullPath(tryPath, *ei)) {
+ for (std::string const& ext : srcExts) {
+ if (this->TryFullPath(tryPath, ext)) {
return true;
}
}
- for (std::vector<std::string>::const_iterator ei = hdrExts.begin();
- ei != hdrExts.end(); ++ei) {
- if (this->TryFullPath(tryPath, *ei)) {
+ for (std::string const& ext : hdrExts) {
+ if (this->TryFullPath(tryPath, ext)) {
return true;
}
}
@@ -171,13 +169,11 @@ bool cmSourceFile::FindFullPath(std::string* error)
}
missing += this->Location.GetName();
e << "Cannot find source file:\n " << missing << "\nTried extensions";
- for (std::vector<std::string>::const_iterator ext = srcExts.begin();
- ext != srcExts.end(); ++ext) {
- e << " ." << *ext;
+ for (std::string const& srcExt : srcExts) {
+ e << " ." << srcExt;
}
- for (std::vector<std::string>::const_iterator ext = hdrExts.begin();
- ext != hdrExts.end(); ++ext) {
- e << " ." << *ext;
+ for (std::string const& ext : hdrExts) {
+ e << " ." << ext;
}
if (error) {
*error = e.str();
diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx
index 77fde7b..08a1aa4 100644
--- a/Source/cmSourceGroupCommand.cxx
+++ b/Source/cmSourceGroupCommand.cxx
@@ -41,8 +41,8 @@ std::set<std::string> getSourceGroupFilesPaths(
std::set<std::string> ret;
const std::string::size_type rootLength = root.length();
- for (size_t i = 0; i < files.size(); ++i) {
- ret.insert(files[i].substr(rootLength + 1)); // +1 to also omnit last '/'
+ for (std::string const& file : files) {
+ ret.insert(file.substr(rootLength + 1)); // +1 to also omnit last '/'
}
return ret;
@@ -51,9 +51,9 @@ std::set<std::string> getSourceGroupFilesPaths(
bool rootIsPrefix(const std::string& root,
const std::vector<std::string>& files, std::string& error)
{
- for (size_t i = 0; i < files.size(); ++i) {
- if (!cmSystemTools::StringStartsWith(files[i], root.c_str())) {
- error = "ROOT: " + root + " is not a prefix of file: " + files[i];
+ for (std::string const& file : files) {
+ if (!cmSystemTools::StringStartsWith(file, root.c_str())) {
+ error = "ROOT: " + root + " is not a prefix of file: " + file;
return false;
}
}
@@ -108,14 +108,13 @@ bool addFilesToItsSourceGroups(const std::string& root,
{
cmSourceGroup* sg;
- for (std::set<std::string>::const_iterator it = sgFilesPaths.begin();
- it != sgFilesPaths.end(); ++it) {
+ for (std::string const& sgFilesPath : sgFilesPaths) {
std::vector<std::string> tokenizedPath;
if (!prefix.empty()) {
- tokenizedPath = tokenizePath(prefix + '/' + *it);
+ tokenizedPath = tokenizePath(prefix + '/' + sgFilesPath);
} else {
- tokenizedPath = tokenizePath(*it);
+ tokenizedPath = tokenizePath(sgFilesPath);
}
if (tokenizedPath.size() > 1) {
@@ -124,10 +123,10 @@ bool addFilesToItsSourceGroups(const std::string& root,
sg = addSourceGroup(tokenizedPath, makefile);
if (!sg) {
- errorMsg = "Could not create source group for file: " + *it;
+ errorMsg = "Could not create source group for file: " + sgFilesPath;
return false;
}
- const std::string fullPath = getFullFilePath(root, *it);
+ const std::string fullPath = getFullFilePath(root, sgFilesPath);
sg->AddGroupFile(fullPath);
}
}
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 90d8b7b..5957b5b 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -444,15 +444,11 @@ std::vector<std::string> cmState::GetCommandNames() const
std::vector<std::string> commandNames;
commandNames.reserve(this->BuiltinCommands.size() +
this->ScriptedCommands.size());
- for (std::map<std::string, cmCommand*>::const_iterator cmds =
- this->BuiltinCommands.begin();
- cmds != this->BuiltinCommands.end(); ++cmds) {
- commandNames.push_back(cmds->first);
+ for (auto const& bc : this->BuiltinCommands) {
+ commandNames.push_back(bc.first);
}
- for (std::map<std::string, cmCommand*>::const_iterator cmds =
- this->ScriptedCommands.begin();
- cmds != this->ScriptedCommands.end(); ++cmds) {
- commandNames.push_back(cmds->first);
+ for (auto const& sc : this->ScriptedCommands) {
+ commandNames.push_back(sc.first);
}
std::sort(commandNames.begin(), commandNames.end());
commandNames.erase(std::unique(commandNames.begin(), commandNames.end()),
diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx
index 46a1858..418f051 100644
--- a/Source/cmStateDirectory.cxx
+++ b/Source/cmStateDirectory.cxx
@@ -6,7 +6,6 @@
#include <algorithm>
#include <assert.h>
#include <iterator>
-#include <map>
#include <utility>
#include "cmProperty.h"
@@ -443,9 +442,8 @@ const char* cmStateDirectory::GetProperty(const std::string& prop,
std::vector<std::string> child_dirs;
std::vector<cmStateSnapshot> const& children =
this->DirectoryState->Children;
- for (std::vector<cmStateSnapshot>::const_iterator ci = children.begin();
- ci != children.end(); ++ci) {
- child_dirs.push_back(ci->GetDirectory().GetCurrentSource());
+ for (cmStateSnapshot const& ci : children) {
+ child_dirs.push_back(ci.GetDirectory().GetCurrentSource());
}
output = cmJoin(child_dirs, ";");
return output.c_str();
@@ -514,10 +512,8 @@ std::vector<std::string> cmStateDirectory::GetPropertyKeys() const
{
std::vector<std::string> keys;
keys.reserve(this->DirectoryState->Properties.size());
- for (cmPropertyMap::const_iterator it =
- this->DirectoryState->Properties.begin();
- it != this->DirectoryState->Properties.end(); ++it) {
- keys.push_back(it->first);
+ for (auto const& it : this->DirectoryState->Properties) {
+ keys.push_back(it.first);
}
return keys;
}
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 592f66e..3b6a7ee 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -412,13 +412,13 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
}
// Concatenate the replacement for the match.
- for (unsigned int i = 0; i < replacement.size(); ++i) {
- if (replacement[i].number < 0) {
+ for (RegexReplacement const& i : replacement) {
+ if (i.number < 0) {
// This is just a plain-text part of the replacement.
- output += replacement[i].value;
+ output += i.value;
} else {
// Replace with part of the match.
- int n = replacement[i].number;
+ int n = i.number;
std::string::size_type start = re.start(n);
std::string::size_type end = re.end(n);
std::string::size_type len = input.length() - base;
diff --git a/Source/cmSubdirCommand.cxx b/Source/cmSubdirCommand.cxx
index 3727dfa..c74ca59 100644
--- a/Source/cmSubdirCommand.cxx
+++ b/Source/cmSubdirCommand.cxx
@@ -18,36 +18,35 @@ bool cmSubdirCommand::InitialPass(std::vector<std::string> const& args,
bool res = true;
bool excludeFromAll = false;
- for (std::vector<std::string>::const_iterator i = args.begin();
- i != args.end(); ++i) {
- if (*i == "EXCLUDE_FROM_ALL") {
+ for (std::string const& i : args) {
+ if (i == "EXCLUDE_FROM_ALL") {
excludeFromAll = true;
continue;
}
- if (*i == "PREORDER") {
+ if (i == "PREORDER") {
// Ignored
continue;
}
// if they specified a relative path then compute the full
std::string srcPath =
- std::string(this->Makefile->GetCurrentSourceDirectory()) + "/" + *i;
+ std::string(this->Makefile->GetCurrentSourceDirectory()) + "/" + i;
if (cmSystemTools::FileIsDirectory(srcPath)) {
std::string binPath =
- std::string(this->Makefile->GetCurrentBinaryDirectory()) + "/" + *i;
+ std::string(this->Makefile->GetCurrentBinaryDirectory()) + "/" + i;
this->Makefile->AddSubDirectory(srcPath, binPath, excludeFromAll, false);
}
// otherwise it is a full path
- else if (cmSystemTools::FileIsDirectory(*i)) {
+ else if (cmSystemTools::FileIsDirectory(i)) {
// we must compute the binPath from the srcPath, we just take the last
// element from the source path and use that
std::string binPath =
std::string(this->Makefile->GetCurrentBinaryDirectory()) + "/" +
- cmSystemTools::GetFilenameName(*i);
- this->Makefile->AddSubDirectory(*i, binPath, excludeFromAll, false);
+ cmSystemTools::GetFilenameName(i);
+ this->Makefile->AddSubDirectory(i, binPath, excludeFromAll, false);
} else {
std::string error = "Incorrect SUBDIRS command. Directory: ";
- error += *i + " does not exist.";
+ error += i + " does not exist.";
this->SetError(error);
res = false;
}
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 5c63d98..fd9fb5e 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -353,8 +353,8 @@ bool cmSystemTools::IsInternallyOn(const char* val)
return false;
}
- for (std::string::iterator c = v.begin(); c != v.end(); c++) {
- *c = static_cast<char>(toupper(*c));
+ for (char& c : v) {
+ c = static_cast<char>(toupper(c));
}
return v == "I_ON";
}
@@ -378,8 +378,8 @@ bool cmSystemTools::IsOn(const char* val)
onValues.insert("TRUE");
onValues.insert("Y");
}
- for (std::string::iterator c = v.begin(); c != v.end(); c++) {
- *c = static_cast<char>(toupper(*c));
+ for (char& c : v) {
+ c = static_cast<char>(toupper(c));
}
return (onValues.count(v) > 0);
}
@@ -414,8 +414,8 @@ bool cmSystemTools::IsOff(const char* val)
}
// Try and avoid toupper().
std::string v(val, len);
- for (std::string::iterator c = v.begin(); c != v.end(); c++) {
- *c = static_cast<char>(toupper(*c));
+ for (char& c : v) {
+ c = static_cast<char>(toupper(c));
}
return (offValues.count(v) > 0);
}
@@ -650,9 +650,8 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
double timeout, Encoding encoding)
{
std::vector<const char*> argv;
- for (std::vector<std::string>::const_iterator a = command.begin();
- a != command.end(); ++a) {
- argv.push_back(a->c_str());
+ for (std::string const& cmd : command) {
+ argv.push_back(cmd.c_str());
}
argv.push_back(nullptr);
@@ -814,11 +813,10 @@ bool cmSystemTools::DoesFileExistWithExtensions(
{
std::string hname;
- for (std::vector<std::string>::const_iterator ext = headerExts.begin();
- ext != headerExts.end(); ++ext) {
+ for (std::string const& headerExt : headerExts) {
hname = name;
hname += ".";
- hname += *ext;
+ hname += headerExt;
if (cmSystemTools::FileExists(hname.c_str())) {
return true;
}
@@ -1367,9 +1365,8 @@ std::vector<std::string> cmSystemTools::GetEnvironmentVariables()
void cmSystemTools::AppendEnv(std::vector<std::string> const& env)
{
- for (std::vector<std::string>::const_iterator eit = env.begin();
- eit != env.end(); ++eit) {
- cmSystemTools::PutEnv(*eit);
+ for (std::string const& eit : env) {
+ cmSystemTools::PutEnv(eit);
}
}
@@ -1382,10 +1379,7 @@ cmSystemTools::SaveRestoreEnvironment::~SaveRestoreEnvironment()
{
// First clear everything in the current environment:
std::vector<std::string> currentEnv = GetEnvironmentVariables();
- for (std::vector<std::string>::const_iterator eit = currentEnv.begin();
- eit != currentEnv.end(); ++eit) {
- std::string var(*eit);
-
+ for (std::string var : currentEnv) {
std::string::size_type pos = var.find('=');
if (pos != std::string::npos) {
var = var.substr(0, pos);
@@ -1464,9 +1458,7 @@ bool cmSystemTools::CreateTar(const char* outFileName,
a.SetMTime(mtime);
a.SetVerbose(verbose);
- for (std::vector<std::string>::const_iterator i = files.begin();
- i != files.end(); ++i) {
- std::string path = *i;
+ for (auto path : files) {
if (cmSystemTools::FileIsFullPath(path.c_str())) {
// Get the relative path to the file.
path = cmSystemTools::RelativePath(cwd.c_str(), path.c_str());
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 4d93810..8d21e68 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -80,22 +80,18 @@ const char* cmTargetPropertyComputer::GetSources<cmTarget>(
std::ostringstream ss;
const char* sep = "";
- for (std::vector<std::string>::const_iterator i = entries.begin();
- i != entries.end(); ++i) {
- std::string const& entry = *i;
-
+ for (std::string const& entry : entries) {
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:") &&
- (*li)[li->size() - 1] == '>') {
- std::string objLibName = li->substr(17, li->size() - 18);
+ for (std::string const& file : files) {
+ if (cmHasLiteralPrefix(file, "$<TARGET_OBJECTS:") &&
+ file[file.size() - 1] == '>') {
+ std::string objLibName = file.substr(17, file.size() - 18);
if (cmGeneratorExpression::Find(objLibName) != std::string::npos) {
ss << sep;
sep = ";";
- ss << *li;
+ ss << file;
continue;
}
@@ -130,14 +126,14 @@ const char* cmTargetPropertyComputer::GetSources<cmTarget>(
if (addContent) {
ss << sep;
sep = ";";
- ss << *li;
+ ss << file;
}
- } else if (cmGeneratorExpression::Find(*li) == std::string::npos) {
+ } else if (cmGeneratorExpression::Find(file) == std::string::npos) {
ss << sep;
sep = ";";
- ss << *li;
+ ss << file;
} else {
- cmSourceFile* sf = tgt->GetMakefile()->GetOrCreateSource(*li);
+ cmSourceFile* sf = tgt->GetMakefile()->GetOrCreateSource(file);
// Construct what is known about this source file location.
cmSourceFileLocation const& location = sf->GetLocation();
std::string sname = location.GetDirectory();
@@ -301,9 +297,8 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
"COMPILE_PDB_OUTPUT_DIRECTORY_", "MAP_IMPORTED_CONFIG_",
"INTERPROCEDURAL_OPTIMIZATION_", nullptr
};
- for (std::vector<std::string>::iterator ci = configNames.begin();
- ci != configNames.end(); ++ci) {
- std::string configUpper = cmSystemTools::UpperCase(*ci);
+ for (std::string const& configName : configNames) {
+ std::string configUpper = cmSystemTools::UpperCase(configName);
for (const char** p = configProps; *p; ++p) {
// Interface libraries have no output locations, so honor only
// the configuration map.
@@ -323,7 +318,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
// property directly.
if (this->TargetTypeValue != cmStateEnums::EXECUTABLE &&
this->TargetTypeValue != cmStateEnums::INTERFACE_LIBRARY) {
- std::string property = cmSystemTools::UpperCase(*ci);
+ std::string property = cmSystemTools::UpperCase(configName);
property += "_POSTFIX";
this->SetPropertyDefault(property, nullptr);
}
@@ -483,9 +478,7 @@ void cmTarget::AddSources(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;
+ for (auto filename : srcs) {
const char* src = filename.c_str();
if (!(src[0] == '$' && src[1] == '<')) {
@@ -714,12 +707,10 @@ void cmTarget::GetTllSignatureTraces(std::ostream& s, TLLSignature sig) const
const char* sigString =
(sig == cmTarget::KeywordTLLSignature ? "keyword" : "plain");
s << "The uses of the " << sigString << " signature are here:\n";
- typedef std::vector<std::pair<TLLSignature, cmListFileContext>> Container;
cmOutputConverter converter(this->GetMakefile()->GetStateSnapshot());
- for (Container::const_iterator it = this->TLLCommands.begin();
- it != this->TLLCommands.end(); ++it) {
- if (it->first == sig) {
- cmListFileContext lfc = it->second;
+ for (auto const& cmd : this->TLLCommands) {
+ if (cmd.first == sig) {
+ cmListFileContext lfc = cmd.second;
lfc.FilePath = converter.ConvertToRelativePath(
this->Makefile->GetState()->GetSourceDirectory(), lfc.FilePath);
s << " * " << lfc << std::endl;
diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx
index 008d1a2..d159d41 100644
--- a/Source/cmTargetCompileDefinitionsCommand.cxx
+++ b/Source/cmTargetCompileDefinitionsCommand.cxx
@@ -41,12 +41,11 @@ std::string cmTargetCompileDefinitionsCommand::Join(
{
std::string defs;
std::string sep;
- for (std::vector<std::string>::const_iterator it = content.begin();
- it != content.end(); ++it) {
- if (cmHasLiteralPrefix(it->c_str(), "-D")) {
- defs += sep + it->substr(2);
+ for (std::string const& it : content) {
+ if (cmHasLiteralPrefix(it.c_str(), "-D")) {
+ defs += sep + it.substr(2);
} else {
- defs += sep + *it;
+ defs += sep + it;
}
sep = ";";
}
diff --git a/Source/cmTargetCompileFeaturesCommand.cxx b/Source/cmTargetCompileFeaturesCommand.cxx
index 1b6c008..722bbe5 100644
--- a/Source/cmTargetCompileFeaturesCommand.cxx
+++ b/Source/cmTargetCompileFeaturesCommand.cxx
@@ -45,10 +45,9 @@ std::string cmTargetCompileFeaturesCommand::Join(
bool cmTargetCompileFeaturesCommand::HandleDirectContent(
cmTarget* tgt, const std::vector<std::string>& content, bool, bool)
{
- for (std::vector<std::string>::const_iterator it = content.begin();
- it != content.end(); ++it) {
+ for (std::string const& it : content) {
std::string error;
- if (!this->Makefile->AddRequiredTargetFeature(tgt, *it, &error)) {
+ if (!this->Makefile->AddRequiredTargetFeature(tgt, it, &error)) {
this->SetError(error);
return false;
}
diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx
index 65a3149..4646c7e 100644
--- a/Source/cmTargetIncludeDirectoriesCommand.cxx
+++ b/Source/cmTargetIncludeDirectoriesCommand.cxx
@@ -47,13 +47,12 @@ std::string cmTargetIncludeDirectoriesCommand::Join(
std::string sep;
std::string prefix =
this->Makefile->GetCurrentSourceDirectory() + std::string("/");
- for (std::vector<std::string>::const_iterator it = content.begin();
- it != content.end(); ++it) {
- if (cmSystemTools::FileIsFullPath(it->c_str()) ||
- cmGeneratorExpression::Find(*it) == 0) {
- dirs += sep + *it;
+ for (std::string const& it : content) {
+ if (cmSystemTools::FileIsFullPath(it.c_str()) ||
+ cmGeneratorExpression::Find(it) == 0) {
+ dirs += sep + it;
} else {
- dirs += sep + prefix + *it;
+ dirs += sep + prefix + it;
}
sep = ";";
}
@@ -70,13 +69,12 @@ bool cmTargetIncludeDirectoriesCommand::HandleDirectContent(
std::string prefix =
this->Makefile->GetCurrentSourceDirectory() + std::string("/");
std::set<std::string> sdirs;
- for (std::vector<std::string>::const_iterator it = content.begin();
- it != content.end(); ++it) {
- if (cmSystemTools::FileIsFullPath(it->c_str()) ||
- cmGeneratorExpression::Find(*it) == 0) {
- sdirs.insert(*it);
+ for (std::string const& it : content) {
+ if (cmSystemTools::FileIsFullPath(it.c_str()) ||
+ cmGeneratorExpression::Find(it) == 0) {
+ sdirs.insert(it);
} else {
- sdirs.insert(prefix + *it);
+ sdirs.insert(prefix + it);
}
}
tgt->AddSystemIncludeDirectories(sdirs);
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index d146640..dda0464 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -429,10 +429,9 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
// Include this library in the link interface for the target.
if (llt == DEBUG_LibraryType || llt == GENERAL_LibraryType) {
// Put in the DEBUG configuration interfaces.
- for (std::vector<std::string>::const_iterator i = debugConfigs.begin();
- i != debugConfigs.end(); ++i) {
+ for (std::string const& dc : debugConfigs) {
prop = "LINK_INTERFACE_LIBRARIES_";
- prop += *i;
+ prop += dc;
this->Target->AppendProperty(prop, lib.c_str());
}
}
@@ -442,10 +441,9 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
// Make sure the DEBUG configuration interfaces exist so that the
// general one will not be used as a fall-back.
- for (std::vector<std::string>::const_iterator i = debugConfigs.begin();
- i != debugConfigs.end(); ++i) {
+ for (std::string const& dc : debugConfigs) {
prop = "LINK_INTERFACE_LIBRARIES_";
- prop += *i;
+ prop += dc;
if (!this->Target->GetProperty(prop)) {
this->Target->SetProperty(prop, "");
}
diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx
index 85d4b97..78ca6bc 100644
--- a/Source/cmTestGenerator.cxx
+++ b/Source/cmTestGenerator.cxx
@@ -2,7 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTestGenerator.h"
-#include <map>
#include <ostream>
#include <utility>
@@ -114,10 +113,10 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
if (!pm.empty()) {
os << indent << "set_tests_properties(" << this->Test->GetName()
<< " PROPERTIES ";
- for (cmPropertyMap::const_iterator i = pm.begin(); i != pm.end(); ++i) {
- os << " " << i->first << " "
+ for (auto const& i : pm) {
+ os << " " << i.first << " "
<< cmOutputConverter::EscapeForCMake(
- ge.Parse(i->second.GetValue())->Evaluate(this->LG, config));
+ ge.Parse(i.second.GetValue())->Evaluate(this->LG, config));
}
os << ")" << std::endl;
}
@@ -154,15 +153,14 @@ void cmTestGenerator::GenerateOldStyle(std::ostream& fout, Indent indent)
// Just double-quote all arguments so they are re-parsed
// correctly by the test system.
fout << " \"";
- for (std::string::const_iterator c = argit->begin(); c != argit->end();
- ++c) {
+ for (char c : *argit) {
// Escape quotes within arguments. We should escape
// backslashes too but we cannot because it makes the result
// inconsistent with previous behavior of this command.
- if ((*c == '"')) {
+ if (c == '"') {
fout << '\\';
}
- fout << *c;
+ fout << c;
}
fout << "\"";
}
@@ -173,9 +171,9 @@ void cmTestGenerator::GenerateOldStyle(std::ostream& fout, Indent indent)
if (!pm.empty()) {
fout << indent << "set_tests_properties(" << this->Test->GetName()
<< " PROPERTIES ";
- for (cmPropertyMap::const_iterator i = pm.begin(); i != pm.end(); ++i) {
- fout << " " << i->first << " "
- << cmOutputConverter::EscapeForCMake(i->second.GetValue());
+ for (auto const& i : pm) {
+ fout << " " << i.first << " "
+ << cmOutputConverter::EscapeForCMake(i.second.GetValue());
}
fout << ")" << std::endl;
}
diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx
index 07095b1..c04a683 100644
--- a/Source/cmUseMangledMesaCommand.cxx
+++ b/Source/cmUseMangledMesaCommand.cxx
@@ -38,11 +38,10 @@ bool cmUseMangledMesaCommand::InitialPass(std::vector<std::string> const& args,
return false;
}
cmSystemTools::MakeDirectory(destDir);
- for (std::vector<std::string>::iterator i = files.begin(); i != files.end();
- ++i) {
+ for (std::string const& f : files) {
std::string path = inputDir;
path += "/";
- path += *i;
+ path += f;
this->CopyAndFullPathMesaHeader(path.c_str(), destDir);
}
diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx
index 419e1a4..0e072b8 100644
--- a/Source/cmVariableWatch.cxx
+++ b/Source/cmVariableWatch.cxx
@@ -45,17 +45,15 @@ bool cmVariableWatch::AddWatch(const std::string& variable, WatchMethod method,
p->Method = method;
p->ClientData = client_data;
p->DeleteDataCall = delete_data;
- cmVariableWatch::VectorOfPairs* vp = &this->WatchMap[variable];
- cmVariableWatch::VectorOfPairs::size_type cc;
- for (cc = 0; cc < vp->size(); cc++) {
- cmVariableWatch::Pair* pair = (*vp)[cc];
+ cmVariableWatch::VectorOfPairs& vp = this->WatchMap[variable];
+ for (cmVariableWatch::Pair* pair : vp) {
if (pair->Method == method && client_data &&
client_data == pair->ClientData) {
// Callback already exists
return false;
}
}
- vp->push_back(p.release());
+ vp.push_back(p.release());
return true;
}
@@ -87,9 +85,8 @@ bool cmVariableWatch::VariableAccessed(const std::string& variable,
this->WatchMap.find(variable);
if (mit != this->WatchMap.end()) {
const cmVariableWatch::VectorOfPairs* vp = &mit->second;
- cmVariableWatch::VectorOfPairs::const_iterator it;
- for (it = vp->begin(); it != vp->end(); it++) {
- (*it)->Method(variable, access_type, (*it)->ClientData, newValue, mf);
+ for (cmVariableWatch::Pair* it : *vp) {
+ it->Method(variable, access_type, it->ClientData, newValue, mf);
}
return true;
}
diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx
index 281850e..9930086 100644
--- a/Source/cmVariableWatchCommand.cxx
+++ b/Source/cmVariableWatchCommand.cxx
@@ -91,11 +91,9 @@ cmVariableWatchCommand::cmVariableWatchCommand()
cmVariableWatchCommand::~cmVariableWatchCommand()
{
- std::set<std::string>::const_iterator it;
- for (it = this->WatchedVariables.begin(); it != this->WatchedVariables.end();
- ++it) {
+ for (std::string const& wv : this->WatchedVariables) {
this->Makefile->GetCMakeInstance()->GetVariableWatch()->RemoveWatch(
- *it, cmVariableWatchCommandVariableAccessed);
+ wv, cmVariableWatchCommandVariableAccessed);
}
}
diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx
index 24d7bf1..172ac62 100644
--- a/Source/cmWhileCommand.cxx
+++ b/Source/cmWhileCommand.cxx
@@ -60,11 +60,10 @@ bool cmWhileFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
while (isTrue) {
if (!errorString.empty()) {
std::string err = "had incorrect arguments: ";
- unsigned int i;
- for (i = 0; i < this->Args.size(); ++i) {
- err += (this->Args[i].Delim ? "\"" : "");
- err += this->Args[i].Value;
- err += (this->Args[i].Delim ? "\"" : "");
+ for (cmListFileArgument const& arg : this->Args) {
+ err += (arg.Delim ? "\"" : "");
+ err += arg.Value;
+ err += (arg.Delim ? "\"" : "");
err += " ";
}
err += "(";
@@ -78,9 +77,9 @@ bool cmWhileFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
}
// Invoke all the functions that were collected in the block.
- for (unsigned int c = 0; c < this->Functions.size(); ++c) {
+ for (cmListFileFunction const& fn : this->Functions) {
cmExecutionStatus status;
- mf.ExecuteCommand(this->Functions[c], status);
+ mf.ExecuteCommand(fn, status);
if (status.GetReturnInvoked()) {
inStatus.SetReturnInvoked();
return true;
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 425e221..9ffb9f8 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -244,31 +244,28 @@ Json::Value cmake::ReportCapabilitiesJson(bool haveServerMode) const
this->GetRegisteredGenerators(generatorInfoList);
JsonValueMapType generatorMap;
- for (std::vector<cmake::GeneratorInfo>::const_iterator i =
- generatorInfoList.begin();
- i != generatorInfoList.end(); ++i) {
- if (i->isAlias) { // skip aliases, they are there for compatibility reasons
+ for (cmake::GeneratorInfo const& gi : generatorInfoList) {
+ if (gi.isAlias) { // skip aliases, they are there for compatibility reasons
// only
continue;
}
- if (i->extraName.empty()) {
+ if (gi.extraName.empty()) {
Json::Value gen = Json::objectValue;
- gen["name"] = i->name;
- gen["toolsetSupport"] = i->supportsToolset;
- gen["platformSupport"] = i->supportsPlatform;
+ gen["name"] = gi.name;
+ gen["toolsetSupport"] = gi.supportsToolset;
+ gen["platformSupport"] = gi.supportsPlatform;
gen["extraGenerators"] = Json::arrayValue;
- generatorMap[i->name] = gen;
+ generatorMap[gi.name] = gen;
} else {
- Json::Value& gen = generatorMap[i->baseName];
- gen["extraGenerators"].append(i->extraName);
+ Json::Value& gen = generatorMap[gi.baseName];
+ gen["extraGenerators"].append(gi.extraName);
}
}
Json::Value generators = Json::arrayValue;
- for (JsonValueMapType::const_iterator i = generatorMap.begin();
- i != generatorMap.end(); ++i) {
- generators.append(i->second);
+ for (auto const& i : generatorMap) {
+ generators.append(i.second);
}
obj["generators"] = generators;
obj["serverMode"] = haveServerMode;
@@ -407,21 +404,18 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
// removed
std::vector<std::string> entriesToDelete;
std::vector<std::string> cacheKeys = this->State->GetCacheEntryKeys();
- for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
- it != cacheKeys.end(); ++it) {
- cmStateEnums::CacheEntryType t = this->State->GetCacheEntryType(*it);
+ for (std::string const& ck : cacheKeys) {
+ cmStateEnums::CacheEntryType t = this->State->GetCacheEntryType(ck);
if (t != cmStateEnums::STATIC) {
- if (regex.find(it->c_str())) {
- entriesToDelete.push_back(*it);
+ if (regex.find(ck.c_str())) {
+ entriesToDelete.push_back(ck);
}
}
}
// now remove them from the cache
- for (std::vector<std::string>::const_iterator currentEntry =
- entriesToDelete.begin();
- currentEntry != entriesToDelete.end(); ++currentEntry) {
- this->State->RemoveCacheEntry(*currentEntry);
+ for (std::string const& currentEntry : entriesToDelete) {
+ this->State->RemoveCacheEntry(currentEntry);
}
} else if (arg.find("-C", 0) == 0) {
std::string path = arg.substr(2);
@@ -568,9 +562,8 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
std::string libs = mf->GetSafeDefinition("PACKAGE_LIBRARIES");
std::vector<std::string> libList;
cmSystemTools::ExpandListArgument(libs, libList);
- for (std::vector<std::string>::const_iterator libIt = libList.begin();
- libIt != libList.end(); ++libIt) {
- tgt->AddLinkLibrary(*mf, *libIt, GENERAL_LibraryType);
+ for (std::string const& lib : libList) {
+ tgt->AddLinkLibrary(*mf, lib, GENERAL_LibraryType);
}
std::string buildType = mf->GetSafeDefinition("CMAKE_BUILD_TYPE");
@@ -906,49 +899,42 @@ void cmake::AddDefaultExtraGenerators()
void cmake::GetRegisteredGenerators(
std::vector<GeneratorInfo>& generators) const
{
- for (RegisteredGeneratorsVector::const_iterator i = this->Generators.begin(),
- e = this->Generators.end();
- i != e; ++i) {
+ for (cmGlobalGeneratorFactory* gen : this->Generators) {
std::vector<std::string> names;
- (*i)->GetGenerators(names);
+ gen->GetGenerators(names);
- for (size_t j = 0; j < names.size(); ++j) {
+ for (std::string const& name : names) {
GeneratorInfo info;
- info.supportsToolset = (*i)->SupportsToolset();
- info.supportsPlatform = (*i)->SupportsPlatform();
- info.name = names[j];
- info.baseName = names[j];
+ info.supportsToolset = gen->SupportsToolset();
+ info.supportsPlatform = gen->SupportsPlatform();
+ info.name = name;
+ info.baseName = name;
info.isAlias = false;
generators.push_back(info);
}
}
- for (RegisteredExtraGeneratorsVector::const_iterator
- i = this->ExtraGenerators.begin(),
- e = this->ExtraGenerators.end();
- i != e; ++i) {
+ for (cmExternalMakefileProjectGeneratorFactory* eg : this->ExtraGenerators) {
const std::vector<std::string> genList =
- (*i)->GetSupportedGlobalGenerators();
- for (std::vector<std::string>::const_iterator gen = genList.begin();
- gen != genList.end(); ++gen) {
+ eg->GetSupportedGlobalGenerators();
+ for (std::string const& gen : genList) {
GeneratorInfo info;
info.name = cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
- *gen, (*i)->GetName());
- info.baseName = *gen;
- info.extraName = (*i)->GetName();
+ gen, eg->GetName());
+ info.baseName = gen;
+ info.extraName = eg->GetName();
info.supportsPlatform = false;
info.supportsToolset = false;
info.isAlias = false;
generators.push_back(info);
}
- for (std::vector<std::string>::const_iterator a = (*i)->Aliases.begin();
- a != (*i)->Aliases.end(); ++a) {
+ for (std::string const& a : eg->Aliases) {
GeneratorInfo info;
- info.name = *a;
+ info.name = a;
if (!genList.empty()) {
info.baseName = genList.at(0);
}
- info.extraName = (*i)->GetName();
+ info.extraName = eg->GetName();
info.supportsPlatform = false;
info.supportsToolset = false;
info.isAlias = true;
@@ -962,23 +948,19 @@ createExtraGenerator(
const std::vector<cmExternalMakefileProjectGeneratorFactory*>& in,
const std::string& name)
{
- for (std::vector<cmExternalMakefileProjectGeneratorFactory*>::const_iterator
- i = in.begin();
- i != in.end(); ++i) {
+ for (cmExternalMakefileProjectGeneratorFactory* i : in) {
const std::vector<std::string> generators =
- (*i)->GetSupportedGlobalGenerators();
- if ((*i)->GetName() == name) { // Match aliases
- return std::make_pair((*i)->CreateExternalMakefileProjectGenerator(),
+ i->GetSupportedGlobalGenerators();
+ if (i->GetName() == name) { // Match aliases
+ return std::make_pair(i->CreateExternalMakefileProjectGenerator(),
generators.at(0));
}
- for (std::vector<std::string>::const_iterator g = generators.begin();
- g != generators.end(); ++g) {
+ for (std::string const& g : generators) {
const std::string fullName =
cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
- *g, (*i)->GetName());
+ g, i->GetName());
if (fullName == name) {
- return std::make_pair((*i)->CreateExternalMakefileProjectGenerator(),
- *g);
+ return std::make_pair(i->CreateExternalMakefileProjectGenerator(), g);
}
}
}
@@ -994,9 +976,8 @@ cmGlobalGenerator* cmake::CreateGlobalGenerator(const std::string& gname)
const std::string name = extra.second;
cmGlobalGenerator* generator = nullptr;
- for (RegisteredGeneratorsVector::const_iterator i = this->Generators.begin();
- i != this->Generators.end(); ++i) {
- generator = (*i)->CreateGlobalGenerator(name, this);
+ for (cmGlobalGeneratorFactory* g : this->Generators) {
+ generator = g->CreateGlobalGenerator(name, this);
if (generator) {
break;
}
@@ -1192,9 +1173,8 @@ int cmake::HandleDeleteCacheVariables(const std::string& var)
// load the empty cache
this->LoadCache();
// restore the changed compilers
- for (std::vector<SaveCacheEntry>::iterator i = saved.begin();
- i != saved.end(); ++i) {
- this->AddCacheEntry(i->key, i->value.c_str(), i->help.c_str(), i->type);
+ for (SaveCacheEntry const& i : saved) {
+ this->AddCacheEntry(i.key, i.value.c_str(), i.help.c_str(), i.type);
}
cmSystemTools::Message(warning.str().c_str());
// avoid reconfigure if there were errors
@@ -1791,35 +1771,30 @@ void cmake::SetIsInTryCompile(bool b)
void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v)
{
- for (RegisteredGeneratorsVector::const_iterator i = this->Generators.begin();
- i != this->Generators.end(); ++i) {
+ for (cmGlobalGeneratorFactory* g : this->Generators) {
cmDocumentationEntry e;
- (*i)->GetDocumentation(e);
+ g->GetDocumentation(e);
v.push_back(e);
}
- for (RegisteredExtraGeneratorsVector::const_iterator i =
- this->ExtraGenerators.begin();
- i != this->ExtraGenerators.end(); ++i) {
- const std::string doc = (*i)->GetDocumentation();
- const std::string name = (*i)->GetName();
+ for (cmExternalMakefileProjectGeneratorFactory* eg : this->ExtraGenerators) {
+ const std::string doc = eg->GetDocumentation();
+ const std::string name = eg->GetName();
// Aliases:
- for (std::vector<std::string>::const_iterator a = (*i)->Aliases.begin();
- a != (*i)->Aliases.end(); ++a) {
+ for (std::string const& a : eg->Aliases) {
cmDocumentationEntry e;
- e.Name = *a;
+ e.Name = a;
e.Brief = doc;
v.push_back(e);
}
// Full names:
const std::vector<std::string> generators =
- (*i)->GetSupportedGlobalGenerators();
- for (std::vector<std::string>::const_iterator g = generators.begin();
- g != generators.end(); ++g) {
+ eg->GetSupportedGlobalGenerators();
+ for (std::string const& g : generators) {
cmDocumentationEntry e;
e.Name =
- cmExternalMakefileProjectGenerator::CreateFullGeneratorName(*g, name);
+ cmExternalMakefileProjectGenerator::CreateFullGeneratorName(g, name);
e.Brief = doc;
v.push_back(e);
}
@@ -1935,13 +1910,12 @@ int cmake::CheckBuildSystem()
if (const char* productStr = mf->GetDefinition("CMAKE_MAKEFILE_PRODUCTS")) {
cmSystemTools::ExpandListArgument(productStr, products);
}
- for (std::vector<std::string>::const_iterator pi = products.begin();
- pi != products.end(); ++pi) {
- if (!(cmSystemTools::FileExists(pi->c_str()) ||
- cmSystemTools::FileIsSymlink(*pi))) {
+ for (std::string const& p : products) {
+ if (!(cmSystemTools::FileExists(p.c_str()) ||
+ cmSystemTools::FileIsSymlink(p))) {
if (verbose) {
std::ostringstream msg;
- msg << "Re-run cmake, missing byproduct: " << *pi << "\n";
+ msg << "Re-run cmake, missing byproduct: " << p << "\n";
cmSystemTools::Stdout(msg.str().c_str());
}
return 1;
@@ -2479,12 +2453,10 @@ void cmake::RunCheckForUnusedVariables()
bool haveUnused = false;
std::ostringstream msg;
msg << "Manually-specified variables were not used by the project:";
- for (std::map<std::string, bool>::const_iterator it =
- this->UsedCliVariables.begin();
- it != this->UsedCliVariables.end(); ++it) {
- if (!it->second) {
+ for (auto const& it : this->UsedCliVariables) {
+ if (!it.second) {
haveUnused = true;
- msg << "\n " << it->first;
+ msg << "\n " << it.first;
}
}
if (haveUnused) {
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index a60b2b2..09dcb6d 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -311,22 +311,20 @@ int do_cmake(int ac, char const* const* av)
if (list_cached || list_all_cached) {
std::cout << "-- Cache values" << std::endl;
std::vector<std::string> keys = cm.GetState()->GetCacheEntryKeys();
- for (std::vector<std::string>::const_iterator it = keys.begin();
- it != keys.end(); ++it) {
- cmStateEnums::CacheEntryType t = cm.GetState()->GetCacheEntryType(*it);
+ for (std::string const& k : keys) {
+ cmStateEnums::CacheEntryType t = cm.GetState()->GetCacheEntryType(k);
if (t != cmStateEnums::INTERNAL && t != cmStateEnums::STATIC &&
t != cmStateEnums::UNINITIALIZED) {
const char* advancedProp =
- cm.GetState()->GetCacheEntryProperty(*it, "ADVANCED");
+ cm.GetState()->GetCacheEntryProperty(k, "ADVANCED");
if (list_all_cached || !advancedProp) {
if (list_help) {
std::cout << "// "
- << cm.GetState()->GetCacheEntryProperty(*it,
- "HELPSTRING")
+ << cm.GetState()->GetCacheEntryProperty(k, "HELPSTRING")
<< std::endl;
}
- std::cout << *it << ":" << cmState::CacheEntryTypeToString(t) << "="
- << cm.GetState()->GetCacheEntryValue(*it) << std::endl;
+ std::cout << k << ":" << cmState::CacheEntryTypeToString(t) << "="
+ << cm.GetState()->GetCacheEntryValue(k) << std::endl;
if (list_help) {
std::cout << std::endl;
}
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 0791cb3..91c229c 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -1462,24 +1462,23 @@ private:
// For visual studio 2005 and newer manifest files need to be embedded into
// exe and dll's. This code does that in such a way that incremental linking
// still works.
-int cmcmd::VisualStudioLink(std::vector<std::string>& args, int type)
+int cmcmd::VisualStudioLink(std::vector<std::string> const& args, int type)
{
if (args.size() < 2) {
return -1;
}
const bool verbose = cmSystemTools::HasEnv("VERBOSE");
std::vector<std::string> expandedArgs;
- for (std::vector<std::string>::iterator i = args.begin(); i != args.end();
- ++i) {
+ for (std::string const& i : args) {
// check for nmake temporary files
- if ((*i)[0] == '@' && i->find("@CMakeFiles") != 0) {
- cmsys::ifstream fin(i->substr(1).c_str());
+ if (i[0] == '@' && i.find("@CMakeFiles") != 0) {
+ cmsys::ifstream fin(i.substr(1).c_str());
std::string line;
while (cmSystemTools::GetLineFromStream(fin, line)) {
cmSystemTools::ParseWindowsCommandLine(line.c_str(), expandedArgs);
}
} else {
- expandedArgs.push_back(*i);
+ expandedArgs.push_back(i);
}
}
diff --git a/Source/cmcmd.h b/Source/cmcmd.h
index faac1d2..457b760 100644
--- a/Source/cmcmd.h
+++ b/Source/cmcmd.h
@@ -29,7 +29,7 @@ protected:
static int ExecuteLinkScript(std::vector<std::string>& args);
static int WindowsCEEnvironment(const char* version,
const std::string& name);
- static int VisualStudioLink(std::vector<std::string>& args, int type);
+ static int VisualStudioLink(std::vector<std::string> const& args, int type);
};
#endif