FASTBuild -- drop in replacement for Ninja?

I got curious to try the new generator FASTBuild supported by the latest release-candidate of CMake 4.2. I have a codebase of ~2M lines of code that have used CMake + Ninja on Linux for many years.

When building with -G FASTBuild instead of Ninja, I got compiler warnings, that I don’t see when building with Ninja. The compiler is the same in both cases (GCC 13 on Ubuntu 24.04).

After some investigation I see that FASTBuild internally first pre-processes my source, and then compiles the preprocessed “*.cpp.ii” files to object files. This simple difference makes GCC behave differently ( no warning –> warnings ).

If I copy/paste the compile command FASTNinja uses to compile a “.cpp.ii” file with warnings, and instead use the same command to compile the original source code, the warning disappear.

So I conclude the my CMake files still produces “working” command lines, when feeded directly to GCC. But FASTBuild’s way of using preprocessed files as an intermediate step causes the difference.

I usually have CMAKE_COMPILE_WARNING_AS_ERROR set to TRUE, but when doing this experiment with FASTBuild I used –compile-no-warning-as-error–compile-no-warning-as-error to see how far FASTBuild got ignoring these “new” warnings. But if I should use FASTBuild, I want to be able to be “warning free” eventually.

AFAIK, that is a decision of FASTBuild, not CMake. It is certainly prone to changing behavior in MSVC (well, as of a few years ago; not sure if that was fixed) and GCC and Clang definitely use “is in a macro” to suppress some warnings (e.g., -Wtautological will not fire if the expression involves a macro argument) that gets lost when the macro is actually stripped away.

I suspect FASTBuild does this for caching purposes, but it could probably hash the preprocessed source and still compile the original one if necessary.

Cc: @Eduard_Voronkin @vito.gamberini

I don’t think any of the generators are drop-in replacements for one another.

Ben is half right, it is for caching, but also distributed builds. FASTBuild doesn’t ship the headers out alongside the preprocessed translation units when farming out to workers. FASTBuild will build the code in a single pass locally if the file size is over a threshold or if distributed builds are disallowed for the file entirely.

AFAIK there’s no way we can set anything globally that changes the default to follow that behavior. FASTBuild is always “distributed build ready” even if you’re not performing one right now.