[Cmake-commits] CMake branch, next, updated. v3.2.2-2543-g6260e4a

Stephen Kelly steveire at gmail.com
Tue May 5 16:19:12 EDT 2015


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, next has been updated
       via  6260e4aecdcd21ed488c93842c0a3a5302f1037f (commit)
       via  d63bc31e0201c36cc88e51426ff4987ca32b60f2 (commit)
       via  00dbdef2b085a6aeffbac2dcd6747df610fd155e (commit)
       via  13b00c09d99dfde1dd4532b269399edffa68b65c (commit)
      from  98b925cbda5e331a3540d57eebe92cf17b7ff548 (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 -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6260e4aecdcd21ed488c93842c0a3a5302f1037f
commit 6260e4aecdcd21ed488c93842c0a3a5302f1037f
Merge: 98b925c d63bc31
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue May 5 16:19:11 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue May 5 16:19:11 2015 -0400

    Merge topic 'refactor-cmLocalGenerator' into next
    
    d63bc31e Revert "Revert "cmState::Snapshot: Store components for current directories.""
    00dbdef2 Revert "cmState::Snapshot: Store components for current directories."
    13b00c09 Revert "cmState: Store computed relative paths to to current directories."


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d63bc31e0201c36cc88e51426ff4987ca32b60f2
commit d63bc31e0201c36cc88e51426ff4987ca32b60f2
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue May 5 22:18:48 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Tue May 5 22:18:48 2015 +0200

    Revert "Revert "cmState::Snapshot: Store components for current directories.""
    
    This reverts commit 00dbdef2b085a6aeffbac2dcd6747df610fd155e.

diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 0a955bb..f64cb2d 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -67,7 +67,6 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
   this->Configured = false;
   this->EmitUniversalBinaryFlags = true;
   this->RelativePathsConfigured = false;
-  this->PathConversionsSetup = false;
   this->BackwardsCompatibility = 0;
   this->BackwardsCompatibilityFinal = false;
 }
@@ -229,22 +228,6 @@ void cmLocalGenerator::ReadInputFile()
     }
 }
 
