On 05/15/2013 04:10 PM, Mark Cianciosa wrote:
> 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?

CMake's Fortran dependency scanning does do some basic preprocessing
for conditions like this but it does not look for definitions in the
COMPILE_FLAGS property.  Use the COMPILE_DEFINITIONS property instead:

 set_property(TARGET animec APPEND PROPERTY COMPILE_DEFINITIONS _ANIMEC)

-Brad
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to