PSA: Building Fortran apps with submodules using the Cray compiler environment with CMake

Hello,

Just another FYI, if you are using CMake to build a Fortran project that uses submodules and you are using Makefiles as the generator, the build will fail.

Cray introduced a problem and the CMake people haven’t dealt with it. Building with FPM works well, if you don’t have FPM you can use “Ninja” as the backend and it works. I.e. cmake -G “Ninja” ../ and poof, it works well.

1 Like

Can you elaborate, and perhaps provide a small example?

1 Like

More details would be helpful. What version of CMake is the problem? Does the problem occur only with the Cray compiler? I use submodules ubiquitously and collaborated with Kitware on much of their modern Fortran support (mostly by submitting bug reports and feature requests) for more than a decade up to around 2020. CMake handled submodules fine as of the last time I tried, but I haven’t tried it recently.

This with cmake 3.28 with Cray Fortran 19.0.0. I am building Cmake 4.1.2 right now…and yes, this is only with Cray

Also fails with cmake 4.1.2 - it will not fail if I use Ninja as the backend

This is CMake Issue 18925. No one has contributed support for Cray Fortran submodules.

The initial build might work, but AFAIK the dynamically discovered dependencies refer to the wrong .[s]mod file paths so future ninja invocations will rebuild the modules and their consumers every time.

I guess I could give it a go…