CMake FortranCInterface

Can you elaborate what you mean? That’s exactly what CMake does, discover module dependencies and generate a Makefile. It uses the parser from makedepf90 (originally implemented using yacc and lex), which has been extended by hand to deal with new features of Fortran such as submodules. makedepf90 is a variant of the makedepend program but for Fortran instead of C.

The authors of CMake have explained the whole procedure in an article: How CMake supports Fortran modules and its applicability to C++


Scanners for Fortran module dependencies have been re-implemented several times by now:

The question how to correctly compile source files containing modules pops up constantly on Discourse, StackOverflow, and also on comp.lang.fortran. The following are from Fortran Discourse: