# Various version of the same Fortran/C compiler

**URL:** https://discourse.cmake.org/t/various-version-of-the-same-fortran-c-compiler/10661
**Category:** Usage
**Created:** [April 15, 2024, 2:20pm UTC](https://discourse.cmake.org/t/various-version-of-the-same-fortran-c-compiler/10661 "2024-04-15T14:20:02Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ruben\_Meana\_Paneda](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ruben_meana_paneda/32/4441_2.png) [@Ruben\_Meana\_Paneda](https://discourse.cmake.org/u/Ruben_Meana_Paneda)
#### Post date: [April 15, 2024, 2:20pm UTC](https://discourse.cmake.org/t/various-version-of-the-same-fortran-c-compiler/10661/1 "2024-04-15T14:20:02Z")

</div>

When we have several versions of the same compiler how can we make that cmake chooses the newest one by default?

---

<div class="post-metadata">

### Author: ![bill.hoffman](https://discourse.cmake.org/user_avatar/discourse.cmake.org/bill.hoffman/32/13_2.png) [@bill.hoffman](https://discourse.cmake.org/u/bill.hoffman)
#### Post date: [April 15, 2024, 3:27pm UTC](https://discourse.cmake.org/t/various-version-of-the-same-fortran-c-compiler/10661/2 "2024-04-15T15:27:44Z")

</div>

The FC env var would be the way to tell CMake which Fortran compiler to pick.

---

<div class="post-metadata">

### Author: ![Ruben\_Meana\_Paneda](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ruben_meana_paneda/32/4441_2.png) [@Ruben\_Meana\_Paneda](https://discourse.cmake.org/u/Ruben_Meana_Paneda)
#### Post date: [April 16, 2024, 7:23pm UTC](https://discourse.cmake.org/t/various-version-of-the-same-fortran-c-compiler/10661/3 "2024-04-16T19:23:14Z")

</div>

Understood. That is the most common way to do it (specially using lmod/modules). My question was more on the sense that if is there any way to force cmake to take the newest available version of the compilers when project is called?

---

<div class="post-metadata">

### Author: ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)
#### Post date: [April 17, 2024, 1:44am UTC](https://discourse.cmake.org/t/various-version-of-the-same-fortran-c-compiler/10661/4 "2024-04-17T01:44:47Z")

</div>

There is such an option say in FindPython, but not for compilers.
