[Cmake-commits] CMake branch, next, updated. v3.2.2-2546-g40711ca

Stephen Kelly steveire at gmail.com
Tue May 5 17:01:54 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  40711ca7f849f9d753f8c06a20f54085034c8110 (commit)
       via  d426a2e46e08f675456048c5b2c321a5ee56f6cc (commit)
       via  2d4ccb49a8df14b95ad6f1d23a8683ba72bc6967 (commit)
      from  6260e4aecdcd21ed488c93842c0a3a5302f1037f (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=40711ca7f849f9d753f8c06a20f54085034c8110
commit 40711ca7f849f9d753f8c06a20f54085034c8110
Merge: 6260e4a d426a2e
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue May 5 17:01:53 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue May 5 17:01:53 2015 -0400

    Merge topic 'refactor-cmLocalGenerator' into next
    
    d426a2e4 fixup! cmState: Compute and store directory components.
    2d4ccb49 Revert some commits.


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

    fixup! cmState: Compute and store directory components.

diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index 586070b..20d303d 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -204,6 +204,8 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
     }
 
   cmake cm;
+  cm.SetHomeDirectory("");
+  cm.SetHomeOutputDirectory("");
   std::string cmakeOutString;
   cmCTestBuildAndTestCaptureRAII captureRAII(cm, cmakeOutString);
   static_cast<void>(captureRAII);

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2d4ccb49a8df14b95ad6f1d23a8683ba72bc6967
commit 2d4ccb49a8df14b95ad6f1d23a8683ba72bc6967
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue May 5 23:00:42 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Tue May 5 23:00:56 2015 +0200

    Revert some commits.

diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index f64cb2d..a5f603f 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -66,7 +66,6 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
   this->UseRelativePaths = false;
   this->Configured = false;
   this->EmitUniversalBinaryFlags = true;
-  this->RelativePathsConfigured = false;
   this->BackwardsCompatibility = 0;
   this->BackwardsCompatibilityFinal = false;
 }
@@ -2812,97 +2811,6 @@ 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) ||
@@ -2927,26 +2835,19 @@ 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->RelativePathTopBinary.c_str()) &&
+              this->StateSnapshot.GetRelativePathTopBinary()) &&
           cmLocalGeneratorNotAbove(in_remote.c_str(),
-                                   this->RelativePathTopBinary.c_str())) ||
+              this->StateSnapshot.GetRelativePathTopBinary())) ||
          (cmLocalGeneratorNotAbove(local_path.c_str(),
-                                   this->RelativePathTopSource.c_str()) &&
+              this->StateSnapshot.GetRelativePathTopSource()) &&
           cmLocalGeneratorNotAbove(in_remote.c_str(),
-                                   this->RelativePathTopSource.c_str()))))
+              this->StateSnapshot.GetRelativePathTopSource()))))
       {
       return in_remote;
       }
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index bf447e5..c0da4f6 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -435,10 +435,6 @@ 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);
 
@@ -468,15 +464,6 @@ 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 f11c79e..54bff7f 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -545,9 +545,11 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile()
   // Setup relative path conversion tops.
   infoFileStream
     << "# Relative path conversion top directories.\n"
-    << "set(CMAKE_RELATIVE_PATH_TOP_SOURCE \"" << this->RelativePathTopSource
+    << "set(CMAKE_RELATIVE_PATH_TOP_SOURCE \""
+    << this->StateSnapshot.GetRelativePathTopSource()
     << "\")\n"
-    << "set(CMAKE_RELATIVE_PATH_TOP_BINARY \"" << this->RelativePathTopBinary
+    << "set(CMAKE_RELATIVE_PATH_TOP_BINARY \""
+    << this->StateSnapshot.GetRelativePathTopBinary()
     << "\")\n"
     << "\n";
 
@@ -1613,16 +1615,15 @@ cmLocalUnixMakefileGenerator3
       }
 
     // Setup relative path top directories.
-    this->RelativePathsConfigured = true;
     if(const char* relativePathTopSource =
        mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_SOURCE"))
       {
-      this->RelativePathTopSource = relativePathTopSource;
+      this->StateSnapshot.SetRelativePathTopSource(relativePathTopSource);
       }
     if(const char* relativePathTopBinary =
        mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_BINARY"))
       {
-      this->RelativePathTopBinary = relativePathTopBinary;
+      this->StateSnapshot.SetRelativePathTopBinary(relativePathTopBinary);
       }
     }
   else
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index dacf799..04a59fc 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -494,6 +494,86 @@ 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();
@@ -504,6 +584,8 @@ 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);
 }
 
@@ -531,6 +613,7 @@ 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
@@ -551,6 +634,7 @@ 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&
@@ -565,6 +649,26 @@ 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 81f2d48..23d3f0d 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -39,10 +39,19 @@ 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;
@@ -139,11 +148,18 @@ 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/CTest/cmCTestBuildAndTestHandler.cxx |    2 +
 Source/cmLocalGenerator.cxx                 |  107 +--------------------------
 Source/cmLocalGenerator.h                   |   13 ----
 Source/cmLocalUnixMakefileGenerator3.cxx    |   11 +--
 Source/cmState.cxx                          |  104 ++++++++++++++++++++++++++
 Source/cmState.h                            |   20 ++++-
 6 files changed, 134 insertions(+), 123 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list