CMake doesn't detect Fortran module dependencies correctly when using the Ninja generator
See this build log: https://ci.appveyor.com/project/isuruf/flang/build/1.0.511
There is this line:
[792/1586] cmd.exe /C "C:\Miniconda36-x64\Library\bin\flang.exe -cpp -DGTEST_HAS_RTTI=0 -DHOST_WIN -DMAXCPUS=256 -DMAXCPUSL=8 -DMAXCPUSR=8 -DNATIVE_FPCVT -DPGF90 -DPGFLANG -DPGI_LITTLE_ENDIAN -DTARGET_LLVM -DTARGET_WIN -DTARGET_WIN_X86 -DTARGET_WIN_X8664 -DTARGET_X8664 -DUNICODE -DWIN32 -DWIN64 -DWINNT -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_DEBUG_POINTER_IMPL="" -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DHAVE_LONG_LONG_INT -DINT32PTR64 -DTARGET_WIN_X8664 -DTM_I8 -I..\include -Iinclude -IC:\Miniconda36-x64\Library\include -I..\runtime\include -I..\runtime\flang -Iruntime\flang -B C:/projects/flang/build/./bin -no-flang-libs -module include-static -Mreentrant -E ..\runtime\flang\iso_c_bind.F95 -o runtime\flang\CMakeFiles\flang_static.dir\iso_c_bind.F95-pp.f95 && C:\Miniconda36-x64\Library\bin\cmake.exe -E cmake_ninja_depends --tdi=runtime\flang\CMakeFiles\flang_static.dir\FortranDependInfo.json --pp=runtime\flang\CMakeFiles\flang_static.dir\iso_c_bind.F95-pp.f95 --dep=runtime\flang\CMakeFiles\flang_static.dir\iso_c_bind.F95-pp.f95.d --obj=runtime\flang\CMakeFiles\flang_static.dir\iso_c_bind.F95.obj --ddi=runtime\flang\CMakeFiles\flang_static.dir\iso_c_bind.F95-pp.f95.ddi"
Sometime later, there is this line:
C:\Miniconda36-x64\Library\bin\flang.exe -I..\runtime\flang -I..\include -Iinclude -IC:\Miniconda36-x64\Library\include -I..\runtime\include -I..\runtime\flang -Iruntime\flang -B C:/projects/flang/build/./bin -no-flang-libs -module include-static -Mreentrant -c runtime\flang\CMakeFiles\flang_static.dir\ieee_exceptions.F95-pp.f95 -o runtime\flang\CMakeFiles\flang_static.dir\ieee_exceptions.F95.obj
F90-F-0004-Unable to open MODULE file iso_c_binding.mod (runtime\flang\CMakeFiles\flang_static.dir\ieee_exceptions.F95-pp.f95: 98)
This is a portion of the content of ieee_exceptions.F95-pp.f95
:
! External interfaces
!--------------------
interface
pure integer function __fenv_fegetexceptflag(flagp, exc) bind(c)
use, intrinsic :: iso_c_binding
integer(c_int) :: flagp
integer(c_int), value :: exc
end function __fenv_fegetexceptflag
This is a portion of the content of iso_c_bind.F95-pp.f65
:
module ISO_C_BINDING
!DEC$ ATTRIBUTES DLLEXPORT :: ISO_C_BINDING
public
integer C_INT
parameter ( C_INT = 4)
integer C_SHORT
The question is why Ninja attempted to build ieee_arithmetic
before iso_c_bind
, when it should have had enough information to determine that iso_c_bind
needed to be built first.