-void cmLocalGenerator::SetupPathConversions()
-{
-  // Setup the current output directory components for use by
-  // Convert
-  std::string outdir;
-
-  outdir = cmSystemTools::CollapseFullPath(
-      this->StateSnapshot.GetCurrentSourceDirectory());
-  cmSystemTools::SplitPath(outdir, this->StartDirectoryComponents);
-
-  outdir = cmSystemTools::CollapseFullPath
-    (this->StateSnapshot.GetCurrentBinaryDirectory());
-  cmSystemTools::SplitPath(outdir,
-                           this->StartOutputDirectoryComponents);
-}
-
 void cmLocalGenerator::ConfigureFinalPass()
 {
   this->Makefile->ConfigureFinalPass();
@@ -2731,13 +2714,6 @@ std::string cmLocalGenerator::Convert(const std::string& source,
                                       OutputFormat output,
                                       bool optional)
 {
-  // Make sure the relative path conversion components are set.
-  if(!this->PathConversionsSetup)
-    {
-    this->SetupPathConversions();
-    this->PathConversionsSetup = true;
-    }
-
   // Convert the path to a relative path.
   std::string result = source;
 
@@ -2752,20 +2728,18 @@ std::string cmLocalGenerator::Convert(const std::string& source,
         break;
       case START:
         //result = cmSystemTools::CollapseFullPath(result.c_str());
-        result = this->ConvertToRelativePath(this->StartDirectoryComponents,
-                                             result);
+        result = this->ConvertToRelativePath(
+            this->StateSnapshot.GetCurrentSourceDirectoryComponents(), result);
         break;
       case HOME_OUTPUT:
         //result = cmSystemTools::CollapseFullPath(result.c_str());
-        result =
-          this->ConvertToRelativePath(
-              this->GetState()->GetBinaryDirectoryComponents(), result);
+        result = this->ConvertToRelativePath(
+            this->GetState()->GetBinaryDirectoryComponents(), result);
         break;
       case START_OUTPUT:
         //result = cmSystemTools::CollapseFullPath(result.c_str());
-        result =
-          this->ConvertToRelativePath(this->StartOutputDirectoryComponents,
-                                      result);
+        result = this->ConvertToRelativePath(
+            this->StateSnapshot.GetCurrentBinaryDirectoryComponents(), result);
         break;
       case FULL:
         result = cmSystemTools::CollapseFullPath(result);
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 5cdf161..bf447e5 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -438,7 +438,6 @@ protected:
   void ConfigureRelativePaths();
   std::string FindRelativePathTopSource();
   std::string FindRelativePathTopBinary();
-  void SetupPathConversions();
 
   virtual std::string ConvertToLinkReference(std::string const& lib,
                                              OutputFormat format = SHELL);
@@ -453,8 +452,6 @@ protected:
   cmMakefile *Makefile;
   cmState::Snapshot StateSnapshot;
   cmGlobalGenerator *GlobalGenerator;
-  std::vector<std::string> StartDirectoryComponents;
-  std::vector<std::string> StartOutputDirectoryComponents;
   cmLocalGenerator* Parent;
   std::vector<cmLocalGenerator*> Children;
   std::map<std::string, std::string> UniqueObjectNamesMap;
@@ -479,7 +476,6 @@ protected:
   std::string RelativePathTopSource;
   std::string RelativePathTopBinary;
   bool RelativePathsConfigured;
-  bool PathConversionsSetup;
 
   cmIML_INT_uint64_t BackwardsCompatibility;
   bool BackwardsCompatibilityFinal;
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index c5b12d9..dacf799 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -500,6 +500,10 @@ cmState::Snapshot cmState::CreateSnapshot(Snapshot originSnapshot)
   this->ParentPositions.push_back(originSnapshot.Position);
   this->Locations.resize(this->Locations.size() + 1);
   this->OutputLocations.resize(this->OutputLocations.size() + 1);
+  this->CurrentSourceDirectoryComponents.resize(
+      this->CurrentSourceDirectoryComponents.size() + 1);
+  this->CurrentBinaryDirectoryComponents.resize(
+      this->CurrentBinaryDirectoryComponents.size() + 1);
   return cmState::Snapshot(this, pos);
 }
 
@@ -523,6 +527,10 @@ void cmState::Snapshot::SetCurrentSourceDirectory(std::string const& dir)
       this->State->Locations[this->Position]);
   this->State->Locations[this->Position] =
     cmSystemTools::CollapseFullPath(this->State->Locations[this->Position]);
+
+  cmSystemTools::SplitPath(
+      this->State->Locations[this->Position],
+      this->State->CurrentSourceDirectoryComponents[this->Position]);
 }
 
 const char* cmState::Snapshot::GetCurrentBinaryDirectory() const
@@ -539,6 +547,22 @@ void cmState::Snapshot::SetCurrentBinaryDirectory(std::string const& dir)
   this->State->OutputLocations[this->Position] =
     cmSystemTools::CollapseFullPath(
         this->State->OutputLocations[this->Position]);
+
+  cmSystemTools::SplitPath(
+      this->State->OutputLocations[this->Position],
+      this->State->CurrentBinaryDirectoryComponents[this->Position]);
+}
+
+std::vector<std::string> const&
+cmState::Snapshot::GetCurrentSourceDirectoryComponents()
+{
+  return this->State->CurrentSourceDirectoryComponents[this->Position];
+}
+
+std::vector<std::string> const&
+cmState::Snapshot::GetCurrentBinaryDirectoryComponents()
+{
+  return this->State->CurrentBinaryDirectoryComponents[this->Position];
 }
 
 bool cmState::Snapshot::IsValid() const
diff --git a/Source/cmState.h b/Source/cmState.h
index c58a461..81f2d48 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -36,6 +36,9 @@ public:
     const char* GetCurrentBinaryDirectory() const;
     void SetCurrentBinaryDirectory(std::string const& dir);
 
+    std::vector<std::string> const& GetCurrentSourceDirectoryComponents();
+    std::vector<std::string> const& GetCurrentBinaryDirectoryComponents();
+
     bool IsValid() const;
     Snapshot GetParent() const;
 
@@ -138,6 +141,8 @@ private:
 
   std::vector<std::string> SourceDirectoryComponents;
   std::vector<std::string> BinaryDirectoryComponents;
+  std::vector<std::vector<std::string> > CurrentSourceDirectoryComponents;
+  std::vector<std::vector<std::string> > CurrentBinaryDirectoryComponents;
 
   std::string SourceDirectory;
   std::string BinaryDirectory;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=00dbdef2b085a6aeffbac2dcd6747df610fd155e
