mirror of
https://github.com/curl/curl.git
synced 2026-04-11 12:01:42 +08:00
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
This commit is contained in:
parent
52f58ebb10
commit
855acb3bb0
@ -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()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user