From: Viktor Szakats Date: Sun, 22 Jun 2025 08:30:07 +0000 (+0200) Subject: cmake: add target property dumper helper function X-Git-Tag: curl-8_15_0~191 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=855acb3bb07e0dd06b5722218eb5fded333f7ce0;p=thirdparty%2Fcurl.git cmake: add target property dumper helper function It's pretty rough and a giant hack, but helps debugging and findind ways while navigating the CMake maze. I find it sad CMake doesn't have a built-in function for this that works correctly in all situations. It's invaluable to be able to see what properties and values an object has. It's also possible there is a better solution to this, but I could not find it. Cherry-picked from #16973 Closes #17701 --- diff --git a/CMake/Utilities.cmake b/CMake/Utilities.cmake index ff2173fc08..efa28b7515 100644 --- a/CMake/Utilities.cmake +++ b/CMake/Utilities.cmake @@ -51,3 +51,32 @@ function(curl_dumpvars) endforeach() message("::endgroup::") endfunction() + +# Dump all target properties +function(curl_dumptargetprops _target) + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19 AND TARGET "${_target}") + execute_process(COMMAND "${CMAKE_COMMAND}" "--help-property-list" OUTPUT_VARIABLE _cmake_property_list) + string(REPLACE "\n" ";" _cmake_property_list "${_cmake_property_list}") + list(REMOVE_DUPLICATES _cmake_property_list) + list(REMOVE_ITEM _cmake_property_list "") + list(APPEND _cmake_property_list "INTERFACE_LIBCURL_PC_MODULES") + foreach(_prop IN LISTS _cmake_property_list) + if(_prop MATCHES "") + foreach(_config IN ITEMS "DEBUG" "RELEASE" "MINSIZEREL" "RELWITHDEBINFO") + string(REPLACE "" "${_config}" _propconfig "${_prop}") + get_property(_is_set TARGET "${_target}" PROPERTY "${_propconfig}" SET) + if(_is_set) + get_target_property(_val "${_target}" "${_propconfig}") + message("${_target}.${_propconfig} = '${_val}'") + endif() + endforeach() + else() + get_property(_is_set TARGET "${_target}" PROPERTY "${_prop}" SET) + if(_is_set) + get_target_property(_val "${_target}" "${_prop}") + message("${_target}.${_prop} = '${_val}'") + endif() + endif() + endforeach() + endif() +endfunction()