Merge topic 'remove_extra_matches'

dc03499 Do not set CMAKE_MATCH_ variables when not neeeded
This commit is contained in:
Brad King 2013-06-14 09:00:11 -04:00 committed by CMake Topic Stage
commit f247474eb6
1 changed files with 14 additions and 6 deletions

View File

@ -534,21 +534,29 @@ void cmStringCommand::ClearMatches(cmMakefile* mf)
{ {
char name[128]; char name[128];
sprintf(name, "CMAKE_MATCH_%d", i); sprintf(name, "CMAKE_MATCH_%d", i);
const char* s = mf->GetDefinition(name);
if(s && *s != 0)
{
mf->AddDefinition(name, ""); mf->AddDefinition(name, "");
mf->MarkVariableAsUsed(name); mf->MarkVariableAsUsed(name);
} }
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmStringCommand::StoreMatches(cmMakefile* mf,cmsys::RegularExpression& re) void cmStringCommand::StoreMatches(cmMakefile* mf,cmsys::RegularExpression& re)
{ {
for (unsigned int i=0; i<10; i++) for (unsigned int i=0; i<10; i++)
{
std::string m = re.match(i);
if(m.size() > 0)
{ {
char name[128]; char name[128];
sprintf(name, "CMAKE_MATCH_%d", i); sprintf(name, "CMAKE_MATCH_%d", i);
mf->AddDefinition(name, re.match(i).c_str()); mf->AddDefinition(name, re.match(i).c_str());
mf->MarkVariableAsUsed(name); mf->MarkVariableAsUsed(name);
} }
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------