Ninja+Fortran: Module dependency not detected from INCLUDEd file
Consider this example with a module dependency inside a file included by the Fortran INCLUDE
directive:
$ cat CMakeLists.txt
cmake_minimum_required (VERSION 3.26)
project(Example Fortran)
add_executable(main main.f90 foo.f90)
$ cat main.f90
include "included.f90"
program main
!use foo ! uncomment to work around
call included_subroutine
end program
$ cat included.f90
subroutine included_subroutine
use foo
call foo_subroutine
end subroutine
$ cat foo.f90
module foo
contains
subroutine foo_subroutine
print *, "Hello World!"
end subroutine
end module
The dependency of main.f90.o
on foo.mod
is not discovered unless the work around is uncommented:
$ ninja CMakeFiles/main.dir/main.f90.o
...
Fatal Error: Cannot open module file ‘foo.mod’ for reading at (1): No such file or directory