diff options
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 191 |
1 files changed, 77 insertions, 114 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index c9dc93c..845568b 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; } } @@ -2094,9 +2067,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; @@ -2243,9 +2215,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; } } @@ -2967,23 +2939,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); @@ -3000,29 +2971,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)); } } } @@ -3112,10 +3082,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; } @@ -3166,12 +3133,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()) { @@ -3365,9 +3331,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; @@ -3657,14 +3621,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); } } |