Fortran: Suprious dependencies with submodules
CMake creates a spurious dependency on real.mod
for submodule module functions of the form:
module real function x()
end function x
This results in unnecessary recompilation of code.
(other similiar constructs with the same problem include:
module pure real function x()
end function x
module pure elemental real function x()
end function x
module impure real function x()
end function x
module pure function x()
real :: x
end function x
module elemental real function x()
end function x
module pure subroutine point_dist()
end subroutine point_dist
etc).
cmake -G Ninja ../submodule2 ninja [6/6] Linking Fortran static library libpoints.a ninja [2/2] Linking Fortran static library libpoints.a ninja -d explain ninja explain: loading dyndep file 'CMakeFiles/points.dir/Fortran.dd' ninja explain: output real.mod doesn't exist ninja explain: CMakeFiles/points.dir/points_a.f90.o is dirty ninja explain: libpoints.a is dirty [2/2] Linking Fortran static library libpoints.a
It looks like Source/LexerParser/cmFortranParser.y
line 113 doe not handle a type before the function name or 'pure', 'impure' or 'elemental' before function or subroutine:
| MODULE WORD other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
if (cmsysString_strcasecmp($2, "function") != 0 &&
cmsysString_strcasecmp($2, "procedure") != 0 &&
cmsysString_strcasecmp($2, "subroutine") != 0) {
cmFortranParser_RuleModule(parser, $2);
}