Possible regression with c564a3e3 in CMake 3.21

My use case is building a Fortran project with CMake, Ninja, Intel Fortran Compiler through Conan on Windows.
Commit c564a3e3 “Ninja: Always compile sources using absolute paths” included in CMake 3.21
had the following side effect for my use case.

When Ninja calls the Intel compiler for the preprocessing step the -P parameter now gets the Fortran source file with an absolute path.
The preprocessor adds this path as it was provided on the commandline as the first line (incl. “# 1”) in the preprocessed Fortran file.

There seems to be an bug in Intel compiler (I am using 19.1) which makes the compiler fail on lines longer than 139 characters. See for example here.

As I am using Conan for building the base path already is quiet long so that using an absolute path in the preprocessed file now leads to the Intel compiler issue. Using relative paths at this place (like in CMake <= 3.20) did not lead to this issue.

I also found the following CMake issue touching on this absolute vs. relative path issue in the preprocessed file altough in a different context.

I was wondering if CMake could again use relative paths just when calling the preprocessor although I recognise that my issue probably is more an issue of the Intel compiler.

This behavior is not intended to be controllable. The Makefile generators have long used absolute paths. The Ninja generator also used absolute paths before if the build tree was outside the source tree.

It sounds like the problem is in the Intel Compiler. Use a shorter path to work around it.

I also see it as a problem in the Intel Compiler, but I was hoping for a workaround in CMake. Anyhow, thank you very much for your considerations and quick help.