commit 00dbdef2b085a6aeffbac2dcd6747df610fd155e
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue May 5 22:12:01 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Tue May 5 22:12:01 2015 +0200

    Revert "cmState::Snapshot: Store components for current directories."
    
    This reverts commit 091bf33f737f7fc8115eb4c3f066df41dbcebb44.

diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index f64cb2d..0a955bb 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -67,6 +67,7 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
   this->Configured = false;
   this->EmitUniversalBinaryFlags = true;
   this->RelativePathsConfigured = false;
+  this->PathConversionsSetup = false;
   this->BackwardsCompatibility = 0;
   this->BackwardsCompatibilityFinal = false;
 }
@@ -228,6 +229,22 @@ void cmLocalGenerator::ReadInputFile()
     }
 }
 
+void cmLocalGenerator::SetupPathConversions()
+{
+  // Setup the current output directory components for use by
+  // Convert
+  std::string outdir;
+
+  outdir = cmSystemTools::CollapseFullPath(
+      this->StateSnapshot.GetCurrentSourceDirectory());
+  cmSystemTools::SplitPath(outdir, this->StartDirectoryComponents);
+
+  outdir = cmSystemTools::CollapseFullPath
+    (this->StateSnapshot.GetCurrentBinaryDirectory());
+  cmSystemTools::SplitPath(outdir,
+                           this->StartOutputDirectoryComponents);
+}
+
 void cmLocalGenerator::ConfigureFinalPass()
 {
   this->Makefile->ConfigureFinalPass();
@@ -2714,6 +2731,13 @@ std::string cmLocalGenerator::Convert(const std::string& source,
                                       OutputFormat output,
                                       bool optional)
 {
+  // Make sure the relative path conversion components are set.
+  if(!this->PathConversionsSetup)
+    {
+    this->SetupPathConversions();
+    this->PathConversionsSetup = true;
+    }
+
   // Convert the path to a relative path.
   std::string result = source;
 
@@ -2728,18 +2752,20 @@ std::string cmLocalGenerator::Convert(const std::string& source,
         break;
       case START:
         //result = cmSystemTools::CollapseFullPath(result.c_str());
-        result = this->ConvertToRelativePath(
-            this->StateSnapshot.GetCurrentSourceDirectoryComponents(), result);
+        result = this->ConvertToRelativePath(this->StartDirectoryComponents,
+                                             result);
         break;
       case HOME_OUTPUT:
         //result = cmSystemTools::CollapseFullPath(result.c_str());
-        result = this->ConvertToRelativePath(
-            this->GetState()->GetBinaryDirectoryComponents(), result);
+        result =
+          this->ConvertToRelativePath(
+              this->GetState()->GetBinaryDirectoryComponents(), result);
         break;
       case START_OUTPUT:
         //result = cmSystemTools::CollapseFullPath(result.c_str());
-        result = this->ConvertToRelativePath(
-            this->StateSnapshot.GetCurrentBinaryDirectoryComponents(), result);
+        result =
+          this->ConvertToRelativePath(this->StartOutputDirectoryComponents,
+                                      result);
         break;
       case FULL:
         result = cmSystemTools::CollapseFullPath(result);
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index bf447e5..5cdf161 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -438,6 +438,7 @@ protected:
   void ConfigureRelativePaths();
   std::string FindRelativePathTopSource();
   std::string FindRelativePathTopBinary();
+  void SetupPathConversions();
 
   virtual std::string ConvertToLinkReference(std::string const& lib,
                                              OutputFormat format = SHELL);
@@ -452,6 +453,8 @@ protected:
   cmMakefile *Makefile;
   cmState::Snapshot StateSnapshot;
   cmGlobalGenerator *GlobalGenerator;
+  std::vector<std::string> StartDirectoryComponents;
+  std::vector<std::string> StartOutputDirectoryComponents;
   cmLocalGenerator* Parent;
   std::vector<cmLocalGenerator*> Children;
   std::map<std::string, std::string> UniqueObjectNamesMap;
@@ -476,6 +479,7 @@ protected:
   std::string RelativePathTopSource;
   std::string RelativePathTopBinary;
   bool RelativePathsConfigured;
+  bool PathConversionsSetup;
 
   cmIML_INT_uint64_t BackwardsCompatibility;
   bool BackwardsCompatibilityFinal;
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index dacf799..c5b12d9 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -500,10 +500,6 @@ cmState::Snapshot cmState::CreateSnapshot(Snapshot originSnapshot)
   this->ParentPositions.push_back(originSnapshot.Position);
   this->Locations.resize(this->Locations.size() + 1);
   this->OutputLocations.resize(this->OutputLocations.size() + 1);
-  this->CurrentSourceDirectoryComponents.resize(
-      this->CurrentSourceDirectoryComponents.size() + 1);
-  this->CurrentBinaryDirectoryComponents.resize(
-      this->CurrentBinaryDirectoryComponents.size() + 1);
   return cmState::Snapshot(this, pos);
 }
 
@@ -527,10 +523,6 @@ void cmState::Snapshot::SetCurrentSourceDirectory(std::string const& dir)
       this->State->Locations[this->Position]);
   this->State->Locations[this->Position] =
     cmSystemTools::CollapseFullPath(this->State->Locations[this->Position]);
-
-  cmSystemTools::SplitPath(
-      this->State->Locations[this->Position],
-      this->State->CurrentSourceDirectoryComponents[this->Position]);
 }
 
 const char* cmState::Snapshot::GetCurrentBinaryDirectory() const
