diff options
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 160 |
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] == '\"') |