Repository navigation
Add cmake.cacheVariable command - #4422
Merged
Garrett Campbell (gcampbell-msft) merged 8 commits intoMay 19, 2025
Merged
Conversation
Contributor
Author
|
I would love to get a maintainer's take on bcbc15e to confirm that 1) I should be doing that and 2) I'm doing it the right way. |
Garrett Campbell (gcampbell-msft)
requested changes
May 12, 2025
Garrett Campbell (gcampbell-msft)
left a comment
Collaborator
There was a problem hiding this comment.
Overall, this seems like a good idea and allows people to get variables set in their CMake project, whether from CMakePresets, CMakeLists.txt, or anywhere else. With a couple of small changes, this looks like a good addition with minimal risk. Thanks!
Garrett Campbell (gcampbell-msft)
previously approved these changes
May 12, 2025
Contributor
Author
|
OK awesome. Looks like the CI is failing on localization. I admit to some wishful mimicry when it comes to that part of the PR. I'll see if I can figure out what the problem is and fix it. Any pointers on what I might be doing wrong would be appreciated. |
Dennis Lambe Jr. (malsyned)
force-pushed
the
cache-command
branch
from
May 13, 2025 15:02
c4996f8 to
cb3275b
Compare
Garrett Campbell (gcampbell-msft)
approved these changes
May 13, 2025
This is to get the fix for the flaky mac CI tests
Contributor
Author
|
I pulled in your mac CI flakiness fix, in the hopes of getting a green light. |
Mateusz Pfeifer (fajkomix1990)
pushed a commit
to fajkomix1990/mati---glowny
that referenced
this pull request
Jul 2, 2025
* Add cmake.cacheVariable for command substitution * Add PR microsoft#4422 to CHANGELOG * cacheVariable: report usage errors * cacheVariable: configure before lookup if needed * Fix "second argument of a localize call must be a string literal." * move quotes into main localization string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change partially addresses items #1936 and #4301
This changes visible behavior & documentation
The following changes are proposed:
Add a new command,
cmake.cacheVariable, which can be used inlaunch.jsonandtasks.jsonas a command input, allowing substitution of cache variables defined inCMakeLists.txtor in theconfigurePresets.cacheVariablesproperty ofCMakePresets.json.The
inputssection can be used to pass a CMake cache variablenametocmake.cacheVariable, and that input can in turn be used for variable substitution in property values in theconfigurationsection.Example:
{ "version": "0.2.0", "configurations": [ { "name": "Debug with J-Link", "request": "launch", "type": "cortex-debug", "executable": "${command:cmake.launchTargetPath}", "cwd": "${workspaceFolder}", "servertype": "jlink", "interface": "jtag", "device": "${input:DEVICE}" } ], "inputs": [ { "id": "DEVICE", "type": "command", "command": "cmake.cacheVariable", "args": { "name": "DEVICE", "default": "rm44l520" } } ] }The purpose of this change
To allow
CMakeLists.txtto serve as a single point of truth for configuration information specific to the user's project. In my case, for example, I can keep the part number of my project's microcontroller in a CMake cache variable, and use it to populatecortex-debugproperties like"device"and"svdFile". The description in #1976 looks to me like it has the same use case in mind, but I bet there are plenty of other situations where this would come in handy.Other Notes/Information
The referenced issue tickets mention providing access not just to cache variables, but also to environment variables. This PR doesn't address the environment variable part of those feature requests.