cmMakefile: Add a method for processing buildsystem files.

These are different from other ListFiles in that a project() command is
required if it is top-level.
This commit is contained in:
Stephen Kelly 2015-04-18 14:50:31 +02:00
parent 5bb4248a80
commit 68f791cd06
3 changed files with 13 additions and 18 deletions

View File

@ -181,7 +181,7 @@ void cmLocalGenerator::ReadInputFile()
currentStart += "/CMakeLists.txt"; currentStart += "/CMakeLists.txt";
if(cmSystemTools::FileExists(currentStart.c_str(), true)) if(cmSystemTools::FileExists(currentStart.c_str(), true))
{ {
this->Makefile->ReadListFile(currentStart.c_str()); this->Makefile->ProcessBuildsystemFile(currentStart.c_str());
return; return;
} }

View File

@ -522,12 +522,19 @@ void cmMakefile::IncludeScope::EnforceCMP0011()
} }
} }
bool cmMakefile::ProcessBuildsystemFile(const char* listfile)
{
return this->ReadListFile(listfile, 0, true,
this->cmStartDirectory == this->cmHomeDirectory);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Parse the given CMakeLists.txt file executing all commands // Parse the given CMakeLists.txt file executing all commands
// //
bool cmMakefile::ReadListFile(const char* filename_in, bool cmMakefile::ReadListFile(const char* filename_in,
const char *external_in, const char *external_in,
bool noPolicyScope) bool noPolicyScope,
bool requireProjectCommand)
{ {
std::string currentParentFile std::string currentParentFile
= this->GetSafeDefinition("CMAKE_PARENT_LIST_FILE"); = this->GetSafeDefinition("CMAKE_PARENT_LIST_FILE");
@ -580,21 +587,6 @@ bool cmMakefile::ReadListFile(const char* filename_in,
cmSystemTools::GetFilenamePath(filenametoread).c_str()); cmSystemTools::GetFilenamePath(filenametoread).c_str());
this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_DIR"); this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_DIR");
// try to see if the list file is the top most
// list file for a project, and if it is, then it
// must have a project command. If there is not
// one, then cmake will provide one via the
// cmListFileCache class.
bool requireProjectCommand = false;
if(!external && this->cmStartDirectory == this->cmHomeDirectory)
{
if(cmSystemTools::LowerCase(
cmSystemTools::GetFilenameName(filename)) == "cmakelists.txt")
{
requireProjectCommand = true;
}
}
// push the listfile onto the stack // push the listfile onto the stack
this->ListFileStack.push_back(filenametoread); this->ListFileStack.push_back(filenametoread);
cmListFile cacheFile; cmListFile cacheFile;

View File

@ -87,7 +87,10 @@ public:
*/ */
bool ReadListFile(const char* listfile, bool ReadListFile(const char* listfile,
const char* external= 0, const char* external= 0,
bool noPolicyScope = true); bool noPolicyScope = true,
bool requireProjectCommand = false);
bool ProcessBuildsystemFile(const char* listfile);
/** /**
* Add a function blocker to this makefile * Add a function blocker to this makefile