last day (17 days later) » 

3:02 PM
1
Q: CMake: Fortran modules and compilation order

JellbyI have a big Fortran program which contains many directories. Each directory is compiled separately in a pseudo-library, but there is still an interdependency mess, so at the end all pseudo-libraries are combined in a single usable library. I'd like to use Fortran modules, but it's very fragile, ...

 
What is your version of cmake? cmake --version
For info, "cmake version 3.13.4" resolves the dependency properly.
 
@PierredeBuyl I've tried 2.8.12.2 and 3.8.1.
 
Is it feasible for you to update? If you don't have an up-to-date package on your system's package manager installing from source is quite painless :-) cmake.org/download
 
@PierredeBuyl It should be feasible, since that's the way I got 3.8.1. In the meantime, I tried in another machine where I have 3.13.2, and got the same error. Did something relevant change from 3.13.2 to 3.13.4? Did you somehow compile mod.f90 first? Or is this a random/system dependent behaviour?
 
I wrote all the files from a copy-paste of your question. Then mkdir build, cd build, cmake .. and make.
If you have already attempted compilation, consider clear all of cmake's cache with rm -r CMake* in the build directory. Before using rm, make sure that you are in the proper directory and that CMake* is only the cached files.
 
3:02 PM
@PierredeBuyl I compiled 3.14.5 and indeed it worked, but not after rm foo.mod ; touch ../dir1/lib1.f90. Actually, just changing the order of lib1 and lib2 in the CMakeLists.txt file made it fail with 3.14.5 and work with 2.8.12.2.
 
This is weird, it should not need that specific order of operation. On my computer, lib1.f90 is created earlier than lib2.f90 and it still works. Did you do the rm -r CMake* thing? Do you build "in source tree" or "out of source tree"?
 
I created a build directory, and then rm -rf * inside every time. Of course, if you only do rm -r CMake* and leave the old foo.mod in the build directory, it will never fail.
 
 
2 hours later…
4:37 PM
This was on the first try, so no old foo.mod
 
 
1 hour later…
5:42 PM
Did you try (with a clean build directory) after exchanging the lib1 and lib2 lines in the CMakeLists.txt file? Does it compile lib1 first and it doesn't fail?
 

  last day (17 days later) »