[CMake] How to find fortran library
Maik Beckmann
beckmann.maik at googlemail.com
Thu Dec 4 02:13:51 EST 2008
Am Mittwoch, 3. Dezember 2008 schrieb Javier Gonzalez:
> Hi all,
>
> I have a project that links to another project built with Fortran. My
> own project is a C++ project and I usually need to link against a
> fortran library of some sort to use the first one. I use gcc, so it
> usually is libgfortran or libg2c.
>
> Now my question is: if I enable Fortran, will there be a variable that
> tells me the location of the library I need to link to?
No. The compiler frontend (gfortran, g77, ...) makes the decision which
system and compiler libraries have to be linked in.
If you or cmake link an fortran executable with
g77 -o myapp a.o b.o ..
libg2c will be linked in by g77. When doing
g77 -o myapp a.o b.o ..
libgfortran will be linked in by gfortran.
The same is true for g++, which links in libstdc++ by default.
> What I do at the moment is that I guess which library I need to link to
> based on the Fortran compiler's name and, since I use gcc, try to find
> it in the path given by 'gcc -print-search-dirs'. Is this the right way?
> I would expect that cmake defines a variable with this information
> somewhere.
This is the right way. Maybe an effort to write cmake module which handles
this task is worthy.
Best,
-- Maik
More information about the CMake
mailing list