[CMake] Fortran submodule cannot be built

Brad King brad.king at kitware.com
Fri Mar 25 13:42:12 EDT 2016


On 03/24/2016 03:32 PM, Brad King wrote:
> CMake's approximate Fortran parser will need to be
> updated to account for submodule syntax.

I don't know if/when I'll have time to look at this myself.
If anyone is interested in working on it, please come to the
[developer list](https://cmake.org/mailman/listinfo/cmake-developers)
to discuss more details.  For reference, submodules are summarized
[here](http://fortranwiki.org/fortran/show/Submodules).

The parser is in Source/cmFortranParser.y in the CMake source tree.
There are a few problems currently:

* Submodules introduce a new syntax

    module function point_dist(a, b) result(distance)

  Currently CMake parses the "module function" part and thinks
  there is a module called "function".  We cannot simply exclude
  this name because it is valid to define such a module normally.
  The parser may have to learn more about the structure of Fortran
  sources to distinguish true module definitions from these new
  "module function" and "module procedure" definitions within a
  module.  At least it may need to track the opening/closing of
  modules (module foo ... end).

* The submodule syntax

    submodule (points) points_a

  can be used to define the "points" module with no explicit
  "module points", as shown on the fortranwiki page.  CMake will
  need to learn this syntax.

* It needs to be determined whether there are cases that CMake's
  dependency scanning needs to be aware of the ".smod" files.

-Brad



More information about the CMake mailing list