@@ -547,22 +539,6 @@ void cmState::Snapshot::SetCurrentBinaryDirectory(std::string const& dir)
   this->State->OutputLocations[this->Position] =
     cmSystemTools::CollapseFullPath(
         this->State->OutputLocations[this->Position]);
-
-  cmSystemTools::SplitPath(
-      this->State->OutputLocations[this->Position],
-      this->State->CurrentBinaryDirectoryComponents[this->Position]);
-}
-
-std::vector<std::string> const&
-cmState::Snapshot::GetCurrentSourceDirectoryComponents()
-{
-  return this->State->CurrentSourceDirectoryComponents[this->Position];
-}
-
-std::vector<std::string> const&
-cmState::Snapshot::GetCurrentBinaryDirectoryComponents()
-{
-  return this->State->CurrentBinaryDirectoryComponents[this->Position];
 }
 
 bool cmState::Snapshot::IsValid() const
diff --git a/Source/cmState.h b/Source/cmState.h
index 81f2d48..c58a461 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -36,9 +36,6 @@ public:
     const char* GetCurrentBinaryDirectory() const;
     void SetCurrentBinaryDirectory(std::string const& dir);
 
-    std::vector<std::string> const& GetCurrentSourceDirectoryComponents();
-    std::vector<std::string> const& GetCurrentBinaryDirectoryComponents();
-
     bool IsValid() const;
     Snapshot GetParent() const;
 
@@ -141,8 +138,6 @@ private:
 
   std::vector<std::string> SourceDirectoryComponents;
   std::vector<std::string> BinaryDirectoryComponents;
-  std::vector<std::vector<std::string> > CurrentSourceDirectoryComponents;
-  std::vector<std::vector<std::string> > CurrentBinaryDirectoryComponents;
 
   std::string SourceDirectory;
   std::string BinaryDirectory;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=13b00c09d99dfde1dd4532b269399edffa68b65c
commit 13b00c09d99dfde1dd4532b269399edffa68b65c
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue May 5 22:04:00 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Tue May 5 22:04:00 2015 +0200

    Revert "cmState: Store computed relative paths to to current directories."
    
    This reverts commit 364469ce9338c1720475425f64d8328e94607880.

diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index a5f603f..f64cb2d 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -66,6 +66,7 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
   this->UseRelativePaths = false;
   this->Configured = false;
   this->EmitUniversalBinaryFlags = true;
+  this->RelativePathsConfigured = false;
   this->BackwardsCompatibility = 0;
   this->BackwardsCompatibilityFinal = false;
 }
@@ -2811,6 +2812,97 @@ std::string cmLocalGenerator::Convert(RelativeRoot remote,
 }
 
 //----------------------------------------------------------------------------
