CMake supporting for Fortran 2008 submodules
The transcript below and the attached file fortran-submodule-support.tar.gz demonstrate a skeleton Fortran 2008 submodule implementation that is currently supported by the GNU, Cray, IBM, and Intel compilers. As discussed on the CMake users list in March 2016, the CMake parser apparently cannot handle this syntax.
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.6)
project (fortran-submodule-issue Fortran)
add_executable(submodule-issue-reproducer fortran-submodule.F90)
rouson@localhost:~/Code/AdHoc/src/cmake/bug-xxxxy$ cat fortran-submodule.f90
module foo_interface
implicit none
interface
module subroutine foo()
end subroutine
end interface
end module
submodule (foo_interface) foo_implementation
implicit none
contains
module subroutine foo()
end subroutine
end submodule
end ! Dummy main program to produce an executable file
$ mkdir build
$ cd build
$ FC=gfortran cmake ..
-- The Fortran compiler identification is GNU 6.1.0
-- Checking whether Fortran compiler has -isysroot
-- Checking whether Fortran compiler has -isysroot - yes
-- Checking whether Fortran compiler supports OSX deployment target flag
-- Checking whether Fortran compiler supports OSX deployment target flag - yes
-- Check for working Fortran compiler: /opt/local/bin/gfortran
-- Check for working Fortran compiler: /opt/local/bin/gfortran -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /opt/local/bin/gfortran supports Fortran 90
-- Checking whether /opt/local/bin/gfortran supports Fortran 90 -- yes
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/rouson/Code/AdHoc/src/cmake/bug-xxxxy/build
rouson@localhost:~/Code/AdHoc/src/cmake/bug-xxxxy/build$ make
Scanning dependencies of target submodule-issue-reproducer
[ 50%] Building Fortran object CMakeFiles/submodule-issue-reproducer.dir/fortran-submodule.F90.o
Error copying Fortran module "subroutine". Tried "SUBROUTINE.mod" and "subroutine.mod".
make[2]: *** [CMakeFiles/submodule-issue-reproducer.dir/fortran-submodule.F90.o.provides.build] Error 1
make[1]: *** [CMakeFiles/submodule-issue-reproducer.dir/all] Error 2
make: *** [all] Error 2
$ gfortran --version
GNU Fortran (MacPorts gcc6 6.1.0_0) 6.1.0
$ cmake --version
cmake version 3.6.1