Skip to content
Snippets Groups Projects

presets: Add preset overriding

Closed Cristian Le requested to merge LecrisUT/cmake:feat/preset-override into master

I have cherry-picked and updated !8227 (closed). @Arastais I hope you don't mind, if you want to take over again, feel free to cherry-pick this commit back.

TODO:

  • Resolve cherry-pick issue from missing global environment
  • Port the override to the other presets as well
  • Add appropriate tests

Closes: #23046
Topic-rename: presets-override

Edited by Brad King

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Cristian Le changed the description

    changed the description

  • Cristian Le added 1 commit

    added 1 commit

    • 9b51b86c - presets: Add preset overriding

    Compare with previous version

  • Cristian Le added 1 commit

    added 1 commit

    • 7a3bc4c3 - presets: Add preset overriding

    Compare with previous version

  • Cristian Le marked the checklist item Port the override to the other presets as well as completed

    marked the checklist item Port the override to the other presets as well as completed

  • Cristian Le added 1 commit

    added 1 commit

    • f903f877 - presets: Add preset overriding

    Compare with previous version

  • Cristian Le changed the description

    changed the description

  • Cristian Le mentioned in issue #23046

    mentioned in issue #23046

    • Author Contributor
      Resolved by Brad King

      Question about this design, do we still want to add the override field, or should we just allow the presets to be overridden as long as the preset version >= 9?

      Considering the restrictions on CMakeUserPresets.json/CMakePresets.json for the new/existing presets respectively, I am leaning to get rid of the override field requirement. What do you guys think?

    • Resolved by Brad King

      What should happen if two different presets try to override the same preset? Which one should be retained, or should it be considered an error? Can you override an override? Such cases are likely to occur in more complex preset hierarchies, and in some cases the overrides will be identical, but in others they might not be. When not identical, the ordering of overrides then also becomes important. That may impact whether we can relax the constraint where presets must include all presets they inherit from (I still think we should keep that constraint, but I mention it here to highlight the complexities introduced when overriding presets becomes possible).

    • Author Contributor
      Resolved by Cristian Le

      I have noticed something odd when repairing the tests: CMakeUserPresets.json is being read before CMakePresets.json. Why was it designed like this? @craig.scott do you have any insight on this?

      I have tried simply inverting the read order, but it seems to be breaking some other tests with unreachable errors, so I would appreciate more insight on this.

  • Cristian Le added 1 commit

    added 1 commit

    • 17507cf5 - presets: Add preset overriding

    Compare with previous version

  • Cristian Le marked the checklist item Resolve cherry-pick issue from missing global environment as completed

    marked the checklist item Resolve cherry-pick issue from missing global environment as completed

  • Cristian Le marked the checklist item Add appropriate tests as completed

    marked the checklist item Add appropriate tests as completed

    • Author Contributor
      Resolved by Cristian Le

      Hmm the failing test is quite weird. The regex seems just fine, but the fedora tests are reporting failure, even though the MacOS and windows one pass, and locally on Fedora this test passed as well.

      Tests are passing now. The JSON validation did not happen locally for me maybe because of find_package(Python) vs find_package(Python 3.8), but that one is fixed now

      Edited by Cristian Le
  • Cristian Le added 15 commits

    added 15 commits

    Compare with previous version

  • Cristian Le added 164 commits

    added 164 commits

    Compare with previous version

    • Resolved by Brad King

      Regarding the design of this feature, I would say that each preset may be defined at most once each in CMakePresets.json and CMakeUserPresets.json. It can even be defined in files included by them. For example, if CMakePresets.json defines preset foo, and CMakeUserPresets.json includes foo.json, then foo.json can override preset foo. However, if CMakePresets.json also includes foo.json, that is an error, since preset foo is being defined more than once in CMakePresets.json.

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading