summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2007-03-07 20:15:46 (GMT)
committerBrad King <brad.king@kitware.com>2007-03-07 20:15:46 (GMT)
commitfc19882e8f85516c4f774083b6d9f57f843fb941 (patch)
tree0e673dc5a8b7dfe6eedeb01bfe8f2ec123e3d7bb /Source/cmGlobalGenerator.cxx
parent3bd9d67488b98cb1141b7aaadbffb6550935f2aa (diff)
downloadCMake-fc19882e8f85516c4f774083b6d9f57f843fb941.zip
CMake-fc19882e8f85516c4f774083b6d9f57f843fb941.tar.gz
CMake-fc19882e8f85516c4f774083b6d9f57f843fb941.tar.bz2
ENH: Moved ConvertToRelativePath from cmGlobalGenerator to cmLocalGenerator. This is in preparation for setting up each local generator to have its own RelativePathTopSource and RelativePathTopBinary based on its ancestor directories.
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r--Source/cmGlobalGenerator.cxx160
1 files changed, 0 insertions, 160 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 92f6420..36d6fba 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -42,9 +42,6 @@ cmGlobalGenerator::cmGlobalGenerator()
// By default do not use link scripts.
this->UseLinkScript = false;
- // Relative paths are not configured in the constructor.
- this->RelativePathsConfigured = false;
-
// Whether an install target is needed.
this->InstallTargetEnabled = false;
@@ -1107,163 +1104,6 @@ cmTarget* cmGlobalGenerator::FindTarget(const char* project,
return 0;
}
-//----------------------------------------------------------------------------
-void cmGlobalGenerator::ConfigureRelativePaths()
-{
- // The current working directory on Windows cannot be a network
- // path. Therefore relative paths cannot work when the build tree
- // is a network path.
- std::string source = this->CMakeInstance->GetHomeDirectory();
- std::string binary = this->CMakeInstance->GetHomeOutputDirectory();
- if(binary.size() < 2 || binary.substr(0, 2) != "//")
- {
- this->RelativePathTopSource = source;
- this->RelativePathTopBinary = binary;
- }
- else
- {
- this->RelativePathTopSource = "";
- this->RelativePathTopBinary = "";
- }
-}
-
-//----------------------------------------------------------------------------
-std::string cmGlobalGenerator
-::ConvertToRelativePath(const std::vector<std::string>& local,
- const char* in_remote)
-{
- // The path should never be quoted.
- assert(in_remote[0] != '\"');
-
- // The local path should never have a trailing slash.
- assert(local.size() > 0 && !(local[local.size()-1] == ""));
-
- // If the path is already relative then just return the path.
- if(!cmSystemTools::FileIsFullPath(in_remote))
- {
- return in_remote;
- }
-
- // Make sure relative path conversion is configured.
- if(!this->RelativePathsConfigured)
- {
- this->ConfigureRelativePaths();
- this->RelativePathsConfigured = true;
- }
-
- std::string original = in_remote;
-
- // 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);
- bool should_convert = false;
-
- // is the root in the binary tree?
- if (local_path.size() >= this->RelativePathTopBinary.size() &&
- cmSystemTools::ComparePath
- (local_path.substr(0, this->RelativePathTopBinary.size()).c_str(),
- this->RelativePathTopBinary.c_str()))
- {
- // is the source also in the binary tree?
- if (original.size() >= this->RelativePathTopBinary.size() &&
- cmSystemTools::ComparePath
- (original.substr(0, this->RelativePathTopBinary.size()).c_str(),
- this->RelativePathTopBinary.c_str()))
- {
- should_convert = true;
- }
- }
-
- if (local_path.size() >= this->RelativePathTopSource.size() &&
- cmSystemTools::ComparePath
- (local_path.substr(0, this->RelativePathTopSource.size()).c_str(),
- this->RelativePathTopSource.c_str()))
- {
- // is the source also in the binary tree?
- if (original.size() >= this->RelativePathTopSource.size() &&
- cmSystemTools::ComparePath
- (original.substr(0, this->RelativePathTopSource.size()).c_str(),
- this->RelativePathTopSource.c_str()))
- {
- should_convert = true;
- }
- }
-
- if (!should_convert)
- {
- return in_remote;
- }
-
- // Identify the longest shared path component between the remote
- // path and the local path.
- std::vector<std::string> remote;
- cmSystemTools::SplitPath(in_remote, remote);
- unsigned int common=0;
- while(common < remote.size() &&
- common < local.size() &&
- cmSystemTools::ComparePath(remote[common].c_str(),
- local[common].c_str()))
- {
- ++common;
- }
-
- // If no part of the path is in common then return the full path.
- if(common == 0)
- {
- return in_remote;
- }
-
- // If the entire path is in common then just return a ".".
- if(common == remote.size() &&
- common == local.size())
- {
- return ".";
- }
-
- // If the entire path is in common except for a trailing slash then
- // just return a "./".
- if(common+1 == remote.size() &&
- remote[common].size() == 0 &&
- common == local.size())
- {
- return "./";
- }
-
- // Construct the relative path.
- std::string relative;
-
- // First add enough ../ to get up to the level of the shared portion
- // of the path. Leave off the trailing slash. Note that the last
- // component of local will never be empty because local should never
- // have a trailing slash.
- for(unsigned int i=common; i < local.size(); ++i)
- {
- relative += "..";
- if(i < local.size()-1)
- {
- relative += "/";
- }
- }
-
- // Now add the portion of the destination path that is not included
- // in the shared portion of the path. Add a slash the first time
- // only if there was already something in the path. If there was a
- // trailing slash in the input then the last iteration of the loop
- // will add a slash followed by an empty string which will preserve
- // the trailing slash in the output.
- for(unsigned int i=common; i < remote.size(); ++i)
- {
- if(relative.size() > 0)
- {
- relative += "/";
- }
- relative += remote[i];
- }
-
- // Finally return the path.
- return relative;
-}
-
inline std::string removeQuotes(const std::string& s)
{
if(s[0] == '\"' && s[s.size()-1] == '\"')