[CMake] Mixing C++ and Fortran

Bill Hoffman bill.hoffman at kitware.com
Tue Jan 29 12:21:24 EST 2008


Honest Guvnor wrote:
> On Jan 29, 2008 3:33 PM, Bill Hoffman <bill.hoffman at kitware.com> wrote:
> 
>> Well, you are sort of stuck...
> 
> That is  surprising. The combination of C++ (GUI) and Fortran
> (science/engineering number crunching) is going to be a common one and
> I had assumed I was doing something wrong.
> 
> Is there no cmake variable for the fortran library I can add to the
> list of what to link?
> 
>> You might be able to put the fortran stuff in a shared library and have
>> the fortran runtime pulled in that way.
> 
> Perhaps but a number of tools/problems push us towards using static
> libraries at least when developing.
> 
>>  You could write some fancy
>> find_* fortran stuff using try-compile that finds out the fortran run
>> time library.
> 
> If this is what is required has nobody done it years ago?
> 
Good Fortran support is relatively new to CMake.  In fact, CVS CMake is 
really the only version that handles all the Fortran depend stuff 
reliably.  CMake relies on the compiler to provide the correct run time 
libraries.  If you build with a C++ compiler, it will automatically link 
in the run time libraries for C++ that go with that compiler.  If you 
link with a fortran compiler, it will get the run time libraries for the 
fortran compiler.  So, CMake has not had to "care" about system runtime 
libraries.  It is easy to mix C with anything because both Fortran and 
C++ always link in the C runtime libraries by default.    Anyway, it is 
what it is.  If you figure something out, we could add it to the cmake 
modules directory.

-Bill


More information about the CMake mailing list