From 30268b46f8237f25c82858693c000f5da8ede6ad Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 31 Jan 2013 11:18:49 +0100 Subject: [PATCH] Handle reading empty properties defined by the link interface. This was segfaulting before. --- Source/cmGeneratorExpressionEvaluator.cxx | 4 +++- Tests/CompatibleInterface/CMakeLists.txt | 14 +++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index f74b69e5f..55f54e464 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -465,9 +465,11 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (target->IsLinkInterfaceDependentStringProperty(propertyName, context->Config)) { - return target->GetLinkInterfaceDependentStringProperty( + const char *propContent = + target->GetLinkInterfaceDependentStringProperty( propertyName, context->Config); + return propContent ? propContent : ""; } return std::string(); diff --git a/Tests/CompatibleInterface/CMakeLists.txt b/Tests/CompatibleInterface/CMakeLists.txt index 259b5a186..329510b05 100644 --- a/Tests/CompatibleInterface/CMakeLists.txt +++ b/Tests/CompatibleInterface/CMakeLists.txt @@ -48,10 +48,22 @@ target_compile_definitions(CompatibleInterface add_library(iface2 SHARED iface2.cpp) generate_export_header(iface2) +set_property(TARGET iface2 APPEND PROPERTY + COMPATIBLE_INTERFACE_STRING + Iface2_PROP +) + # For the LINK_LIBRARIES and related properties, we should not evaluate # properties defined only in the interface - they should be implicitly zero set_property(TARGET iface2 APPEND PROPERTY LINK_INTERFACE_LIBRARIES $<$>:nonexistant> ) -target_link_libraries(CompatibleInterface iface2) +target_link_libraries(CompatibleInterface iface2 + $<$>:nonexistant> +) +# Test that this does not segfault: +target_compile_definitions(CompatibleInterface + PRIVATE + $<$>:SOME_DEFINE> +)