[CMake] Spurious test failure in CMakeTestFortranCompiler

Neil Carlson neil.n.carlson at gmail.com
Mon Jul 1 12:17:53 EDT 2013


It's easy (in this case at least) to modify the test program.  Replace
the second line of this program (from CMakeTestFortranCompiler)

      PROGRAM TESTFortran90
      stop = 1 ; do while ( stop .eq. 0 ) ; end do
      END PROGRAM TESTFortran90

with

      integer stop; stop = 1 ; do while ( stop .eq. 0 ) ; end do

(Note that the implicit typing rules of Fortran meant that stop was
a real variable in the original program -- not that it particularly
mattered.)

In other Fortran test code, including that specifically for F77 compilers,
just explicitly declaring the types of all variables will keep the "-u" flag
from breaking the test.

I think there is a larger issue here though.  I assume that the intent
of CMakeTestFortranCompiler is generally to probe the language capabilities
of the compiler.  If so, I can imagine there being certain flags that would
be
relevant to this, like a "-f95" flag which sets the compiler to F95
language level,
while others like debug or optimization flags that would be totally
irrelevant
and perhaps shouldn't even be used to avoid unintended consequences.
Is there a second set of variables (CMAKE_Fortran_FLAGS_DEBUG e.g.)
that ought to be used for the latter category of flags which get appended
automatically to the flags from CMAKE_Fortran_FLAGS when compiling
actual project code?  (I'm still very new to cmake)

-Neil






On Mon, Jul 1, 2013 at 9:20 AM, Brad King <brad.king at kitware.com> wrote:

> On 6/30/2013 11:10 PM, Neil Carlson wrote:
> > Why is that module using CMake_Fortran_FLAGS at all?  Shouldn't it be
> > invoking the bare compiler when it runs its tests?  Or am I misusing
> > CMake_Fortran_FLAGS?  Should I be defining its value at a later stage in
> > the cmake files?
>
> The test for a working compiler is building a tiny project
> using all the settings that will be used in the main project.
> This checks up front that things are configured correctly for
> the build you're trying to do rather than waiting for a build
> failure much later.
>
> CMAKE_Fortran_FLAGS could have flags affecting the target
> architecture and such, so we need to use them for the test.
>
> You can work around this by waiting until after the project()
> or enable_language() command that loads Fortran support to
> add the -u flag.  However, if we can modify the test code that
> CMake uses to verify the toolchain so that it works with that
> flag then we should do so.  How might the tiny project source
> have to be modified to work?  Will it still be compatible with
> F77 compilers?
>
> -Brad
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130701/380a8c90/attachment.htm>


More information about the CMake mailing list