llnl / llnl/blt

Add utility macro to conditionally print CMake variables

Open
#505 0 comments 0 reactions 0 assignees View on GitHub
feature
Dominant language
C++
Stars
296
Forks
66
Avg merge
1h 3m
Merged PRs (30d)
1

Description

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:
```cmake
blt_print_variables(
[NAME_REGEX ] # optional
[VALUE_REGEX ] # 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):
```cmake
get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
```
from: https://stackoverflow.com/a/9328525

Contributor guide

Open the contributing guide

Research direction

Start from the proposed blt_print_variables(...) entry point and compare it with the provided get_cmake_property/list/foreach example. Define the behavior for optional NAME_REGEX, VALUE_REGEX, and ENV filters, then verify that matching variable names and values are printed in sorted order. Done means the macro works for filtered and unfiltered cases and has coverage in the project’s existing test setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake
Domain
build-system
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.