cmake: improve curl_dumpvars() and move to Utilities.cmake

Also:
- dump variable types.
- show which variables are marked as advanced.
- use `IN ITEMS`.

Closes #15562
This commit is contained in:
Viktor Szakats 2024-11-12 21:37:07 +01:00
parent dc874d4369
commit f58342ae21
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
2 changed files with 18 additions and 9 deletions

View File

@ -33,3 +33,21 @@ function(count_true _output_count_var)
endforeach()
set(${_output_count_var} ${lst_len} PARENT_SCOPE)
endfunction()
# Dump all defined variables with their values
function(curl_dumpvars)
message("::group::CMake Variable Dump")
get_cmake_property(_vars VARIABLES)
foreach(_var IN ITEMS ${_vars})
get_property(_var_type CACHE ${_var} PROPERTY TYPE)
get_property(_var_advanced CACHE ${_var} PROPERTY ADVANCED)
if(_var_type)
set(_var_type ":${_var_type}")
endif()
if(_var_advanced)
set(_var_advanced " [adv]")
endif()
message("${_var}${_var_type}${_var_advanced} = ${${_var}}")
endforeach()
message("::endgroup::")
endfunction()

View File

@ -66,15 +66,6 @@ if(NOT "$ENV{CURL_BUILDINFO}$ENV{CURL_CI}$ENV{CI}" STREQUAL "")
endforeach()
endif()
function(curl_dumpvars) # Dump all defined variables with their values
message("::group::CMake Variable Dump")
get_cmake_property(_vars VARIABLES)
foreach(_var ${_vars})
message("${_var} = ${${_var}}")
endforeach()
message("::endgroup::")
endfunction()
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}")
include(Utilities)
include(Macros)