summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-03-18 14:22:11 -0400
committerBrad King <brad.king@kitware.com>2020-03-24 10:10:06 -0400
commit25f48761faad8308f23690a51030a49d05007391 (patch)
tree1f3ece02d09b79e7a6bab7b0fb4593323e5e66bd
parent12b39aef7599a3ab6b1c1b9537d427839a9346b3 (diff)
downloadcmake-25f48761faad8308f23690a51030a49d05007391.tar.gz
Simplify absolute path conversions using CollapseFullPath full signature
-rw-r--r--Source/cmFileCommand.cxx7
-rw-r--r--Source/cmGetDirectoryPropertyCommand.cxx11
-rw-r--r--Source/cmGetPropertyCommand.cxx10
-rw-r--r--Source/cmLocalNinjaGenerator.cxx5
-rw-r--r--Source/cmMakefileTargetGenerator.cxx6
-rw-r--r--Source/cmSetPropertyCommand.cxx10
-rw-r--r--Source/cmSourceGroupCommand.cxx21
7 files changed, 19 insertions, 51 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 8b450d0638..4603b13b3d 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -2327,12 +2327,9 @@ bool HandleLockCommand(std::vector<std::string> const& args,
path += "/cmake.lock";
}
- if (!cmsys::SystemTools::FileIsFullPath(path)) {
- path = status.GetMakefile().GetCurrentSourceDirectory() + "/" + path;
- }
-
// Unify path (remove '//', '/../', ...)
- path = cmSystemTools::CollapseFullPath(path);
+ path = cmSystemTools::CollapseFullPath(
+ path, status.GetMakefile().GetCurrentSourceDirectory());
// Create file and directories if needed
std::string parentDir = cmSystemTools::GetParentDirectory(path);
diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx
index 64438d50a5..65b3457af8 100644
--- a/Source/cmGetDirectoryPropertyCommand.cxx
+++ b/Source/cmGetDirectoryPropertyCommand.cxx
@@ -7,7 +7,6 @@
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
-#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
namespace {
@@ -37,14 +36,8 @@ bool cmGetDirectoryPropertyCommand(std::vector<std::string> const& args,
"DIRECTORY argument provided without subsequent arguments");
return false;
}
- std::string sd = *i;
- // make sure the start dir is a full path
- if (!cmSystemTools::FileIsFullPath(sd)) {
- sd = cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/', *i);
- }
-
- // The local generators are associated with collapsed paths.
- sd = cmSystemTools::CollapseFullPath(sd);
+ std::string sd = cmSystemTools::CollapseFullPath(
+ *i, status.GetMakefile().GetCurrentSourceDirectory());
// lookup the makefile from the directory name
dir = status.GetMakefile().GetGlobalGenerator()->FindMakefile(sd);
diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx
index 947d893db2..2c3addec98 100644
--- a/Source/cmGetPropertyCommand.cxx
+++ b/Source/cmGetPropertyCommand.cxx
@@ -256,14 +256,8 @@ bool HandleDirectoryMode(cmExecutionStatus& status, const std::string& name,
if (!name.empty()) {
// Construct the directory name. Interpret relative paths with
// respect to the current directory.
- std::string dir = name;
- if (!cmSystemTools::FileIsFullPath(dir)) {
- dir =
- cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/', name);
- }
-
- // The local generators are associated with collapsed paths.
- dir = cmSystemTools::CollapseFullPath(dir);
+ std::string dir = cmSystemTools::CollapseFullPath(
+ name, status.GetMakefile().GetCurrentSourceDirectory());
// Lookup the generator.
mf = status.GetMakefile().GetGlobalGenerator()->FindMakefile(dir);
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index be1dd0df53..156839711f 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -144,8 +144,9 @@ std::string cmLocalNinjaGenerator::ConvertToIncludeReference(
bool forceFullPaths)
{
if (forceFullPaths) {
- return this->ConvertToOutputFormat(cmSystemTools::CollapseFullPath(path),
- format);
+ return this->ConvertToOutputFormat(
+ cmSystemTools::CollapseFullPath(path, this->GetCurrentBinaryDirectory()),
+ format);
}
return this->ConvertToOutputFormat(
this->MaybeConvertToRelativePath(this->GetBinaryDirectory(), path),
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 4389228dd9..b70376ee69 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -1245,8 +1245,10 @@ void cmMakefileTargetGenerator::GenerateCustomRuleFile(
// Setup implicit dependency scanning.
for (auto const& idi : ccg.GetCC().GetImplicitDepends()) {
- std::string objFullPath = cmSystemTools::CollapseFullPath(outputs[0]);
- std::string srcFullPath = cmSystemTools::CollapseFullPath(idi.second);
+ std::string objFullPath = cmSystemTools::CollapseFullPath(
+ outputs[0], this->LocalGenerator->GetCurrentBinaryDirectory());
+ std::string srcFullPath = cmSystemTools::CollapseFullPath(
+ idi.second, this->LocalGenerator->GetCurrentBinaryDirectory());
this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, idi.first,
objFullPath, srcFullPath);
}
diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx
index e7330ef7a8..4dbbbd733b 100644
--- a/Source/cmSetPropertyCommand.cxx
+++ b/Source/cmSetPropertyCommand.cxx
@@ -235,14 +235,8 @@ bool HandleDirectoryMode(cmExecutionStatus& status,
if (!names.empty()) {
// Construct the directory name. Interpret relative paths with
// respect to the current directory.
- std::string dir = *names.begin();
- if (!cmSystemTools::FileIsFullPath(dir)) {
- dir = cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/',
- *names.begin());
- }
-
- // The local generators are associated with collapsed paths.
- dir = cmSystemTools::CollapseFullPath(dir);
+ std::string dir = cmSystemTools::CollapseFullPath(
+ *names.begin(), status.GetMakefile().GetCurrentSourceDirectory());
mf = status.GetMakefile().GetGlobalGenerator()->FindMakefile(dir);
if (!mf) {
diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx
index cc62952d8b..8350410fd3 100644
--- a/Source/cmSourceGroupCommand.cxx
+++ b/Source/cmSourceGroupCommand.cxx
@@ -30,18 +30,6 @@ std::vector<std::string> tokenizePath(const std::string& path)
return cmTokenize(path, "\\/");
}
-std::string getFullFilePath(const std::string& currentPath,
- const std::string& path)
-{
- std::string fullPath = path;
-
- if (!cmSystemTools::FileIsFullPath(path)) {
- fullPath = cmStrCat(currentPath, '/', path);
- }
-
- return cmSystemTools::CollapseFullPath(fullPath);
-}
-
std::set<std::string> getSourceGroupFilesPaths(
const std::string& root, const std::vector<std::string>& files)
{
@@ -124,7 +112,8 @@ bool addFilesToItsSourceGroups(const std::string& root,
errorMsg = "Could not create source group for file: " + sgFilesPath;
return false;
}
- const std::string fullPath = getFullFilePath(root, sgFilesPath);
+ const std::string fullPath =
+ cmSystemTools::CollapseFullPath(sgFilesPath, root);
sg->AddGroupFile(fullPath);
}
}
@@ -255,10 +244,8 @@ bool cmSourceGroupCommand(std::vector<std::string> const& args,
parsedArguments[kFilesOptionName];
for (auto const& filesArg : filesArguments) {
std::string src = filesArg;
- if (!cmSystemTools::FileIsFullPath(src)) {
- src = cmStrCat(mf.GetCurrentSourceDirectory(), '/', filesArg);
- }
- src = cmSystemTools::CollapseFullPath(src);
+ src =
+ cmSystemTools::CollapseFullPath(src, mf.GetCurrentSourceDirectory());
sg->AddGroupFile(src);
}
}