diff options
author | Brad King <brad.king@kitware.com> | 2017-04-13 20:32:46 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-04-13 20:32:46 (GMT) |
commit | dadf1570d919a8dd79547b8a01644d03ae607040 (patch) | |
tree | 4d15933bddb0e2ee8b9e1248b5bfca611326b210 /Source | |
parent | e155fba644d4686ac8b4f43dfe31c749bba30c67 (diff) | |
download | CMake-dadf1570d919a8dd79547b8a01644d03ae607040.zip CMake-dadf1570d919a8dd79547b8a01644d03ae607040.tar.gz CMake-dadf1570d919a8dd79547b8a01644d03ae607040.tar.bz2 |
file: Refactor COPY/INSTALL relative path handling
Delay conversion to absolute path until the last moment.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmFileCommand.cxx | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index deb7187..51fb945 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -1314,13 +1314,7 @@ bool cmFileCopier::CheckValue(std::string const& arg) { switch (this->Doing) { case DoingFiles: - if (arg.empty() || cmSystemTools::FileIsFullPath(arg.c_str())) { - this->Files.push_back(arg); - } else { - std::string file = this->Makefile->GetCurrentSourceDirectory(); - file += "/" + arg; - this->Files.push_back(file); - } + this->Files.push_back(arg); break; case DoingDestination: if (arg.empty() || cmSystemTools::FileIsFullPath(arg.c_str())) { @@ -1390,11 +1384,20 @@ bool cmFileCopier::Run(std::vector<std::string> const& args) return false; } - std::vector<std::string> const& files = this->Files; - for (std::vector<std::string>::size_type i = 0; i < files.size(); ++i) { + for (std::vector<std::string>::const_iterator i = this->Files.begin(); + i != this->Files.end(); ++i) { + std::string file; + if (!i->empty() && !cmSystemTools::FileIsFullPath(*i)) { + file = this->Makefile->GetCurrentSourceDirectory(); + file += "/"; + file += *i; + } else { + file = *i; + } + // Split the input file into its directory and name components. std::vector<std::string> fromPathComponents; - cmSystemTools::SplitPath(files[i], fromPathComponents); + cmSystemTools::SplitPath(file, fromPathComponents); std::string fromName = *(fromPathComponents.end() - 1); std::string fromDir = cmSystemTools::JoinPath( fromPathComponents.begin(), fromPathComponents.end() - 1); |