[CMake] Fortran 90 Module Issues in CMake

Matthew Schuchard ms503 at gtri.gatech.edu
Thu Mar 1 14:38:18 EST 2012


I did see those links on the bug report for Fortran 90 module dependency in subdirectories,
but I am having some kind of XML schema error preventing me from viewing them in Firefox.

If I understand you correctly, you are saying that to generate the module dependencies in my example case,
I would need to do:

/topdir/dir1/src/CMakeLists.txt
add_library(dir1src foo1.f90)
target_link_libraries(dir1src dir2mod)

/topdir/dir2/mod/CMakeLists.txt
add_library(dir2mod foo2.f90)

but this seems odd to me so I am not sure if I am interpreting it correctly.  Also, this seems
to suggest that for my same directory dependency generation error I would need to do:

add_library(thefoo foo.f90 foo2.f90 foo3.f90)
target_link_libraries(thefoo thefoo)

which also seems awkward and has not fixed my error in same directory Fortran 90 module dependency checks.

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120301/9b1e592c/attachment.htm>


More information about the CMake mailing list