summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-04-11 17:37:46 (GMT)
committerBrad King <brad.king@kitware.com>2024-04-11 22:35:40 (GMT)
commitc94cfe92eb579b07ab7a9bbb66d98090ec6fe840 (patch)
treec783b90c706b39003675487eb027c31afdb718e5
parent061f7a6b9756bafa2d3d2f0ce86b6abd2b2e4598 (diff)
downloadCMake-c94cfe92eb579b07ab7a9bbb66d98090ec6fe840.zip
CMake-c94cfe92eb579b07ab7a9bbb66d98090ec6fe840.tar.gz
CMake-c94cfe92eb579b07ab7a9bbb66d98090ec6fe840.tar.bz2
GenEx: Fix COMPATIBLE_INTERFACE_ evaluation outside usage requirements
In commit ff6c401309 (cmTarget: Add interface for compatible numeric properties, 2013-10-22, v3.0.0-rc1~460^2) the condition dagCheckerParent && !dagCheckerParent->EvaluatingLinkLibraries() was written that way to avoid a nullptr dereference, but is actually meant to say "is not evaluating link libraries". That can also be true when there is no `dagCheckerParent`, such as when evaluating a generator expression outside of usage requirements, e.g., for `add_custom_target`. The original commit tried to account for that by duplicating the implementation in another code path, but that did not work in all cases. Fix the condition, remove the duplication, and enable tests for the now-working cases.
-rw-r--r--Source/cmGeneratorExpressionNode.cxx23
-rw-r--r--Tests/CompatibleInterface/CMakeLists.txt5
2 files changed, 3 insertions, 25 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 65da33c..5c97e22 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -2980,29 +2980,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
context->Config);
return propContent ? propContent : "";
}
- // FIXME: This duplicates the COMPATIBLE_INTERFACE_NUMBER_{MAX,MIN}
- // evaluation below because it is not reached when evaluating outside of
- // usage requirements, such as in add_custom_target, because there is no
- // dagCheckerParent.
- if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName,
- context->Config)) {
- context->HadContextSensitiveCondition = true;
- const char* propContent =
- target->GetLinkInterfaceDependentNumberMinProperty(propertyName,
- context->Config);
- return propContent ? propContent : "";
- }
- if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName,
- context->Config)) {
- context->HadContextSensitiveCondition = true;
- const char* propContent =
- target->GetLinkInterfaceDependentNumberMaxProperty(propertyName,
- context->Config);
- return propContent ? propContent : "";
- }
}
- if (!target->IsImported() && dagCheckerParent &&
- !dagCheckerParent->EvaluatingLinkLibraries()) {
+ if (!evaluatingLinkLibraries && !target->IsImported()) {
if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName,
context->Config)) {
context->HadContextSensitiveCondition = true;
diff --git a/Tests/CompatibleInterface/CMakeLists.txt b/Tests/CompatibleInterface/CMakeLists.txt
index 4927329..5d57ce4 100644
--- a/Tests/CompatibleInterface/CMakeLists.txt
+++ b/Tests/CompatibleInterface/CMakeLists.txt
@@ -228,9 +228,8 @@ add_custom_target(check ALL VERBATIM
"ON" "$<TARGET_PROPERTY:static1,BOOL_PROP5>"
"prop4" "$<TARGET_PROPERTY:static1,STRING_PROP4>"
- #FIXME: These two cases do not work correctly.
- #"6" "$<TARGET_PROPERTY:static1,NUMBER_MIN_PROP6>"
- #"4" "$<TARGET_PROPERTY:static1,NUMBER_MAX_PROP4>"
+ "6" "$<TARGET_PROPERTY:static1,NUMBER_MIN_PROP6>"
+ "4" "$<TARGET_PROPERTY:static1,NUMBER_MAX_PROP4>"
"ON" "$<TARGET_PROPERTY:object1,BOOL_PROP5>"
"prop4" "$<TARGET_PROPERTY:object1,STRING_PROP4>"