+std::string cmLocalGenerator::FindRelativePathTopSource()
+{
+  cmState::Snapshot snapshot = this->StateSnapshot;
+  std::vector<cmState::Snapshot> snapshots;
+  snapshots.push_back(snapshot);
+  while (true)
+    {
+    snapshot = snapshot.GetParent();
+    if (snapshot.IsValid())
+      {
+      snapshots.push_back(snapshot);
+      }
+    else
+      {
+      break;
+      }
+    }
+
+  std::string result = snapshots.front().GetCurrentSourceDirectory();
+
+  for (std::vector<cmState::Snapshot>::const_iterator it =
+       snapshots.begin() + 1; it != snapshots.end(); ++it)
+  {
+    std::string currentSource = it->GetCurrentSourceDirectory();
+    if(cmSystemTools::IsSubDirectory(result, currentSource))
+      {
+      result = currentSource;
+      }
+    }
+
+  return result;
+}
+
+//----------------------------------------------------------------------------
+std::string cmLocalGenerator::FindRelativePathTopBinary()
+{
+  cmState::Snapshot snapshot = this->StateSnapshot;
+  std::vector<cmState::Snapshot> snapshots;
+  snapshots.push_back(snapshot);
+  while (true)
+    {
+    snapshot = snapshot.GetParent();
+    if (snapshot.IsValid())
+      {
+      snapshots.push_back(snapshot);
+      }
+    else
+      {
+      break;
+      }
+    }
+
+  std::string result = snapshots.front().GetCurrentBinaryDirectory();
+
+  for (std::vector<cmState::Snapshot>::const_iterator it =
+       snapshots.begin() + 1; it != snapshots.end(); ++it)
+  {
+    std::string currentBinary = it->GetCurrentBinaryDirectory();
+    if(cmSystemTools::IsSubDirectory(result, currentBinary))
+      {
+      result = currentBinary;
+      }
+    }
+
+  return result;
+}
+
+//----------------------------------------------------------------------------
+void cmLocalGenerator::ConfigureRelativePaths()
+{
+  // Relative path conversion inside the source tree is not used to
+  // construct relative paths passed to build tools so it is safe to
+  // even when the source is a network path.
+  std::string source = this->FindRelativePathTopSource();
+  this->RelativePathTopSource = source;
+
+  // The current working directory on Windows cannot be a network
+  // path.  Therefore relative paths cannot work when the binary tree
+  // is a network path.
+  std::string binary = this->FindRelativePathTopBinary();
+  if(binary.size() < 2 || binary.substr(0, 2) != "//")
+    {
+    this->RelativePathTopBinary = binary;
+    }
+  else
+    {
+    this->RelativePathTopBinary = "";
+    }
+}
+
+//----------------------------------------------------------------------------
 static bool cmLocalGeneratorNotAbove(const char* a, const char* b)
 {
   return (cmSystemTools::ComparePath(a, b) ||
@@ -2835,19 +2927,26 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
     return in_remote;
     }
 
+  // Make sure relative path conversion is configured.
+  if(!this->RelativePathsConfigured)
+    {
+    this->ConfigureRelativePaths();
+    this->RelativePathsConfigured = true;
+    }
+
   if(!force)
     {
     // Skip conversion if the path and local are not both in the source
     // or both in the binary tree.
     std::string local_path = cmSystemTools::JoinPath(local);
     if(!((cmLocalGeneratorNotAbove(local_path.c_str(),
-              this->StateSnapshot.GetRelativePathTopBinary()) &&
+                                   this->RelativePathTopBinary.c_str()) &&
           cmLocalGeneratorNotAbove(in_remote.c_str(),
-              this->StateSnapshot.GetRelativePathTopBinary())) ||
+                                   this->RelativePathTopBinary.c_str())) ||
          (cmLocalGeneratorNotAbove(local_path.c_str(),
-              this->StateSnapshot.GetRelativePathTopSource()) &&
+                                   this->RelativePathTopSource.c_str()) &&
           cmLocalGeneratorNotAbove(in_remote.c_str(),
-              this->StateSnapshot.GetRelativePathTopSource()))))
+                                   this->RelativePathTopSource.c_str()))))
       {
       return in_remote;
       }
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index c0da4f6..bf447e5 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -435,6 +435,10 @@ protected:
                                               std::string const& dir_max);
   void ComputeObjectMaxPath();
 
+  void ConfigureRelativePaths();
+  std::string FindRelativePathTopSource();
+  std::string FindRelativePathTopBinary();
+
   virtual std::string ConvertToLinkReference(std::string const& lib,
                                              OutputFormat format = SHELL);
 
@@ -464,6 +468,15 @@ protected:
   // committed.
   std::string TargetImplib;
 
+  // The top-most directories for relative path conversion.  Both the
+  // source and destination location of a relative path conversion
+  // must be underneath one of these directories (both under source or
+  // both under binary) in order for the relative path to be evaluated
+  // safely by the build tools.
+  std::string RelativePathTopSource;
+  std::string RelativePathTopBinary;
+  bool RelativePathsConfigured;
+
   cmIML_INT_uint64_t BackwardsCompatibility;
   bool BackwardsCompatibilityFinal;
 private:
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 54bff7f..f11c79e 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -545,11 +545,9 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile()
   // Setup relative path conversion tops.
   infoFileStream
     << "# Relative path conversion top directories.\n"
