Fortran/Makefiles: CMake fails to recognize dependencies
I have identified a possible bug in the algorithm that checks dependencies in source files during a CMake build.
My problematic source file (written in Fortran) originally had the following chunk:
#ifdef OSHELL
subroutine denspt_oshell &
#else
subroutine denspt_cshell &
#endif
(gridx,gridy,gridz,densitya,densityb,gax,gay,gaz,gbx,gby,gbz,Ibin)
use quick_basis_module
Like this, CMake is not able to identify that quick_basis_module
is a dependency of this source file during a parallel build (make -j2
). But for some reason the serial build works fine (make
).
Nevertheless, after removing the & symbol and rewriting this chunk of the code as follows the problem is completely solved:
#ifdef OSHELL
subroutine denspt_oshell(gridx,gridy,gridz,densitya,densityb,gax,gay,gaz,gbx,gby,gbz,Ibin)
#else
subroutine denspt_cshell(gridx,gridy,gridz,densitya,densityb,gax,gay,gaz,gbx,gby,gbz,Ibin)
#endif
use quick_basis_module
Thus, it seems that there is something in the CMake code that does not like the & symbol, even though it is a valid Fortran syntax (but not commonly used though).
It is important to emphasize that the problem I described here does not happen when building the same code with CMake and ninja.
Please let me know if you need any information further.