summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-04-20 18:37:05 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-04-20 18:37:05 (GMT)
commitf438cd373131b85dd71b1f902c56fb3584cf8f87 (patch)
tree29b655886a9530785de3bb00f87b90589814b73f /Source/cmMakefile.cxx
parent5e0e65c18926b0a9c5b66ff4ec93d45cc008d383 (diff)
parent05245b42294a38c5f7be9b40a918e42575b7dbd7 (diff)
downloadCMake-f438cd373131b85dd71b1f902c56fb3584cf8f87.zip
CMake-f438cd373131b85dd71b1f902c56fb3584cf8f87.tar.gz
CMake-f438cd373131b85dd71b1f902c56fb3584cf8f87.tar.bz2
Merge topic 'clean-up-ReadListFile'
05245b42 cmMakefile: Move some preamble out of the Internal method. 6e23a4bd cmMakefile: Remove always-null first parameter to ReadListFile. d21ebcb2 cmMakefile: Swap parameters of calls to ReadListFile. 95a27267 cmMakefile: Extract conditional code to caller. 7d248547 cmMakefile: Remove intermediate variable. 9db15954 cmMakefile: Move condition to the only calling context where it is true. 5d4480a8 cmMakefile: Populate CMAKE_PARENT_LIST_FILE in callers. 3a8ac242 cmMakefile: Collapse nested conditional. 5947d9b0 cmMakefile: Convert filenametoread into a std::string. e2d0e0fb cmMakefile: Remove intermediate variable. 3a1ad171 cmMakefile: Combine duplicate condition. f0dae032 cmMakefile: Re-order independent statements. 08da8742 cmMakefile: Split a conditional. 3dc4fe02 cmMakefile: Re-order independent variable setting. e4f8f1f1 cmMakefile: Remove intermediate variable. 2d6121a9 cmMakefile: Remove use of intermediate variable. ...
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx141
1 files changed, 52 insertions, 89 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 205508b..7be920d 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -522,102 +522,79 @@ void cmMakefile::IncludeScope::EnforceCMP0011()
}
}
+bool cmMakefile::ProcessBuildsystemFile(const char* listfile)
+{
+ this->AddDefinition("CMAKE_PARENT_LIST_FILE", listfile);
+ this->cmCurrentListFile = listfile;
+ return this->ReadListFile(listfile, true,
+ this->cmStartDirectory == this->cmHomeDirectory);
+}
+
+bool cmMakefile::ReadDependentFile(const char* listfile, bool noPolicyScope)
+{
+ this->AddDefinition("CMAKE_PARENT_LIST_FILE", this->GetCurrentListFile());
+ this->cmCurrentListFile =
+ cmSystemTools::CollapseFullPath(listfile,
+ this->cmStartDirectory.c_str());
+ return this->ReadListFile(this->cmCurrentListFile.c_str(),
+ noPolicyScope);
+}
+
//----------------------------------------------------------------------------
// Parse the given CMakeLists.txt file executing all commands
//
-bool cmMakefile::ReadListFile(const char* filename_in,
- const char *external_in,
- std::string* fullPath,
- bool noPolicyScope)
+bool cmMakefile::ReadListFile(const char* listfile,
+ bool noPolicyScope,
+ bool requireProjectCommand)
{
+ std::string filenametoread =
+ cmSystemTools::CollapseFullPath(listfile,
+ this->cmStartDirectory.c_str());
+
std::string currentParentFile
- = this->GetSafeDefinition("CMAKE_PARENT_LIST_FILE");
+ = 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;
-
- const char* filename = filename_in;
- std::string filename_abs;
-
- if (external_in)
- {
- external_abs =
- cmSystemTools::CollapseFullPath(external_in,
- this->cmStartDirectory.c_str());
- external = external_abs.c_str();
- if (filename_in)
- {
- filename_abs =
- cmSystemTools::CollapseFullPath(filename_in,
- this->cmStartDirectory.c_str());
- filename = filename_abs.c_str();
- }
- }
+ this->AddDefinition("CMAKE_CURRENT_LIST_FILE", filenametoread.c_str());
+ this->AddDefinition("CMAKE_CURRENT_LIST_DIR",
+ cmSystemTools::GetFilenamePath(filenametoread).c_str());
- // keep track of the current file being read
- if (filename)
- {
- if(this->cmCurrentListFile != filename)
- {
- this->cmCurrentListFile = filename;
- }
- }
+ this->MarkVariableAsUsed("CMAKE_PARENT_LIST_FILE");
+ this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE");
+ this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_DIR");
- // Now read the input file
- const char *filenametoread= filename;
+ this->ListFileStack.push_back(filenametoread);
- if( external)
- {
- filenametoread= external;
- }
+ bool res = this->ReadListFileInternal(filenametoread.c_str(),
+ noPolicyScope, requireProjectCommand);
- this->AddDefinition("CMAKE_CURRENT_LIST_FILE", filenametoread);
- this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE");
+ 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(filenametoread).c_str());
+ cmSystemTools::GetFilenamePath(currentFile).c_str());
+ this->MarkVariableAsUsed("CMAKE_PARENT_LIST_FILE");
+ this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE");
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;
- }
- }
+ this->ListFileStack.pop_back();
- // push the listfile onto the stack
- this->ListFileStack.push_back(filenametoread);
- if(fullPath!=0)
+ if (res)
{
- *fullPath=filenametoread;
+ // Check for unused variables
+ this->CheckForUnusedVariables();
}
+
+ return res;
+}
+
+bool cmMakefile::ReadListFileInternal(const char* filenametoread,
+ bool noPolicyScope,
+ bool requireProjectCommand)
+{
cmListFile cacheFile;
if( !cacheFile.ParseFile(filenametoread, requireProjectCommand, this) )
{
- // pop the listfile off the stack
- this->ListFileStack.pop_back();
- if(fullPath!=0)
- {
- *fullPath = "";
- }
- 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
@@ -656,20 +633,6 @@ bool cmMakefile::ReadListFile(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;
}