summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2020-07-12 13:25:18 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2020-07-13 14:27:19 (GMT)
commit6491d2503c942b9dfb4db94dba6569e400b57a95 (patch)
tree94e25a580d85774cb4361c0fe56b744da1938698 /Source
parentc361600fc4b654ececa2f5ebdda64bb39b59ef95 (diff)
downloadCMake-6491d2503c942b9dfb4db94dba6569e400b57a95.zip
CMake-6491d2503c942b9dfb4db94dba6569e400b57a95.tar.gz
CMake-6491d2503c942b9dfb4db94dba6569e400b57a95.tar.bz2
Genex $<COMPILE_LANGUAGE>: Extend contexts supported
When genex $<TARGET_PROPERTY:...> for properties like INCLUDE_DIRECTORIES is evaluated as part of add_custom_command or add_custom_target, genex $<COMPILE_LANGUAGE> and $<COMPLIE_LANG_AND_ID> should be supported. Fixes: #20926
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.cxx8
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.h1
-rw-r--r--Source/cmGeneratorExpressionNode.cxx9
3 files changed, 15 insertions, 3 deletions
diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx
index 4f379cd..e223f15 100644
--- a/Source/cmGeneratorExpressionDAGChecker.cxx
+++ b/Source/cmGeneratorExpressionDAGChecker.cxx
@@ -154,6 +154,14 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingPICExpression() const
return this->Top()->Property == "INTERFACE_POSITION_INDEPENDENT_CODE";
}
+bool cmGeneratorExpressionDAGChecker::EvaluatingCompileExpression() const
+{
+ cm::string_view property(this->Top()->Property);
+
+ return property == "INCLUDE_DIRECTORIES"_s ||
+ property == "COMPILE_DEFINITIONS"_s || property == "COMPILE_OPTIONS"_s;
+}
+
bool cmGeneratorExpressionDAGChecker::EvaluatingLinkExpression() const
{
cm::string_view property(this->Top()->Property);
diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h
index c2c5b6b..ac2314c 100644
--- a/Source/cmGeneratorExpressionDAGChecker.h
+++ b/Source/cmGeneratorExpressionDAGChecker.h
@@ -68,6 +68,7 @@ struct cmGeneratorExpressionDAGChecker
bool EvaluatingGenexExpression() const;
bool EvaluatingPICExpression() const;
+ bool EvaluatingCompileExpression() const;
bool EvaluatingLinkExpression() const;
bool EvaluatingLinkOptionsExpression() const;
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 4adc6a2..a1a0ae8 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -967,9 +967,10 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode
const std::vector<std::string>& parameters,
cmGeneratorExpressionContext* context,
const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
+ cmGeneratorExpressionDAGChecker* dagChecker) const override
{
- if (context->Language.empty()) {
+ if (context->Language.empty() &&
+ (!dagChecker || !dagChecker->EvaluatingCompileExpression())) {
reportError(
context, content->GetOriginalExpression(),
"$<COMPILE_LANGUAGE:...> may only be used to specify include "
@@ -1014,7 +1015,9 @@ static const struct CompileLanguageAndIdNode : public cmGeneratorExpressionNode
const GeneratorExpressionContent* content,
cmGeneratorExpressionDAGChecker* dagChecker) const override
{
- if (!context->HeadTarget || context->Language.empty()) {
+ if (!context->HeadTarget ||
+ (context->Language.empty() &&
+ (!dagChecker || !dagChecker->EvaluatingCompileExpression()))) {
// reportError(context, content->GetOriginalExpression(), "");
reportError(
context, content->GetOriginalExpression(),