[CMake] Auxiliary fortran link libraries?

Brad King brad.king at kitware.com
Mon Jul 19 08:35:41 EDT 2010


On 07/18/2010 09:10 PM, John Cary wrote:
> Thanks for your help with this.  I did
> INCLUDE(FortranCInterface), but I did not
> see in CMakeCache.txt any variables that
> might contain the fortran libs needed by
> the C/C++ linkers (e.g., libgfortran).
> Did I miss something?

The FortranCInterface module detects the *mangling* of Fortran symbols
with respect to C and does not deal with implicit Fortran library
dependencies.  CMake 2.8 automatically handles the implicit libraries
for mixed-language binaries.

After configuring your build tree look in CMakeFiles/CMake*Compiler.cmake.
There are variables like these:

SET(CMAKE_C_IMPLICIT_LINK_LIBRARIES "...")
SET(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "...")
SET(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "stdc++;...")
SET(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "...")
SET(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "gfortranbegin;gfortran;...")
SET(CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES "...")

However, you should never need to reference them explicitly.  When CMake
generates the link line for a binary that includes both Fortran and C++
we automatically use these variables to list the libraries not known to
be implicitly linked by the compiler used to drive the linker.

-Brad


More information about the CMake mailing list