[Cmake-commits] CMake branch, master, updated. v3.10.0-rc5-304-gac38bb3

Kitware Robot kwrobot at kitware.com
Mon Nov 13 09:55:08 EST 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, master has been updated
       via  ac38bb3aa633c8abf01b3ddad003afd5664c3410 (commit)
       via  b62eb8f69728f9ff1a7ab3aae6e69224763c86a6 (commit)
       via  98cbcedd7414f9e33e166b09ef082c6ecabcb7cf (commit)
       via  2ee10119eac2802a234543581b1303d91b944afa (commit)
      from  67c981fdc25e01ae52daa67c447a03fd05b40634 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ac38bb3aa633c8abf01b3ddad003afd5664c3410
commit ac38bb3aa633c8abf01b3ddad003afd5664c3410
Merge: b62eb8f 2ee1011
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Nov 13 14:53:44 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Mon Nov 13 09:53:51 2017 -0500

    Merge topic 'swig-broken-dependency-scan'
    
    2ee10119 swig: fix incremental build in case of removed interface files
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !1457


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b62eb8f69728f9ff1a7ab3aae6e69224763c86a6
commit b62eb8f69728f9ff1a7ab3aae6e69224763c86a6
Merge: 67c981f 98cbced
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Nov 13 14:52:07 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Mon Nov 13 09:52:43 2017 -0500

    Merge topic 'xcodeForLoopCleanup'
    
    98cbcedd Xcode: use ranged for loops, cleanup existing for loops
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !1456


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=98cbcedd7414f9e33e166b09ef082c6ecabcb7cf
commit 98cbcedd7414f9e33e166b09ef082c6ecabcb7cf
Author:     Craig Scott <craig.scott at crascit.com>
AuthorDate: Tue Nov 7 15:41:47 2017 +0800
Commit:     Craig Scott <craig.scott at crascit.com>
CommitDate: Fri Nov 10 13:12:57 2017 +0800

    Xcode: use ranged for loops, cleanup existing for loops
    
    The changes are mostly converting old-style explicit iterator for loops
    into ranged for statements. A number of for loops had already been
    changed over, but local variables had been left behind instead of being
    absorbed into the ranged for statement, so these have been cleaned up
    too. A couple of minor improvements were made in areas already being
    updated by the for loop changes to slightly simplify the code or to
    avoid unnecessary conversions between `const char*` and `std::string`.

diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index a85a700..397a53c 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -368,14 +368,13 @@ cmLocalGenerator* cmGlobalXCodeGenerator::CreateLocalGenerator(cmMakefile* mf)
 
 void cmGlobalXCodeGenerator::AddExtraIDETargets()
 {
-  std::map<std::string, std::vector<cmLocalGenerator*>>::iterator it;
   // make sure extra targets are added before calling
   // the parent generate which will call trace depends
-  for (it = this->ProjectMap.begin(); it != this->ProjectMap.end(); ++it) {
-    cmLocalGenerator* root = it->second[0];
+  for (auto keyVal : this->ProjectMap) {
+    cmLocalGenerator* root = keyVal.second[0];
     this->SetGenerationRoot(root);
     // add ALL_BUILD, INSTALL, etc
-    this->AddExtraTargets(root, it->second);
+    this->AddExtraTargets(root, keyVal.second);
   }
 }
 
@@ -385,9 +384,8 @@ void cmGlobalXCodeGenerator::Generate()
   if (cmSystemTools::GetErrorOccuredFlag()) {
     return;
   }
-  std::map<std::string, std::vector<cmLocalGenerator*>>::iterator it;
-  for (it = this->ProjectMap.begin(); it != this->ProjectMap.end(); ++it) {
-    cmLocalGenerator* root = it->second[0];
+  for (auto keyVal : this->ProjectMap) {
+    cmLocalGenerator* root = keyVal.second[0];
 
     bool generateTopLevelProjectOnly =
       root->GetMakefile()->IsOn("CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY");
@@ -401,7 +399,7 @@ void cmGlobalXCodeGenerator::Generate()
 
     this->SetGenerationRoot(root);
     // now create the project
-    this->OutputXCodeProject(root, it->second);
+    this->OutputXCodeProject(root, keyVal.second);
   }
 }
 
@@ -481,8 +479,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
       continue;
     }
 
