As kwm@ reported a quite significant build-speedup in wekbit2-gtk3 when using ninja instead of gmake, I'm interested to know whether using the ninja-generator of cmake could lead to at least some amount of speedup in other ports as well -- as cmake is used by many ports, this could be significant for the package builders.
At the moment cmake.mk has an opt-in to use ninja. Make this an opt-out.
As there are apparently some ports breaking with ninja, make disabling ninja an argument to cmake.mk noninja instead of a variable. This way the broken ports can be fixed cleanly by just setting USES=cmake:<otherargs>,noninja.
I will test-build the ports depending on ninja... to see what breaks.
To complement what @kwm said, this patch is lacking documentation: right now, I don't think it's clear to other ports contributors when to add noninja at all. I tested a handful of the ports that need noninja here on Poudriere and they seem to fall into two categories:
Broken CMake files that have broken dependency rules that confuse ninja.
Ports setting BUILD_WRKSRC to build only part of the source code. Since build.ninja is generated in the top-level work directory, calling ninja from a subdirectory fails.
I wonder if it makes sense to try to fix the second case automatically in Uses/cmake.mk.
I've added some inline comments about ports that do not need noninja. In addition to what you added to CHANGES, I'd expect some documentation in Uses/cmake.mk as well, otherwise it's not much better than not adding anything at all. Specifically, there needs to be some documentation explaining that noninja is a stop-gap measure that's normally used by:
meta-ports (or ports that change BUILD_WRKSRC)
Ports with broken CMake rules (ninja refuses to work with circular dependencies, multiple rules that generate the same files or custom targets that do not quote $ symbols properly).
Ports that call CMake themselves as part of the build, as we end up with something that uses make and ninja at different points.
I have trouble figuring out if there are more ports using cmake that should use ninja that ports that should not use ninja. And so, I am wondering if it should not be a USES=cmake:ninja to enable it.
I have trouble figuring out if there are more ports using cmake that should use ninja that ports that should not use ninja. And so, I am wondering if it should not be a USES=cmake:ninja to enable it.
Using freshports.org/devel/cmake as reference and filtering out ports that no longer exist, there are 1317 ports that have a build-time dependency on CMake, ~70 of which don't work with ninja as far as I can see.
lgtm from my side, thanks for working on this. In your commit message, make sure you mention why some changes were done (e.g. why MAKE_ARGS was removed from compiler-rt).