diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2014-03-12 18:23:12 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2014-04-29 20:00:05 (GMT) |
commit | f718b30a95e07d72a361d55b7ba495eda5d79680 (patch) | |
tree | 5f06d51f999483a1e111fa2969d7a0d125356b55 /Source/cmMakefile.cxx | |
parent | bb1c41a085c6eb9296bf701ea7633f715a06f6e1 (diff) | |
download | CMake-f718b30a95e07d72a361d55b7ba495eda5d79680.zip CMake-f718b30a95e07d72a361d55b7ba495eda5d79680.tar.gz CMake-f718b30a95e07d72a361d55b7ba495eda5d79680.tar.bz2 |
ClearMatches: Only clear matches which were actually set
ClearMatches was clearing many variables which were never set in the
first place. Instead, store how many matches were made last time and
only clear those. It is moved to the cmMakefile class since it is a
common utility used by multiple commands.
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 07cfe12..262f29d 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -148,6 +148,8 @@ cmMakefile::cmMakefile(): Internal(new Internals) this->Initialize(); this->PreOrder = false; this->GeneratingBuildSystem = false; + + this->NumLastMatches = 0; } cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals) @@ -196,6 +198,8 @@ cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals) this->CheckSystemVars = mf.CheckSystemVars; this->ListFileStack = mf.ListFileStack; this->OutputToSource = mf.OutputToSource; + + this->NumLastMatches = mf.NumLastMatches; } //---------------------------------------------------------------------------- @@ -4329,6 +4333,42 @@ std::vector<cmSourceFile*> cmMakefile::GetQtUiFilesWithOptions() const } //---------------------------------------------------------------------------- +void cmMakefile::ClearMatches() +{ + std::stringstream sstr; + for (unsigned int i=0; i<this->NumLastMatches; i++) + { + sstr.str(""); + sstr << "CMAKE_MATCH_" << i; + std::string const& name = sstr.str(); + std::string const& s = this->GetSafeDefinition(name); + if(!s.empty()) + { + this->AddDefinition(name, ""); + this->MarkVariableAsUsed(name); + } + } + this->NumLastMatches = 0; +} + +//---------------------------------------------------------------------------- +void cmMakefile::StoreMatches(cmsys::RegularExpression& re) +{ + for (unsigned int i=0; i<10; i++) + { + std::string m = re.match(i); + if(m.size() > 0) + { + char name[128]; + sprintf(name, "CMAKE_MATCH_%d", i); + this->AddDefinition(name, re.match(i).c_str()); + this->MarkVariableAsUsed(name); + this->NumLastMatches = i + 1; + } + } +} + +//---------------------------------------------------------------------------- cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const { |