[CMake] CMake thinks Fortran is C++ when linking statically
erlend.pedersen at holberger.com
Tue May 10 06:19:06 EDT 2011
I am having problems with Fortran linking that doesn't work when
building static libraries, only when building shared libraries. I am
using cmake from Ubuntu 10.04 (2.8.0-5ubuntu1).
I use CMake to build a project, including project-internal shared
libraries. All executables are Fortran, but one of the internal
libraries contain minimal sprinklings of C and C++. All works well when
building shared libraries, but when I switch to building static
libraries, CMake decides to try to link all Fortran executables as if
they were C++. Unfortunately, this means that the main function is not
properly located, and linking fails.
I tried forcing Fortran linkage on libraries only (hoping this would
propagate into the executables that link to them), using
SET_TARGET_PROPERTIES(<libname> PROPERTIES LINKER_LANGUAGE Fortran)
and when building the libraries, output shows that they are indeed
treated as Fortran static libraries. But the executables (typically
conisting of a single .f90 file, and linked to one or more of the
internal libraries) are still treated as C++.
Only when I force the LINKER_LANGUAGE by using SET_TARGET_PROPERTIES on
both libraries and executables does things build properly. But that
seems needlessly redundant and noisy and redundant.
Is there some easier way I can convince CMake to link the executables
correctly? Is this a bug?
Holberg Research AS
More information about the CMake