-    << "set(CMAKE_RELATIVE_PATH_TOP_SOURCE \""
-    << this->StateSnapshot.GetRelativePathTopSource()
+    << "set(CMAKE_RELATIVE_PATH_TOP_SOURCE \"" << this->RelativePathTopSource
     << "\")\n"
-    << "set(CMAKE_RELATIVE_PATH_TOP_BINARY \""
-    << this->StateSnapshot.GetRelativePathTopBinary()
+    << "set(CMAKE_RELATIVE_PATH_TOP_BINARY \"" << this->RelativePathTopBinary
     << "\")\n"
     << "\n";
 
@@ -1615,15 +1613,16 @@ cmLocalUnixMakefileGenerator3
       }
 
     // Setup relative path top directories.
+    this->RelativePathsConfigured = true;
     if(const char* relativePathTopSource =
        mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_SOURCE"))
       {
-      this->StateSnapshot.SetRelativePathTopSource(relativePathTopSource);
+      this->RelativePathTopSource = relativePathTopSource;
       }
     if(const char* relativePathTopBinary =
        mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_BINARY"))
       {
-      this->StateSnapshot.SetRelativePathTopBinary(relativePathTopBinary);
+      this->RelativePathTopBinary = relativePathTopBinary;
       }
     }
   else
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 04a59fc..dacf799 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -494,86 +494,6 @@ std::vector<std::string> const& cmState::GetBinaryDirectoryComponents() const
   return this->BinaryDirectoryComponents;
 }
 
-void cmState::Snapshot::ComputeRelativePathTopSource()
-{
-  // Relative path conversion inside the source tree is not used to
-  // construct relative paths passed to build tools so it is safe to use
-  // even when the source is a network path.
-
-  cmState::Snapshot snapshot = *this;
-  std::vector<cmState::Snapshot> snapshots;
-  snapshots.push_back(snapshot);
-  while (true)
-    {
-    snapshot = snapshot.GetParent();
-    if (snapshot.IsValid())
-      {
-      snapshots.push_back(snapshot);
-      }
-    else
-      {
-      break;
-      }
-    }
-
-  std::string result = snapshots.front().GetCurrentSourceDirectory();
-
-  for (std::vector<cmState::Snapshot>::const_iterator it =
-       snapshots.begin() + 1; it != snapshots.end(); ++it)
-    {
-    std::string currentSource = it->GetCurrentSourceDirectory();
-    if(cmSystemTools::IsSubDirectory(result, currentSource))
-      {
-      result = currentSource;
-      }
-    }
-  this->State->RelativePathTopSource[this->Position] = result;
-}
-
-void cmState::Snapshot::ComputeRelativePathTopBinary()
-{
-  cmState::Snapshot snapshot = *this;
-  std::vector<cmState::Snapshot> snapshots;
-  snapshots.push_back(snapshot);
-  while (true)
-    {
-    snapshot = snapshot.GetParent();
-    if (snapshot.IsValid())
-      {
-      snapshots.push_back(snapshot);
-      }
-    else
-      {
-      break;
-      }
-    }
-
-  std::string result =
-      snapshots.front().GetCurrentBinaryDirectory();
-
-  for (std::vector<cmState::Snapshot>::const_iterator it =
-       snapshots.begin() + 1; it != snapshots.end(); ++it)
-    {
-    std::string currentBinary = it->GetCurrentBinaryDirectory();
-    if(cmSystemTools::IsSubDirectory(result, currentBinary))
-      {
-      result = currentBinary;
-      }
-    }
-
-  // The current working directory on Windows cannot be a network
-  // path.  Therefore relative paths cannot work when the binary tree
-  // is a network path.
-  if(result.size() < 2 || result.substr(0, 2) != "//")
-    {
-    this->State->RelativePathTopBinary[this->Position] = result;
-    }
-  else
-    {
-    this->State->RelativePathTopBinary[this->Position] = "";
-    }
-}
-
 cmState::Snapshot cmState::CreateSnapshot(Snapshot originSnapshot)
 {
   PositionType pos = this->ParentPositions.size();
@@ -584,8 +504,6 @@ cmState::Snapshot cmState::CreateSnapshot(Snapshot originSnapshot)
       this->CurrentSourceDirectoryComponents.size() + 1);
   this->CurrentBinaryDirectoryComponents.resize(
       this->CurrentBinaryDirectoryComponents.size() + 1);
