1function(print_target_properties tgt) 2 # Get all propreties that cmake supports 3 execute_process(COMMAND cmake --help-property-list OUTPUT_VARIABLE CMAKE_PROPERTY_LIST) 4 5 # Convert command output into a CMake list 6 STRING(REGEX REPLACE ";" "\\\\;" CMAKE_PROPERTY_LIST "${CMAKE_PROPERTY_LIST}") 7 STRING(REGEX REPLACE "\n" ";" CMAKE_PROPERTY_LIST "${CMAKE_PROPERTY_LIST}") 8 if(NOT TARGET ${tgt}) 9 message("There is no target named '${tgt}'") 10 return() 11 endif() 12 13 foreach(prop ${CMAKE_PROPERTY_LIST}) 14 string(REPLACE "<CONFIG>" "${CMAKE_BUILD_TYPE}" prop ${prop}) 15 # Fix https://stackoverflow.com/questions/32197663/how-can-i-remove-the-the-location-property-may-not-be-read-from-target-error-i 16 if(prop STREQUAL "LOCATION" OR prop MATCHES "^LOCATION_" OR prop MATCHES "_LOCATION$") 17 continue() 18 endif() 19 # message ("Checking ${prop}") 20 get_property(propval TARGET ${tgt} PROPERTY ${prop} SET) 21 if(propval) 22 get_target_property(propval ${tgt} ${prop}) 23 message("${tgt} ${prop} = ${propval}") 24 endif() 25 endforeach(prop) 26endfunction(print_target_properties) 27