summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorExpressionEvaluationFile.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-06-08 13:54:37 (GMT)
committerBrad King <brad.king@kitware.com>2017-06-08 14:41:28 (GMT)
commitc41a7c7d90e1fca52896dfeb99b7efd717aa6262 (patch)
tree301bf40d2b648d8ae8ec23dfcecf8275df57bc5a /Source/cmGeneratorExpressionEvaluationFile.cxx
parentcab94b7c4f82653796e407c90c8d348e8f45a904 (diff)
downloadCMake-c41a7c7d90e1fca52896dfeb99b7efd717aa6262.zip
CMake-c41a7c7d90e1fca52896dfeb99b7efd717aa6262.tar.gz
CMake-c41a7c7d90e1fca52896dfeb99b7efd717aa6262.tar.bz2
file: Normalize GENERATE command input and output file paths
Normalize absolute paths so that no extra components like `../` or `...//...` appear that later confuse relative path computation. In particular, we expect paths sent to AddCMakeDependFile and AddCMakeOutputFile to be normalized. Do this only for paths that are already absolute because we can't handle relative paths yet (see #16786). Fixes: #16892
Diffstat (limited to 'Source/cmGeneratorExpressionEvaluationFile.cxx')
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.cxx18
1 files changed, 13 insertions, 5 deletions
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx
index 1526454..c21e4f6 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.cxx
+++ b/Source/cmGeneratorExpressionEvaluationFile.cxx
@@ -51,11 +51,15 @@ void cmGeneratorExpressionEvaluationFile::Generate(
}
}
- const std::string outputFileName = this->OutputFileExpr->Evaluate(
+ std::string outputFileName = this->OutputFileExpr->Evaluate(
lg, config, false, CM_NULLPTR, CM_NULLPTR, CM_NULLPTR, lang);
const std::string outputContent = inputExpression->Evaluate(
lg, config, false, CM_NULLPTR, CM_NULLPTR, CM_NULLPTR, lang);
+ if (cmSystemTools::FileIsFullPath(outputFileName)) {
+ outputFileName = cmSystemTools::CollapseFullPath(outputFileName);
+ }
+
std::map<std::string, std::string>::iterator it =
outputFiles.find(outputFileName);
@@ -111,12 +115,16 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg)
if (this->InputIsContent) {
inputContent = this->Input;
} else {
- lg->GetMakefile()->AddCMakeDependFile(this->Input);
- cmSystemTools::GetPermissions(this->Input.c_str(), perm);
- cmsys::ifstream fin(this->Input.c_str());
+ std::string inputFileName = this->Input;
+ if (cmSystemTools::FileIsFullPath(inputFileName)) {
+ inputFileName = cmSystemTools::CollapseFullPath(inputFileName);
+ }
+ lg->GetMakefile()->AddCMakeDependFile(inputFileName);
+ cmSystemTools::GetPermissions(inputFileName.c_str(), perm);
+ cmsys::ifstream fin(inputFileName.c_str());
if (!fin) {
std::ostringstream e;
- e << "Evaluation file \"" << this->Input << "\" cannot be read.";
+ e << "Evaluation file \"" << inputFileName << "\" cannot be read.";
lg->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}