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

**URL:** <https://fortran-lang.discourse.group/t/psa-building-fortran-apps-with-submodules-using-the-cray-compiler-environment-with-cmake/10460>\
**Category:** Compilers\
**Created:** [October 27, 2025, 4:16am UTC](https://fortran-lang.discourse.group/t/psa-building-fortran-apps-with-submodules-using-the-cray-compiler-environment-with-cmake/10460 "2025-10-27T04:16:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jorgeg](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jorgeg/32/6835_2.png) [@jorgeg](https://fortran-lang.discourse.group/u/jorgeg)\
**Post date:** [October 27, 2025, 4:16am UTC](https://fortran-lang.discourse.group/t/psa-building-fortran-apps-with-submodules-using-the-cray-compiler-environment-with-cmake/10460/1 "2025-10-27T04:16:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tmj](https://avatars.discourse-cdn.com/v4/letter/t/ed655f/32.png) [@tmj](https://fortran-lang.discourse.group/u/tmj)\
**Post date:** [November 1, 2025, 2:03pm UTC](https://fortran-lang.discourse.group/t/psa-building-fortran-apps-with-submodules-using-the-cray-compiler-environment-with-cmake/10460/2 "2025-11-01T14:03:32Z")

</div>

Can you elaborate, and perhaps provide a small example?

---

<div class="post-metadata">

**Author:** ![rouson](https://avatars.discourse-cdn.com/v4/letter/r/ce7236/32.png) [@rouson](https://fortran-lang.discourse.group/u/rouson)\
**Post date:** [November 2, 2025, 3:00am UTC](https://fortran-lang.discourse.group/t/psa-building-fortran-apps-with-submodules-using-the-cray-compiler-environment-with-cmake/10460/3 "2025-11-02T03:00:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jorgeg](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jorgeg/32/6835_2.png) [@jorgeg](https://fortran-lang.discourse.group/u/jorgeg)\
**Post date:** [November 2, 2025, 9:53am UTC](https://fortran-lang.discourse.group/t/psa-building-fortran-apps-with-submodules-using-the-cray-compiler-environment-with-cmake/10460/4 "2025-11-02T09:53:38Z")

</div>

> **[GitHub - JorgeG94/submodule\_cray: An MRE for a weird bug (?)](https://github.com/JorgeG94/submodule_cray)**
>
> An MRE for a weird bug (?)

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

---

<div class="post-metadata">

**Author:** ![jorgeg](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jorgeg/32/6835_2.png) [@jorgeg](https://fortran-lang.discourse.group/u/jorgeg)\
**Post date:** [November 2, 2025, 10:03am UTC](https://fortran-lang.discourse.group/t/psa-building-fortran-apps-with-submodules-using-the-cray-compiler-environment-with-cmake/10460/5 "2025-11-02T10:03:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![brad.king](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/brad.king/32/6546_2.png) [@brad.king](https://fortran-lang.discourse.group/u/brad.king)\
**Post date:** [November 3, 2025, 4:56pm UTC](https://fortran-lang.discourse.group/t/psa-building-fortran-apps-with-submodules-using-the-cray-compiler-environment-with-cmake/10460/6 "2025-11-03T16:56:31Z")

</div>

This is [CMake Issue 18925](https://gitlab.kitware.com/cmake/cmake/-/issues/18925). No one has contributed support for Cray Fortran submodules.

> [@jorgeg](#):
>
> you can use “Ninja” as the backend and it works

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.

---

<div class="post-metadata">

**Author:** ![jorgeg](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jorgeg/32/6835_2.png) [@jorgeg](https://fortran-lang.discourse.group/u/jorgeg)\
**Post date:** [November 3, 2025, 10:34pm UTC](https://fortran-lang.discourse.group/t/psa-building-fortran-apps-with-submodules-using-the-cray-compiler-environment-with-cmake/10460/7 "2025-11-03T22:34:59Z")

</div>

I guess I could give it a go…
