diff options
author | Zsolt Parragi <zsolt.parragi@cancellar.hu> | 2016-10-25 16:23:22 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-10-28 15:18:03 (GMT) |
commit | 1e4bb358946a100ea04bbc97f8195b90b44a5e9c (patch) | |
tree | ec0cebb25ef0f6fcc0d68ab8548e0d2a1f004ab3 /Source/cmMakefileTargetGenerator.cxx | |
parent | ee0f2d23fcf3cd7a67ad8d7bd132a475ed78405f (diff) | |
download | CMake-1e4bb358946a100ea04bbc97f8195b90b44a5e9c.zip CMake-1e4bb358946a100ea04bbc97f8195b90b44a5e9c.tar.gz CMake-1e4bb358946a100ea04bbc97f8195b90b44a5e9c.tar.bz2 |
Add generator expression support to per-source COMPILE_FLAGS
This allows users to specify different genex-based compile flags for
each file in a target, e.g. compiling just a single file with `Od/Ox` in
release builds on Visual Studio.
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 68c166e..68aabef 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -437,8 +437,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( langFlags += "_FLAGS)"; this->LocalGenerator->AppendFlags(flags, langFlags); - std::string configUpper = - cmSystemTools::UpperCase(this->LocalGenerator->GetConfigName()); + std::string config = this->LocalGenerator->GetConfigName(); + std::string configUpper = cmSystemTools::UpperCase(config); // Add Fortran format flags. if (lang == "Fortran") { @@ -446,12 +446,14 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( } // Add flags from source file properties. - if (source.GetProperty("COMPILE_FLAGS")) { - this->LocalGenerator->AppendFlags(flags, - source.GetProperty("COMPILE_FLAGS")); + if (const char* cflags = source.GetProperty("COMPILE_FLAGS")) { + cmGeneratorExpression ge; + CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(cflags); + const char* evaluatedFlags = cge->Evaluate(this->LocalGenerator, config, + false, this->GeneratorTarget); + this->LocalGenerator->AppendFlags(flags, evaluatedFlags); *this->FlagFileStream << "# Custom flags: " << relativeObj - << "_FLAGS = " << source.GetProperty("COMPILE_FLAGS") - << "\n" + << "_FLAGS = " << evaluatedFlags << "\n" << "\n"; } |