-    const std::vector<cmGeneratorTarget*>& tgts = gen->GetGeneratorTargets();
-    for (auto target : tgts) {
+    for (auto target : gen->GetGeneratorTargets()) {
       if (target->GetType() == cmStateEnums::GLOBAL_TARGET) {
         continue;
       }
@@ -549,10 +546,9 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
   makefileStream << "space:= $(empty) $(empty)\n";
   makefileStream << "spaceplus:= $(empty)\\ $(empty)\n\n";
 
-  for (std::vector<std::string>::const_iterator i = lfiles.begin();
-       i != lfiles.end(); ++i) {
+  for (const auto& lfile : lfiles) {
     makefileStream << "TARGETS += $(subst $(space),$(spaceplus),$(wildcard "
-                   << this->ConvertToRelativeForMake(i->c_str()) << "))\n";
+                   << this->ConvertToRelativeForMake(lfile.c_str()) << "))\n";
   }
 
   std::string checkCache = root->GetBinaryDirectory();
@@ -761,9 +757,8 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
     cmSystemTools::ExpandListArgument(extraFileAttributes, attributes);
 
     // Store the attributes.
-    for (std::vector<std::string>::const_iterator ai = attributes.begin();
-         ai != attributes.end(); ++ai) {
-      attrs->AddObject(this->CreateString(*ai));
+    for (const auto& attribute : attributes) {
+      attrs->AddObject(this->CreateString(attribute));
     }
   }
 
@@ -958,12 +953,10 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
   cmLocalGenerator* gen, std::vector<cmXCodeObject*>& targets)
 {
   this->SetCurrentLocalGenerator(gen);
-  const std::vector<cmGeneratorTarget*>& tgts =
-    this->CurrentLocalGenerator->GetGeneratorTargets();
   typedef std::map<std::string, cmGeneratorTarget*, cmCompareTargets>
     cmSortedTargets;
   cmSortedTargets sortedTargets;
-  for (auto tgt : tgts) {
+  for (auto tgt : this->CurrentLocalGenerator->GetGeneratorTargets()) {
     sortedTargets[tgt->GetName()] = tgt;
   }
   for (auto& sortedTarget : sortedTargets) {
@@ -1010,21 +1003,20 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
     std::vector<cmXCodeObject*> headerFiles;
     std::vector<cmXCodeObject*> resourceFiles;
     std::vector<cmXCodeObject*> sourceFiles;
-    for (std::vector<cmSourceFile*>::const_iterator i = classes.begin();
-         i != classes.end(); ++i) {
-      cmXCodeObject* xsf =
-        this->CreateXCodeSourceFile(this->CurrentLocalGenerator, *i, gtgt);
+    for (auto sourceFile : classes) {
+      cmXCodeObject* xsf = this->CreateXCodeSourceFile(
+        this->CurrentLocalGenerator, sourceFile, gtgt);
       cmXCodeObject* fr = xsf->GetObject("fileRef");
       cmXCodeObject* filetype = fr->GetObject()->GetObject("explicitFileType");
 
       cmGeneratorTarget::SourceFileFlags tsFlags =
-        gtgt->GetTargetSourceFileFlags(*i);
+        gtgt->GetTargetSourceFileFlags(sourceFile);
 
       if (filetype && filetype->GetString() == "compiled.mach-o.objfile") {
-        if ((*i)->GetObjectLibrary().empty()) {
+        if (sourceFile->GetObjectLibrary().empty()) {
           externalObjFiles.push_back(xsf);
         }
-      } else if (this->IsHeaderFile(*i) ||
+      } else if (this->IsHeaderFile(sourceFile) ||
                  (tsFlags.Type ==
                   cmGeneratorTarget::SourceFileTypePrivateHeader) ||
                  (tsFlags.Type ==
@@ -1032,12 +1024,13 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
         headerFiles.push_back(xsf);
       } else if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource) {
         resourceFiles.push_back(xsf);
-      } else if (!(*i)->GetPropertyAsBool("HEADER_FILE_ONLY")) {
+      } else if (!sourceFile->GetPropertyAsBool("HEADER_FILE_ONLY")) {
         // Include this file in the build if it has a known language
         // and has not been listed as an ignored extension for this
         // generator.
-        if (!this->CurrentLocalGenerator->GetSourceFileLanguage(**i).empty() &&
-            !this->IgnoreFile((*i)->GetExtension().c_str())) {
+        if (!this->CurrentLocalGenerator->GetSourceFileLanguage(*sourceFile)
+               .empty() &&
+            !this->IgnoreFile(sourceFile->GetExtension().c_str())) {
           sourceFiles.push_back(xsf);
         }
       }
@@ -1049,12 +1042,11 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
       // within the target.)
       std::vector<cmSourceFile const*> objs;
       gtgt->GetExternalObjects(objs, "");
-      for (std::vector<cmSourceFile const*>::const_iterator oi = objs.begin();
-           oi != objs.end(); ++oi) {
-        if ((*oi)->GetObjectLibrary().empty()) {
+      for (auto sourceFile : objs) {
+        if (sourceFile->GetObjectLibrary().empty()) {
           continue;
         }
-        std::string const& obj = (*oi)->GetFullPath();
+        std::string const& obj = sourceFile->GetFullPath();
         cmXCodeObject* xsf =
           this->CreateXCodeSourceFileFromPath(obj, gtgt, "", nullptr);
         externalObjFiles.push_back(xsf);
@@ -1127,16 +1119,14 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
       typedef std::map<std::string, std::vector<cmSourceFile*>>
         mapOfVectorOfSourceFiles;
       mapOfVectorOfSourceFiles bundleFiles;
-      for (std::vector<cmSourceFile*>::const_iterator i = classes.begin();
-           i != classes.end(); ++i) {
+      for (auto sourceFile : classes) {
         cmGeneratorTarget::SourceFileFlags tsFlags =
-          gtgt->GetTargetSourceFileFlags(*i);
+          gtgt->GetTargetSourceFileFlags(sourceFile);
         if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeMacContent) {
-          bundleFiles[tsFlags.MacFolder].push_back(*i);
+          bundleFiles[tsFlags.MacFolder].push_back(sourceFile);
         }
       }
-      mapOfVectorOfSourceFiles::iterator mit;
-      for (mit = bundleFiles.begin(); mit != bundleFiles.end(); ++mit) {
+      for (auto keySources : bundleFiles) {
         cmXCodeObject* copyFilesBuildPhase =
           this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase);
         copyFilesBuildPhase->SetComment("Copy files");
@@ -1147,13 +1137,13 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
         std::ostringstream ostr;
         if (gtgt->IsFrameworkOnApple()) {
           // dstPath in frameworks is relative to Versions/<version>
-          ostr << mit->first;
-        } else if (mit->first != "MacOS") {
+          ostr << keySources.first;
+        } else if (keySources.first != "MacOS") {
           if (gtgt->Target->GetMakefile()->PlatformIsAppleIos()) {
-            ostr << mit->first;
+            ostr << keySources.first;
           } else {
             // dstPath in bundles is relative to Contents/MacOS
-            ostr << "../" << mit->first;
+            ostr << "../" << keySources.first;
           }
         }
         copyFilesBuildPhase->AddAttribute("dstPath",
@@ -1162,10 +1152,9 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
                                           this->CreateString("0"));
         buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
         copyFilesBuildPhase->AddAttribute("files", buildFiles);
-        std::vector<cmSourceFile*>::iterator sfIt;
-        for (sfIt = mit->second.begin(); sfIt != mit->second.end(); ++sfIt) {
+        for (auto sourceFile : keySources.second) {
           cmXCodeObject* xsf = this->CreateXCodeSourceFile(
-            this->CurrentLocalGenerator, *sfIt, gtgt);
+            this->CurrentLocalGenerator, sourceFile, gtgt);
           buildFiles->AddObject(xsf);
         }
         contentBuildPhases.push_back(copyFilesBuildPhase);
@@ -1178,16 +1167,14 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
       typedef std::map<std::string, std::vector<cmSourceFile*>>
         mapOfVectorOfSourceFiles;
       mapOfVectorOfSourceFiles bundleFiles;
-      for (std::vector<cmSourceFile*>::const_iterator i = classes.begin();
-           i != classes.end(); ++i) {
+      for (auto sourceFile : classes) {
         cmGeneratorTarget::SourceFileFlags tsFlags =
-          gtgt->GetTargetSourceFileFlags(*i);
+          gtgt->GetTargetSourceFileFlags(sourceFile);
         if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeDeepResource) {
-          bundleFiles[tsFlags.MacFolder].push_back(*i);
+          bundleFiles[tsFlags.MacFolder].push_back(sourceFile);
         }
       }
-      mapOfVectorOfSourceFiles::iterator mit;
-      for (mit = bundleFiles.begin(); mit != bundleFiles.end(); ++mit) {
+      for (auto keySources : bundleFiles) {
         cmXCodeObject* copyFilesBuildPhase =
           this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase);
         copyFilesBuildPhase->SetComment("Copy files");
@@ -1195,16 +1182,15 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
                                           this->CreateString("2147483647"));
         copyFilesBuildPhase->AddAttribute("dstSubfolderSpec",
                                           this->CreateString("7"));
-        copyFilesBuildPhase->AddAttribute("dstPath",
-                                          this->CreateString(mit->first));
+        copyFilesBuildPhase->AddAttribute(
+          "dstPath", this->CreateString(keySources.first));
         copyFilesBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
                                           this->CreateString("0"));
         buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
         copyFilesBuildPhase->AddAttribute("files", buildFiles);
-        std::vector<cmSourceFile*>::iterator sfIt;
-        for (sfIt = mit->second.begin(); sfIt != mit->second.end(); ++sfIt) {
+        for (auto sourceFile : keySources.second) {
           cmXCodeObject* xsf = this->CreateXCodeSourceFile(
-            this->CurrentLocalGenerator, *sfIt, gtgt);
+            this->CurrentLocalGenerator, sourceFile, gtgt);
           buildFiles->AddObject(xsf);
         }
         contentBuildPhases.push_back(copyFilesBuildPhase);
@@ -1243,11 +1229,9 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
 
 void cmGlobalXCodeGenerator::ForceLinkerLanguages()
 {
-  for (auto& localGenerator : this->LocalGenerators) {
-    const std::vector<cmGeneratorTarget*>& tgts =
-      localGenerator->GetGeneratorTargets();
+  for (auto localGenerator : this->LocalGenerators) {
     // All targets depend on the build-system check target.
-    for (auto tgt : tgts) {
+    for (auto tgt : localGenerator->GetGeneratorTargets()) {
       // This makes sure all targets link using the proper language.
       this->ForceLinkerLanguage(tgt);
     }
@@ -1269,8 +1253,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt)
   }
 
   // If the language is compiled as a source trust Xcode to link with it.
-  cmLinkImplementation const* impl = gtgt->GetLinkImplementation("NOCONFIG");
-  for (auto const& Language : impl->Languages) {
+  for (auto const& Language :
+       gtgt->GetLinkImplementation("NOCONFIG")->Languages) {
     if (Language == llang) {
       return;
     }
@@ -1370,10 +1354,9 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(
   }
   // add all the sources
   std::vector<cmCustomCommand> commands;
-  for (std::vector<cmSourceFile*>::const_iterator i = classes.begin();
-       i != classes.end(); ++i) {
-    if ((*i)->GetCustomCommand()) {
-      commands.push_back(*(*i)->GetCustomCommand());
+  for (auto sourceFile : classes) {
+    if (sourceFile->GetCustomCommand()) {
+      commands.push_back(*sourceFile->GetCustomCommand());
     }
   }
   // create prebuild phase
@@ -1405,10 +1388,8 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(
   if (resourceBuildPhase) {
     buildPhases->AddObject(resourceBuildPhase);
   }
-  std::vector<cmXCodeObject*>::iterator cit;
-  for (cit = contentBuildPhases.begin(); cit != contentBuildPhases.end();
-       ++cit) {
-    buildPhases->AddObject(*cit);
+  for (auto obj : contentBuildPhases) {
+    buildPhases->AddObject(obj);
   }
   if (sourceBuildPhase) {
     buildPhases->AddObject(sourceBuildPhase);
@@ -1531,12 +1512,9 @@ void cmGlobalXCodeGenerator::AddCommandsToBuildPhase(
   makefile += name;
   makefile += ".make";
 
-  for (std::vector<std::string>::const_iterator currentConfig =
-         this->CurrentConfigurationTypes.begin();
-       currentConfig != this->CurrentConfigurationTypes.end();
-       currentConfig++) {
+  for (const auto& currentConfig : this->CurrentConfigurationTypes) {
     this->CreateCustomRulesMakefile(makefile.c_str(), target, commands,
-                                    *currentConfig);
+                                    currentConfig);
   }
 
   std::string cdir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory();
@@ -2016,8 +1994,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
   }
   // Add framework search paths needed for linking.
   if (cmComputeLinkInformation* cli = gtgt->GetLinkInformation(configName)) {
-    std::vector<std::string> const& fwDirs = cli->GetFrameworkPaths();
-    for (auto const& fwDir : fwDirs) {
+    for (auto const& fwDir : cli->GetFrameworkPaths()) {
       if (emitted.insert(fwDir).second) {
         std::string incpath = this->XCodeEscapePath(fwDir);
         if (emitSystemIncludes &&
@@ -2182,9 +2159,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
     // runpath dirs needs to be unique to prevent corruption
     std::set<std::string> unique_dirs;
 
-    for (std::vector<std::string>::const_iterator i = runtimeDirs.begin();
-         i != runtimeDirs.end(); ++i) {
-      std::string runpath = *i;
+    for (auto runpath : runtimeDirs) {
       runpath = this->ExpandCFGIntDir(runpath, configName);
 
       if (unique_dirs.find(runpath) == unique_dirs.end()) {
@@ -2244,8 +2219,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
   // put this last so it can override existing settings
   // Convert "XCODE_ATTRIBUTE_*" properties directly.
   {
-    std::vector<std::string> const& props = gtgt->GetPropertyKeys();
-    for (auto const& prop : props) {
+    for (auto const& prop : gtgt->GetPropertyKeys()) {
       if (prop.find("XCODE_ATTRIBUTE_") == 0) {
         std::string attribute = prop.substr(16);
         this->FilterConfigurationAttribute(configName, attribute);
@@ -2312,10 +2286,9 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateUtilityTarget(
     listfile += "/CMakeLists.txt";
     sources.push_back(gtgt->Makefile->GetOrCreateSource(listfile));
 
-    for (std::vector<cmSourceFile*>::const_iterator i = sources.begin();
-         i != sources.end(); ++i) {
-      if (!(*i)->GetPropertyAsBool("GENERATED")) {
-        this->CreateXCodeFileReference(*i, gtgt);
+    for (auto sourceFile : sources) {
+      if (!sourceFile->GetPropertyAsBool("GENERATED")) {
+        this->CreateXCodeFileReference(sourceFile, gtgt);
       }
     }
   }
@@ -2584,17 +2557,10 @@ void cmGlobalXCodeGenerator::AppendBuildSettingAttribute(
     target->GetObject("buildConfigurationList")->GetObject();
   cmXCodeObject* buildConfigs =
     configurationList->GetObject("buildConfigurations");
-  std::vector<cmXCodeObject*> list = buildConfigs->GetObjectList();
-  // each configuration and the target itself has a buildSettings in it
-  // list.push_back(target);
-  for (auto& i : list) {
-    if (!configName.empty()) {
-      if (i->GetObject("name")->GetString() == configName) {
-        cmXCodeObject* settings = i->GetObject("buildSettings");
-        this->AppendOrAddBuildSetting(settings, attribute, value);
-      }
-    } else {
-      cmXCodeObject* settings = i->GetObject("buildSettings");
+  for (auto obj : buildConfigs->GetObjectList()) {
+    if (configName.empty() ||
+        obj->GetObject("name")->GetString() == configName) {
+      cmXCodeObject* settings = obj->GetObject("buildSettings");
       this->AppendOrAddBuildSetting(settings, attribute, value);
     }
   }
@@ -2612,8 +2578,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
   }
 
   // Add dependencies on other CMake targets.
-  TargetDependSet const& deps = this->GetTargetDirectDepends(gt);
-  for (auto dep : deps) {
+  for (const auto& dep : this->GetTargetDirectDepends(gt)) {
     if (cmXCodeObject* dptarget = this->FindXCodeTarget(dep)) {
       this->AddDependTarget(target, dptarget);
     }
@@ -2628,14 +2593,13 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
       const char* sep = "";
       std::vector<cmSourceFile const*> objs;
       gt->GetExternalObjects(objs, configName);
-      for (std::vector<cmSourceFile const*>::const_iterator oi = objs.begin();
-           oi != objs.end(); ++oi) {
-        if ((*oi)->GetObjectLibrary().empty()) {
+      for (auto sourceFile : objs) {
+        if (sourceFile->GetObjectLibrary().empty()) {
           continue;
         }
         linkObjs += sep;
         sep = " ";
-        linkObjs += this->XCodeEscapePath((*oi)->GetFullPath());
+        linkObjs += this->XCodeEscapePath(sourceFile->GetFullPath());
       }
       this->AppendBuildSettingAttribute(
         target, this->GetTargetLinkFlagsVar(gt), linkObjs.c_str(), configName);
@@ -2655,18 +2619,14 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
     cmComputeLinkInformation& cli = *pcli;
 
     // Add dependencies directly on library files.
-    {
-      std::vector<std::string> const& libDeps = cli.GetDepends();
-      for (auto const& libDep : libDeps) {
-        target->AddDependLibrary(configName, libDep);
-      }
+    for (auto const& libDep : cli.GetDepends()) {
+      target->AddDependLibrary(configName, libDep);
     }
 
     // add the library search paths
     {
-      std::vector<std::string> const& libDirs = cli.GetDirectories();
       std::string linkDirs;
-      for (auto const& libDir : libDirs) {
+      for (auto const& libDir : cli.GetDirectories()) {
         if (!libDir.empty() && libDir != "/usr/lib") {
           // Now add the same one but append
           // $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to it:
@@ -2685,9 +2645,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
     {
       std::string linkLibs;
       const char* sep = "";
-      typedef cmComputeLinkInformation::ItemVector ItemVector;
-      ItemVector const& libNames = cli.GetItems();
-      for (auto const& libName : libNames) {
+      for (auto const& libName : cli.GetItems()) {
         linkLibs += sep;
         sep = " ";
         if (libName.IsPath) {
@@ -2713,9 +2671,7 @@ bool cmGlobalXCodeGenerator::CreateGroups(
   for (auto& generator : generators) {
     cmMakefile* mf = generator->GetMakefile();
     std::vector<cmSourceGroup> sourceGroups = mf->GetSourceGroups();
-    const std::vector<cmGeneratorTarget*>& tgts =
-      generator->GetGeneratorTargets();
-    for (auto gtgt : tgts) {
+    for (auto gtgt : generator->GetGeneratorTargets()) {
       // Same skipping logic here as in CreateXCodeTargets so that we do not
       // end up with (empty anyhow) ZERO_CHECK, install, or test source
       // groups:
@@ -2738,11 +2694,8 @@ bool cmGlobalXCodeGenerator::CreateGroups(
         gtgt->AddSource(plist);
       }
 
-      std::vector<cmGeneratorTarget::AllConfigSource> const& sources =
-        gtgt->GetAllConfigSources();
-
       // Put cmSourceFile instances in proper groups:
-      for (auto const& si : sources) {
+      for (auto const& si : gtgt->GetAllConfigSources()) {
         cmSourceFile const* sf = si.Source;
         if (this->XcodeVersion >= 50 && !sf->GetObjectLibrary().empty()) {
           // Object library files go on the link line instead.
@@ -2851,11 +2804,10 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateOrGetPBXGroup(
 
   // It's a recursive folder structure, let's find the real parent group
   if (std::string(sg->GetFullName()) != std::string(sg->GetName())) {
-    std::vector<std::string> folders =
-      cmSystemTools::tokenize(sg->GetFullName(), "\\");
     std::string curr_folder = target;
     curr_folder += "/";
-    for (auto const& folder : folders) {
+    for (auto const& folder :
+         cmSystemTools::tokenize(sg->GetFullName(), "\\")) {
       curr_folder += folder;
       std::map<std::string, cmXCodeObject*>::iterator i_folder =
         this->GroupNameMap.find(curr_folder);
@@ -2960,10 +2912,9 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
     this->CreateObject(cmXCodeObject::OBJECT_LIST);
   typedef std::vector<std::pair<std::string, cmXCodeObject*>> Configs;
   Configs configs;
-  const char* defaultConfigName = "Debug";
-  for (unsigned int i = 0; i < this->CurrentConfigurationTypes.size(); ++i) {
-    const char* name = this->CurrentConfigurationTypes[i].c_str();
-    if (0 == i) {
+  std::string defaultConfigName;
+  for (const auto& name : this->CurrentConfigurationTypes) {
+    if (defaultConfigName.empty()) {
       defaultConfigName = name;
     }
     cmXCodeObject* config =
@@ -2971,6 +2922,9 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
     config->AddAttribute("name", this->CreateString(name));
     configs.push_back(std::make_pair(name, config));
   }
+  if (defaultConfigName.empty()) {
+    defaultConfigName = "Debug";
+  }
   for (auto& config : configs) {
     buildConfigurations->AddObject(config.second);
   }
@@ -3035,16 +2989,14 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
 
     // Put this last so it can override existing settings
     // Convert "CMAKE_XCODE_ATTRIBUTE_*" variables directly.
-    std::vector<std::string> vars = this->CurrentMakefile->GetDefinitions();
-    for (std::vector<std::string>::const_iterator d = vars.begin();
-         d != vars.end(); ++d) {
-      if (d->find("CMAKE_XCODE_ATTRIBUTE_") == 0) {
-        std::string attribute = d->substr(22);
+    for (const auto& var : this->CurrentMakefile->GetDefinitions()) {
+      if (var.find("CMAKE_XCODE_ATTRIBUTE_") == 0) {
+        std::string attribute = var.substr(22);
         this->FilterConfigurationAttribute(config.first, attribute);
         if (!attribute.empty()) {
           cmGeneratorExpression ge;
           std::string processed =
-            ge.Parse(this->CurrentMakefile->GetDefinition(*d))
+            ge.Parse(this->CurrentMakefile->GetDefinition(var))
               ->Evaluate(this->CurrentLocalGenerator, config.first);
           buildSettingsForCfg->AddAttribute(attribute,
                                             this->CreateString(processed));
@@ -3160,10 +3112,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
     "# link.  This forces Xcode to relink the targets from scratch.  It\n"
     "# does not seem to check these dependencies itself.\n";
   /* clang-format on */
-  for (std::vector<std::string>::const_iterator ct =
-         this->CurrentConfigurationTypes.begin();
-       ct != this->CurrentConfigurationTypes.end(); ++ct) {
-    std::string configName = *ct;
+  for (const auto& configName : this->CurrentConfigurationTypes) {
     for (auto target : targets) {
       cmGeneratorTarget* gt = target->GetTarget();
 
@@ -3173,7 +3122,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
           gt->GetType() == cmStateEnums::SHARED_LIBRARY ||
           gt->GetType() == cmStateEnums::MODULE_LIBRARY) {
         // Declare an entry point for the target post-build phase.
-        makefileStream << this->PostBuildMakeTarget(gt->GetName(), *ct)
+        makefileStream << this->PostBuildMakeTarget(gt->GetName(), configName)
                        << ":\n";
       }
 
@@ -3186,21 +3135,19 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
 
         // Add this target to the post-build phases of its dependencies.
         std::map<std::string, cmXCodeObject::StringVec>::const_iterator y =
-          target->GetDependTargets().find(*ct);
+          target->GetDependTargets().find(configName);
         if (y != target->GetDependTargets().end()) {
-          std::vector<std::string> const& deptgts = y->second;
-          for (auto const& deptgt : deptgts) {
-            makefileStream << this->PostBuildMakeTarget(deptgt, *ct) << ": "
-                           << trel << "\n";
+          for (auto const& deptgt : y->second) {
+            makefileStream << this->PostBuildMakeTarget(deptgt, configName)
+                           << ": " << trel << "\n";
           }
         }
 
         std::vector<cmGeneratorTarget*> objlibs;
         gt->GetObjectLibrariesCMP0026(objlibs);
-        for (std::vector<cmGeneratorTarget*>::const_iterator it =
-               objlibs.begin();
-             it != objlibs.end(); ++it) {
-          makefileStream << this->PostBuildMakeTarget((*it)->GetName(), *ct)
+        for (auto objLib : objlibs) {
+          makefileStream << this->PostBuildMakeTarget(objLib->GetName(),
+                                                      configName)
                          << ": " << trel << "\n";
         }
 
@@ -3209,23 +3156,20 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
 
         // List dependencies if any exist.
         std::map<std::string, cmXCodeObject::StringVec>::const_iterator x =
-          target->GetDependLibraries().find(*ct);
+          target->GetDependLibraries().find(configName);
         if (x != target->GetDependLibraries().end()) {
-          std::vector<std::string> const& deplibs = x->second;
-          for (auto const& deplib : deplibs) {
+          for (auto const& deplib : x->second) {
             std::string file = this->ConvertToRelativeForMake(deplib.c_str());
             makefileStream << "\\\n\t" << file;
             dummyRules.insert(file);
           }
         }
 
-        for (std::vector<cmGeneratorTarget*>::const_iterator it =
-               objlibs.begin();
-             it != objlibs.end(); ++it) {
+        for (auto objLib : objlibs) {
 
-          const std::string objLibName = (*it)->GetName();
+          const std::string objLibName = objLib->GetName();
           std::string d = this->GetObjectsNormalDirectory(this->CurrentProject,
-                                                          configName, *it);
+                                                          configName, objLib);
           d += "lib";
           d += objLibName;
           d += ".a";
@@ -3245,7 +3189,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
         if (this->Architectures.size() > 1) {
           std::string universal = this->GetObjectsNormalDirectory(
             this->CurrentProject, configName, gt);
-          for (auto& architecture : this->Architectures) {
+          for (const auto& architecture : this->Architectures) {
             std::string universalFile = universal;
             universalFile += architecture;
             universalFile += "/";
@@ -3276,7 +3220,7 @@ void cmGlobalXCodeGenerator::OutputXCodeProject(
     return;
   }
   // Skip local generators that are excluded from this project.
-  for (auto& generator : generators) {
+  for (auto generator : generators) {
     if (this->IsExcluded(root, generator)) {
       continue;
     }
@@ -3322,10 +3266,7 @@ void cmGlobalXCodeGenerator::OutputXCodeSharedSchemes(
   // collect all tests for the targets
   std::map<std::string, cmXCodeScheme::TestObjects> testables;
 
-  for (std::vector<cmXCodeObject*>::const_iterator i =
-         this->XCodeObjects.begin();
-       i != this->XCodeObjects.end(); ++i) {
-    cmXCodeObject* obj = *i;
+  for (auto obj : this->XCodeObjects) {
     if (obj->GetType() != cmXCodeObject::OBJECT ||
         obj->GetIsA() != cmXCodeObject::PBXNativeTarget) {
       continue;
@@ -3344,10 +3285,7 @@ void cmGlobalXCodeGenerator::OutputXCodeSharedSchemes(
   }
 
   // generate scheme
-  for (std::vector<cmXCodeObject*>::const_iterator i =
-         this->XCodeObjects.begin();
-       i != this->XCodeObjects.end(); ++i) {
-    cmXCodeObject* obj = *i;
+  for (auto obj : this->XCodeObjects) {
     if (obj->GetType() == cmXCodeObject::OBJECT &&
         (obj->GetIsA() == cmXCodeObject::PBXNativeTarget ||
          obj->GetIsA() == cmXCodeObject::PBXAggregateTarget)) {
@@ -3576,17 +3514,17 @@ void cmGlobalXCodeGenerator::AppendFlag(std::string& flags,
   }
 
   // Flag value with escaped quotes and backslashes.
-  for (const char* c = flag.c_str(); *c; ++c) {
-    if (*c == '\'') {
+  for (auto c : flag) {
+    if (c == '\'') {
       if (this->XcodeVersion >= 40) {
         flags += "'\\''";
       } else {
         flags += "\\'";
       }
-    } else if (*c == '\\') {
+    } else if (c == '\\') {
       flags += "\\\\";
     } else {
-      flags += *c;
+      flags += c;
     }
   }
 
diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx
index 853e66c..457d1fd 100644
--- a/Source/cmLocalXCodeGenerator.cxx
+++ b/Source/cmLocalXCodeGenerator.cxx
@@ -42,8 +42,7 @@ void cmLocalXCodeGenerator::Generate()
 {
   cmLocalGenerator::Generate();
 
-  const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
-  for (auto target : targets) {
+  for (auto target : this->GetGeneratorTargets()) {
     target->HasMacOSXRpathInstallNameDir("");
   }
 }
@@ -52,8 +51,7 @@ void cmLocalXCodeGenerator::GenerateInstallRules()
 {
   cmLocalGenerator::GenerateInstallRules();
 
-  const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
-  for (auto target : targets) {
+  for (auto target : this->GetGeneratorTargets()) {
     target->HasMacOSXRpathInstallNameDir("");
   }
 }
diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx
index e54f1f3..1747c9c 100644
--- a/Source/cmXCodeObject.cxx
+++ b/Source/cmXCodeObject.cxx
@@ -115,16 +115,15 @@ void cmXCodeObject::Print(std::ostream& out)
   if (separator == "\n") {
     out << separator;
   }
-  std::map<std::string, cmXCodeObject*>::iterator i;
   cmXCodeObject::Indent(3 * indentFactor, out);
   out << "isa = " << PBXTypeNames[this->IsA] << ";" << separator;
-  for (i = this->ObjectAttributes.begin(); i != this->ObjectAttributes.end();
-       ++i) {
-    if (i->first == "isa") {
+  for (const auto& keyVal : this->ObjectAttributes) {
+    if (keyVal.first == "isa") {
       continue;
     }
 
-    PrintAttribute(out, 3, separator, indentFactor, i->first, i->second, this);
+    PrintAttribute(out, 3, separator, indentFactor, keyVal.first,
+                   keyVal.second, this);
   }
   cmXCodeObject::Indent(2 * indentFactor, out);
   out << "};\n";
@@ -167,11 +166,9 @@ void cmXCodeObject::PrintAttribute(std::ostream& out, int level,
       if (separator == "\n") {
         out << separator;
       }
-      std::map<std::string, cmXCodeObject*>::const_iterator i;
-      for (i = object->ObjectAttributes.begin();
-           i != object->ObjectAttributes.end(); ++i) {
-        PrintAttribute(out, (level + 1) * factor, separator, factor, i->first,
-                       i->second, object);
+      for (const auto& keyVal : object->ObjectAttributes) {
+        PrintAttribute(out, (level + 1) * factor, separator, factor,
+                       keyVal.first, keyVal.second, object);
       }
       cmXCodeObject::Indent(level * factor, out);
       out << "};" << separator;
@@ -221,7 +218,7 @@ void cmXCodeObject::CopyAttributes(cmXCodeObject* copy)
   this->Object = copy->Object;
 }
 
-void cmXCodeObject::PrintString(std::ostream& os, std::string String)
+void cmXCodeObject::PrintString(std::ostream& os, const std::string& String)
 {
   // The string needs to be quoted if it contains any characters
   // considered special by the Xcode project file parser.
@@ -234,13 +231,12 @@ void cmXCodeObject::PrintString(std::ostream& os, std::string String)
 
   // Print the string, quoted and escaped as necessary.
   os << quote;
-  for (std::string::const_iterator i = String.begin(); i != String.end();
-       ++i) {
-    if (*i == '"' || *i == '\\') {
+  for (auto c : String) {
+    if (c == '"' || c == '\\') {
       // Escape double-quotes and backslashes.
       os << '\\';
     }
-    os << *i;
+    os << c;
   }
   os << quote;
 }
diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h
index b0f1d31..51e5d36 100644
--- a/Source/cmXCodeObject.h
+++ b/Source/cmXCodeObject.h
@@ -150,7 +150,7 @@ public:
     return this->List;
   }
   void SetComment(const std::string& c) { this->Comment = c; }
-  static void PrintString(std::ostream& os, std::string String);
+  static void PrintString(std::ostream& os, const std::string& String);
 
 protected:
   void PrintString(std::ostream& os) const;

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2ee10119eac2802a234543581b1303d91b944afa
commit 2ee10119eac2802a234543581b1303d91b944afa
Author:     Felix Schwitzer <flx107809 at gmail.com>
AuthorDate: Mon Nov 6 22:10:18 2017 +0100
Commit:     Felix Schwitzer <flx107809 at gmail.com>
CommitDate: Wed Nov 8 15:25:20 2017 +0100

    swig: fix incremental build in case of removed interface files
    
    Commit v3.8.0-rc1~123^2 (UseSWIG: Automatically scan dependencies of SWIG files
    for Makefiles, 2016-12-21) introduced automatic dependency scanning for files
    `%include`d in a swig interface definition file. This works fine as long as no
    such file is removed. But removing a dependent file breaks an incremental build
    and `make` complains about a missing dependency, see #16830.
    
    Integrate the approach proposed in the issue above into the SWIG-module, do the
    workaround in a conditional step as it arises only for Makefile generators. For
    other generators use the implementation before that commit.
    
    Fixes: #17433.

diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake
index c8b1cd7..b8bcd92 100644
--- a/Modules/UseSWIG.cmake
+++ b/Modules/UseSWIG.cmake
@@ -201,10 +201,32 @@ macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
   if(SWIG_MODULE_${name}_EXTRA_FLAGS)
     set(swig_extra_flags ${swig_extra_flags} ${SWIG_MODULE_${name}_EXTRA_FLAGS})
   endif()
+  # IMPLICIT_DEPENDS below can not handle situations where a dependent file is
+  # removed. We need an extra step with timestamp and custom target, see #16830
+  # As this is needed only for Makefile generator do it conditionally
+  if(CMAKE_GENERATOR MATCHES "Make")
+    get_filename_component(swig_generated_timestamp
+      "${swig_generated_file_fullname}" NAME_WE)
+    set(swig_gen_target gen_${swig_generated_timestamp})
+    set(swig_generated_timestamp
+      "${swig_outdir}/${swig_generated_timestamp}.stamp")
+    set(swig_custom_output ${swig_generated_timestamp})
+    set(swig_custom_products
+      BYPRODUCTS "${swig_generated_file_fullname}" ${swig_extra_generated_files})
+    set(swig_timestamp_command
+      COMMAND ${CMAKE_COMMAND} -E touch ${swig_generated_timestamp})
+  else()
+    set(swig_custom_output
+      "${swig_generated_file_fullname}" ${swig_extra_generated_files})
+    set(swig_custom_products)
+    set(swig_timestamp_command)
+  endif()
   add_custom_command(
-    OUTPUT "${swig_generated_file_fullname}" ${swig_extra_generated_files}
+    OUTPUT ${swig_custom_output}
+    ${swig_custom_products}
     # Let's create the ${swig_outdir} at execution time, in case dir contains $(OutDir)
     COMMAND ${CMAKE_COMMAND} -E make_directory ${swig_outdir}
+    ${swig_timestamp_command}
     COMMAND "${SWIG_EXECUTABLE}"
     ARGS "-${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}"
     ${swig_source_file_flags}
@@ -219,6 +241,13 @@ macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
     DEPENDS ${SWIG_MODULE_${name}_EXTRA_DEPS}
     IMPLICIT_DEPENDS CXX "${swig_source_file_fullname}"
     COMMENT "Swig source")
+  if(CMAKE_GENERATOR MATCHES "Make")
+    add_custom_target(${swig_gen_target} DEPENDS ${swig_generated_timestamp})
+  endif()
+  unset(swig_generated_timestamp)
+  unset(swig_custom_output)
+  unset(swig_custom_products)
+  unset(swig_timestamp_command)
   set_source_files_properties("${swig_generated_file_fullname}" ${swig_extra_generated_files}
     PROPERTIES GENERATED 1)
   set(${outfiles} "${swig_generated_file_fullname}" ${swig_extra_generated_files})
@@ -281,6 +310,10 @@ macro(SWIG_ADD_LIBRARY name)
     ${_SAM_TYPE}
     ${swig_generated_sources}
     ${swig_other_sources})
+  if(CMAKE_GENERATOR MATCHES "Make")
+    # see IMPLICIT_DEPENDS above
+    add_dependencies(${SWIG_MODULE_${name}_REAL_NAME} ${swig_gen_target})
+  endif()
   if("${_SAM_TYPE}" STREQUAL "MODULE")
     set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES NO_SONAME ON)
   endif()

-----------------------------------------------------------------------

Summary of changes:
 Modules/UseSWIG.cmake             |   35 ++++-
 Source/cmGlobalXCodeGenerator.cxx |  278 ++++++++++++++-----------------------
 Source/cmLocalXCodeGenerator.cxx  |    6 +-
 Source/cmXCodeObject.cxx          |   26 ++--
 Source/cmXCodeObject.h            |    2 +-
 5 files changed, 156 insertions(+), 191 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list