diff options
author | Peter Kümmel <syntheticpp@gmx.net> | 2012-08-21 22:11:17 (GMT) |
---|---|---|
committer | Peter Kümmel <syntheticpp@gmx.net> | 2012-09-18 16:02:10 (GMT) |
commit | a1c9c136c33bb9370e5d6c2780817590530c9fbc (patch) | |
tree | eb3d382f4b18f48c05a394f9d608cc71b25f2e79 /Source/cmNinjaTargetGenerator.cxx | |
parent | 21f5fc12ee4ca043838264962fc7608a97b8f35f (diff) | |
download | CMake-a1c9c136c33bb9370e5d6c2780817590530c9fbc.zip CMake-a1c9c136c33bb9370e5d6c2780817590530c9fbc.tar.gz CMake-a1c9c136c33bb9370e5d6c2780817590530c9fbc.tar.bz2 |
Ninja: filter target specific compile flags with language specific regex
sync with Makefile code.
Bug: 13486
Many thanks to Nils Gladitz
Diffstat (limited to 'Source/cmNinjaTargetGenerator.cxx')
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 4cc23ca..385b4a0 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -167,11 +167,41 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, // Append old-style preprocessor definition flags. this->LocalGenerator->AppendFlags(flags, this->Makefile->GetDefineFlags()); - // Add target-specific and source-specific flags. - this->LocalGenerator->AppendFlags(flags, - this->Target->GetProperty("COMPILE_FLAGS")); - this->LocalGenerator->AppendFlags(flags, - source->GetProperty("COMPILE_FLAGS")); + // Add target-specific flags. + if(this->Target->GetProperty("COMPILE_FLAGS")) + { + std::string langIncludeExpr = "CMAKE_"; + 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. |