Fortran_PREPROCESS ignored on Linux

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 (227 Bytes)
source.f90 (78 Bytes)

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

Yes that solves it, thanks!

I see now 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.

I agree. However, it will have to be a policy. Can you please file an issue?

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?

Actually I found different issue. Fortran_PREPROCESS is fine

https://gitlab.kitware.com/cmake/cmake/-/work_items/28098