summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2014-12-01 15:51:49 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2014-12-03 16:06:44 (GMT)
commitceecd7902fe80baabfad0235c54719e19a3df06b (patch)
tree06dd7fdaa510c14d25e176f02d7aa1f6404d14f6 /Source/cmMakefile.cxx
parent7878d06189e6ee11646fcad9851d5bc4d19a16e6 (diff)
downloadCMake-ceecd7902fe80baabfad0235c54719e19a3df06b.zip
CMake-ceecd7902fe80baabfad0235c54719e19a3df06b.tar.gz
CMake-ceecd7902fe80baabfad0235c54719e19a3df06b.tar.bz2
cmMakefile: store the number of last matches in a CMake var
With PushScope and PopScope, keeping track of another bit of data for each scope isn't easy. Instead, store it as another CMake variable so it gets implicitly tracked along with everything else. This works in a revert of commit 7d674b5f0b28a610333644d417c2e8cb796cc9e4.
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx58
1 files changed, 58 insertions, 0 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 53fd56f..a7acc27 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4841,6 +4841,64 @@ std::vector<cmSourceFile*> cmMakefile::GetQtUiFilesWithOptions() const
return this->QtUiFilesWithOptions;
}
+static std::string const matchVariables[] = {
+ "CMAKE_MATCH_0",
+ "CMAKE_MATCH_1",
+ "CMAKE_MATCH_2",
+ "CMAKE_MATCH_3",
+ "CMAKE_MATCH_4",
+ "CMAKE_MATCH_5",
+ "CMAKE_MATCH_6",
+ "CMAKE_MATCH_7",
+ "CMAKE_MATCH_8",
+ "CMAKE_MATCH_9"
+};
+
+static std::string const nMatchesVariable = "CMAKE_MATCH_COUNT";
+
+//----------------------------------------------------------------------------
+void cmMakefile::ClearMatches()
+{
+ const char* nMatchesStr = this->GetDefinition(nMatchesVariable);
+ if (!nMatchesStr)
+ {
+ return;
+ }
+ int nMatches = atoi(nMatchesStr);
+ for (int i=0; i<=nMatches; i++)
+ {
+ std::string const& var = matchVariables[i];
+ std::string const& s = this->GetSafeDefinition(var);
+ if(!s.empty())
+ {
+ this->AddDefinition(var, "");
+ this->MarkVariableAsUsed(var);
+ }
+ }
+ this->AddDefinition(nMatchesVariable, "0");
+ this->MarkVariableAsUsed(nMatchesVariable);
+}
+
+//----------------------------------------------------------------------------
+void cmMakefile::StoreMatches(cmsys::RegularExpression& re)
+{
+ char highest = 0;
+ for (int i=0; i<10; i++)
+ {
+ std::string const& m = re.match(i);
+ if(!m.empty())
+ {
+ std::string const& var = matchVariables[i];
+ this->AddDefinition(var, m.c_str());
+ this->MarkVariableAsUsed(var);
+ highest = static_cast<char>('0' + i);
+ }
+ }
+ char nMatches[] = {highest, '\0'};
+ this->AddDefinition(nMatchesVariable, nMatches);
+ this->MarkVariableAsUsed(nMatchesVariable);
+}
+
//----------------------------------------------------------------------------
cmPolicies::PolicyStatus
cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const