From 541a788264a6908ae6fe81e0afab3827c0877a38 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 11 Apr 2024 16:55:36 -0400 Subject: Tests: Add COMPATIBLE_INTERFACE_ cases outside usage requirements --- Source/cmGeneratorExpressionNode.cxx | 4 ++++ Tests/CompatibleInterface/CMakeLists.txt | 41 ++++++++++++++++++++++++++++++++ Tests/CompatibleInterface/main.cpp | 12 +++++++++- 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 4274448..94803da 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -2968,6 +2968,10 @@ 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; diff --git a/Tests/CompatibleInterface/CMakeLists.txt b/Tests/CompatibleInterface/CMakeLists.txt index da15ae9..4927329 100644 --- a/Tests/CompatibleInterface/CMakeLists.txt +++ b/Tests/CompatibleInterface/CMakeLists.txt @@ -201,3 +201,44 @@ set_property(TARGET iface3 PROPERTY STRING_PROP4 prop4) set_property(TARGET iface3 PROPERTY NUMBER_MIN_PROP6 7) set_property(TARGET iface3 PROPERTY NUMBER_MAX_PROP4 1) target_link_libraries(iface3 INTERFACE iface1) + +# Test COMPATIBLE_INTERFACE_* property evaluation outside of usage requirements. +add_custom_target(check ALL VERBATIM + COMMAND CompatibleInterface + # expect actual + "1" "$" + "prop1" "$" + "3" "$" + "5" "$" + + "1" "$" + "prop1" "$" + "3" "$" + "5" "$" + + "" "$" + "" "$" + "" "$" + "" "$" + + "" "$" + "" "$" + "" "$" + "" "$" + + "ON" "$" + "prop4" "$" + #FIXME: These two cases do not work correctly. + #"6" "$" + #"4" "$" + + "ON" "$" + "prop4" "$" + "7" "$" + "1" "$" + + "ON" "$" + "prop4" "$" + "7" "$" + "1" "$" + ) diff --git a/Tests/CompatibleInterface/main.cpp b/Tests/CompatibleInterface/main.cpp index 2cd3c3f..1205cca 100644 --- a/Tests/CompatibleInterface/main.cpp +++ b/Tests/CompatibleInterface/main.cpp @@ -1,3 +1,5 @@ +#include +#include #ifndef BOOL_PROP1 # error Expected BOOL_PROP1 @@ -149,6 +151,14 @@ __declspec(dllimport) int main(int argc, char** argv) { + int result = 0; + for (int i = 2; i < argc; i += 2) { + if (strcmp(argv[i - 1], argv[i]) != 0) { + fprintf(stderr, "Argument %d expected '%s' but got '%s'.\n", i, + argv[i - 1], argv[i]); + result = 1; + } + } Iface2 if2; - return if2.foo() + foo() + bar(); + return result + if2.foo() + foo() + bar(); } -- cgit v0.12