Skip to content

Much better support for ninja cmake backend#5005

Merged
jgfouca merged 11 commits into
masterfrom
jgfouca/more_ninja_stuff
Jul 2, 2026
Merged

Much better support for ninja cmake backend#5005
jgfouca merged 11 commits into
masterfrom
jgfouca/more_ninja_stuff

Conversation

@jgfouca

@jgfouca jgfouca commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Description

Add much better support for different cmake backends, specifically ninja.

Change list:

  1. Instead of hardcoding gmake invocations, use cmake --build . which will flexibly work for any backend
  2. Add arguments for picking a specific backend to case.build and create_test
  3. env_mach will automatically add ninja to PATH if it's there.
  4. Instead of using CIME_SHAREDLIB_NINJA as a magic var, use the env that is known to CMake (CMAKE_GENERATOR).
  5. Add machine setting / case env var CMAKE_BACKEND

Checklist

  • My code follows the style guidelines of this project (black formatting)
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that exercise my feature/fix and existing tests continue to pass
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding additions and changes to the documentation

@jgfouca jgfouca self-assigned this Jul 1, 2026
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves CMake build backend flexibility (with a focus on Ninja) by shifting away from hard-coded GNU Make invocations and adding configuration / CLI support for selecting a backend, along with documentation and schema updates to support a new CMAKE_BACKEND machine setting.

Changes:

  • Replace direct gmake/ninja calls with cmake --build in several build paths to better support multiple CMake generators.
  • Add CLI options to select Ninja vs gmake in case.build and create_test, plus a new machine/case setting CMAKE_BACKEND.
  • Update machine env handling to expose Ninja on PATH when vendored, and update schemas/docs to include CMAKE_BACKEND.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
doc/source/ccs/model-configuration/variables/machine.rst Documents new CMAKE_BACKEND machine variable in the machine variables reference and schema examples.
doc/source/ccs/building-a-case.rst Documents CMAKE_BACKEND as a build-affecting variable and adds a note about backend availability.
CIME/XML/env_mach_specific.py Prepends vendored Ninja to PATH during env setup for cases.
CIME/Tools/case.build Adds --ninja/--gmake flags and uses CMAKE_BACKEND defaulting behavior when no flag is provided.
CIME/test_scheduler.py Propagates backend selection into scheduled build phases by appending --ninja/--gmake to case.build invocations.
CIME/SystemTests/hommebaseclass.py Switches HOMME build/run targets to use cmake --build rather than direct make invocations.
CIME/scripts/create_test.py Adds backend selection flags and passes them through to the test scheduler.
CIME/data/config/xml_schemas/config_machines.xsd Adds CMAKE_BACKEND to v2 schema.
CIME/data/config/xml_schemas/config_machines_version3.xsd Adds CMAKE_BACKEND to v3 schema.
CIME/data/config/xml_schemas/config_machines_template.xml Documents optional CMAKE_BACKEND in the machine template.
CIME/build.py Refactors model and clean build commands to use cmake --build and uses CMAKE_GENERATOR instead of a CIME-specific Ninja env var.
CIME/build_scripts/buildlib.cprnc Uses cmake --build for cprnc build step instead of gmake.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CIME/SystemTests/hommebaseclass.py
Comment thread CIME/SystemTests/hommebaseclass.py
Comment thread CIME/SystemTests/hommebaseclass.py
Comment thread CIME/build.py Outdated
Comment thread CIME/XML/env_mach_specific.py Outdated
Comment thread CIME/Tools/case.build Outdated
Comment thread CIME/Tools/case.build Outdated
Comment thread doc/source/ccs/building-a-case.rst Outdated
Comment thread CIME/scripts/create_test.py

@bartgol bartgol left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I would also consider renaming GMAKE_J to something like BUILD_J...

Comment thread CIME/test_scheduler.py
self._namelists_only = namelists_only

self._ninja = ninja
self._gmake = gmake

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check that only one between gmake and ninja is true?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that happens at the case.build level. I can add it here too.

@billsacks billsacks requested review from fischer-ncar and removed request for billsacks July 2, 2026 15:56

@fischer-ncar fischer-ncar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@jgfouca jgfouca merged commit ed580a8 into master Jul 2, 2026
11 checks passed
@jgfouca jgfouca deleted the jgfouca/more_ninja_stuff branch July 2, 2026 18:57
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.

4 participants