[CMake] Fortran 90 Module Issues in CMake

Brad King brad.king at kitware.com
Thu Mar 1 13:00:29 EST 2012


On 3/1/2012 11:21 AM, Matthew Schuchard wrote:
> In particular, I have noticed that CMake cannot do module dependency scanning outside of the current directory/subdirectories.
>
> For example, if /topdir/dir1/src/ has a Fortran file with a dependency on a module built in /topdir/dir2/mod/, CMake will not instruct the module in /dir2/mod/ to be built before the Fortran file in /dir1/src/. This is not necessarily an issue as I can simply instruct CMake to build the /dir2/mod
> directory before the /dir1/src/ directory via add_subdirectory ordering.

When scanning dependencies of sources in a given target CMake
looks at targets to which that target links to find possible
module providers.  If a target uses a module provided by
another target but does not link to it then the link will
fail.

It does not matter whether the targets are in the same
directory or different directories so long as they are
all handled during a single CMake configuration.  The
case is even covered in the test suite:

http://cmake.org/gitweb?p=cmake.git;a=blob;f=Tests/Fortran/Library/CMakeLists.txt;hb=v2.8.7
http://cmake.org/gitweb?p=cmake.git;a=blob;f=Tests/Fortran/Library/a.f90;hb=v2.8.7
http://cmake.org/gitweb?p=cmake.git;a=blob;f=Tests/Fortran/Library/b.f90;hb=v2.8.7
http://cmake.org/gitweb?p=cmake.git;a=blob;f=Tests/Fortran/Executable/CMakeLists.txt;hb=v2.8.7
http://cmake.org/gitweb?p=cmake.git;a=blob;f=Tests/Fortran/Executable/main.f90;hb=v2.8.7

-Brad


More information about the CMake mailing list