Fortran build systems

We build numerous Fortran projects from small to large, universally using the CMake build system. Sometimes the question is raised: why use CMake over all others for Fortran builds (and all other compiled languages we use)? To answer, let us consider the most important aspects of a build system:

Generation speed

Regardless of team size, for non-trivial projects in any compiled language, build speed can become a significant pain point. Only large projects have build times beyond several seconds typically, but even for medium projects, when iteratively developing or using CI with a substantial build matrix, those few seconds add up to annoyance and lost productivity for developers.

In this regard, CMake and Meson are known to be among the fastest generators, while SCons and Autotools are among the slowest.

Build speed

Ninja is known to be generally faster than GNU Make, particularly for the case where only a few out of very many files need to be rebuilt. This is the usual case for developers. So as long as the generator works with Ninja, you can get fast builds.

However, through at least Ninja 1.8.2, Ninja doesn’t work with Fortran and CMake. This error results from

cmake -G Ninja ..

The Ninja generator does not support Fortran using Ninja version


due to lack of required features. Kitware has implemented the required features but as of this version of CMake they have not been integrated to upstream ninja. Pending integration, Kitware maintains a branch at:

with the required features. One may build ninja from that branch to get support for Fortran.

Meson can generate Ninja build files that work with Fortran, but Meson 0.48.0 only supports Gfortran, there are numerous bugs for other major Fortran compilers that make them not work including Ifort, PGI and Flang among others, despite Meson’s claimed support.


Thus after a brief survey, we decide to stick with CMake as Kitware is regularly adding Fortran features to CMake and CMake has wide compiler support.

Tags: ,


Written by Michael Hirsch, Ph.D. //