cmMakefile: Remove duplication in ReadListFile.

This commit is contained in:
Stephen Kelly 2015-04-18 14:50:33 +02:00
parent 0d9555779d
commit 5c201f1ee6
1 changed files with 28 additions and 32 deletions

View File

@ -542,8 +542,34 @@ bool cmMakefile::ReadListFile(const char* filename_in,
bool noPolicyScope,
bool requireProjectCommand)
{
return this->ReadListFileInternal(filename_in, external_in,
noPolicyScope, requireProjectCommand);
std::string currentParentFile
= this->GetSafeDefinition("CMAKE_PARENT_LIST_FILE");
std::string currentFile
= this->GetSafeDefinition("CMAKE_CURRENT_LIST_FILE");
this->AddDefinition("CMAKE_PARENT_LIST_FILE", filename_in);
this->MarkVariableAsUsed("CMAKE_PARENT_LIST_FILE");
bool res = this->ReadListFileInternal(filename_in, external_in,
noPolicyScope, requireProjectCommand);
this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentParentFile.c_str());
this->AddDefinition("CMAKE_CURRENT_LIST_FILE", currentFile.c_str());
this->AddDefinition("CMAKE_CURRENT_LIST_DIR",
cmSystemTools::GetFilenamePath(currentFile).c_str());
this->MarkVariableAsUsed("CMAKE_PARENT_LIST_FILE");
this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE");
this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_DIR");
this->ListFileStack.pop_back();
if (res)
{
// Check for unused variables
this->CheckForUnusedVariables();
}
return res;
}
bool cmMakefile::ReadListFileInternal(const char* filename_in,
@ -551,13 +577,6 @@ bool cmMakefile::ReadListFileInternal(const char* filename_in,
bool noPolicyScope,
bool requireProjectCommand)
{
std::string currentParentFile
= this->GetSafeDefinition("CMAKE_PARENT_LIST_FILE");
std::string currentFile
= this->GetSafeDefinition("CMAKE_CURRENT_LIST_FILE");
this->AddDefinition("CMAKE_PARENT_LIST_FILE", filename_in);
this->MarkVariableAsUsed("CMAKE_PARENT_LIST_FILE");
const char* external = 0;
std::string external_abs;
@ -604,15 +623,6 @@ bool cmMakefile::ReadListFileInternal(const char* filename_in,
cmListFile cacheFile;
if( !cacheFile.ParseFile(filenametoread, requireProjectCommand, this) )
{
// pop the listfile off the stack
this->ListFileStack.pop_back();
this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentParentFile.c_str());
this->MarkVariableAsUsed("CMAKE_PARENT_LIST_FILE");
this->AddDefinition("CMAKE_CURRENT_LIST_FILE", currentFile.c_str());
this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE");
this->AddDefinition("CMAKE_CURRENT_LIST_DIR",
cmSystemTools::GetFilenamePath(currentFile).c_str());
this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_DIR");
return false;
}
// add this list file to the list of dependencies
@ -651,20 +661,6 @@ bool cmMakefile::ReadListFileInternal(const char* filename_in,
this->EnforceDirectoryLevelRules();
}
this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentParentFile.c_str());
this->MarkVariableAsUsed("CMAKE_PARENT_LIST_FILE");
this->AddDefinition("CMAKE_CURRENT_LIST_FILE", currentFile.c_str());
this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE");
this->AddDefinition("CMAKE_CURRENT_LIST_DIR",
cmSystemTools::GetFilenamePath(currentFile).c_str());
this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_DIR");
// pop the listfile off the stack
this->ListFileStack.pop_back();
// Check for unused variables
this->CheckForUnusedVariables();
return true;
}