[CMake] Fortran dependency problem when two source files produce the same .mod file (with reproducer)

Tom Clune Thomas.L.Clune at nasa.gov
Mon Apr 6 17:09:16 EDT 2015


This is a somewhat artificial example, but is being used by a client as an objection for migrating to CMake.

In the attached example, there are two source files:  file1.F90 and file2.F90.   Both define the module ‘foo_mod’, but only one is listed in CMakeLists.txt for any given configuration.  (The interfaces defined by each are different.)

If one does a build, and  then toggles file1 and file2 in CMakeLists.txt, the code will _correctly_ report a compilation error:

   call gamma(x)
              1
Error: Type mismatch in argument ‘x’ at (1); passed REAL(4) to REAL(8)

However, if one then switches back to file1.F90, the error remains.  Cmake does not correctly identify that file1.F90 needs to be recompiled.

Note 1: If both files have the _same_ interface, then CMake _does_ recompile correctly.  Otherwise, I’d have provided a cleaner demonstration.

Note 2: If I turn down the verbosity, the build ’succeeds’ in both cases, but instead causes a segmentation fault.  This surprises me, as I would expect a compiler error regardless of verbosity.  But this is not an immediate concern.

—————-

Now, one can probably argue that this example is not a CMake bug, but a ‘fix’ would certainly help me in my efforts to convince my client to upgrade.

Thanks in advance,

- Tom








Thomas Clune, Ph. D. 				<Thomas.L.Clune at nasa.gov>
Head ASTG,Code 606
NASA GSFC		
MS 610.8 B33-C128
Greenbelt, MD 20771
301-286-4635









-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150406/a24ea155/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmake_ex.tar
Type: application/x-tar
Size: 10752 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150406/a24ea155/attachment-0001.tar>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150406/a24ea155/attachment-0003.html>


More information about the CMake mailing list