diff options
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 208 |
1 files changed, 80 insertions, 128 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7c98970..57e33df 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -273,6 +273,38 @@ void cmMakefile::IssueMessage(cmake::MessageType t, } } +cmStringRange cmMakefile::GetIncludeDirectoriesEntries() const +{ + return this->StateSnapshot.GetDirectory().GetIncludeDirectoriesEntries(); +} + +cmBacktraceRange cmMakefile::GetIncludeDirectoriesBacktraces() const +{ + return this->StateSnapshot.GetDirectory() + .GetIncludeDirectoriesEntryBacktraces(); +} + +cmStringRange cmMakefile::GetCompileOptionsEntries() const +{ + return this->StateSnapshot.GetDirectory().GetCompileOptionsEntries(); +} + +cmBacktraceRange cmMakefile::GetCompileOptionsBacktraces() const +{ + return this->StateSnapshot.GetDirectory().GetCompileOptionsEntryBacktraces(); +} + +cmStringRange cmMakefile::GetCompileDefinitionsEntries() const +{ + return this->StateSnapshot.GetDirectory().GetCompileDefinitionsEntries(); +} + +cmBacktraceRange cmMakefile::GetCompileDefinitionsBacktraces() const +{ + return this->StateSnapshot.GetDirectory() + .GetCompileDefinitionsEntryBacktraces(); +} + //---------------------------------------------------------------------------- cmListFileBacktrace cmMakefile::GetBacktrace() const { @@ -1438,7 +1470,7 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove) std::remove(defs.begin(), defs.end(), define); std::vector<std::string>::const_iterator defBegin = defs.begin(); - std::string ndefs = cmJoin(cmRange(defBegin, defEnd), ";"); + std::string ndefs = cmJoin(cmMakeRange(defBegin, defEnd), ";"); // Store the new list. this->SetProperty("COMPILE_DEFINITIONS", ndefs.c_str()); @@ -1533,29 +1565,13 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent) // Initialize definitions with the closure of the parent scope. this->Internal->InitializeDefinitions(parent); + this->StateSnapshot.InitializeFromParent(); + this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", this->GetCurrentSourceDirectory()); this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", this->GetCurrentBinaryDirectory()); - const std::vector<cmValueWithOrigin>& parentIncludes = - parent->GetIncludeDirectoriesEntries(); - this->IncludeDirectoriesEntries.insert(this->IncludeDirectoriesEntries.end(), - parentIncludes.begin(), - parentIncludes.end()); - - const std::vector<cmValueWithOrigin>& parentOptions = - parent->GetCompileOptionsEntries(); - this->CompileOptionsEntries.insert(this->CompileOptionsEntries.end(), - parentOptions.begin(), - parentOptions.end()); - - const std::vector<cmValueWithOrigin>& parentDefines = - parent->GetCompileDefinitionsEntries(); - this->CompileDefinitionsEntries.insert(this->CompileDefinitionsEntries.end(), - parentDefines.begin(), - parentDefines.end()); - this->SystemIncludeDirectories = parent->SystemIncludeDirectories; // define flags @@ -1898,20 +1914,25 @@ void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs, return; } - std::vector<cmValueWithOrigin>::iterator position = - before ? this->IncludeDirectoriesEntries.begin() - : this->IncludeDirectoriesEntries.end(); - cmListFileBacktrace lfbt = this->GetBacktrace(); - cmValueWithOrigin entry(cmJoin(incs, ";"), lfbt); - this->IncludeDirectoriesEntries.insert(position, entry); + std::string entryString = cmJoin(incs, ";"); + if (before) + { + this->StateSnapshot.GetDirectory() + .PrependIncludeDirectoriesEntry(entryString, lfbt); + } + else + { + this->StateSnapshot.GetDirectory() + .AppendIncludeDirectoriesEntry(entryString, lfbt); + } // Property on each target: for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end(); ++l) { cmTarget &t = l->second; - t.InsertInclude(entry, before); + t.InsertInclude(entryString, lfbt, before); } } @@ -4130,37 +4151,35 @@ void cmMakefile::SetProperty(const std::string& prop, const char* value) { if (prop == "INCLUDE_DIRECTORIES") { - this->IncludeDirectoriesEntries.clear(); if (!value) { + this->StateSnapshot.GetDirectory().ClearIncludeDirectories(); return; } cmListFileBacktrace lfbt = this->GetBacktrace(); - this->IncludeDirectoriesEntries.push_back( - cmValueWithOrigin(value, lfbt)); + this->StateSnapshot.GetDirectory().SetIncludeDirectories(value, lfbt); return; } if (prop == "COMPILE_OPTIONS") { - this->CompileOptionsEntries.clear(); if (!value) { + this->StateSnapshot.GetDirectory().ClearCompileOptions(); return; } cmListFileBacktrace lfbt = this->GetBacktrace(); - this->CompileOptionsEntries.push_back(cmValueWithOrigin(value, lfbt)); + this->StateSnapshot.GetDirectory().SetCompileOptions(value, lfbt); return; } if (prop == "COMPILE_DEFINITIONS") { - this->CompileDefinitionsEntries.clear(); if (!value) { + this->StateSnapshot.GetDirectory().ClearCompileDefinitions(); return; } cmListFileBacktrace lfbt = this->GetBacktrace(); - cmValueWithOrigin entry(value, lfbt); - this->CompileDefinitionsEntries.push_back(entry); + this->StateSnapshot.GetDirectory().SetCompileDefinitions(value, lfbt); return; } @@ -4174,22 +4193,21 @@ void cmMakefile::AppendProperty(const std::string& prop, if (prop == "INCLUDE_DIRECTORIES") { cmListFileBacktrace lfbt = this->GetBacktrace(); - this->IncludeDirectoriesEntries.push_back( - cmValueWithOrigin(value, lfbt)); + this->StateSnapshot.GetDirectory().AppendIncludeDirectoriesEntry(value, + lfbt); return; } if (prop == "COMPILE_OPTIONS") { cmListFileBacktrace lfbt = this->GetBacktrace(); - this->CompileOptionsEntries.push_back( - cmValueWithOrigin(value, lfbt)); + this->StateSnapshot.GetDirectory().AppendCompileOptionsEntry(value, lfbt); return; } if (prop == "COMPILE_DEFINITIONS") { cmListFileBacktrace lfbt = this->GetBacktrace(); - this->CompileDefinitionsEntries.push_back( - cmValueWithOrigin(value, lfbt)); + this->StateSnapshot.GetDirectory().AppendCompileDefinitionsEntry(value, + lfbt); return; } @@ -4244,44 +4262,20 @@ const char *cmMakefile::GetProperty(const std::string& prop, } else if (prop == "INCLUDE_DIRECTORIES") { - std::string sep; - for (std::vector<cmValueWithOrigin>::const_iterator - it = this->IncludeDirectoriesEntries.begin(), - end = this->IncludeDirectoriesEntries.end(); - it != end; ++it) - { - output += sep; - output += it->Value; - sep = ";"; - } + output = cmJoin(this->StateSnapshot.GetDirectory() + .GetIncludeDirectoriesEntries(), ";"); return output.c_str(); } else if (prop == "COMPILE_OPTIONS") { - std::string sep; - for (std::vector<cmValueWithOrigin>::const_iterator - it = this->CompileOptionsEntries.begin(), - end = this->CompileOptionsEntries.end(); - it != end; ++it) - { - output += sep; - output += it->Value; - sep = ";"; - } + output = cmJoin(this->StateSnapshot.GetDirectory() + .GetCompileOptionsEntries(), ";"); return output.c_str(); } else if (prop == "COMPILE_DEFINITIONS") { - std::string sep; - for (std::vector<cmValueWithOrigin>::const_iterator - it = this->CompileDefinitionsEntries.begin(), - end = this->CompileDefinitionsEntries.end(); - it != end; ++it) - { - output += sep; - output += it->Value; - sep = ";"; - } + output = cmJoin(this->StateSnapshot.GetDirectory() + .GetCompileDefinitionsEntries(), ";"); return output.c_str(); } @@ -4753,53 +4747,30 @@ const char* cmMakefile::GetDefineFlagsCMP0059() const cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const { - // Get the current setting of the policy. - cmPolicies::PolicyStatus cur = this->GetPolicyStatusInternal(id); + cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id); - // If the policy is required to be set to NEW but is not, ignore the - // current setting and tell the caller. - if(cur != cmPolicies::NEW) + if(status == cmPolicies::REQUIRED_ALWAYS || + status == cmPolicies::REQUIRED_IF_USED) { - if(cur == cmPolicies::REQUIRED_ALWAYS || - cur == cmPolicies::REQUIRED_IF_USED) - { - return cur; - } - cmPolicies::PolicyStatus def = cmPolicies::GetPolicyStatus(id); - if(def == cmPolicies::REQUIRED_ALWAYS || - def == cmPolicies::REQUIRED_IF_USED) - { - return def; - } + return status; } - // The current setting is okay. - return cur; -} - -//---------------------------------------------------------------------------- -cmPolicies::PolicyStatus -cmMakefile::GetPolicyStatusInternal(cmPolicies::PolicyID id) const -{ - // Is the policy set in our stack? - for(PolicyStackType::const_reverse_iterator psi = this->PolicyStack.rbegin(); - psi != this->PolicyStack.rend(); ++psi) + cmLocalGenerator* lg = this->LocalGenerator; + while(lg) { - if(psi->IsDefined(id)) + cmMakefile const* mf = lg->GetMakefile(); + for(PolicyStackType::const_reverse_iterator psi = + mf->PolicyStack.rbegin(); psi != mf->PolicyStack.rend(); ++psi) { - return psi->Get(id); + if(psi->IsDefined(id)) + { + status = psi->Get(id); + return status; + } } + lg = lg->GetParent(); } - - // If we have a parent directory, recurse up to it. - if(this->LocalGenerator->GetParent()) - { - cmMakefile* parent = this->LocalGenerator->GetParent()->GetMakefile(); - return parent->GetPolicyStatusInternal(id); - } - - // The policy is not set. Use the default for this CMake version. - return cmPolicies::GetPolicyStatus(id); + return status; } //---------------------------------------------------------------------------- @@ -4857,25 +4828,6 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id, previous_was_weak = psi->Weak; } - // Special hook for presenting compatibility variable as soon as - // the user requests it. - if(id == cmPolicies::CMP0001 && - (status == cmPolicies::WARN || status == cmPolicies::OLD)) - { - if(!(this->GetState() - ->GetInitializedCacheValue("CMAKE_BACKWARDS_COMPATIBILITY"))) - { - // Set it to 2.4 because that is the last version where the - // variable had meaning. - this->AddCacheDefinition - ("CMAKE_BACKWARDS_COMPATIBILITY", "2.4", - "For backwards compatibility, what version of CMake " - "commands and " - "syntax should this version of CMake try to support.", - cmState::STRING); - } - } - return true; } |