function(echo_target_property tgt prop)
    # v for value, d for defined, s for set
    get_property(v TARGET ${tgt} PROPERTY ${prop})
    get_property(d TARGET ${tgt} PROPERTY ${prop} DEFINED)
    get_property(s TARGET ${tgt} PROPERTY ${prop} SET)
    # only produce output for values that are set
    if(s)
        message("Property = '${prop}' Defined='${d}' Set='${s}'")
        message("   Value = '${v}'")
    endif()
endfunction()

function(echo_target tgt)
    # Property list from:
    # https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#properties-on-targets
    set(props
    ALIASED_TARGET
    ANDROID_ANT_ADDITIONAL_OPTIONS
    ANDROID_API
    ANDROID_API_MIN
    ANDROID_ARCH
    ANDROID_ASSETS_DIRECTORIES
    ANDROID_GUI
    ANDROID_JAR_DEPENDENCIES
    ANDROID_JAR_DIRECTORIES
    ANDROID_JAVA_SOURCE_DIR
    ANDROID_NATIVE_LIB_DEPENDENCIES
    ANDROID_NATIVE_LIB_DIRECTORIES
    ANDROID_PROCESS_MAX
    ANDROID_PROGUARD
    ANDROID_PROGUARD_CONFIG_PATH
    ANDROID_SECURE_PROPS_PATH
    ANDROID_SKIP_ANT_STEP
    ANDROID_STL_TYPE
    ARCHIVE_OUTPUT_DIRECTORY_DEBUG
    ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL
    ARCHIVE_OUTPUT_DIRECTORY_RELEASE
    ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO
    ARCHIVE_OUTPUT_DIRECTORY
    ARCHIVE_OUTPUT_NAME_DEBUG
    ARCHIVE_OUTPUT_NAME_MINSIZEREL
    ARCHIVE_OUTPUT_NAME_RELEASE
    ARCHIVE_OUTPUT_NAME_RELWITHDEBINFO
    ARCHIVE_OUTPUT_NAME
    AUTOGEN_BUILD_DIR
    AUTOGEN_PARALLEL
    AUTOGEN_TARGET_DEPENDS
    AUTOMOC_COMPILER_PREDEFINES
    AUTOMOC_DEPEND_FILTERS
    AUTOMOC_MACRO_NAMES
    AUTOMOC_MOC_OPTIONS
    AUTOMOC
    AUTOUIC
    AUTOUIC_OPTIONS
    AUTOUIC_SEARCH_PATHS
    AUTORCC
    AUTORCC_OPTIONS
    BINARY_DIR
    BUILD_RPATH
    BUILD_WITH_INSTALL_NAME_DIR
    BUILD_WITH_INSTALL_RPATH
    BUNDLE_EXTENSION
    BUNDLE
    C_EXTENSIONS
    C_STANDARD
    C_STANDARD_REQUIRED
    COMPATIBLE_INTERFACE_BOOL
    COMPATIBLE_INTERFACE_NUMBER_MAX
    COMPATIBLE_INTERFACE_NUMBER_MIN
    COMPATIBLE_INTERFACE_STRING
    COMPILE_DEFINITIONS
    COMPILE_FEATURES
    COMPILE_FLAGS
    COMPILE_OPTIONS
    COMPILE_PDB_NAME
    COMPILE_PDB_NAME_DEBUG
    COMPILE_PDB_NAME_MINSIZEREL
    COMPILE_PDB_NAME_RELEASE
    COMPILE_PDB_NAME_RELWITHDEBINFO
    COMPILE_PDB_OUTPUT_DIRECTORY
    COMPILE_PDB_OUTPUT_DIRECTORY_DEBUG
    COMPILE_PDB_OUTPUT_DIRECTORY_MINSIZEREL
    COMPILE_PDB_OUTPUT_DIRECTORY_RELEASE
    COMPILE_PDB_OUTPUT_DIRECTORY_RELWITHDEBINFO
    DEBUG_OUTPUT_NAME
    MINSIZEREL_OUTPUT_NAME
    RELEASE_OUTPUT_NAME
    RELWITHDEBINFO_OUTPUT_NAME
    DEBUG_POSTFIX
    MINSIZEREL_POSTFIX
    RELEASE_POSTFIX
    RELWITHDEBINFO_POSTFIX
    CROSSCOMPILING_EMULATOR
    CUDA_PTX_COMPILATION
    CUDA_SEPARABLE_COMPILATION
    CUDA_RESOLVE_DEVICE_SYMBOLS
    CUDA_EXTENSIONS
    CUDA_STANDARD
    CUDA_STANDARD_REQUIRED
    CXX_EXTENSIONS
    CXX_STANDARD
    CXX_STANDARD_REQUIRED
    DEBUG_POSTFIX
    DEFINE_SYMBOL
    DEPLOYMENT_REMOTE_DIRECTORY
    EchoString
    ENABLE_EXPORTS
    EXCLUDE_FROM_ALL
    EXCLUDE_FROM_DEFAULT_BUILD_DEBUG
    EXCLUDE_FROM_DEFAULT_BUILD_MINSIZEREL
    EXCLUDE_FROM_DEFAULT_BUILD_RELEASE
    EXCLUDE_FROM_DEFAULT_BUILD_RELWITHDEBINFO
    EXCLUDE_FROM_DEFAULT_BUILD
    EXPORT_NAME
    FOLDER
    Fortran_FORMAT
    Fortran_MODULE_DIRECTORY
    FRAMEWORK
    FRAMEWORK_VERSION
    GENERATOR_FILE_NAME
    GNUtoMS
    HAS_CXX
    IMPLICIT_DEPENDS_INCLUDE_TRANSFORM
    IMPORTED_CONFIGURATIONS
    IMPORTED_GLOBAL
    IMPORTED_IMPLIB_DEBUG
    IMPORTED_IMPLIB_MINSIZEREL
    IMPORTED_IMPLIB_RELEASE
    IMPORTED_IMPLIB_RELWITHDEBINFO
    IMPORTED_IMPLIB
    IMPORTED_LIBNAME_DEBUG
    IMPORTED_LIBNAME_MINSIZEREL
    IMPORTED_LIBNAME_RELEASE
    IMPORTED_LIBNAME_RELWITHDEBINFO
    IMPORTED_LIBNAME
    IMPORTED_LINK_DEPENDENT_LIBRARIES_DEBUG
    IMPORTED_LINK_DEPENDENT_LIBRARIES_MINSIZEREL
    IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE
    IMPORTED_LINK_DEPENDENT_LIBRARIES_RELWITHDEBINFO
    IMPORTED_LINK_DEPENDENT_LIBRARIES
    IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG
    IMPORTED_LINK_INTERFACE_LANGUAGES_MINSIZEREL
    IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE
    IMPORTED_LINK_INTERFACE_LANGUAGES_RELWITHDEBINFO
    IMPORTED_LINK_INTERFACE_LANGUAGES
    IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG
    IMPORTED_LINK_INTERFACE_LIBRARIES_MINSIZEREL
    IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE
    IMPORTED_LINK_INTERFACE_LIBRARIES_RELWITHDEBINFO
    IMPORTED_LINK_INTERFACE_LIBRARIES
    IMPORTED_LINK_INTERFACE_MULTIPLICITY_DEBUG
    IMPORTED_LINK_INTERFACE_MULTIPLICITY_MINSIZEREL
    IMPORTED_LINK_INTERFACE_MULTIPLICITY_RELEASE
    IMPORTED_LINK_INTERFACE_MULTIPLICITY_RELWITHDEBINFO
    IMPORTED_LINK_INTERFACE_MULTIPLICITY
    IMPORTED_LOCATION_DEBUG
    IMPORTED_LOCATION_MINSIZEREL
    IMPORTED_LOCATION_RELEASE
    IMPORTED_LOCATION_RELWITHDEBINFO
    IMPORTED_LOCATION
    IMPORTED_NO_SONAME_DEBUG
    IMPORTED_NO_SONAME_MINSIZEREL
    IMPORTED_NO_SONAME_RELEASE
    IMPORTED_NO_SONAME_RELWITHDEBINFO
    IMPORTED_NO_SONAME
    IMPORTED_OBJECTS_DEBUG
    IMPORTED_OBJECTS_MINSIZEREL
    IMPORTED_OBJECTS_RELEASE
    IMPORTED_OBJECTS_RELWITHDEBINFO
    IMPORTED_OBJECTS
    IMPORTED
    IMPORTED_SONAME_DEBUG
    IMPORTED_SONAME_MINSIZEREL
    IMPORTED_SONAME_RELEASE
    IMPORTED_SONAME_RELWITHDEBINFO
    IMPORTED_SONAME
    IMPORT_PREFIX
    IMPORT_SUFFIX
    INCLUDE_DIRECTORIES
    INSTALL_NAME_DIR
    INSTALL_RPATH
    INSTALL_RPATH_USE_LINK_PATH
    INTERFACE_AUTOUIC_OPTIONS
    INTERFACE_COMPILE_DEFINITIONS
    INTERFACE_COMPILE_FEATURES
    INTERFACE_COMPILE_OPTIONS
    INTERFACE_INCLUDE_DIRECTORIES
    INTERFACE_LINK_LIBRARIES
    INTERFACE_POSITION_INDEPENDENT_CODE
    INTERFACE_SOURCES
    INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
    INTERPROCEDURAL_OPTIMIZATION_DEBUG
    INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL
    INTERPROCEDURAL_OPTIMIZATION_RELEASE
    INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO
    INTERPROCEDURAL_OPTIMIZATION
    IOS_INSTALL_COMBINED
    JOB_POOL_COMPILE
    JOB_POOL_LINK
    LABELS
    C_CLANG_TIDY
    CXX_CLANG_TIDY
    C_COMPILER_LAUNCHER
    CXX_COMPILER_LAUNCHER
    C_CPPCHECK
    CXX_CPPCHECK
    C_CPPLINT
    CXX_CPPLINT
    C_INCLUDE_WHAT_YOU_USE
    CXX_INCLUDE_WHAT_YOU_USE
    C_VISIBILITY_PRESET
    CXX_VISIBILITY_PRESET
    LIBRARY_OUTPUT_DIRECTORY_DEBUG
    LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL
    LIBRARY_OUTPUT_DIRECTORY_RELEASE
    LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO
    LIBRARY_OUTPUT_DIRECTORY
    LIBRARY_OUTPUT_NAME_DEBUG
    LIBRARY_OUTPUT_NAME_MINSIZEREL
    LIBRARY_OUTPUT_NAME_RELEASE
    LIBRARY_OUTPUT_NAME_RELWITHDEBINFO
    LIBRARY_OUTPUT_NAME
    LINK_DEPENDS_NO_SHARED
    LINK_DEPENDS
    LINKER_LANGUAGE
    LINK_FLAGS_DEBUG
    LINK_FLAGS_MINSIZEREL
    LINK_FLAGS_RELEASE
    LINK_FLAGS_RELWITHDEBINFO
    LINK_FLAGS
    LINK_INTERFACE_LIBRARIES_DEBUG
    LINK_INTERFACE_LIBRARIES_MINSIZEREL
    LINK_INTERFACE_LIBRARIES_RELEASE
    LINK_INTERFACE_LIBRARIES_RELWITHDEBINFO
    LINK_INTERFACE_LIBRARIES
    LINK_INTERFACE_MULTIPLICITY_DEBUG
    LINK_INTERFACE_MULTIPLICITY_MINSIZEREL
    LINK_INTERFACE_MULTIPLICITY_RELEASE
    LINK_INTERFACE_MULTIPLICITY_RELWITHDEBINFO
    LINK_INTERFACE_MULTIPLICITY
    LINK_LIBRARIES
    LINK_SEARCH_END_STATIC
    LINK_SEARCH_START_STATIC
    LINK_WHAT_YOU_USE
    #LOCATION_DEBUG
    #LOCATION_MINSIZEREL
    #LOCATION_RELEASE
    #LOCATION_RELWITHDEBINFO
    #LOCATION
    MACOSX_BUNDLE_INFO_PLIST
    MACOSX_BUNDLE
    MACOSX_FRAMEWORK_INFO_PLIST
    MACOSX_RPATH
    MANUALLY_ADDED_DEPENDENCIES
    MAP_IMPORTED_CONFIG_DEBUG
    MAP_IMPORTED_CONFIG_MINSIZEREL
    MAP_IMPORTED_CONFIG_RELEASE
    MAP_IMPORTED_CONFIG_RELWITHDEBINFO
    NAME
    NO_SONAME
    NO_SYSTEM_FROM_IMPORTED
    OSX_ARCHITECTURES_DEBUG
    OSX_ARCHITECTURES_MINSIZEREL
    OSX_ARCHITECTURES_RELEASE
    OSX_ARCHITECTURES_RELWITHDEBINFO
    OSX_ARCHITECTURES
    OUTPUT_NAME_DEBUG
    OUTPUT_NAME_MINSIZEREL
    OUTPUT_NAME_RELEASE
    OUTPUT_NAME_RELWITHDEBINFO
    OUTPUT_NAME
    PDB_NAME_DEBUG
    PDB_NAME_MINSIZEREL
    PDB_NAME_RELEASE
    PDB_NAME_RELWITHDEBINFO
    PDB_NAME
    PDB_OUTPUT_DIRECTORY_DEBUG
    PDB_OUTPUT_DIRECTORY_MINSIZEREL
    PDB_OUTPUT_DIRECTORY_RELEASE
    PDB_OUTPUT_DIRECTORY_RELWITHDEBINFO
    PDB_OUTPUT_DIRECTORY
    POSITION_INDEPENDENT_CODE
    PREFIX
    PRIVATE_HEADER
    PROJECT_LABEL
    PUBLIC_HEADER
    RESOURCE
    RULE_LAUNCH_COMPILE
    RULE_LAUNCH_CUSTOM
    RULE_LAUNCH_LINK
    RUNTIME_OUTPUT_DIRECTORY_DEBUG
    RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL
    RUNTIME_OUTPUT_DIRECTORY_RELEASE
    RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO
    RUNTIME_OUTPUT_DIRECTORY
    RUNTIME_OUTPUT_NAME_DEBUG
    RUNTIME_OUTPUT_NAME_MINSIZEREL
    RUNTIME_OUTPUT_NAME_RELEASE
    RUNTIME_OUTPUT_NAME_RELWITHDEBINFO
    RUNTIME_OUTPUT_NAME
    SKIP_BUILD_RPATH
    SOURCE_DIR
    SOURCES
    SOVERSION
    STATIC_LIBRARY_FLAGS_DEBUG
    STATIC_LIBRARY_FLAGS_MINSIZEREL
    STATIC_LIBRARY_FLAGS_RELEASE
    STATIC_LIBRARY_FLAGS_RELWITHDEBINFO
    STATIC_LIBRARY_FLAGS
    SUFFIX
    TYPE
    VERSION
    VISIBILITY_INLINES_HIDDEN
    VS_CONFIGURATION_TYPE
    VS_DEBUGGER_WORKING_DIRECTORY
    VS_DESKTOP_EXTENSIONS_VERSION
    VS_DOTNET_REFERENCE_<refname>
    VS_DOTNET_REFERENCEPROP_<refname>_TAG_<tagname>
    VS_DOTNET_REFERENCES
    VS_DOTNET_REFERENCES_COPY_LOCAL
    VS_DOTNET_TARGET_FRAMEWORK_VERSION
    VS_GLOBAL_KEYWORD
    VS_GLOBAL_PROJECT_TYPES
    VS_GLOBAL_ROOTNAMESPACE
    VS_GLOBAL_<variable>
    VS_IOT_EXTENSIONS_VERSION
    VS_IOT_STARTUP_TASK
    VS_KEYWORD
    VS_MOBILE_EXTENSIONS_VERSION
    VS_SCC_AUXPATH
    VS_SCC_LOCALPATH
    VS_SCC_PROJECTNAME
    VS_SCC_PROVIDER
    VS_SDK_REFERENCES
    VS_USER_PROPS
    VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION
    VS_WINRT_COMPONENT
    VS_WINRT_EXTENSIONS
    VS_WINRT_REFERENCES
    WIN32_EXECUTABLE
    WINDOWS_EXPORT_ALL_SYMBOLS
    XCODE_ATTRIBUTE_<an-attribute>
    XCODE_EXPLICIT_FILE_TYPE
    XCODE_PRODUCT_TYPE
    XCTEST
    )
    message("======================== ${tgt} ========================")

    if(NOT TARGET ${tgt})
        message("There is no target named '${tgt}'")
        return()
    endif()


    set(interface_whitlist 
        COMPATIBLE_INTERFACE_BOOL
        COMPATIBLE_INTERFACE_NUMBER_MAX
        COMPATIBLE_INTERFACE_NUMBER_MIN
        COMPATIBLE_INTERFACE_STRING
        EXPORT_NAME
        IMPORTED
        IMPORTED_GLOBAL
        NAME
        TYPE
        IMPORTED_CONFIGURATIONS
        IMPORTED_LIBNAME
    )

    get_property(target_type TARGET ${tgt} PROPERTY TYPE)
    foreach(p ${props})
        if(${target_type} STREQUAL  "INTERFACE_LIBRARY")
            # Whitelist rules from:
            # https://gitlab.kitware.com/cmake/cmake/blob/master/Source/cmTargetPropertyComputer.cxx
            if(${p} MATCHES "^INTERFACE_")
            elseif(${p} MATCHES "^_")
            elseif(${p} MATCHES "^[a-z]")
            elseif(${p} IN_LIST interface_whitlist)
            elseif(${p} MATCHES "^IMPORTED_LIBNAME_")
            elseif(${p} MATCHES "^MAP_IMPORTED_CONFIG_")
            else()
                continue()
            endif()
        endif()
        echo_target_property("${tgt}" "${p}")
    endforeach()
    message("")
endfunction()

function(echo_targets)
    set(tgts ${ARGV})
    foreach(t ${tgts})
        echo_target("${t}")
    endforeach()
endfunction()
