[CMake] problem about Fortran and C mixing

Biddiscombe, John A. biddisco at cscs.ch
Wed Nov 25 10:05:29 EST 2009


Rather than try to explain, have a look at this one I made earlier ....it inherits stuff from the parent project, but you should see what’s going on.

http://gitorious.org/hdf5/hdf5-v18/blobs/master/fortran/CMakeLists.txt

scroll down until you see

#-----------------------------------------------------------------------------

# Setup the Fortran auto-detection utilities

# H5test_kind(_SIZEOF).f90 used to generate H5fortran_detect.f90

# H5fortran_detect.f90     used to generate H5fort_type_defines.h

# H5fort_type_defines.h    used to generate H5f90i_gen.h + H5fortran_types.f90

#-----------------------------------------------------------------------------

and then you’ll see chained targets, which generate the next one. Mixing C/Fortran will be ok, - note that some of the generated files are listed as sources in the next one - this ensures that the rules are defined in succession.

JB


From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf Of ??
Sent: 24 November 2009 16:22
To: CMake List
Subject: [CMake] problem about Fortran and C mixing

Hi all,

I have decided to mix Fortran with C, due to a library that only has C interface. Here is the scienario:

suppose there are several programs, file1.f90, file2.f90, file3.c and a C library <lib>.

1. file1.f90 calls file2.f90 to generate a executable
2. file2.f90 calls file3.c to generate a module <mod>
3. file3.c calls <lib>

so how to setup CMakeLists.txt? Thanks for Help!

Best regards,

DONG Li
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091125/97e0532f/attachment-0001.htm>


More information about the CMake mailing list