[SCons] Make check for Fortran compiler more robust
If we can compile and run an F90 program that is sufficient. The previous test required the C compiler to be able to link to the Fortran standard library, which isn't actually necessary, and would fail in some cases (such as brew-installed gfortran on OS X).
This commit is contained in:
parent
8ef4f6445f
commit
91161f0bc2
1 changed files with 13 additions and 13 deletions
26
SConstruct
26
SConstruct
|
|
@ -918,22 +918,21 @@ else: # env['system_sundials'] == 'n'
|
|||
|
||||
|
||||
# Try to find a working Fortran compiler:
|
||||
fortran_libs = {'gfortran':'gfortran', 'g95':'f95'}
|
||||
def check_fortran(compiler, expected=False):
|
||||
hello_world = '''
|
||||
program main
|
||||
write(*,'(a)') 'Hello, world!'
|
||||
end program main
|
||||
'''
|
||||
if which(compiler) is not None:
|
||||
lib = fortran_libs.get(compiler)
|
||||
if lib:
|
||||
have_lib = conf.CheckLib(lib)
|
||||
if have_lib:
|
||||
env['FORTRAN'] = compiler
|
||||
return True
|
||||
else:
|
||||
print ("WARNING: Unable to use '%s' to compile the Fortran "
|
||||
"interface because the library '%s' could not be found." %
|
||||
(compiler, lib))
|
||||
else:
|
||||
env['FORTRAN'] = compiler
|
||||
env['FORTRAN'] = compiler
|
||||
success, output = conf.TryRun(hello_world, '.f90')
|
||||
if success and 'Hello, world!' in output:
|
||||
return True
|
||||
else:
|
||||
print ("WARNING: Unable to use '%s' to compile the Fortran "
|
||||
"interface. See config.log for details." % compiler)
|
||||
return False
|
||||
elif expected:
|
||||
print "ERROR: Couldn't find specified Fortran compiler: '%s'" % compiler
|
||||
sys.exit(1)
|
||||
|
|
@ -959,6 +958,7 @@ if env['f90_interface'] in ('y','default'):
|
|||
sys.exit(1)
|
||||
else:
|
||||
env['f90_interface'] = 'n'
|
||||
env['FORTRAN'] = ''
|
||||
print "INFO: Skipping compilation of the Fortran 90 interface."
|
||||
|
||||
if 'gfortran' in env['FORTRAN']:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue