blt icon indicating copy to clipboard operation
blt copied to clipboard

Add utility macro to conditionally print CMake variables

Open kennyweiss opened this issue 4 years ago • 0 comments

When debugging configuration issues, I often find that it would be helpful to print out a subset of CMake's variables and their values.

I'd like to add a new utility macro that can filter the variables and their values by a regular expression and then print the results. E.g. something like:

blt_print_variables(
   [NAME_REGEX <regex_on_variable_names>] # optional
   [VALUE_REGEX  <regex_on_variable_values>] # optional 
   [ENV   TRUE|FALSE]  # optional, include environment variables in results, default is false
)

Here is a simple script to print out all values (without filtering):

get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
    message(STATUS "${_variableName}=${${_variableName}}")
endforeach()

from: https://stackoverflow.com/a/9328525

kennyweiss avatar Jun 25 '21 20:06 kennyweiss