diff options
author | Marc Chevrier <marc.chevrier@sap.com> | 2017-11-30 14:06:21 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@sap.com> | 2017-12-05 13:47:39 (GMT) |
commit | 9432f686e62082045f53bd0ec8f8911966476df1 (patch) | |
tree | 9e03e1ae0c08fa693fbfb741b763d45c78b5feef /Source/cmNinjaTargetGenerator.cxx | |
parent | d06b8264212c893b5da8d7499328eb403aaaad37 (diff) | |
download | CMake-9432f686e62082045f53bd0ec8f8911966476df1.zip CMake-9432f686e62082045f53bd0ec8f8911966476df1.tar.gz CMake-9432f686e62082045f53bd0ec8f8911966476df1.tar.bz2 |
Add generator expression support to per-source COMPILE_DEFINITIONS
This allows users to specify different genex-based compile definitions for each file in a target.
Fixes: #17508
Diffstat (limited to 'Source/cmNinjaTargetGenerator.cxx')
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index bad4112..1036977 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -177,13 +177,20 @@ std::string cmNinjaTargetGenerator::ComputeDefines(cmSourceFile const* source, const std::string& language) { std::set<std::string> defines; - this->LocalGenerator->AppendDefines( - defines, source->GetProperty("COMPILE_DEFINITIONS")); - { - std::string defPropName = "COMPILE_DEFINITIONS_"; - defPropName += cmSystemTools::UpperCase(this->GetConfigName()); - this->LocalGenerator->AppendDefines(defines, - source->GetProperty(defPropName)); + const std::string config = this->LocalGenerator->GetConfigName(); + cmGeneratorExpressionInterpreter genexInterpreter( + this->LocalGenerator, this->GeneratorTarget, config); + + if (const char* compile_defs = source->GetProperty("COMPILE_DEFINITIONS")) { + this->LocalGenerator->AppendDefines( + defines, genexInterpreter.Evaluate(compile_defs)); + } + + std::string defPropName = "COMPILE_DEFINITIONS_"; + defPropName += cmSystemTools::UpperCase(config); + if (const char* config_compile_defs = source->GetProperty(defPropName)) { + this->LocalGenerator->AppendDefines( + defines, genexInterpreter.Evaluate(config_compile_defs)); } std::string definesString = this->GetDefines(language); |