Wednesday, April 16, 2025

F43 Change Proposal: CMake: Use ninja generator by default (system-wide)

Wiki - https://fedoraproject.org/wiki/Changes/CMake_ninja_default
Discussion thread -
https://discussion.fedoraproject.org/t/f43-change-proposal-cmake-use-ninja-generator-by-default-system-wide/148867/4

This is a proposed Change for Fedora Linux.
This document represents a proposed Change. As part of the Changes
process, proposals are publicly announced in order to receive
community feedback. This proposal will only be implemented if approved
by the Fedora Engineering Steering Committee.

== Summary ==


Change the default generator used in the `%cmake` macro from `make` to
`ninja`. Affected projects are tracked in
[https://copr.fedorainfracloud.org/coprs/lecris/cmake-ninja/ this copr
repo], please check if your packages are failing there.

== Owner ==
* Name: [[User:lecris| Cristian Le]]
* Email: fedora@lecris.me


== Detailed Description ==

`ninja` is generally regarded as a faster build backend/generator than
`make`, and recently CMake features support the `ninja` backend
better. Various packages already define and use the `ninja` backend
manually, and this change proposal would change the build backend to
all of the other packages that use the `%cmake` macro.

Indirect callers to `cmake` such as when part of python package, would
be unaffected and they could implement an equivalent change
independently.

=== Migration ===


{{admon/tip | Compatibility with fedora releases | Any proposed
changes here are compatible with any CMake versions and can be
included at any point and backported to any Fedora release.
<br>The corresponding
[https://src.fedoraproject.org/rpms/cmake/pull-request/51 cmake PR]
will not be merged until the affected packages are patched.
}}

* Make sure you do not use any `%make_install` and equivalent in the
spec file. Instead use the generator agnostic macros `%cmake_build`,
`%cmake_install`, etc.
* If you need to opt-out of the ninja generator add the following line
in the specfile before the `%cmake` execution
%global cmake_generator make

== Benefit to Fedora ==

* Faster build system
* Better out-of-the-box support for newer CMake features such as C++
module support

== Scope ==
* Proposal owners:
** Make the `ninja` build backend be the default
** Try to propose appropriate fixes as much as possible
** Investigate the edge-cases that are not covered in [[Migration]]

* Other developers:
** Adjust the spec file at least with the minimum quick fix. See [[Migration]].

* Release engineering: [https://pagure.io/releng/issues #Releng issue number]

* Policies and guidelines: N/A (not needed for this Change)

== Upgrade/compatibility impact ==

Affected packages would be FTBFS (in the tracked
[https://copr.fedorainfracloud.org/coprs/lecris/cmake-ninja/ copr
repo]) and would require patching before the corresponding
[https://src.fedoraproject.org/rpms/cmake/pull-request/51 cmake PR]
can be merged.


== How To Test ==

A copr repo will be provided with these variables dropped. Use it to
try local builds, e.g. using:

copr mock-config lecris/cmake-drop_vars fedora-rawhide-x86_64

If the build is successful, that should be sufficient.



== Dependencies ==
There are currently 310/2359 packages affected gathered and built
using mass-pre-build in
[https://copr.fedorainfracloud.org/coprs/lecris/cmake-drop_vars/
copr], [https://copr.fedorainfracloud.org/coprs/lecris/cmake-ninja.checker/builds/
many of them] are previously FTBFS in rawhide.



== Contingency Plan ==
* Contingency mechanism: N/A (no deadline set)
* Contingency deadline: No deadline necessary yet
* Blocks release? No


== Documentation ==
* [https://docs.fedoraproject.org/en-US/packaging-guidelines/CMake
CMake Packaging Guidelines]

== Release Notes ==


--
Aoife Moloney

Fedora Operations Architect

Fedora Project

Matrix: @amoloney:fedora.im

IRC: amoloney

--
_______________________________________________
devel-announce mailing list -- devel-announce@lists.fedoraproject.org
To unsubscribe send an email to devel-announce-leave@lists.fedoraproject.org
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel-announce@lists.fedoraproject.org
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue

No comments:

Post a Comment