diff options
author | Brad King <brad.king@kitware.com> | 2020-08-20 11:59:16 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-08-20 11:59:23 (GMT) |
commit | 2a8f363a54c77bf1f110deabf1933e71a93ef3f4 (patch) | |
tree | 002163214463dfa83dfa9475369e5347f3792b20 /Source | |
parent | 692d259f9e92d58aff3064ffef0d7574cd5f2f79 (diff) | |
parent | 462b6d83e8c1113296ae52202ab664508f7865a7 (diff) | |
download | CMake-2a8f363a54c77bf1f110deabf1933e71a93ef3f4.zip CMake-2a8f363a54c77bf1f110deabf1933e71a93ef3f4.tar.gz CMake-2a8f363a54c77bf1f110deabf1933e71a93ef3f4.tar.bz2 |
Merge topic 'fix-file-generate-cmp0070'
462b6d83e8 file(GENERATE): Test source properties
1977f7833b file(GENERATE): Update existing tests
04fbd7566a file(GENERATE): Fix missing check for policy CMP0070
2dc2732f67 file(GENERATE): Refactor outputFileName calculation
a9602bb41e file(GENERATE): Refactor inputFileName calculation
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5090
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorExpressionEvaluationFile.cxx | 48 | ||||
-rw-r--r-- | Source/cmGeneratorExpressionEvaluationFile.h | 4 |
2 files changed, 36 insertions, 16 deletions
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index 1107adb..6647e62 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -54,17 +54,10 @@ void cmGeneratorExpressionEvaluationFile::Generate( } } - std::string outputFileName = this->OutputFileExpr->Evaluate( - lg, config, nullptr, nullptr, nullptr, lang); + const std::string outputFileName = this->GetOutputFileName(lg, config, lang); const std::string& outputContent = inputExpression->Evaluate(lg, config, nullptr, nullptr, nullptr, lang); - if (cmSystemTools::FileIsFullPath(outputFileName)) { - outputFileName = cmSystemTools::CollapseFullPath(outputFileName); - } else { - outputFileName = this->FixRelativePath(outputFileName, PathForOutput, lg); - } - auto it = outputFiles.find(outputFileName); if (it != outputFiles.end()) { @@ -101,8 +94,7 @@ void cmGeneratorExpressionEvaluationFile::CreateOutputFile( gg->GetEnabledLanguages(enabledLanguages); for (std::string const& le : enabledLanguages) { - std::string name = this->OutputFileExpr->Evaluate(lg, config, nullptr, - nullptr, nullptr, le); + std::string const name = this->GetOutputFileName(lg, config, le); cmSourceFile* sf = lg->GetMakefile()->GetOrCreateSource( name, false, cmSourceFileLocationKind::Known); // Tell TraceDependencies that the file is not expected to exist @@ -125,12 +117,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg) if (this->InputIsContent) { inputContent = this->Input; } else { - std::string inputFileName = this->Input; - if (cmSystemTools::FileIsFullPath(inputFileName)) { - inputFileName = cmSystemTools::CollapseFullPath(inputFileName); - } else { - inputFileName = this->FixRelativePath(inputFileName, PathForInput, lg); - } + const std::string inputFileName = this->GetInputFileName(lg); lg->GetMakefile()->AddCMakeDependFile(inputFileName); cmSystemTools::GetPermissions(inputFileName.c_str(), perm); cmsys::ifstream fin(inputFileName.c_str()); @@ -174,6 +161,35 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg) } } +std::string cmGeneratorExpressionEvaluationFile::GetInputFileName( + cmLocalGenerator* lg) +{ + std::string inputFileName = this->Input; + + if (cmSystemTools::FileIsFullPath(inputFileName)) { + inputFileName = cmSystemTools::CollapseFullPath(inputFileName); + } else { + inputFileName = this->FixRelativePath(inputFileName, PathForInput, lg); + } + + return inputFileName; +} + +std::string cmGeneratorExpressionEvaluationFile::GetOutputFileName( + cmLocalGenerator* lg, const std::string& config, const std::string& lang) +{ + std::string outputFileName = this->OutputFileExpr->Evaluate( + lg, config, nullptr, nullptr, nullptr, lang); + + if (cmSystemTools::FileIsFullPath(outputFileName)) { + outputFileName = cmSystemTools::CollapseFullPath(outputFileName); + } else { + outputFileName = this->FixRelativePath(outputFileName, PathForOutput, lg); + } + + return outputFileName; +} + std::string cmGeneratorExpressionEvaluationFile::FixRelativePath( std::string const& relativePath, PathRole role, cmLocalGenerator* lg) { diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h index c3bc4c8..a258a2d 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.h +++ b/Source/cmGeneratorExpressionEvaluationFile.h @@ -38,6 +38,10 @@ private: cmCompiledGeneratorExpression* inputExpression, std::map<std::string, std::string>& outputFiles, mode_t perm); + std::string GetInputFileName(cmLocalGenerator* lg); + std::string GetOutputFileName(cmLocalGenerator* lg, + const std::string& config, + const std::string& lang); enum PathRole { PathForInput, |