Hello. The default location for Fortran compiler-generated .mod files
is ${CMAKE_CURRENT_BINARY_DIR}. I think this is really a problem.

Suppose a given source file belongs to several targets, in the same source directory. Then CMake will re-compile this source file for each target it belongs to. But it will each time generate the corresponding .mod files in the same directory. This can crash the compilation if the compilation is parallel. It can even produce silent nasty errors if the source file is compiled with different compiler options of preprocessor definitions for different targets.

Note the same problem does not occur for object files because CMake wisely puts object files in directories specific to each target.

I think the default location of compiler-generated .mod files should be the same as the location of the corresponding object files.

What do you think?


I agree, but it would need to be a policy (because the current location can be assumed by existing code, the default cannot just be moved). Please file an issue to track this.

Hello. It is done: issue 22898.