get_property should probably return quoted variables
I ran into an issue with KDE's Kirigami library where they were doing
if(NOT BUILD_SHARED_LIBS)
set(STATIC_LIBRARY 1)
elseif(STATIC_LIBRARY)
set(BUILD_SHARED_LIBS 0)
endif()
and then they used GenerateExportHeader.cmake to try and generate an export header. This failed on static builds because GenerateExportHeader does:
get_property(type TARGET ${TARGET_LIBRARY} PROPERTY TYPE)
if(NOT ${type} STREQUAL "STATIC_LIBRARY"
AND NOT ${type} STREQUAL "SHARED_LIBRARY"
AND NOT ${type} STREQUAL "OBJECT_LIBRARY"
AND NOT ${type} STREQUAL "MODULE_LIBRARY")
message(WARNING "This macro can only be used with libraries")
return()
endif()
and because the "type" variable was considered unquoted it got expanded to "1" in cmConditionEvauator::GetVariableOrString (called from cmConditionEvaluator.cxx:610.
I'm working on a patch for kirigami now, but if this is considered a bug in cmake I could do a patch here too. I'm not sure how much of a compatibility issue changing this would be, I can imagine someone using this particular behavior to have something like references using cmake properties