Skip to content

Inital support for CMakeUserPresets.json and including other presets#85

Merged
MarkSchofield merged 1 commit intodevelopfrom
mschofie/includes
Dec 20, 2025
Merged

Inital support for CMakeUserPresets.json and including other presets#85
MarkSchofield merged 1 commit intodevelopfrom
mschofie/includes

Conversation

@MarkSchofield
Copy link
Owner

Fixes #1 and #49.

This PR adds support for CMakeUserPresets.json and including other presets. The two are somewhat intertwined - CMakeUserPresets.json implicitly includes CMakePresets.json - so I'm sending the PR for both. #81 laid the groundwork for this change - all paths that load presets go through a common GetCMakePresets path, and that can be responsible for resolving and merging the includes. Whilst merging is slightly more up-front work than I'd like - compared to, say, maintaining a list of loaded presets - caching the merged version sounds interesting... But I'll ponder the two approaches...

The changes:

  1. FindCMakePresets, FindCMakePresets, GetPathOfFileAbove changes are necessary to support CMakeUserPresets.json - the crux of which is GetPathOfFileAbove accommodating multiple files and checking them in order - a CMakeUserPresets.json should be preferred over CMakePresets.json
  2. GetCMakePresets is the support for 'includes' - it performs a breadth-first traversal of the presets .json, and accumulates the presets on the first instance found.

By making sure that CMakeUserPresets.json is preferred over CMakePresets.json, and that included presets are added to the end of existing presets, then the CMakeUserPresets.json presets will be discovered first when presets aren't passed to, say, Build-CMakeBuild or Configure-CMake build, and are included first in the tab-completion order.

I haven't really thought too much about testing right now... Mocking out the file system seems like a good amount of work, and building reference presets sounds like a good amount of work. But getting this checked-in gets this into the Beta builds, and I'll try things out there.

@MarkSchofield MarkSchofield merged commit edfa630 into develop Dec 20, 2025
1 check passed
@MarkSchofield MarkSchofield deleted the mschofie/includes branch December 20, 2025 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Take into account 'CMakeUserPresets.json'

1 participant