From fc7ab8874b0e5c2c010fb73718ae8702b8853ca0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:31 +0200 Subject: CPack: Read the config listfile in the normal way. This is a unique function call in CMake, and it was likely a programming error when introduced. All other similar calls to ReadListFile use a null first paramter. The effect of this patch is to no-longer define CMAKE_PARENT_LIST_FILE to the config file itself while evaluating it. The ReadListFile method also no longer hits a condition that it uses CollapseFullPath on the input file. However, as cpack does not set the StartDirectory anyway, this has no effect. See bug 15522. --- Source/CPack/cmCPackGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 4f37041..a2edab5 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -1163,7 +1163,7 @@ int cmCPackGenerator::Initialize(const std::string& name, cmMakefile* mf) this->GetOption("CPACK_PROJECT_CONFIG_FILE"); if(config) { - mf->ReadListFile(config); + mf->ReadListFile(0, config); } int result = this->InitializeInternal(); if (cmSystemTools::GetErrorOccuredFlag()) -- cgit v0.12 From 5bb4248a807029053156dbf4a3cdba4427766306 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:31 +0200 Subject: cmMakefile: Remove fullPath parameter from ReadListFile. There is no reason for this to be a responsibility of ReadListFile. Additionally, the only user of it already computes it itself. --- Source/cmFindPackageCommand.cxx | 2 +- Source/cmIncludeCommand.cxx | 6 ++---- Source/cmMakefile.cxx | 9 --------- Source/cmMakefile.h | 1 - 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index e1074b0..af99b1c 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -999,7 +999,7 @@ bool cmFindPackageCommand::FindAppBundleConfig() //---------------------------------------------------------------------------- bool cmFindPackageCommand::ReadListFile(const char* f, PolicyScopeRule psr) { - if(this->Makefile->ReadListFile(this->Makefile->GetCurrentListFile(), f, 0, + if(this->Makefile->ReadListFile(this->Makefile->GetCurrentListFile(), f, !this->PolicyScope || psr == NoPolicyScope)) { return true; diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx index c15d46e..0c2e73a 100644 --- a/Source/cmIncludeCommand.cxx +++ b/Source/cmIncludeCommand.cxx @@ -130,17 +130,15 @@ bool cmIncludeCommand gg->GenerateImportFile(fname_abs); } - std::string fullFilePath; bool readit = this->Makefile->ReadListFile( this->Makefile->GetCurrentListFile(), - fname.c_str(), &fullFilePath, - noPolicyScope); + fname.c_str(), noPolicyScope); // add the location of the included file if a result variable was given if (!resultVarName.empty()) { this->Makefile->AddDefinition(resultVarName, - readit?fullFilePath.c_str():"NOTFOUND"); + readit?fname_abs.c_str():"NOTFOUND"); } if(!optional && !readit && !cmSystemTools::GetFatalErrorOccured()) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 205508b..8bc4ac8 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -527,7 +527,6 @@ void cmMakefile::IncludeScope::EnforceCMP0011() // bool cmMakefile::ReadListFile(const char* filename_in, const char *external_in, - std::string* fullPath, bool noPolicyScope) { std::string currentParentFile @@ -598,19 +597,11 @@ bool cmMakefile::ReadListFile(const char* filename_in, // push the listfile onto the stack this->ListFileStack.push_back(filenametoread); - if(fullPath!=0) - { - *fullPath=filenametoread; - } 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()); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 299d550..ce21c60 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -87,7 +87,6 @@ public: */ bool ReadListFile(const char* listfile, const char* external= 0, - std::string* fullPath= 0, bool noPolicyScope = true); /** -- cgit v0.12 From 68f791cd06983e8fd375edfba74a9d821231e269 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:31 +0200 Subject: 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. --- Source/cmLocalGenerator.cxx | 2 +- Source/cmMakefile.cxx | 24 ++++++++---------------- Source/cmMakefile.h | 5 ++++- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c143bce..56e17ec 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -181,7 +181,7 @@ void cmLocalGenerator::ReadInputFile() currentStart += "/CMakeLists.txt"; if(cmSystemTools::FileExists(currentStart.c_str(), true)) { - this->Makefile->ReadListFile(currentStart.c_str()); + this->Makefile->ProcessBuildsystemFile(currentStart.c_str()); return; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8bc4ac8..b08725e 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -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 // bool cmMakefile::ReadListFile(const char* filename_in, const char *external_in, - bool noPolicyScope) + bool noPolicyScope, + bool requireProjectCommand) { std::string currentParentFile = this->GetSafeDefinition("CMAKE_PARENT_LIST_FILE"); @@ -580,21 +587,6 @@ bool cmMakefile::ReadListFile(const char* filename_in, cmSystemTools::GetFilenamePath(filenametoread).c_str()); 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 this->ListFileStack.push_back(filenametoread); cmListFile cacheFile; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index ce21c60..33c4b20 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -87,7 +87,10 @@ public: */ bool ReadListFile(const char* listfile, 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 -- cgit v0.12 From a2f2aeee2f4d4af1f25f4a5b86bacb8a81a7dec4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:32 +0200 Subject: 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. --- Source/CTest/cmCTestTestHandler.cxx | 8 ++------ Source/cmCTest.cxx | 3 +-- Source/cmFindPackageCommand.cxx | 4 ++-- Source/cmGlobalVisualStudio6Generator.cxx | 2 +- Source/cmIncludeCommand.cxx | 3 +-- Source/cmMakefile.cxx | 6 ++++++ Source/cmMakefile.h | 2 ++ Source/cmProjectCommand.cxx | 3 +-- 8 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index c50ea88..59c5e92 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -117,9 +117,7 @@ bool cmCTestSubdirCommand } fname += "/"; fname += testFilename; - bool readit = - this->Makefile->ReadListFile(this->Makefile->GetCurrentListFile(), - fname.c_str()); + bool readit = this->Makefile->ReadDependentFile(fname.c_str()); cmSystemTools::ChangeDirectory(cwd); if(!readit) { @@ -205,9 +203,7 @@ bool cmCTestAddSubdirectoryCommand } fname += "/"; fname += testFilename; - bool readit = - this->Makefile->ReadListFile(this->Makefile->GetCurrentListFile(), - fname.c_str()); + bool readit = this->Makefile->ReadDependentFile(fname.c_str()); cmSystemTools::ChangeDirectory(cwd); if(!readit) { diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index cd2cd7c..91ae889 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -687,8 +687,7 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) { cmCTestOptionalLog(this, OUTPUT, " Reading ctest configuration file: " << fname << std::endl, command->ShouldBeQuiet()); - bool readit = mf->ReadListFile(mf->GetCurrentListFile(), - fname.c_str() ); + bool readit = mf->ReadDependentFile(fname.c_str()); if(!readit) { std::string m = "Could not find include file: "; diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index af99b1c..aecd230 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -999,8 +999,8 @@ bool cmFindPackageCommand::FindAppBundleConfig() //---------------------------------------------------------------------------- bool cmFindPackageCommand::ReadListFile(const char* f, PolicyScopeRule psr) { - if(this->Makefile->ReadListFile(this->Makefile->GetCurrentListFile(), f, - !this->PolicyScope || psr == NoPolicyScope)) + const bool noPolicyScope = !this->PolicyScope || psr == NoPolicyScope; + if(this->Makefile->ReadDependentFile(f, noPolicyScope)) { return true; } diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index e2b2bbd4..e268852 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -60,7 +60,7 @@ void cmGlobalVisualStudio6Generator::GenerateConfigurations(cmMakefile* mf) fname += "/Templates"; } fname += "/CMakeVisualStudio6Configurations.cmake"; - if(!mf->ReadListFile(mf->GetCurrentListFile(), fname.c_str())) + if(!mf->ReadDependentFile(fname.c_str())) { cmSystemTools::Error("Cannot open ", fname.c_str(), ". Please copy this file from the main " diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx index 0c2e73a..18e3585 100644 --- a/Source/cmIncludeCommand.cxx +++ b/Source/cmIncludeCommand.cxx @@ -131,8 +131,7 @@ bool cmIncludeCommand } bool readit = - this->Makefile->ReadListFile( this->Makefile->GetCurrentListFile(), - fname.c_str(), noPolicyScope); + this->Makefile->ReadDependentFile(fname.c_str(), noPolicyScope); // add the location of the included file if a result variable was given if (!resultVarName.empty()) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index b08725e..29e564f 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -528,6 +528,12 @@ bool cmMakefile::ProcessBuildsystemFile(const char* listfile) 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 // diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 33c4b20..3d925fa 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -90,6 +90,8 @@ public: bool noPolicyScope = true, bool requireProjectCommand = false); + bool ReadDependentFile(const char* listfile, bool noPolicyScope = true); + bool ProcessBuildsystemFile(const char* listfile); /** diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 601dc54..43b02bc 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -236,8 +236,7 @@ bool cmProjectCommand { std::string fullFilePath; bool readit = - this->Makefile->ReadListFile( this->Makefile->GetCurrentListFile(), - include); + this->Makefile->ReadDependentFile(include); if(!readit && !cmSystemTools::GetFatalErrorOccured()) { std::string m = -- cgit v0.12 From 846608f2678b4bced696857b5ca45e11bc86aa2c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:32 +0200 Subject: cmMakefile: Remove useless condition. --- Source/cmMakefile.cxx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 29e564f..2b4b896 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -573,10 +573,7 @@ bool cmMakefile::ReadListFile(const char* filename_in, // keep track of the current file being read if (filename) { - if(this->cmCurrentListFile != filename) - { - this->cmCurrentListFile = filename; - } + this->cmCurrentListFile = filename; } // Now read the input file -- cgit v0.12 From 0d9555779d7bd2a8d068f5b9af431bcf9673453a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:32 +0200 Subject: cmMakefile: Delegate ListFile reading to internal method. --- Source/cmMakefile.cxx | 9 +++++++++ Source/cmMakefile.h | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2b4b896..0211591 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -542,6 +542,15 @@ bool cmMakefile::ReadListFile(const char* filename_in, bool noPolicyScope, bool requireProjectCommand) { + return this->ReadListFileInternal(filename_in, external_in, + noPolicyScope, requireProjectCommand); +} + +bool cmMakefile::ReadListFileInternal(const char* filename_in, + const char* external_in, + bool noPolicyScope, + bool requireProjectCommand) +{ std::string currentParentFile = this->GetSafeDefinition("CMAKE_PARENT_LIST_FILE"); std::string currentFile diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 3d925fa..88faed9 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -991,6 +991,12 @@ protected: private: void Initialize(); + + bool ReadListFileInternal(const char* filename_in, + const char* external_in, + bool noPolicyScope, + bool requireProjectCommand); + bool ParseDefineFlag(std::string const& definition, bool remove); bool EnforceUniqueDir(const std::string& srcPath, -- cgit v0.12 From 5c201f1ee6cc19e0f1871048a6a6af9056c5780f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:33 +0200 Subject: cmMakefile: Remove duplication in ReadListFile. --- Source/cmMakefile.cxx | 60 ++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 0211591..38e94e2 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -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; } -- cgit v0.12 From 813cd719c41b05df7a22ad3ebd267cc9bfc2505e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:33 +0200 Subject: cmMakefile: Determine the file to read before calling Internal. --- Source/cmMakefile.cxx | 69 +++++++++++++++++++++++++-------------------------- Source/cmMakefile.h | 4 +-- 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 38e94e2..dafbfef 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -542,41 +542,6 @@ bool cmMakefile::ReadListFile(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"); - - 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, - const char* external_in, - bool noPolicyScope, - bool requireProjectCommand) -{ const char* external = 0; std::string external_abs; @@ -612,6 +577,40 @@ bool cmMakefile::ReadListFileInternal(const char* filename_in, filenametoread= external; } + 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(filenametoread, + 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* filenametoread, + bool noPolicyScope, + bool requireProjectCommand) +{ this->AddDefinition("CMAKE_CURRENT_LIST_FILE", filenametoread); this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE"); this->AddDefinition("CMAKE_CURRENT_LIST_DIR", diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 88faed9..2664d8e 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -992,8 +992,8 @@ private: void Initialize(); - bool ReadListFileInternal(const char* filename_in, - const char* external_in, + + bool ReadListFileInternal(const char* filenametoread, bool noPolicyScope, bool requireProjectCommand); -- cgit v0.12 From 524ce895427557312eef52d837f0afdb39a0dab6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:33 +0200 Subject: cmMakefile: Change condition to its equivalent. This makes it easier to reason about follow-up commits. --- Source/cmMakefile.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index dafbfef..bb0b8cb 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -572,7 +572,7 @@ bool cmMakefile::ReadListFile(const char* filename_in, // Now read the input file const char *filenametoread= filename; - if( external) + if(external_in) { filenametoread= external; } -- cgit v0.12 From bdd4c5f5ba6d3bf60b4e3bc620b146784e1559f1 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:33 +0200 Subject: cmMakefile: Move variable definition above a condition. --- Source/cmMakefile.cxx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index bb0b8cb..67138ba 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -563,15 +563,14 @@ bool cmMakefile::ReadListFile(const char* filename_in, } } + const char *filenametoread = filename; + // keep track of the current file being read if (filename) { this->cmCurrentListFile = filename; } - // Now read the input file - const char *filenametoread= filename; - if(external_in) { filenametoread= external; -- cgit v0.12 From 2d6121a9a709e319cca733787bcc21bac593a232 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:34 +0200 Subject: cmMakefile: Remove use of intermediate variable. --- Source/cmMakefile.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 67138ba..46a10a9 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -566,9 +566,9 @@ bool cmMakefile::ReadListFile(const char* filename_in, const char *filenametoread = filename; // keep track of the current file being read - if (filename) + if (filenametoread) { - this->cmCurrentListFile = filename; + this->cmCurrentListFile = filenametoread; } if(external_in) -- cgit v0.12 From e4f8f1f1b706d7efc9964826ff4572d27a3062d3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:34 +0200 Subject: cmMakefile: Remove intermediate variable. --- Source/cmMakefile.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 46a10a9..ac71ea5 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -545,7 +545,7 @@ bool cmMakefile::ReadListFile(const char* filename_in, const char* external = 0; std::string external_abs; - const char* filename = filename_in; + const char* filenametoread = filename_in; std::string filename_abs; if (external_in) @@ -559,12 +559,10 @@ bool cmMakefile::ReadListFile(const char* filename_in, filename_abs = cmSystemTools::CollapseFullPath(filename_in, this->cmStartDirectory.c_str()); - filename = filename_abs.c_str(); + filenametoread = filename_abs.c_str(); } } - const char *filenametoread = filename; - // keep track of the current file being read if (filenametoread) { -- cgit v0.12 From 3dc4fe02e63422532486320739e0cf4abddaa270 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:34 +0200 Subject: cmMakefile: Re-order independent variable setting. --- Source/cmMakefile.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ac71ea5..029fd3d 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -550,10 +550,6 @@ bool cmMakefile::ReadListFile(const char* filename_in, if (external_in) { - external_abs = - cmSystemTools::CollapseFullPath(external_in, - this->cmStartDirectory.c_str()); - external = external_abs.c_str(); if (filename_in) { filename_abs = @@ -561,6 +557,10 @@ bool cmMakefile::ReadListFile(const char* filename_in, this->cmStartDirectory.c_str()); filenametoread = filename_abs.c_str(); } + external_abs = + cmSystemTools::CollapseFullPath(external_in, + this->cmStartDirectory.c_str()); + external = external_abs.c_str(); } // keep track of the current file being read -- cgit v0.12 From 08da8742709d6da74d1a17de46990ec5aaf3ad0f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:34 +0200 Subject: cmMakefile: Split a conditional. --- Source/cmMakefile.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 029fd3d..5ab1928 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -557,6 +557,10 @@ bool cmMakefile::ReadListFile(const char* filename_in, this->cmStartDirectory.c_str()); filenametoread = filename_abs.c_str(); } + } + + if (external_in) + { external_abs = cmSystemTools::CollapseFullPath(external_in, this->cmStartDirectory.c_str()); -- cgit v0.12 From f0dae032ee44283d08869c2a948f001dc211bfd5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:35 +0200 Subject: cmMakefile: Re-order independent statements. --- Source/cmMakefile.cxx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 5ab1928..042ffc0 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -559,6 +559,11 @@ bool cmMakefile::ReadListFile(const char* filename_in, } } + if (filenametoread) + { + this->cmCurrentListFile = filenametoread; + } + if (external_in) { external_abs = @@ -567,12 +572,6 @@ bool cmMakefile::ReadListFile(const char* filename_in, external = external_abs.c_str(); } - // keep track of the current file being read - if (filenametoread) - { - this->cmCurrentListFile = filenametoread; - } - if(external_in) { filenametoread= external; -- cgit v0.12 From 3a1ad1713f87ed7219c934dcb32c4d41573807c4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:35 +0200 Subject: cmMakefile: Combine duplicate condition. --- Source/cmMakefile.cxx | 3 --- 1 file changed, 3 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 042ffc0..037d697 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -570,10 +570,7 @@ bool cmMakefile::ReadListFile(const char* filename_in, cmSystemTools::CollapseFullPath(external_in, this->cmStartDirectory.c_str()); external = external_abs.c_str(); - } - if(external_in) - { filenametoread= external; } -- cgit v0.12 From e2d0e0fbeb1bf7b43dc55ce55c6000819d108aee Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:35 +0200 Subject: cmMakefile: Remove intermediate variable. --- Source/cmMakefile.cxx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 037d697..eeba6aa 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -542,7 +542,6 @@ bool cmMakefile::ReadListFile(const char* filename_in, bool noPolicyScope, bool requireProjectCommand) { - const char* external = 0; std::string external_abs; const char* filenametoread = filename_in; @@ -569,9 +568,8 @@ bool cmMakefile::ReadListFile(const char* filename_in, external_abs = cmSystemTools::CollapseFullPath(external_in, this->cmStartDirectory.c_str()); - external = external_abs.c_str(); - filenametoread= external; + filenametoread = external_abs.c_str(); } std::string currentParentFile -- cgit v0.12 From 5947d9b031444b48a7d7a9c70ef02d2333aeabee Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:36 +0200 Subject: cmMakefile: Convert filenametoread into a std::string. Remove other intermediate variables. --- Source/cmMakefile.cxx | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index eeba6aa..851e407 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -542,34 +542,32 @@ bool cmMakefile::ReadListFile(const char* filename_in, bool noPolicyScope, bool requireProjectCommand) { - std::string external_abs; - - const char* filenametoread = filename_in; - std::string filename_abs; + std::string filenametoread; + if (filename_in) + { + filenametoread = filename_in; + } if (external_in) { if (filename_in) { - filename_abs = + filenametoread = cmSystemTools::CollapseFullPath(filename_in, this->cmStartDirectory.c_str()); - filenametoread = filename_abs.c_str(); } } - if (filenametoread) + if (!filenametoread.empty()) { this->cmCurrentListFile = filenametoread; } if (external_in) { - external_abs = + filenametoread = cmSystemTools::CollapseFullPath(external_in, this->cmStartDirectory.c_str()); - - filenametoread = external_abs.c_str(); } std::string currentParentFile @@ -580,7 +578,7 @@ bool cmMakefile::ReadListFile(const char* filename_in, this->AddDefinition("CMAKE_PARENT_LIST_FILE", filename_in); this->MarkVariableAsUsed("CMAKE_PARENT_LIST_FILE"); - bool res = this->ReadListFileInternal(filenametoread, + bool res = this->ReadListFileInternal(filenametoread.c_str(), noPolicyScope, requireProjectCommand); this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentParentFile.c_str()); -- cgit v0.12 From 3a8ac2423ef658e87e366a143428835be48bf88f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:36 +0200 Subject: cmMakefile: Collapse nested conditional. --- Source/cmMakefile.cxx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 851e407..9a57223 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -548,14 +548,11 @@ bool cmMakefile::ReadListFile(const char* filename_in, filenametoread = filename_in; } - if (external_in) + if (external_in && filename_in) { - if (filename_in) - { - filenametoread = - cmSystemTools::CollapseFullPath(filename_in, - this->cmStartDirectory.c_str()); - } + filenametoread = + cmSystemTools::CollapseFullPath(filename_in, + this->cmStartDirectory.c_str()); } if (!filenametoread.empty()) -- cgit v0.12 From 5d4480a8c711a3d5971e100cc1a8984b6305c509 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:36 +0200 Subject: cmMakefile: Populate CMAKE_PARENT_LIST_FILE in callers. Because all external callers of this method pass a null first parameter, this change has no effect for them. This also makes it obvious that the CMAKE_PARENT_LIST_FILE is set to the name of the file being read itself for CMakeLists.txt files, which may not make any sense. --- Source/cmMakefile.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 9a57223..7f4fbc1 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -524,12 +524,14 @@ void cmMakefile::IncludeScope::EnforceCMP0011() bool cmMakefile::ProcessBuildsystemFile(const char* listfile) { + this->AddDefinition("CMAKE_PARENT_LIST_FILE", listfile); return this->ReadListFile(listfile, 0, true, this->cmStartDirectory == this->cmHomeDirectory); } bool cmMakefile::ReadDependentFile(const char* listfile, bool noPolicyScope) { + this->AddDefinition("CMAKE_PARENT_LIST_FILE", this->GetCurrentListFile()); return this->ReadListFile(this->GetCurrentListFile(), listfile, noPolicyScope); } @@ -572,7 +574,6 @@ bool cmMakefile::ReadListFile(const char* filename_in, 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(filenametoread.c_str(), -- cgit v0.12 From 9db15954104455fef54d59c7aa029d798075bf0e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:36 +0200 Subject: cmMakefile: Move condition to the only calling context where it is true. Call the Internal method with equivalent parameters, passing a null first argument. A duplicate path computation exists inside the external_in condition now, but that is harmless at this point. --- Source/cmMakefile.cxx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7f4fbc1..9b2ee35 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -532,7 +532,11 @@ bool cmMakefile::ProcessBuildsystemFile(const char* listfile) bool cmMakefile::ReadDependentFile(const char* listfile, bool noPolicyScope) { this->AddDefinition("CMAKE_PARENT_LIST_FILE", this->GetCurrentListFile()); - return this->ReadListFile(this->GetCurrentListFile(), listfile, + std::string filenametoread = + cmSystemTools::CollapseFullPath(listfile, + this->cmStartDirectory.c_str()); + this->cmCurrentListFile = filenametoread; + return this->ReadListFile(0, filenametoread.c_str(), noPolicyScope); } @@ -550,13 +554,6 @@ bool cmMakefile::ReadListFile(const char* filename_in, filenametoread = filename_in; } - if (external_in && filename_in) - { - filenametoread = - cmSystemTools::CollapseFullPath(filename_in, - this->cmStartDirectory.c_str()); - } - if (!filenametoread.empty()) { this->cmCurrentListFile = filenametoread; -- cgit v0.12 From 7d248547361bbacb4f5b532ef2ce4f4935c97dc8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:37 +0200 Subject: cmMakefile: Remove intermediate variable. --- Source/cmMakefile.cxx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 9b2ee35..d3ea55a 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -532,11 +532,10 @@ bool cmMakefile::ProcessBuildsystemFile(const char* listfile) bool cmMakefile::ReadDependentFile(const char* listfile, bool noPolicyScope) { this->AddDefinition("CMAKE_PARENT_LIST_FILE", this->GetCurrentListFile()); - std::string filenametoread = + this->cmCurrentListFile = cmSystemTools::CollapseFullPath(listfile, this->cmStartDirectory.c_str()); - this->cmCurrentListFile = filenametoread; - return this->ReadListFile(0, filenametoread.c_str(), + return this->ReadListFile(0, this->cmCurrentListFile.c_str(), noPolicyScope); } -- cgit v0.12 From 95a27267daee021514df8c93ffd6d9b9e55dea51 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:37 +0200 Subject: cmMakefile: Extract conditional code to caller. --- Source/cmMakefile.cxx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index d3ea55a..bc225ff 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -525,6 +525,7 @@ void cmMakefile::IncludeScope::EnforceCMP0011() bool cmMakefile::ProcessBuildsystemFile(const char* listfile) { this->AddDefinition("CMAKE_PARENT_LIST_FILE", listfile); + this->cmCurrentListFile = listfile; return this->ReadListFile(listfile, 0, true, this->cmStartDirectory == this->cmHomeDirectory); } @@ -553,11 +554,6 @@ bool cmMakefile::ReadListFile(const char* filename_in, filenametoread = filename_in; } - if (!filenametoread.empty()) - { - this->cmCurrentListFile = filenametoread; - } - if (external_in) { filenametoread = -- cgit v0.12 From d21ebcb2444a4b6001c5997f7004bd5cf917d71b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:37 +0200 Subject: cmMakefile: Swap parameters of calls to ReadListFile. The version with a null first parameter is now equivalent. --- Source/cmMakefile.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index bc225ff..51f9a57 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -526,7 +526,7 @@ bool cmMakefile::ProcessBuildsystemFile(const char* listfile) { this->AddDefinition("CMAKE_PARENT_LIST_FILE", listfile); this->cmCurrentListFile = listfile; - return this->ReadListFile(listfile, 0, true, + return this->ReadListFile(0, listfile, true, this->cmStartDirectory == this->cmHomeDirectory); } -- cgit v0.12 From 6e23a4bdddd2bfee668c682a9ab4081b5e6fcfa2 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:37 +0200 Subject: cmMakefile: Remove always-null first parameter to ReadListFile. --- Source/CPack/cmCPackGenerator.cxx | 8 ++++---- Source/CPack/cpack.cxx | 6 +++--- Source/CTest/cmCTestLaunch.cxx | 2 +- Source/CTest/cmCTestScriptHandler.cxx | 4 ++-- Source/CTest/cmCTestTestHandler.cxx | 2 +- Source/cmCTest.cxx | 4 ++-- Source/cmGlobalGenerator.cxx | 24 ++++++++++++------------ Source/cmGraphVizWriter.cxx | 2 +- Source/cmLocalUnixMakefileGenerator3.cxx | 4 ++-- Source/cmMakefile.cxx | 22 ++++++---------------- Source/cmMakefile.h | 1 - Source/cmQtAutoGenerators.cxx | 4 ++-- Source/cmake.cxx | 6 +++--- 13 files changed, 39 insertions(+), 50 deletions(-) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index a2edab5..2b18c41 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -525,7 +525,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript( tempInstallDirectory.c_str()); this->SetOptionIfNotSet("CMAKE_CURRENT_SOURCE_DIR", tempInstallDirectory.c_str()); - int res = this->MakefileMap->ReadListFile(0, installScript.c_str()); + int res = this->MakefileMap->ReadListFile(installScript.c_str()); if ( cmSystemTools::GetErrorOccuredFlag() || !res ) { return 0; @@ -888,7 +888,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( "1"); } // do installation - int res = mf->ReadListFile(0, installFile.c_str()); + int res = mf->ReadListFile(installFile.c_str()); // forward definition of CMAKE_ABSOLUTE_DESTINATION_FILES // to CPack (may be used by generators like CPack RPM or DEB) // in order to transparently handle ABSOLUTE PATH @@ -980,7 +980,7 @@ bool cmCPackGenerator::ReadListFile(const char* moduleName) { bool retval; std::string fullPath = this->MakefileMap->GetModulesFile(moduleName); - retval = this->MakefileMap->ReadListFile(0, fullPath.c_str()); + retval = this->MakefileMap->ReadListFile(fullPath.c_str()); // include FATAL_ERROR and ERROR in the return status retval = retval && (! cmSystemTools::GetErrorOccuredFlag()); return retval; @@ -1163,7 +1163,7 @@ int cmCPackGenerator::Initialize(const std::string& name, cmMakefile* mf) this->GetOption("CPACK_PROJECT_CONFIG_FILE"); if(config) { - mf->ReadListFile(0, config); + mf->ReadListFile(config); } int result = this->InitializeInternal(); if (cmSystemTools::GetErrorOccuredFlag()) diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index a9cabf1..2752270 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -244,7 +244,7 @@ int main (int argc, char const* const* argv) // paths, so FIND_XXX() commands can be used in scripts std::string systemFile = globalMF->GetModulesFile("CMakeDetermineSystem.cmake"); - if (!globalMF->ReadListFile(0, systemFile.c_str())) + if (!globalMF->ReadListFile(systemFile.c_str())) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Error reading CMakeDetermineSystem.cmake" << std::endl); @@ -253,7 +253,7 @@ int main (int argc, char const* const* argv) systemFile = globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake"); - if (!globalMF->ReadListFile(0, systemFile.c_str())) + if (!globalMF->ReadListFile(systemFile.c_str())) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Error reading CMakeSystemSpecificInformation.cmake" << std::endl); @@ -272,7 +272,7 @@ int main (int argc, char const* const* argv) cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Read CPack configuration file: " << cpackConfigFile << std::endl); - if ( !globalMF->ReadListFile(0, cpackConfigFile.c_str()) ) + if ( !globalMF->ReadListFile(cpackConfigFile.c_str()) ) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Problem reading CPack config file: \"" diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 62fa2be..de6ecde 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -757,7 +757,7 @@ void cmCTestLaunch::LoadConfig() std::string fname = this->LogDir; fname += "CTestLaunchConfig.cmake"; if(cmSystemTools::FileExists(fname.c_str()) && - mf->ReadListFile(0, fname.c_str())) + mf->ReadListFile(fname.c_str())) { this->SourceDir = mf->GetSafeDefinition("CTEST_SOURCE_DIRECTORY"); cmSystemTools::ConvertToUnixSlashes(this->SourceDir); diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 783941b..7f9825c 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -433,7 +433,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) ctest scripting easier. */ std::string systemFile = this->Makefile->GetModulesFile("CTestScriptMode.cmake"); - if (!this->Makefile->ReadListFile(0, systemFile.c_str()) || + if (!this->Makefile->ReadListFile(systemFile.c_str()) || cmSystemTools::GetErrorOccuredFlag()) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read:" @@ -451,7 +451,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) } // finally read in the script - if (!this->Makefile->ReadListFile(0, script.c_str()) || + if (!this->Makefile->ReadListFile(script.c_str()) || cmSystemTools::GetErrorOccuredFlag()) { // Reset the error flag so that it can run more than diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 59c5e92..d778253 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1617,7 +1617,7 @@ void cmCTestTestHandler::GetListOfTests() return; } - if ( !mf->ReadListFile(0, testFilename) ) + if ( !mf->ReadListFile(testFilename) ) { return; } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 91ae889..3697aa4 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -2576,7 +2576,7 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf) bool erroroc = cmSystemTools::GetErrorOccuredFlag(); cmSystemTools::ResetErrorOccuredFlag(); - if ( !mf->ReadListFile(0, fname.c_str()) || + if ( !mf->ReadListFile(fname.c_str()) || cmSystemTools::GetErrorOccuredFlag() ) { cmCTestLog(this, ERROR_MESSAGE, @@ -2606,7 +2606,7 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf) { cmCTestLog(this, DEBUG, "* Read custom CTest configuration file: " << *fileIt << std::endl); - if ( !mf->ReadListFile(0, fileIt->c_str()) || + if ( !mf->ReadListFile(fileIt->c_str()) || cmSystemTools::GetErrorOccuredFlag() ) { cmCTestLog(this, ERROR_MESSAGE, diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index ab044c1..4a9f628 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -278,7 +278,7 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf) mf->GetModulesFile(this->FindMakeProgramFile.c_str()); if(!setMakeProgram.empty()) { - mf->ReadListFile(0, setMakeProgram.c_str()); + mf->ReadListFile(setMakeProgram.c_str()); } } if(!mf->GetDefinition("CMAKE_MAKE_PROGRAM") @@ -428,7 +428,7 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, fpath += "/CMakeSystem.cmake"; if(cmSystemTools::FileExists(fpath.c_str())) { - mf->ReadListFile(0,fpath.c_str()); + mf->ReadListFile(fpath.c_str()); } } // Load the CMakeDetermineSystem.cmake file and find out @@ -456,12 +456,12 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, #endif // Read the DetermineSystem file std::string systemFile = mf->GetModulesFile("CMakeDetermineSystem.cmake"); - mf->ReadListFile(0, systemFile.c_str()); + mf->ReadListFile(systemFile.c_str()); // load the CMakeSystem.cmake from the binary directory // this file is configured by the CMakeDetermineSystem.cmake file fpath = rootBin; fpath += "/CMakeSystem.cmake"; - mf->ReadListFile(0,fpath.c_str()); + mf->ReadListFile(fpath.c_str()); } if(readCMakeSystem) @@ -495,7 +495,7 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INITIALIZE_LOADED")) { fpath = mf->GetModulesFile("CMakeSystemSpecificInitialize.cmake"); - if(!mf->ReadListFile(0,fpath.c_str())) + if(!mf->ReadListFile(fpath.c_str())) { cmSystemTools::Error("Could not find cmake module file: " "CMakeSystemSpecificInitialize.cmake"); @@ -533,7 +533,7 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, // to avoid duplicate compiler tests. if(cmSystemTools::FileExists(fpath.c_str())) { - if(!mf->ReadListFile(0,fpath.c_str())) + if(!mf->ReadListFile(fpath.c_str())) { cmSystemTools::Error("Could not find cmake module file: ", fpath.c_str()); @@ -563,7 +563,7 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, determineCompiler += "Compiler.cmake"; std::string determineFile = mf->GetModulesFile(determineCompiler.c_str()); - if(!mf->ReadListFile(0,determineFile.c_str())) + if(!mf->ReadListFile(determineFile.c_str())) { cmSystemTools::Error("Could not find cmake module file: ", determineCompiler.c_str()); @@ -597,7 +597,7 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, fpath += "/CMake"; fpath += lang; fpath += "Compiler.cmake"; - if(!mf->ReadListFile(0,fpath.c_str())) + if(!mf->ReadListFile(fpath.c_str())) { cmSystemTools::Error("Could not find cmake module file: ", fpath.c_str()); @@ -616,7 +616,7 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INFORMATION_LOADED")) { fpath = mf->GetModulesFile("CMakeSystemSpecificInformation.cmake"); - if(!mf->ReadListFile(0,fpath.c_str())) + if(!mf->ReadListFile(fpath.c_str())) { cmSystemTools::Error("Could not find cmake module file: " "CMakeSystemSpecificInformation.cmake"); @@ -707,7 +707,7 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, cmSystemTools::Error("Could not find cmake module file: ", fpath.c_str()); } - else if(!mf->ReadListFile(0, informationFile.c_str())) + else if(!mf->ReadListFile(informationFile.c_str())) { cmSystemTools::Error("Could not process cmake module file: ", informationFile.c_str()); @@ -732,7 +732,7 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, testLang += lang; testLang += "Compiler.cmake"; std::string ifpath = mf->GetModulesFile(testLang.c_str()); - if(!mf->ReadListFile(0,ifpath.c_str())) + if(!mf->ReadListFile(ifpath.c_str())) { cmSystemTools::Error("Could not find cmake module file: ", testLang.c_str()); @@ -777,7 +777,7 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, projectCompatibility += "Compatibility.cmake"; if(cmSystemTools::FileExists(projectCompatibility.c_str())) { - mf->ReadListFile(0,projectCompatibility.c_str()); + mf->ReadListFile(projectCompatibility.c_str()); } // Inform any extra generator of the new language. if (this->ExtraGenerator) diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index af88d1c..99542a9 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -81,7 +81,7 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName, } } - if ( !mf->ReadListFile(0, inFileName) ) + if ( !mf->ReadListFile(inFileName) ) { cmSystemTools::Error("Problem opening GraphViz options file: ", inFileName); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 8938e67..153ed09 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1475,7 +1475,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo, bool color) { // read in the target info file - if(!this->Makefile->ReadListFile(0, tgtInfo) || + if(!this->Makefile->ReadListFile(tgtInfo) || cmSystemTools::GetErrorOccuredFlag()) { cmSystemTools::Error("Target DependInfo.cmake file not found"); @@ -1592,7 +1592,7 @@ cmLocalUnixMakefileGenerator3 std::string dirInfoFile = this->Makefile->GetStartOutputDirectory(); dirInfoFile += cmake::GetCMakeFilesDirectory(); dirInfoFile += "/CMakeDirectoryInformation.cmake"; - if(mf->ReadListFile(0, dirInfoFile.c_str()) && + if(mf->ReadListFile(dirInfoFile.c_str()) && !cmSystemTools::GetErrorOccuredFlag()) { haveDirectoryInfo = true; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 51f9a57..7790b8a 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -526,7 +526,7 @@ bool cmMakefile::ProcessBuildsystemFile(const char* listfile) { this->AddDefinition("CMAKE_PARENT_LIST_FILE", listfile); this->cmCurrentListFile = listfile; - return this->ReadListFile(0, listfile, true, + return this->ReadListFile(listfile, true, this->cmStartDirectory == this->cmHomeDirectory); } @@ -536,30 +536,20 @@ bool cmMakefile::ReadDependentFile(const char* listfile, bool noPolicyScope) this->cmCurrentListFile = cmSystemTools::CollapseFullPath(listfile, this->cmStartDirectory.c_str()); - return this->ReadListFile(0, this->cmCurrentListFile.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, +bool cmMakefile::ReadListFile(const char* listfile, bool noPolicyScope, bool requireProjectCommand) { - std::string filenametoread; - if (filename_in) - { - filenametoread = filename_in; - } - - if (external_in) - { - filenametoread = - cmSystemTools::CollapseFullPath(external_in, - this->cmStartDirectory.c_str()); - } + std::string filenametoread = + cmSystemTools::CollapseFullPath(listfile, + this->cmStartDirectory.c_str()); std::string currentParentFile = this->GetSafeDefinition("CMAKE_PARENT_LIST_FILE"); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 2664d8e..73d6910 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -86,7 +86,6 @@ public: * Read and parse a CMakeLists.txt file. */ bool ReadListFile(const char* listfile, - const char* external= 0, bool noPolicyScope = true, bool requireProjectCommand = false); diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index d49e997..3d5103f 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1243,7 +1243,7 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, cmSystemTools::ConvertToUnixSlashes(filename); filename += "/AutogenInfo.cmake"; - if (!makefile->ReadListFile(0, filename.c_str())) + if (!makefile->ReadListFile(filename.c_str())) { cmSystemTools::Error("Error processing file: ", filename.c_str()); return false; @@ -1413,7 +1413,7 @@ bool cmQtAutoGenerators::ReadOldMocDefinitionsFile(cmMakefile* makefile, cmSystemTools::ConvertToUnixSlashes(filename); filename += "/AutomocOldMocDefinitions.cmake"; - if (makefile->ReadListFile(0, filename.c_str())) + if (makefile->ReadListFile(filename.c_str())) { this->OldCompileSettingsStr = makefile->GetSafeDefinition("AM_OLD_COMPILE_SETTINGS"); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index a542a24..c4f7c4e 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -388,7 +388,7 @@ void cmake::ReadListFile(const std::vector& args, lg->GetMakefile()->SetArgcArgv(args); } - if (!lg->GetMakefile()->ReadListFile(0, path)) + if (!lg->GetMakefile()->ReadListFile(path)) { cmSystemTools::Error("Error processing file: ", path); } @@ -424,7 +424,7 @@ bool cmake::FindPackage(const std::vector& args) mf->SetArgcArgv(args); std::string systemFile = mf->GetModulesFile("CMakeFindPackageMode.cmake"); - mf->ReadListFile(0, systemFile.c_str()); + mf->ReadListFile(systemFile.c_str()); std::string language = mf->GetSafeDefinition("LANGUAGE"); std::string mode = mf->GetSafeDefinition("MODE"); @@ -1965,7 +1965,7 @@ int cmake::CheckBuildSystem() gg.SetCMakeInstance(&cm); cmsys::auto_ptr lg(gg.CreateLocalGenerator()); cmMakefile* mf = lg->GetMakefile(); - if(!mf->ReadListFile(0, this->CheckBuildSystemArgument.c_str()) || + if(!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) || cmSystemTools::GetErrorOccuredFlag()) { if(verbose) -- cgit v0.12 From 05245b42294a38c5f7be9b40a918e42575b7dbd7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 18 Apr 2015 14:50:38 +0200 Subject: cmMakefile: Move some preamble out of the Internal method. --- Source/cmMakefile.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7790b8a..7be920d 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -556,7 +556,15 @@ bool cmMakefile::ReadListFile(const char* listfile, std::string currentFile = this->GetSafeDefinition("CMAKE_CURRENT_LIST_FILE"); + this->AddDefinition("CMAKE_CURRENT_LIST_FILE", filenametoread.c_str()); + this->AddDefinition("CMAKE_CURRENT_LIST_DIR", + cmSystemTools::GetFilenamePath(filenametoread).c_str()); + this->MarkVariableAsUsed("CMAKE_PARENT_LIST_FILE"); + this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE"); + this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_DIR"); + + this->ListFileStack.push_back(filenametoread); bool res = this->ReadListFileInternal(filenametoread.c_str(), noPolicyScope, requireProjectCommand); @@ -584,14 +592,6 @@ bool cmMakefile::ReadListFileInternal(const char* filenametoread, bool noPolicyScope, bool requireProjectCommand) { - this->AddDefinition("CMAKE_CURRENT_LIST_FILE", filenametoread); - this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE"); - this->AddDefinition("CMAKE_CURRENT_LIST_DIR", - cmSystemTools::GetFilenamePath(filenametoread).c_str()); - this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_DIR"); - - // push the listfile onto the stack - this->ListFileStack.push_back(filenametoread); cmListFile cacheFile; if( !cacheFile.ParseFile(filenametoread, requireProjectCommand, this) ) { -- cgit v0.12