[CMake] CMake 3.11 Fortran submodule parallel compilation fails for a single target

Zaak Beekman zbeekman at gmail.com
Wed Apr 11 13:44:44 EDT 2018


I thought that CMake had Fortran submodule support as of 3.8 or 3.10.
However, when compiling a single library target with submodules in parallel
on macOS with GFortran trunk (or GFortran 7.3) I get:

    f951: Fatal Error: Module file 'mylib.smod' has not been generated,
either because the module does not contain a MODULE PROCEDURE or there is
an error in the module.
    Compilation terminated

   make[2]: *** [src/MyLib/CMakeFiles/MyLib.dir/MyLib_implementation.f90.o]
Error 1

So it seems that CMake is not generating a Makefile in such a way that it
requires MyLib_interface.f90 containing the interface top level module
mylib.mod to be processed/compiled *before* MyLib_interface.f90. Because of
this, there is no mylib.mod file generated from MyLib_interface.f90 before
MyLib_implementation.f90 is compiled.

Am I missing something? Is there a way to express this dependency in such a
way that CMake will generate a make file that ensures the source files are
processed in the correct order, even with `make -j`?

Thanks,
Zaak

Izaak "Zaak" Beekman

-------------------------------------------------------------------------------

HPC Scientist
ParaTools Inc. <http://www.paratools.com/>
1509 16th St, NW
Washington, DC 20036
mobile: (917) 797-3239
-------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180411/0678290d/attachment.html>


More information about the CMake mailing list