[CMake] gfortran/CheckFortranFunctionExists.cmake issue with 2.6.0
Alan W. Irwin
irwin at beluga.phys.uvic.ca
Thu Jun 19 14:06:31 EDT 2008
CheckFortranFunctionExists.cmake (originally implemented by me and
now maintained by Alin Elena in CMake cvs) does not work properly with
gfortran. The issue is the bit of test code that reads as follows:
FILE(WRITE
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f
"
program TESTFortran
external ${FUNCTION}
end
"
try_compile of this test code always succeeds with gfortran regardless of
FUNCTION. To test this for yourself, try to compile
program TESTFortran
external whatever
end
by had with gfortran. At least for the version (GNU Fortran (Debian
4.3.0-5) 4.3.1 20080523 (prerelease)) of gfortran on Debian testing, it
always succeeds.
OTOH, g77 (on an oldstable version of Debian that I have access to) always
fails:
irwin at chickadee> g77 test.f
/tmp/ccIek6VL.o(.data+0x0): undefined reference to whatever_'
collect2: ld returned 1 exit status
Does anybody know why gfortran is essentially ignoring the external statement
for linking? Is that a gfortran bug? Or is that a new fortran standard that
I am not aware of?
Regardless of the cause of this problem, with both g77 and gfortran I get
the proper results (success if the function exists, failure if not) if I
change
external ${FUNCTION}
==>
call ${FUNCTION}()
within CheckFortranFunctionExists.cmake.
Alin and Brad (and any other Fortran experts here who care to comment) do
you think this change to using "call" rather than "external" will work for
most/all other fortran compilers?
If so, I will put in the appropriate bug fix request for 2.6.1.
Alan
__________________________
Alan W. Irwin
Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).
Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________
Linux-powered Science
__________________________
More information about the CMake
mailing list