mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-02 11:49:55 -06:00
file(GENERATE): Refactor outputFileName calculation
This commit is contained in:
committed by
Brad King
parent
a9602bb41e
commit
2dc2732f67
@@ -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()) {
|
||||
@@ -183,6 +176,21 @@ std::string cmGeneratorExpressionEvaluationFile::GetInputFileName(
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -39,6 +39,9 @@ private:
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user