Fortran: Add Fortran_PREPROCESS property
Add a Fortran_PREPROCESS
target/source file property as described in #18870 (closed) to control whether or not Fortran files should always/never be preprocessed.
As this is my first dive into the CMake source, I essentially just copy-pasted the code to handle Fortran_FORMAT
.
EDIT: Design questions posted in original description have been moved to #18870 (comment 742515).
Original Description Design Questions
Some issues:
- Some compilers (NAG, PGI and SunPro) don't have an option to never preprocess files. Two problems with this:
- If the target property is set to
ALWAYS
and then a particular source file is set toNEVER
, what should be done? Does CMake just ignore the target property in favour of the source file property? In which case, I guess this isn't a problem. - If the source file extension is uppercase, most compilers will preprocess it, and for these compilers not doing that won't be possible. One possible fix would be to make a copy of the file with a lowercase extension and compile that.
- If the target property is set to
- No compilers except HP have an explicit option to use the default preprocessing behaviour. That is, aside from HP, it is not possible to select a native
BY_EXTENSION
flag. This could be handled internally by CMake, by checking the file extension and assuming that uppercase meansALWAYS
and lowercase meansNEVER
, but this could cause issues on case insensitive filesystems. - I've not touched the files
cmGlobalXCodeGenerator.cxx
orcmLocalVisualStudio7Generator.cxx
as I wasn't sure exactly what compiler these are supposed to target. - Default behaviour from CMake is unchanged. It was suggested by @ben.boeckel in #18870 (closed) that the default should be
ALWAYS
. Where best to set this? My first thought would be incmOutputConverter::GetFortranPreprocess
to returnFortranPreprocessAlways
by default
Fixes: #18870 (closed)
Topic-rename: fortran-preprocess-property
Edited by Brad King