Even Better/Faster CMake
| F´ Version | |
| Affected Component |
Feature Description
Building on top of #1260, this is the set of changes that is lower priority after the faster install setup. These (lower priority) items are:
Performance (build):
- [ ] Precompiled headers option investigation
- [ ] Single compilation unit option investigation
- [ ] Precache FPP to XML outputs per-deployment
- [x] Ensure Ninja functions correctly as underlying make system
Can a user specify if they want to use Ninja or Make in the case where both are installed? Maybe with fprime-util generate -G Ninja?
At this time, I don't even know if Ninja works. If it does work, we'd need to look into how to specify it. I can see your sugesstion working, or perhaps the more generic:
fprime-util generate --cmake-args -G Ninja...
So that we can expose the full power of CMake. Thoughts?
So I installed ninja-build in Ubuntu 22.04 and then, according to the CMake docs, I set the generator environment variable with export CMAKE_GENERATOR=Ninja. It looks like CMake picked it up and then successfully built the Ref deployment with fprime-util generate and fprime-util build. More testing will be needed but it looks like it all built correctly. I even ran the Ref executable.
Obviously having to export an environment variable isn't the most ideal approach but it works. I like your idea of adding the --cmake-args flag. That could just pass any additional arguments straight to CMake.
I have been running in CMake with ninja for some time because that is what the IDE I use does. No issues.
We should consider also a large restructuring to break apart the large monolith of targets required by modern projects.
I wanted to open a new discussion about Ninja vs Make, but then I found this thread so I'll just post here instead. For our project, Ninja turned out to be ~5x faster than Make. We use Zephyr and its default build system uses Ninja so it probably isn't a coincidence.
However, for me, also the Ref deployment builds >2x faster with Ninja vs Make. So I never used Make in the last 6 months. Maybe it's just my setup, is anyone experiencing similar discrepancies between the two generators? If yes, I believe it would make sense to make Ninja the default generator.
My super simple benchmarks:
# Building Ref first with Ninja and then with Make.
# Ninja
$ time `fprime-util generate -DCMAKE_GENERATOR=Ninja && fprime-util build -j16`
real 0m23.051s
user 1m48.154s
sys 0m26.662s
# Make
$ time `fprime-util generate && fprime-util build -j16`
real 1m5.167s
user 1m30.670s
sys 0m29.443s