# Fortran\_PREPROCESS ignored on Linux

**URL:** https://discourse.cmake.org/t/fortran-preprocess-ignored-on-linux/9105
**Category:** Usage
**Tags:** os:linux, gen:makefiles
**Created:** [September 29, 2023, 7:44am UTC](https://discourse.cmake.org/t/fortran-preprocess-ignored-on-linux/9105 "2023-09-29T07:44:39Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Maarten\_Braakhekke](https://discourse.cmake.org/user_avatar/discourse.cmake.org/maarten_braakhekke/32/1434_2.png) [@Maarten\_Braakhekke](https://discourse.cmake.org/u/Maarten_Braakhekke)
#### Post date: [September 29, 2023, 7:44am UTC](https://discourse.cmake.org/t/fortran-preprocess-ignored-on-linux/9105/1 "2023-09-29T07:44:39Z")

</div>

It seems that the Fortran\_PREPROCESS property is not functioning properly on Linux. The default behavior of CMake on Linux is that source files are _not_ preprocssed and Fortran\_PREPROCESS doesn seem to affect this.  
I attach a minimal example. Building this on Linux fails because source.f90 has not been preprocessed. I tried setting both the source file version and the target version of Fortran\_PREPROCESS to ON but neither works. I also tried it for both Intel Fortran and GNU Fortran.

On Windows using Intel Fortran with Visual Studio it works fine. Here the default behavior is that source files _are_ preprocessed, but I can change that using the Fortran\_PREPROCESS property.

Best,  
Maarten

[CMakeLists.txt](https://discourse.cmake.org/uploads/short-url/exVgjgma8Pi0vlb0FE7UY2EYNSG.txt) (227 Bytes)  
[source.f90](https://discourse.cmake.org/uploads/short-url/riHr0uHPxhlNDm2iqbXjOlBGb9u.f90) (78 Bytes)

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [September 29, 2023, 10:54am UTC](https://discourse.cmake.org/t/fortran-preprocess-ignored-on-linux/9105/2 "2023-09-29T10:54:20Z")

</div>

Thanks, I’ll try to take a look at this today or next week. Does it work if you name it `.F90` instead?

---

<div class="post-metadata">

### Author: ![Maarten\_Braakhekke](https://discourse.cmake.org/user_avatar/discourse.cmake.org/maarten_braakhekke/32/1434_2.png) [@Maarten\_Braakhekke](https://discourse.cmake.org/u/Maarten_Braakhekke)
#### Post date: [September 29, 2023, 1:15pm UTC](https://discourse.cmake.org/t/fortran-preprocess-ignored-on-linux/9105/3 "2023-09-29T13:15:23Z")

</div>

Yes that solves it, thanks!

I [see now](https://fortranwiki.org/fortran/show/File+extensions) that on Linux/UNIX the convention is that source files that must be preprocessed have the extension `.F90`. Still, I would say it’s undesirable that an explicit instruction to preprocess a source file (i.e. using `Fortran_PREPROCESS`) is silently ignored because of the extension of the file.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [September 29, 2023, 7:31pm UTC](https://discourse.cmake.org/t/fortran-preprocess-ignored-on-linux/9105/4 "2023-09-29T19:31:44Z")

</div>

I agree. However, it will have to be a policy. Can you please [file an issue](https://gitlab.kitware.com/cmake/cmake/-/issues)?

---

<div class="post-metadata">

### Author: ![Pavel\_Liavonau](https://discourse.cmake.org/user_avatar/discourse.cmake.org/pavel_liavonau/32/6242_2.png) [@Pavel\_Liavonau](https://discourse.cmake.org/u/Pavel_Liavonau)
#### Post date: [September 15, 2026, 3:17pm UTC](https://discourse.cmake.org/t/fortran-preprocess-ignored-on-linux/9105/5 "2026-09-15T15:17:52Z")

</div>

I faced with this issue with “Unix Makefiles” generator. Ninja generator preprocess sources by default,  
We’d not to change build generator for this reason only.  
Also we’d not rename legacy files for this reason.  
It’s wierd that it’s impossible to force preprocessor run with Makefiles generator.  
Still no solution?

---

<div class="post-metadata">

### Author: ![Pavel\_Liavonau](https://discourse.cmake.org/user_avatar/discourse.cmake.org/pavel_liavonau/32/6242_2.png) [@Pavel\_Liavonau](https://discourse.cmake.org/u/Pavel_Liavonau)
#### Post date: [September 17, 2026, 3:54pm UTC](https://discourse.cmake.org/t/fortran-preprocess-ignored-on-linux/9105/6 "2026-09-17T15:54:19Z")

</div>

Actually I found different issue. Fortran\_PREPROCESS is fine

[https://gitlab.kitware.com/cmake/cmake/-/work\_items/28098](https://gitlab.kitware.com/cmake/cmake/-/work_items/28098)
