summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2022-07-06 15:06:53 +0200
committerMarc Chevrier <marc.chevrier@gmail.com>2022-07-06 16:15:43 +0200
commit913ea78d7a22302fcaecb284096239bdb05b6206 (patch)
tree109938d99efb12ab3be17643e6897c9176c26085 /Source
parent4a8db1783ccc48bfdb9060dfff5775ba42cd94cb (diff)
downloadcmake-913ea78d7a22302fcaecb284096239bdb05b6206.tar.gz
Genex LINK_LIBRARY and LINK_GROUP: check supported properties
Refines check for properties supporting these genex. Enhance error message. Fixes: #23699
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.cxx10
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.h9
-rw-r--r--Source/cmGeneratorExpressionNode.cxx22
3 files changed, 31 insertions, 10 deletions
diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx
index d35d4289c5..6be5153c22 100644
--- a/Source/cmGeneratorExpressionDAGChecker.cxx
+++ b/Source/cmGeneratorExpressionDAGChecker.cxx
@@ -178,7 +178,7 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkOptionsExpression() const
}
bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(
- cmGeneratorTarget const* tgt) const
+ cmGeneratorTarget const* tgt, ForGenex genex) const
{
const auto* top = this->Top();
@@ -188,13 +188,17 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(
return top->Target == tgt && prop == "LINK_LIBRARIES"_s;
}
- return prop == "LINK_LIBRARIES"_s || prop == "INTERFACE_LINK_LIBRARIES"_s ||
+ auto result = prop == "LINK_LIBRARIES"_s ||
+ prop == "INTERFACE_LINK_LIBRARIES"_s ||
prop == "INTERFACE_LINK_LIBRARIES_DIRECT"_s ||
- prop == "INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE"_s ||
prop == "LINK_INTERFACE_LIBRARIES"_s ||
prop == "IMPORTED_LINK_INTERFACE_LIBRARIES"_s ||
cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES_") ||
cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES_");
+
+ return genex == ForGenex::LINK_LIBRARY || genex == ForGenex::LINK_GROUP
+ ? result
+ : (result || prop == "INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE"_s);
}
cmGeneratorExpressionDAGChecker const* cmGeneratorExpressionDAGChecker::Top()
diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h
index 93b44db828..55d131f845 100644
--- a/Source/cmGeneratorExpressionDAGChecker.h
+++ b/Source/cmGeneratorExpressionDAGChecker.h
@@ -71,7 +71,14 @@ struct cmGeneratorExpressionDAGChecker
bool EvaluatingLinkExpression() const;
bool EvaluatingLinkOptionsExpression() const;
- bool EvaluatingLinkLibraries(cmGeneratorTarget const* tgt = nullptr) const;
+ enum class ForGenex
+ {
+ ANY,
+ LINK_LIBRARY,
+ LINK_GROUP
+ };
+ bool EvaluatingLinkLibraries(cmGeneratorTarget const* tgt = nullptr,
+ ForGenex genex = ForGenex::ANY) const;
#define DECLARE_TRANSITIVE_PROPERTY_METHOD(METHOD) bool METHOD() const;
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index d773fdf7f3..45d5a83cf6 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -1662,11 +1662,16 @@ static const struct LinkLibraryNode : public cmGeneratorExpressionNode
const GeneratorExpressionContent* content,
cmGeneratorExpressionDAGChecker* dagChecker) const override
{
+ using ForGenex = cmGeneratorExpressionDAGChecker::ForGenex;
+
if (!context->HeadTarget || !dagChecker ||
- !dagChecker->EvaluatingLinkLibraries()) {
+ !dagChecker->EvaluatingLinkLibraries(nullptr,
+ ForGenex::LINK_LIBRARY)) {
reportError(context, content->GetOriginalExpression(),
"$<LINK_LIBRARY:...> may only be used with binary targets "
- "to specify link libraries.");
+ "to specify link libraries through 'LINK_LIBRARIES', "
+ "'INTERFACE_LINK_LIBRARIES', and "
+ "'INTERFACE_LINK_LIBRARIES_DIRECT' properties.");
return std::string();
}
@@ -1743,11 +1748,16 @@ static const struct LinkGroupNode : public cmGeneratorExpressionNode
const GeneratorExpressionContent* content,
cmGeneratorExpressionDAGChecker* dagChecker) const override
{
+ using ForGenex = cmGeneratorExpressionDAGChecker::ForGenex;
+
if (!context->HeadTarget || !dagChecker ||
- !dagChecker->EvaluatingLinkLibraries()) {
- reportError(context, content->GetOriginalExpression(),
- "$<LINK_GROUP:...> may only be used with binary targets "
- "to specify group of link libraries.");
+ !dagChecker->EvaluatingLinkLibraries(nullptr, ForGenex::LINK_GROUP)) {
+ reportError(
+ context, content->GetOriginalExpression(),
+ "$<LINK_GROUP:...> may only be used with binary targets "
+ "to specify group of link libraries through 'LINK_LIBRARIES', "
+ "'INTERFACE_LINK_LIBRARIES', and "
+ "'INTERFACE_LINK_LIBRARIES_DIRECT' properties.");
return std::string();
}