MantisBT - CMake
View Issue Details
0013471CMakeCMakepublic2012-08-15 05:532013-01-09 14:05
Sylwester Arabas 
Brad King 
normalminoralways
closedno change required 
CMake 2.8.9 
 
0013471: CMake does not understand Fortran interface "module procedure" syntax
Apparently the bug described here:
http://www.cmake.org/pipermail/cmake/2007-October/016831.html [^]
is still there in CMake 2.8.9-rc3:

$ cmake --version
cmake version 2.8.9-rc3
$ make
[ 11%] Built target plot-cpp
Error copying Fortran module "for/procedure". Tried "for/PROCEDURE.mod" and "for/procedure.mod".
make[3]: *** [for/CMakeFiles/test-for.dir/listing_06.f.o.provides.build] Error 1
make[2]: *** [for/CMakeFiles/test-for.dir/listing_06.f.o.provides] Error 2
make[1]: *** [for/CMakeFiles/test-for.dir/all] Error 2
make: *** [all] Error 2

If needed I can provide a full example showing the problem, but the mailing list entry seem to describe it (and there's a mention of a fix being commited).
No tags attached.
related to 0005809closed Brad King Fortran 77/9x support enhancements 
related to 0013474closed Alex Neundorf CMake Makefile generator does not re-scan dependencies if object fails to build 
Issue History
2012-08-15 05:53Sylwester ArabasNew Issue
2012-08-15 08:22Brad KingRelationship addedrelated to 0005809
2012-08-15 08:24Brad KingNote Added: 0030664
2012-08-15 10:08Sylwester ArabasNote Added: 0030670
2012-08-15 11:30Brad KingRelationship addedrelated to 0013474
2012-08-15 11:33Brad KingNote Added: 0030671
2012-08-15 11:33Brad KingAssigned To => Brad King
2012-08-15 11:33Brad KingStatusnew => resolved
2012-08-15 11:33Brad KingResolutionopen => no change required
2013-01-09 14:05Robert MaynardNote Added: 0032067
2013-01-09 14:05Robert MaynardStatusresolved => closed

Notes
(0030664)
Brad King   
2012-08-15 08:24   
Based on the timing I think this was the patch mentioned on the mailing list:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ea564648 [^]

Fortran support has matured quite a bit since 2007. Please post a full example that fails with 2.8.9.
(0030670)
Sylwester Arabas   
2012-08-15 10:08   
I'm sorry. That was apparently a false alarm - it's not the same bug as described in the mailing list, and perhaps it's not even a bug at all. A more user-friendly behavior would be nicer, though.

Here's exactly what one needs to do to get this message:

----------------------------------------------------------------
slayoo@eyrie:~/Temp/bug$ cmake --version
cmake version 2.8.9-rc3
slayoo@eyrie:~/Temp/bug$ cat bug.f90
module m
  type t
    contains
    module procedure :: p ! incorrect!
! procedure :: p ! correct
  end type
  contains
  subroutine p(this)
    class(t) :: this
  end
end module
program bug
end

slayoo@eyrie:~/Temp/bug$ cat CMakeLists.txt
project(bug Fortran)
add_executable(bug bug.f90)

slayoo@eyrie:~/Temp/bug$ cmake .
-- The Fortran compiler identification is GNU
-- Check for working Fortran compiler: /usr/bin/f95
-- Check for working Fortran compiler: /usr/bin/f95 -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /usr/bin/f95 supports Fortran 90
-- Checking whether /usr/bin/f95 supports Fortran 90 -- yes
-- Configuring done
-- Generating done
-- Build files have been written to: /home/slayoo/Temp/bug

slayoo@eyrie:~/Temp/bug$ make
Scanning dependencies of target bug
[100%] Building Fortran object CMakeFiles/bug.dir/bug.f90.o
/home/slayoo/Temp/bug/bug.f90:4.20:

    module procedure :: p ! incorrect!
                    1
Error: MODULE PROCEDURE at (1) must be in a generic module interface
make[2]: *** [CMakeFiles/bug.dir/bug.f90.o] Error 1
make[1]: *** [CMakeFiles/bug.dir/all] Error 2
make: *** [all] Error 2

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

Now, after fixing the bug.f90 file by commenting the line marked with "incorrect", and uncommenting the line marked with "correct":

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

slayoo@eyrie:~/Temp/bug$ cat bug.f90
module m
  type t
    contains
! module procedure :: p ! incorrect!
    procedure :: p ! correct
  end type
  contains
  subroutine p(this)
    class(t) :: this
  end
end module
program bug
end

slayoo@eyrie:~/Temp/bug$ make
[100%] Building Fortran object CMakeFiles/bug.dir/bug.f90.o
Error copying Fortran module "procedure". Tried "PROCEDURE.mod" and "procedure.mod".
make[2]: *** [CMakeFiles/bug.dir/bug.f90.o.provides.build] Error 1
make[1]: *** [CMakeFiles/bug.dir/all] Error 2
make: *** [all] Error 2

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

That's the same error message as mentioned in 2007 in the mailing list, but here it shows up after feeding CMake with incorrect Fortran syntax...

HTH,
Sylwester
(0030671)
Brad King   
2012-08-15 11:33   
Thanks for reporting back. The behavior you're seeing is a more general bug which I've now reported as issue 0013474. You can work around the problem by running "make depend" after fixing the Fortran module interface.

I'm resolving this issue in favor of the more general new issue.
(0032067)
Robert Maynard   
2013-01-09 14:05   
Closing resolved issues that have not been updated in more than 4 months.