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