Ninja: filter target specific compile flags with language specific regex

sync with Makefile code.

Bug: 13486

Many thanks to Nils Gladitz
This commit is contained in:
Peter Kümmel 2012-08-22 00:11:17 +02:00
parent 21f5fc12ee
commit a1c9c136c3
1 changed files with 35 additions and 5 deletions

View File

@ -167,11 +167,41 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
// Append old-style preprocessor definition flags. // Append old-style preprocessor definition flags.
this->LocalGenerator->AppendFlags(flags, this->Makefile->GetDefineFlags()); this->LocalGenerator->AppendFlags(flags, this->Makefile->GetDefineFlags());
// Add target-specific and source-specific flags. // Add target-specific flags.
this->LocalGenerator->AppendFlags(flags, if(this->Target->GetProperty("COMPILE_FLAGS"))
this->Target->GetProperty("COMPILE_FLAGS")); {
this->LocalGenerator->AppendFlags(flags, std::string langIncludeExpr = "CMAKE_";
source->GetProperty("COMPILE_FLAGS")); langIncludeExpr += language;
langIncludeExpr += "_FLAG_REGEX";
const char* regex = this->Makefile->
GetDefinition(langIncludeExpr.c_str());
if(regex)
{
cmsys::RegularExpression r(regex);
std::vector<std::string> args;
cmSystemTools::ParseWindowsCommandLine(
this->Target->GetProperty("COMPILE_FLAGS"),
args);
for(std::vector<std::string>::iterator i = args.begin();
i != args.end(); ++i)
{
if(r.find(i->c_str()))
{
this->LocalGenerator->AppendFlags
(flags, i->c_str());
}
}
}
else
{
this->LocalGenerator->AppendFlags
(flags, this->Target->GetProperty("COMPILE_FLAGS"));
}
}
// Add source file specific flags.
this->LocalGenerator->AppendFlags(flags,
source->GetProperty("COMPILE_FLAGS"));
// TODO: Handle Apple frameworks. // TODO: Handle Apple frameworks.