Splitting function calls across preprocessor definitions breaks the Fortran dependency scanner
When I first used CMake 3.7 to build my project, some of the Fortran modules were being built in the wrong order and the build was failing as a result. I was mystified. What could be causing this? Eventually, I found that several files used code constructs like the one below. Any modules use
d below one of these code blocks would not appear as a dependency in the generated makefiles. It seems like this block is getting the scanner in some kind of bad state where it can't detect any more dependencies.
#ifdef MIC2
call do_slab_pmesh_kspace(frc_pack, pot_ene%elec_recip, &
#else
call do_slab_pmesh_kspace(img_frc, pot_ene%elec_recip, &
#endif /*MIC2*/
ti_vir(2,:,:), need_pot_enes, need_virials)
I changed it to this, and the problem was fixed:
#ifdef MIC2
call do_slab_pmesh_kspace(frc_pack, pot_ene%elec_recip, ti_vir(2,:,:), need_pot_enes, need_virials)
#else
call do_slab_pmesh_kspace(img_frc, pot_ene%elec_recip, ti_vir(2,:,:), need_pot_enes, need_virials)
#endif /*MIC2*/
Older versions of CMake could handle both versions without problems. I don't want to annoy the project developers by having to bug them to not use the preprocessor this way, so could you please look into this?