]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: add target property dumper helper function
authorViktor Szakats <commit@vsz.me>
Sun, 22 Jun 2025 08:30:07 +0000 (10:30 +0200)
committerViktor Szakats <commit@vsz.me>
Sun, 22 Jun 2025 11:15:13 +0000 (13:15 +0200)
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

CMake/Utilities.cmake

index ff2173fc08b8d7d13cf3c99aa9de43d9a0f8b6cc..efa28b75155b0651f18313637b01be2635d1f3d0 100644 (file)
@@ -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 "<CONFIG>")
+        foreach(_config IN ITEMS "DEBUG" "RELEASE" "MINSIZEREL" "RELWITHDEBINFO")
+          string(REPLACE "<CONFIG>" "${_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()