function(gather_vars VAR_NAME PROPERTY_NAME INCLUDED_VAR_NAME LIB)
    #message("${VAR_NAME}:${PROPERTY_NAME}:${INCLUDED_VAR_NAME}:${LIB}")
    if (NOT ${LIB} IN_LIST ${INCLUDED_VAR_NAME})
        string(FIND "${LIB}" "$<" HAS_GENERATOR_EXPRESSIONS)
        string(FIND "${LIB}" "$<" HAS_GENERATOR_EXPRESSIONS)
        if (LIB MATCHES "\\$<")
            message("Skipping generator expression in ${VAR_NAME}: ${LIB}")
        elseif (LIB MATCHES "::@")
            # todo what are these?
        else()
            list(APPEND ${INCLUDED_VAR_NAME} ${LIB})
            set(${INCLUDED_VAR_NAME} ${${INCLUDED_VAR_NAME}} PARENT_SCOPE)
            get_target_property(new_items ${LIB} ${PROPERTY_NAME})
            if (new_items)
                list(APPEND ${VAR_NAME} ${new_items})
            endif()
            get_target_property(trans_depend ${LIB} INTERFACE_LINK_LIBRARIES)
            #            message("Tdep ${trans_depend}")
            if (trans_depend)
                foreach(SUB_LIB ${trans_depend})
                    gather_vars(${VAR_NAME} ${PROPERTY_NAME} ${INCLUDED_VAR_NAME} ${SUB_LIB})
                endforeach()
            endif()
            set(${VAR_NAME} ${${VAR_NAME}} PARENT_SCOPE)
        endif()
    endif()
endfunction()
