# CMAKE\_Fortran\_COMPILER-NOTFOUND

**URL:** <https://root-forum.cern.ch/t/cmake-fortran-compiler-notfound/47317>\
**Category:** ROOT\
**Tags:** build\
**Created:** [October 19, 2021, 6:08pm UTC](https://root-forum.cern.ch/t/cmake-fortran-compiler-notfound/47317 "2021-10-19T18:08:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [October 19, 2021, 6:08pm UTC](https://root-forum.cern.ch/t/cmake-fortran-compiler-notfound/47317/1 "2021-10-19T18:08:57Z")

</div>

This is Ubuntu 20.04 LTS / x86\_64 / gcc, g++, gfortran 9.3.0 / cmake 3.16.3 here.

The building of the current “v6-24-00-patches” branch fails to compile “g2root” and “h2root” (for all three C++11, C++14 and C++17 builds).

I am configuring it with “`-Dall=ON`” and then …  
“`root-config --has-fortran`” says “`yes`”  
“`root-config --f77`” says “`CMAKE_Fortran_COMPILER-NOTFOUND`”

It seems that the configuration step does not even try to “`Check for working Fortran compiler`” at all.

Any ideas?

Looking at the corresponding “v6.24/06” binary distribution provided by the ROOT team, I can see that both Fortran-related executables are there. How come?

BTW. I am able to build both executables with the current “v5-34-00-patches” branch, which is also internally using “`CMAKE_Fortran_COMPILER`”.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [October 20, 2021, 6:21am UTC](https://root-forum.cern.ch/t/cmake-fortran-compiler-notfound/47317/2 "2021-10-20T06:21:14Z")

</div>

So, it’s a bug in the ROOT’s configuration logic.

If, instead of “`-Dall=ON`”, I explicitly use “`-Dfortran=ON`”, it checks for working Fortran compiler, and it compiles both executables.

Note: @Axel I spotted this bug for the “`fortran`” feature but, maybe also other components, which are enabled by “`-Dall=ON`”, face the same problems (i.e., they are “enabled”, but the required configuration steps are omitted).

---

<div class="post-metadata">

**Author:** ![amadio](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/amadio/32/12562_2.png) [@amadio](https://root-forum.cern.ch/u/amadio)\
**Post date:** [October 20, 2021, 6:52am UTC](https://root-forum.cern.ch/t/cmake-fortran-compiler-notfound/47317/3 "2021-10-20T06:52:05Z")

</div>

You are right, the problem is that in `CMakeLists.txt` the line `include(CheckCompiler)` comes right before `include(RootBuildOptions)`, and if you use `-Dall=ON`, the options are enabled in that second module, which is too late for `CheckCompiler` to enable the Fortran compiler. I think that just swapping those two lines should fix the problem, but I’m not sure if `RootBuildOptions` needs to use information from `CheckCompiler`, so that needs to be double checked.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [November 3, 2021, 6:52am UTC](https://root-forum.cern.ch/t/cmake-fortran-compiler-notfound/47317/4 "2021-11-03T06:52:18Z")

</div>

Closed on November 3, 2021, 6:52am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [March 10, 2022, 6:04pm UTC](https://root-forum.cern.ch/t/cmake-fortran-compiler-notfound/47317/5 "2022-03-10T18:04:44Z")

</div>

Half a year later … this bug is still present in the newest “v6-26-00-patches” branch (as of 2022.03.10).

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [May 31, 2022, 12:37pm UTC](https://root-forum.cern.ch/t/cmake-fortran-compiler-notfound/47317/6 "2022-05-31T12:37:13Z")

</div>

> [@amadio](#):
>
> but I’m not sure if `RootBuildOptions` needs to use information from `CheckCompiler`, so that needs to be double checked.

Afaik that’s the case. I don’t know what to do here. @bellenot @amadio suggestions?
