[CMake] Fortan and C++

Dominik Szczerba dominik at itis.ethz.ch
Sat Aug 22 03:00:55 EDT 2009


Michael,
Many thanks for the feedback.
What I am doing with a GNU makefile so far is compile just one file with 
the fortran compiler use C++ linker to link all object files as usual.
A comprehensive solution I would expect in cmake would be 1) nothing 
(.f90 file is understood) or something along the lines of setting the 
file properties (sort of 'to be compiler with' flag)...

- Dominik

Michael Wild wrote:
> 
> 
> 
> On 21.08.2009, at 17:57, Dominik Szczerba <dominik at itis.ethz.ch> wrote:
> 
>> I want to compile one file with fortran compiler (intel) and link  
>> with the rest of my project. Will the latest cmake allow to fully  
>> cmakify such scenario?
> 
> Hi Dominik
> 
> If I remember correctly, you'll have to set the LINK_LANGUAGE property  
> of your target to Fortran and then ensure that the Fortran linker also  
> links against the C++ standard library. For Intel this would be -stdc+ 
> + (or some such). If you are creating an executable, depending on  
> where your main-function is defined, you might also need to tell the  
> linker to not add a Fortran main-function, the flag is called - 
> nofor_main if I remember correctly. Otherwise the ifort man-page will  
> tell you :)
> 
> 
> HTH
> 
> Michael 
>   
> 


-- 
d o m i n i k   s z c z e r b a ,   p h d . . . . . . . . . . .
c o m p u t a t i o n a l   l i f e   s c i e n c e   g r o u p
. . . . . . . i t ' i s   r e s e a r c h   f o u n d a t i o n
. . . . . . . . . . . . . . . . . . . . http://www.itis.ethz.ch



More information about the CMake mailing list