[CMake] Fortran Module dependency inside a preprocessor conditional

Mark Cianciosa ciancmr at tigermail.auburn.edu
Wed May 15 16:10:13 EDT 2013


I have a fortran code that I'm compiling twice to generate two libraries. There is a USE statement inside a preprocessor conditional. It looks like cmake is not picking up the dependency because of it. The code in question is

      SUBROUTINE calc_fbal(bsubu, bsubv)
      ...
      USE realspace, ONLY: wint, phip
#ifdef _ANIMEC
     1                    ,pperp, ppar, onembc, sigma_an,
     2                     pp1, pp2, pp3
      USE vforces, gsqrt => azmn_o
#endif

When I try to compile this, I get an error

[ 39%] Building Fortran object VMEC2000/CMakeFiles/animec.dir/Sources/General/fbal.f.o
/trunk/VMEC2000/Sources/General/fbal.f:22.72:

      USE vforces, gsqrt => azmn_o
                                                                        1
Fatal Error: Can't open module file 'vforces.mod' for reading at (1): No such file or directory

I'm defining _ANIMEC using the line

set_target_properties (animec PROPERTIES COMPILE_FLAGS "${BUILD_FLAGS} -D_ANIMEC")

because I only what it defined for this specific target only. Is there a better way define _ANIMEC so that it correctly finds the dependency?

Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130515/c6de8377/attachment.htm>


More information about the CMake mailing list