From 363caa2fa540190ea394122fca3cb72d951823ad Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 30 May 2015 19:12:38 +0200 Subject: cmLocalGenerator: De-virtualize Configure(). The generators that override it do so in order to populate data members which can instead be populated in Generate(). --- Source/cmLocalGenerator.h | 2 +- Source/cmLocalNinjaGenerator.cxx | 28 +++++++++------------------- Source/cmLocalNinjaGenerator.h | 2 -- Source/cmLocalUnixMakefileGenerator3.cxx | 7 +------ Source/cmLocalUnixMakefileGenerator3.h | 6 ------ 5 files changed, 11 insertions(+), 34 deletions(-) diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index f02b5db..b635180 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -50,7 +50,7 @@ public: * Process the CMakeLists files for this directory to fill in the * Makefile ivar */ - virtual void Configure(); + void Configure(); /** * Calls TraceVSDependencies() on all targets of this generator. diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index c08c91f..427ae10 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -41,6 +41,15 @@ cmLocalNinjaGenerator::~cmLocalNinjaGenerator() void cmLocalNinjaGenerator::Generate() { + // Compute the path to use when referencing the current output + // directory from the top output directory. + this->HomeRelativeOutputPath = + this->Convert(this->Makefile->GetCurrentBinaryDirectory(), HOME_OUTPUT); + if(this->HomeRelativeOutputPath == ".") + { + this->HomeRelativeOutputPath = ""; + } + this->SetConfigName(); this->WriteProcessedMakefile(this->GetBuildFileStream()); @@ -91,25 +100,6 @@ void cmLocalNinjaGenerator::Generate() this->WriteCustomCommandBuildStatements(); } -// Implemented in: -// cmLocalUnixMakefileGenerator3. -// Used in: -// Source/cmMakefile.cxx -// Source/cmGlobalGenerator.cxx -void cmLocalNinjaGenerator::Configure() -{ - // Compute the path to use when referencing the current output - // directory from the top output directory. - this->HomeRelativeOutputPath = - this->Convert(this->Makefile->GetCurrentBinaryDirectory(), HOME_OUTPUT); - if(this->HomeRelativeOutputPath == ".") - { - this->HomeRelativeOutputPath = ""; - } - this->cmLocalGenerator::Configure(); - -} - // TODO: Picked up from cmLocalUnixMakefileGenerator3. Refactor it. std::string cmLocalNinjaGenerator ::GetTargetDirectory(cmTarget const& target) const diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 7ae97de..ce966ff 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -38,8 +38,6 @@ public: virtual void Generate(); - virtual void Configure(); - virtual std::string GetTargetDirectory(cmTarget const& target) const; const cmGlobalNinjaGenerator* GetGlobalNinjaGenerator() const; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 3eea59b..c9eea56 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -98,7 +98,7 @@ cmLocalUnixMakefileGenerator3::~cmLocalUnixMakefileGenerator3() } //---------------------------------------------------------------------------- -void cmLocalUnixMakefileGenerator3::Configure() +void cmLocalUnixMakefileGenerator3::Generate() { // Compute the path to use when referencing the current output // directory from the top output directory. @@ -112,12 +112,7 @@ void cmLocalUnixMakefileGenerator3::Configure() { this->HomeRelativeOutputPath += "/"; } - this->cmLocalGenerator::Configure(); -} -//---------------------------------------------------------------------------- -void cmLocalUnixMakefileGenerator3::Generate() -{ // Store the configuration name that will be generated. if(const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) { diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 988d660..f2a1389 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -40,12 +40,6 @@ public: virtual ~cmLocalUnixMakefileGenerator3(); /** - * Process the CMakeLists files for this directory to fill in the - * Makefile ivar - */ - virtual void Configure(); - - /** * Generate the makefile for this directory. */ virtual void Generate(); -- cgit v0.12 From 27e11c6fea8e863b59c0fdfd63f1e9f2528dbac4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 30 May 2015 19:26:32 +0200 Subject: Merge Configure state with GeneratingBuildSystem state. --- Source/cmGlobalGenerator.cxx | 1 - Source/cmLocalGenerator.cxx | 12 +++--------- Source/cmLocalGenerator.h | 3 --- Source/cmMakefile.cxx | 4 ++-- Source/cmMakefile.h | 6 +++--- Source/cmTarget.cxx | 12 ++++++------ 6 files changed, 14 insertions(+), 24 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index cd05c54..4fa7a61 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1280,7 +1280,6 @@ void cmGlobalGenerator::Generate() // Generate project files for (i = 0; i < this->LocalGenerators.size(); ++i) { - this->LocalGenerators[i]->GetMakefile()->SetGeneratingBuildSystem(); this->SetCurrentLocalGenerator(this->LocalGenerators[i]); this->LocalGenerators[i]->Generate(); if(!this->LocalGenerators[i]->GetMakefile()->IsOn( diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c686ab1..6bebaa7 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -59,7 +59,6 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, this->Makefile = new cmMakefile(this); this->LinkScriptShell = false; - this->Configured = false; this->EmitUniversalBinaryFlags = true; this->BackwardsCompatibility = 0; this->BackwardsCompatibilityFinal = false; @@ -128,7 +127,7 @@ void cmLocalGenerator::Configure() std::vector::iterator sdi = subdirs.begin(); for (; sdi != subdirs.end(); ++sdi) { - if (!(*sdi)->Configured) + if (!(*sdi)->GetMakefile()->IsConfigured()) { this->Makefile->ConfigureSubDirectory(*sdi); } @@ -138,7 +137,7 @@ void cmLocalGenerator::Configure() this->ComputeObjectMaxPath(); - this->Configured = true; + this->Makefile->SetConfigured(); } //---------------------------------------------------------------------------- @@ -3179,11 +3178,6 @@ bool cmLocalGenerator::IsNMake() const return this->GetState()->UseNMake(); } -void cmLocalGenerator::SetConfiguredCMP0014(bool configured) -{ - this->Configured = configured; -} - //---------------------------------------------------------------------------- std::string cmLocalGenerator @@ -3465,7 +3459,7 @@ cmIML_INT_uint64_t cmLocalGenerator::GetBackwardsCompatibility() } } this->BackwardsCompatibility = CMake_VERSION_ENCODE(major, minor, patch); - this->BackwardsCompatibilityFinal = this->Configured; + this->BackwardsCompatibilityFinal = this->Makefile->IsConfigured(); } return this->BackwardsCompatibility; diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index b635180..8a1649e 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -383,8 +383,6 @@ public: bool IsMinGWMake() const; bool IsNMake() const; - void SetConfiguredCMP0014(bool configured); - protected: ///! put all the libraries for a target on into the given stream void OutputLinkLibraries(std::string& linkLibraries, @@ -451,7 +449,6 @@ protected: std::set WarnCMP0063; bool LinkScriptShell; - bool Configured; bool EmitUniversalBinaryFlags; // Hack for ExpandRuleVariable until object-oriented version is diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7c74a0f..d537f34 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -146,7 +146,7 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) this->WarnUnused = this->GetCMakeInstance()->GetWarnUnused(); this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars(); - this->GeneratingBuildSystem = false; + this->Configured = false; this->SuppressWatches = false; // Setup the default include file regular expression (match everything). @@ -1594,7 +1594,7 @@ void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2) // NEW behavior prints the error. this->IssueMessage(cmake::FATAL_ERROR, e.str()); } - lg2->SetConfiguredCMP0014(true); + lg2->GetMakefile()->SetConfigured(); return; } // finally configure the subdir diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index efd73a1..a45d837 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -781,8 +781,8 @@ public: return this->CompileDefinitionsEntries; } - bool IsGeneratingBuildSystem() const { return this->GeneratingBuildSystem; } - void SetGeneratingBuildSystem(){ this->GeneratingBuildSystem = true; } + bool IsConfigured() const { return this->Configured; } + void SetConfigured(){ this->Configured = true; } void AddQtUiFileWithOptions(cmSourceFile *sf); std::vector GetQtUiFilesWithOptions() const; @@ -994,7 +994,7 @@ private: long line, bool removeEmpty, bool replaceAt) const; - bool GeneratingBuildSystem; + bool Configured; /** * Old version of GetSourceFileWithOutput(const std::string&) kept for * backward-compatibility. It implements a linear search and support diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 70005b4..1d1dced 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -764,7 +764,7 @@ void cmTarget::GetSourceFiles(std::vector &files, "SOURCES") != debugProperties.end(); - if (this->Makefile->IsGeneratingBuildSystem()) + if (this->Makefile->IsConfigured()) { this->DebugSourcesDone = true; } @@ -2106,7 +2106,7 @@ cmTarget::GetIncludeDirectories(const std::string& config, "INCLUDE_DIRECTORIES") != debugProperties.end(); - if (this->Makefile->IsGeneratingBuildSystem()) + if (this->Makefile->IsConfigured()) { this->DebugIncludesDone = true; } @@ -2277,7 +2277,7 @@ void cmTarget::GetCompileOptions(std::vector &result, "COMPILE_OPTIONS") != debugProperties.end(); - if (this->Makefile->IsGeneratingBuildSystem()) + if (this->Makefile->IsConfigured()) { this->DebugCompileOptionsDone = true; } @@ -2348,7 +2348,7 @@ void cmTarget::GetCompileDefinitions(std::vector &list, "COMPILE_DEFINITIONS") != debugProperties.end(); - if (this->Makefile->IsGeneratingBuildSystem()) + if (this->Makefile->IsConfigured()) { this->DebugCompileDefinitionsDone = true; } @@ -2449,7 +2449,7 @@ void cmTarget::GetCompileFeatures(std::vector &result, "COMPILE_FEATURES") != debugProperties.end(); - if (this->Makefile->IsGeneratingBuildSystem()) + if (this->Makefile->IsConfigured()) { this->DebugCompileFeaturesDone = true; } @@ -4857,7 +4857,7 @@ cmTarget::ReportPropertyOrigin(const std::string &p, p) != debugProperties.end(); - if (this->Makefile->IsGeneratingBuildSystem()) + if (this->Makefile->IsConfigured()) { this->DebugCompatiblePropertiesDone[p] = true; } -- cgit v0.12 From 0863797037b82f01cb356cb2cd4cdcef7ca8ae48 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 30 May 2015 19:34:09 +0200 Subject: cmLocalGenerator: ComputeObjectMaxPath just before generating. --- Source/cmGlobalGenerator.cxx | 1 + Source/cmLocalGenerator.cxx | 2 -- Source/cmLocalGenerator.h | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 4fa7a61..d1842c1 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1223,6 +1223,7 @@ void cmGlobalGenerator::Generate() this->CreateDefaultGlobalTargets(&globalTargets); for (i = 0; i < this->LocalGenerators.size(); ++i) { + this->LocalGenerators[i]->ComputeObjectMaxPath(); cmMakefile* mf = this->LocalGenerators[i]->GetMakefile(); cmTargets* targets = &(mf->GetTargets()); cmTargets::iterator tit; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 6bebaa7..8931e6f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -135,8 +135,6 @@ void cmLocalGenerator::Configure() this->Makefile->AddCMakeDependFilesFromUser(); - this->ComputeObjectMaxPath(); - this->Makefile->SetConfigured(); } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 8a1649e..c972e8f 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -383,6 +383,7 @@ public: bool IsMinGWMake() const; bool IsNMake() const; + void ComputeObjectMaxPath(); protected: ///! put all the libraries for a target on into the given stream void OutputLinkLibraries(std::string& linkLibraries, @@ -428,7 +429,6 @@ protected: std::string& CreateSafeUniqueObjectFileName(const std::string& sin, std::string const& dir_max); - void ComputeObjectMaxPath(); virtual std::string ConvertToLinkReference(std::string const& lib, OutputFormat format = SHELL); -- cgit v0.12 From 69a038a9e90a8839b69f4cb8826688be611e8b0d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 30 May 2015 19:39:08 +0200 Subject: cmMakefile: Refactor directories specified with the subdirs command. Store the directories on the cmMakefile as explicitly not-configured-yet. --- Source/cmLocalGenerator.cxx | 11 ++++------- Source/cmMakefile.cxx | 13 +++++++++++++ Source/cmMakefile.h | 7 +++++++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 8931e6f..58366d1 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -119,18 +119,15 @@ void cmLocalGenerator::Configure() assert(cmSystemTools::FileExists(currentStart.c_str(), true)); this->Makefile->ProcessBuildsystemFile(currentStart.c_str()); - // at the end of the ReadListFile handle any old style subdirs - // first get all the subdirectories - std::vector subdirs = this->GetChildren(); + // at the end handle any old style subdirs + std::vector subdirs = + this->GetMakefile()->GetUnConfiguredDirectories(); // for each subdir recurse std::vector::iterator sdi = subdirs.begin(); for (; sdi != subdirs.end(); ++sdi) { - if (!(*sdi)->GetMakefile()->IsConfigured()) - { - this->Makefile->ConfigureSubDirectory(*sdi); - } + this->Makefile->ConfigureSubDirectory(*sdi); } this->Makefile->AddCMakeDependFilesFromUser(); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index d537f34..ffc6bf9 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1599,6 +1599,15 @@ void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2) } // finally configure the subdir lg2->Configure(); + + // at the end handle any old style subdirs + for (std::vector::iterator sdi = + this->UnConfiguredDirectories.begin(); + sdi != this->UnConfiguredDirectories.end(); ++sdi) + { + this->ConfigureSubDirectory(*sdi); + } + if (this->GetCMakeInstance()->GetDebugOutput()) { std::string msg=" Returning to "; @@ -1638,6 +1647,10 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, { this->ConfigureSubDirectory(lg2); } + else + { + this->UnConfiguredDirectories.push_back(lg2); + } } void cmMakefile::SetCurrentSourceDirectory(const std::string& dir) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index a45d837..509f5c8 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -262,6 +262,11 @@ public: this->LinkDirectories = vec; } + std::vector GetUnConfiguredDirectories() const + { + return this->UnConfiguredDirectories; + } + /** * Add a subdirectory to the build. */ @@ -920,6 +925,8 @@ private: mutable cmsys::RegularExpression cmAtVarRegex; mutable cmsys::RegularExpression cmNamedCurly; + std::vector UnConfiguredDirectories; + cmPropertyMap Properties; // Unused variable flags -- cgit v0.12 From a653611db0d6e23456c5ef90f95e19ea5d70a428 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 30 May 2015 23:50:28 +0200 Subject: cmake: Replace CurrentLocalGenerator concept with CurrentMakefile. --- Source/cmGlobalGenerator.cxx | 6 +++--- Source/cmGlobalGenerator.h | 12 +++++++----- Source/cmLocalGenerator.cxx | 17 +++++++++-------- Source/cmQtAutoGenerators.cxx | 2 +- Source/cmakemain.cxx | 7 +------ 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index d1842c1..1ee5500 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -70,7 +70,7 @@ cmGlobalGenerator::cmGlobalGenerator(cmake* cm) this->TryCompileTimeout = 0; this->ExtraGenerator = 0; - this->CurrentLocalGenerator = 0; + this->CurrentMakefile = 0; this->TryCompileOuterMakefile = 0; } @@ -1281,7 +1281,7 @@ void cmGlobalGenerator::Generate() // Generate project files for (i = 0; i < this->LocalGenerators.size(); ++i) { - this->SetCurrentLocalGenerator(this->LocalGenerators[i]); + this->SetCurrentMakefile(this->LocalGenerators[i]->GetMakefile()); this->LocalGenerators[i]->Generate(); if(!this->LocalGenerators[i]->GetMakefile()->IsOn( "CMAKE_SKIP_INSTALL_RULES")) @@ -1293,7 +1293,7 @@ void cmGlobalGenerator::Generate() (static_cast(i)+1.0f)/ static_cast(this->LocalGenerators.size())); } - this->SetCurrentLocalGenerator(0); + this->SetCurrentMakefile(0); if(!this->GenerateCPackPropertiesFile()) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 979e971..d2b8504 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -168,11 +168,13 @@ public: const std::vector& GetLocalGenerators() const { return this->LocalGenerators;} - cmLocalGenerator* GetCurrentLocalGenerator() - {return this->CurrentLocalGenerator;} + cmMakefile* GetCurrentMakefile() const + { + return this->CurrentMakefile; + } - void SetCurrentLocalGenerator(cmLocalGenerator* lg) - {this->CurrentLocalGenerator = lg;} + void SetCurrentMakefile(cmMakefile* mf) + {this->CurrentMakefile = mf;} void AddLocalGenerator(cmLocalGenerator *lg); @@ -406,7 +408,7 @@ protected: std::string ConfiguredFilesPath; cmake *CMakeInstance; std::vector LocalGenerators; - cmLocalGenerator* CurrentLocalGenerator; + cmMakefile* CurrentMakefile; // map from project name to vector of local generators in that project std::map > ProjectMap; std::map > diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 58366d1..4b9415b 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -78,16 +78,17 @@ bool cmLocalGenerator::IsRootMakefile() const class cmLocalGeneratorCurrent { cmGlobalGenerator* GG; - cmLocalGenerator* LG; + cmMakefile* MF; cmState::Snapshot Snapshot; public: - cmLocalGeneratorCurrent(cmLocalGenerator* lg) + cmLocalGeneratorCurrent(cmMakefile* mf) { - this->GG = lg->GetGlobalGenerator(); - this->LG = this->GG->GetCurrentLocalGenerator(); + this->GG = mf->GetGlobalGenerator(); + this->MF = this->GG->GetCurrentMakefile(); this->Snapshot = this->GG->GetCMakeInstance()->GetCurrentSnapshot(); - this->GG->GetCMakeInstance()->SetCurrentSnapshot(lg->GetStateSnapshot()); - this->GG->SetCurrentLocalGenerator(lg); + this->GG->GetCMakeInstance()->SetCurrentSnapshot( + this->GG->GetCMakeInstance()->GetCurrentSnapshot()); + this->GG->SetCurrentMakefile(mf); #if defined(CMAKE_BUILD_WITH_CMAKE) this->GG->GetFileLockPool().PushFileScope(); #endif @@ -97,7 +98,7 @@ public: #if defined(CMAKE_BUILD_WITH_CMAKE) this->GG->GetFileLockPool().PopFileScope(); #endif - this->GG->SetCurrentLocalGenerator(this->LG); + this->GG->SetCurrentMakefile(this->MF); this->GG->GetCMakeInstance()->SetCurrentSnapshot(this->Snapshot); } }; @@ -106,7 +107,7 @@ public: void cmLocalGenerator::Configure() { // Manage the global generator's current local generator. - cmLocalGeneratorCurrent clg(this); + cmLocalGeneratorCurrent clg(this->GetMakefile()); static_cast(clg); // make sure the CMakeFiles dir is there diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index cbb06cd..fbd2946 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1215,7 +1215,7 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, cmLocalGenerator* lg = gg.MakeLocalGenerator(); lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); - gg.SetCurrentLocalGenerator(lg); + gg.SetCurrentMakefile(lg->GetMakefile()); this->ReadAutogenInfoFile(lg->GetMakefile(), targetDirectory, config); this->ReadOldMocDefinitionsFile(lg->GetMakefile(), targetDirectory); diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index e5f4700..cc30732 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -113,12 +113,7 @@ static cmMakefile* cmakemainGetMakefile(void *clientdata) cmGlobalGenerator* gg=cm->GetGlobalGenerator(); if (gg) { - cmLocalGenerator* lg=gg->GetCurrentLocalGenerator(); - if (lg) - { - cmMakefile* mf = lg->GetMakefile(); - return mf; - } + return gg->GetCurrentMakefile(); } } return 0; -- cgit v0.12 From f059ed165bafff94f9bcd3823e12a8ce1f5ec647 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 30 May 2015 19:50:58 +0200 Subject: cmMakefile: Move Configure responsibility from cmLocalGenerator. The generator should only have a function at generate time. --- Source/cmGlobalGenerator.cxx | 2 +- Source/cmLocalGenerator.cxx | 62 ---------------------------------------- Source/cmLocalGenerator.h | 6 ---- Source/cmMakefile.cxx | 68 ++++++++++++++++++++++++++++++++++++++------ Source/cmMakefile.h | 7 ++--- 5 files changed, 62 insertions(+), 83 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 1ee5500..1d11475 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1106,7 +1106,7 @@ void cmGlobalGenerator::Configure() this->CMakeInstance->GetHomeOutputDirectory()); // now do it - lg->Configure(); + lg->GetMakefile()->Configure(); // update the cache entry for the number of local generators, this is used // for progress diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 4b9415b..8fcc2ec 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -75,68 +75,6 @@ bool cmLocalGenerator::IsRootMakefile() const } //---------------------------------------------------------------------------- -class cmLocalGeneratorCurrent -{ - cmGlobalGenerator* GG; - cmMakefile* MF; - cmState::Snapshot Snapshot; -public: - cmLocalGeneratorCurrent(cmMakefile* mf) - { - this->GG = mf->GetGlobalGenerator(); - this->MF = this->GG->GetCurrentMakefile(); - this->Snapshot = this->GG->GetCMakeInstance()->GetCurrentSnapshot(); - this->GG->GetCMakeInstance()->SetCurrentSnapshot( - this->GG->GetCMakeInstance()->GetCurrentSnapshot()); - this->GG->SetCurrentMakefile(mf); -#if defined(CMAKE_BUILD_WITH_CMAKE) - this->GG->GetFileLockPool().PushFileScope(); -#endif - } - ~cmLocalGeneratorCurrent() - { -#if defined(CMAKE_BUILD_WITH_CMAKE) - this->GG->GetFileLockPool().PopFileScope(); -#endif - this->GG->SetCurrentMakefile(this->MF); - this->GG->GetCMakeInstance()->SetCurrentSnapshot(this->Snapshot); - } -}; - -//---------------------------------------------------------------------------- -void cmLocalGenerator::Configure() -{ - // Manage the global generator's current local generator. - cmLocalGeneratorCurrent clg(this->GetMakefile()); - static_cast(clg); - - // make sure the CMakeFiles dir is there - std::string filesDir = this->StateSnapshot.GetCurrentBinaryDirectory(); - filesDir += cmake::GetCMakeFilesDirectory(); - cmSystemTools::MakeDirectory(filesDir.c_str()); - - std::string currentStart = this->StateSnapshot.GetCurrentSourceDirectory(); - currentStart += "/CMakeLists.txt"; - assert(cmSystemTools::FileExists(currentStart.c_str(), true)); - this->Makefile->ProcessBuildsystemFile(currentStart.c_str()); - - // at the end handle any old style subdirs - std::vector subdirs = - this->GetMakefile()->GetUnConfiguredDirectories(); - - // for each subdir recurse - std::vector::iterator sdi = subdirs.begin(); - for (; sdi != subdirs.end(); ++sdi) - { - this->Makefile->ConfigureSubDirectory(*sdi); - } - - this->Makefile->AddCMakeDependFilesFromUser(); - - this->Makefile->SetConfigured(); -} - -//---------------------------------------------------------------------------- void cmLocalGenerator::ComputeObjectMaxPath() { // Choose a maximum object file name length. diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index c972e8f..1359dd6 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -47,12 +47,6 @@ public: virtual void Generate() {} /** - * Process the CMakeLists files for this directory to fill in the - * Makefile ivar - */ - void Configure(); - - /** * Calls TraceVSDependencies() on all targets of this generator. */ void TraceDependencies(); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ffc6bf9..05e80d7 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1553,6 +1553,64 @@ void cmMakefile::InitializeFromParent() this->ImportedTargets = parent->ImportedTargets; } +//---------------------------------------------------------------------------- +class cmMakefileCurrent +{ + cmGlobalGenerator* GG; + cmMakefile* MF; + cmState::Snapshot Snapshot; +public: + cmMakefileCurrent(cmMakefile* mf) + { + this->GG = mf->GetGlobalGenerator(); + this->MF = this->GG->GetCurrentMakefile(); + this->Snapshot = this->GG->GetCMakeInstance()->GetCurrentSnapshot(); + this->GG->GetCMakeInstance()->SetCurrentSnapshot( + this->GG->GetCMakeInstance()->GetCurrentSnapshot()); + this->GG->SetCurrentMakefile(mf); +#if defined(CMAKE_BUILD_WITH_CMAKE) + this->GG->GetFileLockPool().PushFileScope(); +#endif + } + ~cmMakefileCurrent() + { +#if defined(CMAKE_BUILD_WITH_CMAKE) + this->GG->GetFileLockPool().PopFileScope(); +#endif + this->GG->SetCurrentMakefile(this->MF); + this->GG->GetCMakeInstance()->SetCurrentSnapshot(this->Snapshot); + } +}; + +//---------------------------------------------------------------------------- +void cmMakefile::Configure() +{ + cmMakefileCurrent cmf(this); + + // make sure the CMakeFiles dir is there + std::string filesDir = this->StateSnapshot.GetCurrentBinaryDirectory(); + filesDir += cmake::GetCMakeFilesDirectory(); + cmSystemTools::MakeDirectory(filesDir.c_str()); + + std::string currentStart = this->StateSnapshot.GetCurrentSourceDirectory(); + currentStart += "/CMakeLists.txt"; + assert(cmSystemTools::FileExists(currentStart.c_str(), true)); + this->ProcessBuildsystemFile(currentStart.c_str()); + + // at the end handle any old style subdirs + std::vector subdirs = this->UnConfiguredDirectories; + + // for each subdir recurse + std::vector::iterator sdi = subdirs.begin(); + for (; sdi != subdirs.end(); ++sdi) + { + this->ConfigureSubDirectory(*sdi); + } + + this->AddCMakeDependFilesFromUser(); + this->SetConfigured(); +} + void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2) { lg2->GetMakefile()->InitializeFromParent(); @@ -1598,15 +1656,7 @@ void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2) return; } // finally configure the subdir - lg2->Configure(); - - // at the end handle any old style subdirs - for (std::vector::iterator sdi = - this->UnConfiguredDirectories.begin(); - sdi != this->UnConfiguredDirectories.end(); ++sdi) - { - this->ConfigureSubDirectory(*sdi); - } + lg2->GetMakefile()->Configure(); if (this->GetCMakeInstance()->GetDebugOutput()) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 509f5c8..e36df36 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -262,11 +262,6 @@ public: this->LinkDirectories = vec; } - std::vector GetUnConfiguredDirectories() const - { - return this->UnConfiguredDirectories; - } - /** * Add a subdirectory to the build. */ @@ -275,6 +270,8 @@ public: bool excludeFromAll, bool immediate); + void Configure(); + /** * Configure a subdirectory */ -- cgit v0.12 From d65e01235da2473e669d6e5c40988ad4015f0dc4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 30 May 2015 19:53:02 +0200 Subject: cmMakefile: Implement ConfigureSubDirectory in terms of cmMakefile. --- Source/cmMakefile.cxx | 14 +++++++------- Source/cmMakefile.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 05e80d7..4079ccf 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1604,17 +1604,17 @@ void cmMakefile::Configure() std::vector::iterator sdi = subdirs.begin(); for (; sdi != subdirs.end(); ++sdi) { - this->ConfigureSubDirectory(*sdi); + this->ConfigureSubDirectory((*sdi)->GetMakefile()); } this->AddCMakeDependFilesFromUser(); this->SetConfigured(); } -void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2) +void cmMakefile::ConfigureSubDirectory(cmMakefile *mf) { - lg2->GetMakefile()->InitializeFromParent(); - std::string currentStart = lg2->GetMakefile()->GetCurrentSourceDirectory(); + mf->InitializeFromParent(); + std::string currentStart = mf->GetCurrentSourceDirectory(); if (this->GetCMakeInstance()->GetDebugOutput()) { std::string msg=" Entering "; @@ -1652,11 +1652,11 @@ void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2) // NEW behavior prints the error. this->IssueMessage(cmake::FATAL_ERROR, e.str()); } - lg2->GetMakefile()->SetConfigured(); + mf->SetConfigured(); return; } // finally configure the subdir - lg2->GetMakefile()->Configure(); + mf->Configure(); if (this->GetCMakeInstance()->GetDebugOutput()) { @@ -1695,7 +1695,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, if (immediate) { - this->ConfigureSubDirectory(lg2); + this->ConfigureSubDirectory(lg2->GetMakefile()); } else { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index e36df36..5807707 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -275,7 +275,7 @@ public: /** * Configure a subdirectory */ - void ConfigureSubDirectory(cmLocalGenerator *); + void ConfigureSubDirectory(cmMakefile* mf); /** * Add an include directory to the build. -- cgit v0.12 From 4e8f242d170ab46d4071254a3a81f7db264b8bc7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 3 Jun 2015 00:55:00 +0200 Subject: cmMakefile: Store unconfigured cmMakefiles. Not cmLocalGenerators. --- Source/cmMakefile.cxx | 8 ++++---- Source/cmMakefile.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 4079ccf..ae9fe32 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1598,13 +1598,13 @@ void cmMakefile::Configure() this->ProcessBuildsystemFile(currentStart.c_str()); // at the end handle any old style subdirs - std::vector subdirs = this->UnConfiguredDirectories; + std::vector subdirs = this->UnConfiguredDirectories; // for each subdir recurse - std::vector::iterator sdi = subdirs.begin(); + std::vector::iterator sdi = subdirs.begin(); for (; sdi != subdirs.end(); ++sdi) { - this->ConfigureSubDirectory((*sdi)->GetMakefile()); + this->ConfigureSubDirectory(*sdi); } this->AddCMakeDependFilesFromUser(); @@ -1699,7 +1699,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, } else { - this->UnConfiguredDirectories.push_back(lg2); + this->UnConfiguredDirectories.push_back(lg2->GetMakefile()); } } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 5807707..4174f44 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -922,7 +922,7 @@ private: mutable cmsys::RegularExpression cmAtVarRegex; mutable cmsys::RegularExpression cmNamedCurly; - std::vector UnConfiguredDirectories; + std::vector UnConfiguredDirectories; cmPropertyMap Properties; -- cgit v0.12 From 7657e8b1df64ed3b5429be34416e8756b659d525 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 3 Jun 2015 00:57:31 +0200 Subject: cmMakefile: Introduce a local cmMakefile variable. --- Source/cmMakefile.cxx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ae9fe32..7e103bc 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1685,21 +1685,23 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, ->MakeLocalGenerator(newSnapshot, this->LocalGenerator); this->GetGlobalGenerator()->AddLocalGenerator(lg2); + cmMakefile* subMf = lg2->GetMakefile(); + // set the subdirs start dirs - lg2->GetMakefile()->SetCurrentSourceDirectory(srcPath); - lg2->GetMakefile()->SetCurrentBinaryDirectory(binPath); + subMf->SetCurrentSourceDirectory(srcPath); + subMf->SetCurrentBinaryDirectory(binPath); if(excludeFromAll) { - lg2->GetMakefile()->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); + subMf->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } if (immediate) { - this->ConfigureSubDirectory(lg2->GetMakefile()); + this->ConfigureSubDirectory(subMf); } else { - this->UnConfiguredDirectories.push_back(lg2->GetMakefile()); + this->UnConfiguredDirectories.push_back(subMf); } } -- cgit v0.12