[CMake] adjusting CMAKE_Fortran_LINK_EXECUTABLE

Brad King brad.king at kitware.com
Thu Mar 10 09:07:09 EST 2011


On 03/10/2011 03:48 AM, Ilias Miroslav wrote:
> By default, the current CMAKE_Fortran_LINK_EXECUTABLE consists of several variables:
> 
> "<CMAKE_Fortran_COMPILER>  <CMAKE_Fortran_LINK_FLAGS> <LINK_FLAGS> <FLAGS> <OBJECTS>  -o <TARGET> <LINK_LIBRARIES>"
[snip]
> selected variables only: "<LINK_FLAGS>  <OBJECTS>  -o <TARGET>  <LINK_LIBRARIES>"

The <FLAGS> are in there because there are cases where the compiler front-end
needs to know what compilation flags were used to produce the object files
to adjust the flags and libraries it passes to the underlying linker.

> The "-ffast-math"flag  works for compilation of fortran source codes,
> but is unsuitable for g95-linking in this case.

Perhaps this change should be extended for executables too:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=88bd3b52

Then -ffast-math could be added to the forbidden flag list for linking.

Meanwhile one can work around this problem by not putting -ffast-math
in CMAKE_Fortran_FLAGS.  Instead add it to each target that needs it
using the COMPILE_FLAGS target property.

-Brad


More information about the CMake mailing list