diff options
author | Brad King <brad.king@kitware.com> | 2021-05-14 19:38:27 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-05-17 14:04:01 (GMT) |
commit | 8526756b61014f780348346ba5fdf0604a02d158 (patch) | |
tree | 875962cd6dd10ef90e65fc64cad8fdfef8dad5b5 /Source/cmStateDirectory.cxx | |
parent | 013ec595c8d6971c568cff4f8e457d90a6e8be88 (diff) | |
download | CMake-8526756b61014f780348346ba5fdf0604a02d158.zip CMake-8526756b61014f780348346ba5fdf0604a02d158.tar.gz CMake-8526756b61014f780348346ba5fdf0604a02d158.tar.bz2 |
cmOutputConverter: Adopt relative path conversion helpers
Move them up from cmLocalGenerator and out of cmStateDirectory.
Diffstat (limited to 'Source/cmStateDirectory.cxx')
-rw-r--r-- | Source/cmStateDirectory.cxx | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx index 140ff0d..9ae2861 100644 --- a/Source/cmStateDirectory.cxx +++ b/Source/cmStateDirectory.cxx @@ -24,41 +24,6 @@ static std::string const kBUILDSYSTEM_TARGETS = "BUILDSYSTEM_TARGETS"; static std::string const kSOURCE_DIR = "SOURCE_DIR"; static std::string const kSUBDIRECTORIES = "SUBDIRECTORIES"; -void cmStateDirectory::ComputeRelativePathTopSource() -{ - // Walk up the buildsystem directory tree to find the highest source - // directory that contains the current source directory. - cmStateSnapshot snapshot = this->Snapshot_; - for (cmStateSnapshot parent = snapshot.GetBuildsystemDirectoryParent(); - parent.IsValid(); parent = parent.GetBuildsystemDirectoryParent()) { - if (cmSystemTools::IsSubDirectory( - snapshot.GetDirectory().GetCurrentSource(), - parent.GetDirectory().GetCurrentSource())) { - snapshot = parent; - } - } - this->DirectoryState->RelativePathTopSource = - snapshot.GetDirectory().GetCurrentSource(); -} - -void cmStateDirectory::ComputeRelativePathTopBinary() -{ - // Walk up the buildsystem directory tree to find the highest binary - // directory that contains the current binary directory. - cmStateSnapshot snapshot = this->Snapshot_; - for (cmStateSnapshot parent = snapshot.GetBuildsystemDirectoryParent(); - parent.IsValid(); parent = parent.GetBuildsystemDirectoryParent()) { - if (cmSystemTools::IsSubDirectory( - snapshot.GetDirectory().GetCurrentBinary(), - parent.GetDirectory().GetCurrentBinary())) { - snapshot = parent; - } - } - - this->DirectoryState->RelativePathTopBinary = - snapshot.GetDirectory().GetCurrentBinary(); -} - std::string const& cmStateDirectory::GetCurrentSource() const { return this->DirectoryState->Location; @@ -70,9 +35,6 @@ void cmStateDirectory::SetCurrentSource(std::string const& dir) loc = dir; cmSystemTools::ConvertToUnixSlashes(loc); loc = cmSystemTools::CollapseFullPath(loc); - - this->ComputeRelativePathTopSource(); - this->Snapshot_.SetDefinition("CMAKE_CURRENT_SOURCE_DIR", loc); } @@ -87,60 +49,9 @@ void cmStateDirectory::SetCurrentBinary(std::string const& dir) loc = dir; cmSystemTools::ConvertToUnixSlashes(loc); loc = cmSystemTools::CollapseFullPath(loc); - - this->ComputeRelativePathTopBinary(); - this->Snapshot_.SetDefinition("CMAKE_CURRENT_BINARY_DIR", loc); } -std::string const& cmStateDirectory::GetRelativePathTopSource() const -{ - return this->DirectoryState->RelativePathTopSource; -} - -std::string const& cmStateDirectory::GetRelativePathTopBinary() const -{ - return this->DirectoryState->RelativePathTopBinary; -} - -void cmStateDirectory::SetRelativePathTopSource(const char* dir) -{ - this->DirectoryState->RelativePathTopSource = dir; -} - -void cmStateDirectory::SetRelativePathTopBinary(const char* dir) -{ - this->DirectoryState->RelativePathTopBinary = dir; -} - -bool cmStateDirectory::ContainsBoth(std::string const& local_path, - std::string const& remote_path) const -{ - auto PathEqOrSubDir = [](std::string const& a, std::string const& b) { - return (cmSystemTools::ComparePath(a, b) || - cmSystemTools::IsSubDirectory(a, b)); - }; - - bool bothInBinary = - PathEqOrSubDir(local_path, this->GetRelativePathTopBinary()) && - PathEqOrSubDir(remote_path, this->GetRelativePathTopBinary()); - - bool bothInSource = - PathEqOrSubDir(local_path, this->GetRelativePathTopSource()) && - PathEqOrSubDir(remote_path, this->GetRelativePathTopSource()); - - return bothInBinary || bothInSource; -} - -std::string cmStateDirectory::ConvertToRelPathIfContained( - std::string const& local_path, std::string const& remote_path) const -{ - if (!this->ContainsBoth(local_path, remote_path)) { - return remote_path; - } - return cmSystemTools::ForceToRelativePath(local_path, remote_path); -} - cmStateDirectory::cmStateDirectory( cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType>::iterator iter, const cmStateSnapshot& snapshot) |