-  this->RelativePathTopSource.resize(this->RelativePathTopSource.size() + 1);
-  this->RelativePathTopBinary.resize(this->RelativePathTopBinary.size() + 1);
   return cmState::Snapshot(this, pos);
 }
 
@@ -613,7 +531,6 @@ void cmState::Snapshot::SetCurrentSourceDirectory(std::string const& dir)
   cmSystemTools::SplitPath(
       this->State->Locations[this->Position],
       this->State->CurrentSourceDirectoryComponents[this->Position]);
-  this->ComputeRelativePathTopSource();
 }
 
 const char* cmState::Snapshot::GetCurrentBinaryDirectory() const
@@ -634,7 +551,6 @@ void cmState::Snapshot::SetCurrentBinaryDirectory(std::string const& dir)
   cmSystemTools::SplitPath(
       this->State->OutputLocations[this->Position],
       this->State->CurrentBinaryDirectoryComponents[this->Position]);
-  this->ComputeRelativePathTopBinary();
 }
 
 std::vector<std::string> const&
@@ -649,26 +565,6 @@ cmState::Snapshot::GetCurrentBinaryDirectoryComponents()
   return this->State->CurrentBinaryDirectoryComponents[this->Position];
 }
 
-const char* cmState::Snapshot::GetRelativePathTopSource() const
-{
-  return this->State->RelativePathTopSource[this->Position].c_str();
-}
-
-const char* cmState::Snapshot::GetRelativePathTopBinary() const
-{
-  return this->State->RelativePathTopBinary[this->Position].c_str();
-}
-
-void cmState::Snapshot::SetRelativePathTopSource(const char* dir)
-{
-  this->State->RelativePathTopSource[this->Position] = dir;
-}
-
-void cmState::Snapshot::SetRelativePathTopBinary(const char* dir)
-{
-  this->State->RelativePathTopBinary[this->Position] = dir;
-}
-
 bool cmState::Snapshot::IsValid() const
 {
   return this->State;
diff --git a/Source/cmState.h b/Source/cmState.h
index 23d3f0d..81f2d48 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -39,19 +39,10 @@ public:
     std::vector<std::string> const& GetCurrentSourceDirectoryComponents();
     std::vector<std::string> const& GetCurrentBinaryDirectoryComponents();
 
-    const char* GetRelativePathTopSource() const;
-    const char* GetRelativePathTopBinary() const;
-    void SetRelativePathTopSource(const char* dir);
-    void SetRelativePathTopBinary(const char* dir);
-
     bool IsValid() const;
     Snapshot GetParent() const;
 
   private:
-    void ComputeRelativePathTopSource();
-    void ComputeRelativePathTopBinary();
-
-  private:
     friend class cmState;
     cmState* State;
     cmState::PositionType Position;
@@ -148,18 +139,11 @@ private:
   std::vector<std::string> OutputLocations;
   std::vector<PositionType> ParentPositions;
 
+  std::vector<std::string> SourceDirectoryComponents;
+  std::vector<std::string> BinaryDirectoryComponents;
   std::vector<std::vector<std::string> > CurrentSourceDirectoryComponents;
   std::vector<std::vector<std::string> > CurrentBinaryDirectoryComponents;
-  // The top-most directories for relative path conversion.  Both the
-  // source and destination location of a relative path conversion
-  // must be underneath one of these directories (both under source or
-  // both under binary) in order for the relative path to be evaluated
-  // safely by the build tools.
-  std::vector<std::string> RelativePathTopSource;
-  std::vector<std::string> RelativePathTopBinary;
 
-  std::vector<std::string> SourceDirectoryComponents;
-  std::vector<std::string> BinaryDirectoryComponents;
   std::string SourceDirectory;
   std::string BinaryDirectory;
   bool IsInTryCompile;

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

Summary of changes:
 Source/cmLocalGenerator.cxx              |  107 ++++++++++++++++++++++++++++--
 Source/cmLocalGenerator.h                |   13 ++++
 Source/cmLocalUnixMakefileGenerator3.cxx |   11 ++-
 Source/cmState.cxx                       |  104 -----------------------------
 Source/cmState.h                         |   20 +-----
 5 files changed, 123 insertions(+), 132 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list