cmMakefile: Add wrapper for reading listfiles which have an origin.

Such files are delegates from other files, and so they set the
CMAKE_PARENT_LIST_FILE to the originator.  They also may set a
policy scope.
This commit is contained in:
Stephen Kelly 2015-04-18 14:50:32 +02:00
parent 68f791cd06
commit a2f2aeee2f
8 changed files with 16 additions and 15 deletions

View File

@ -117,9 +117,7 @@ bool cmCTestSubdirCommand
} }
fname += "/"; fname += "/";
fname += testFilename; fname += testFilename;
bool readit = bool readit = this->Makefile->ReadDependentFile(fname.c_str());
this->Makefile->ReadListFile(this->Makefile->GetCurrentListFile(),
fname.c_str());
cmSystemTools::ChangeDirectory(cwd); cmSystemTools::ChangeDirectory(cwd);
if(!readit) if(!readit)
{ {
@ -205,9 +203,7 @@ bool cmCTestAddSubdirectoryCommand
} }
fname += "/"; fname += "/";
fname += testFilename; fname += testFilename;
bool readit = bool readit = this->Makefile->ReadDependentFile(fname.c_str());
this->Makefile->ReadListFile(this->Makefile->GetCurrentListFile(),
fname.c_str());
cmSystemTools::ChangeDirectory(cwd); cmSystemTools::ChangeDirectory(cwd);
if(!readit) if(!readit)
{ {

View File

@ -687,8 +687,7 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command)
{ {
cmCTestOptionalLog(this, OUTPUT, " Reading ctest configuration file: " cmCTestOptionalLog(this, OUTPUT, " Reading ctest configuration file: "
<< fname << std::endl, command->ShouldBeQuiet()); << fname << std::endl, command->ShouldBeQuiet());
bool readit = mf->ReadListFile(mf->GetCurrentListFile(), bool readit = mf->ReadDependentFile(fname.c_str());
fname.c_str() );
if(!readit) if(!readit)
{ {
std::string m = "Could not find include file: "; std::string m = "Could not find include file: ";

View File

@ -999,8 +999,8 @@ bool cmFindPackageCommand::FindAppBundleConfig()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmFindPackageCommand::ReadListFile(const char* f, PolicyScopeRule psr) bool cmFindPackageCommand::ReadListFile(const char* f, PolicyScopeRule psr)
{ {
if(this->Makefile->ReadListFile(this->Makefile->GetCurrentListFile(), f, const bool noPolicyScope = !this->PolicyScope || psr == NoPolicyScope;
!this->PolicyScope || psr == NoPolicyScope)) if(this->Makefile->ReadDependentFile(f, noPolicyScope))
{ {
return true; return true;
} }

View File

@ -60,7 +60,7 @@ void cmGlobalVisualStudio6Generator::GenerateConfigurations(cmMakefile* mf)
fname += "/Templates"; fname += "/Templates";
} }
fname += "/CMakeVisualStudio6Configurations.cmake"; fname += "/CMakeVisualStudio6Configurations.cmake";
if(!mf->ReadListFile(mf->GetCurrentListFile(), fname.c_str())) if(!mf->ReadDependentFile(fname.c_str()))
{ {
cmSystemTools::Error("Cannot open ", fname.c_str(), cmSystemTools::Error("Cannot open ", fname.c_str(),
". Please copy this file from the main " ". Please copy this file from the main "

View File

@ -131,8 +131,7 @@ bool cmIncludeCommand
} }
bool readit = bool readit =
this->Makefile->ReadListFile( this->Makefile->GetCurrentListFile(), this->Makefile->ReadDependentFile(fname.c_str(), noPolicyScope);
fname.c_str(), noPolicyScope);
// add the location of the included file if a result variable was given // add the location of the included file if a result variable was given
if (!resultVarName.empty()) if (!resultVarName.empty())

View File

@ -528,6 +528,12 @@ bool cmMakefile::ProcessBuildsystemFile(const char* listfile)
this->cmStartDirectory == this->cmHomeDirectory); this->cmStartDirectory == this->cmHomeDirectory);
} }
bool cmMakefile::ReadDependentFile(const char* listfile, bool noPolicyScope)
{
return this->ReadListFile(this->GetCurrentListFile(), listfile,
noPolicyScope);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Parse the given CMakeLists.txt file executing all commands // Parse the given CMakeLists.txt file executing all commands
// //

View File

@ -90,6 +90,8 @@ public:
bool noPolicyScope = true, bool noPolicyScope = true,
bool requireProjectCommand = false); bool requireProjectCommand = false);
bool ReadDependentFile(const char* listfile, bool noPolicyScope = true);
bool ProcessBuildsystemFile(const char* listfile); bool ProcessBuildsystemFile(const char* listfile);
/** /**

View File

@ -236,8 +236,7 @@ bool cmProjectCommand
{ {
std::string fullFilePath; std::string fullFilePath;
bool readit = bool readit =
this->Makefile->ReadListFile( this->Makefile->GetCurrentListFile(), this->Makefile->ReadDependentFile(include);
include);
if(!readit && !cmSystemTools::GetFatalErrorOccured()) if(!readit && !cmSystemTools::GetFatalErrorOccured())
{ {
std::string m = std::string m =