[CMake] Problem with Fortran conditionals

Nikolaus Rath nrath at trialphaenergy.com
Thu Apr 30 18:04:48 EDT 2015


Hello,

I am in the process of converting a bigger project from pure GNU Make to
CMake - mostly because managing dependencies for the Fortran sources has
become too painful.

Things seem to be mostly working, but I'm hitting one problem. When
trying to run the (CMake-generated) Makefile, it fails with:

$ make VERBOSE=1
[...]
make[2]: Entering directory `/home/nrath/Q2D/LamyRidge/src/model/build'
/home/nrath/.local/stow/cmake/bin/cmake -E cmake_copy_f90_mod
dagmg_allroutines CMakeFiles/LR_model.dir/dagmg_allroutines.mod.stamp Intel
/home/nrath/.local/stow/cmake/bin/cmake -E cmake_copy_f90_mod dagmg_mem
CMakeFiles/LR_model.dir/dagmg_mem.mod.stamp Intel
/home/nrath/.local/stow/cmake/bin/cmake -E cmake_copy_f90_mod
dagmg_pardiso CMakeFiles/LR_model.dir/dagmg_pardiso.mod.stamp Intel
Error copying Fortran module "dagmg_pardiso".  Tried "DAGMG_PARDISO.mod"
and "dagmg_pardiso.mod".
make[2]: ***
[CMakeFiles/LR_model.dir/home/nrath/Q2D/LamyRidge/src/comm/agmg-seq/dagmg.f90.o.provides.build]
Error 1
make[2]: Leaving directory `/home/nrath/Q2D/LamyRidge/src/model/build'
make[1]: *** [CMakeFiles/LR_model.dir/all] Error 2
make[1]: Leaving directory `/home/nrath/Q2D/LamyRidge/src/model/build'
make: *** [all] Error 2

I am not sure why CMake is trying to copy module files around, but when
I looked at the file that provides the "dagmg_pardiso" module, I found
this code:

!DEC$ IF DEFINED(_MKL_)
  MODULE dagmg_PARDISO
    USE dagmg_PARDISSO
    INTERFACE
 [...]
    END INTERFACE
  END MODULE dagmg_PARDISO
!DEC$ ENDIF
!-----------------------------------------------------------------------
!DEC$ IF .NOT. DEFINED(_MKL_)
    SUBROUTINE PARDISO( PT, MAXFCT, MNUM, MTYPE, PHASE, N, A, IA, JA    &
         , PERM, NRHS, IPARM, MSGLVL, B, X, ERROR )
[...]
     END SUBROUTINE PARDISO
!DEC$ ENDIF

I do not define __MKL__. Is it possible that the CMake dependency parser
doesn't understand this way of defining conditionals, and thus looks for
a module that does not exist?

If so, what would be the best way to work around this?

(The code is from a third-party library, so unfortunately I cannot
easily change it).


Best,
-Nikolaus


More information about the CMake mailing list