[SCons] Link Fortran sample programs to the correct standard library

This commit is contained in:
Ray Speth 2016-07-20 18:43:41 -04:00
parent 91161f0bc2
commit 3261b4108a
5 changed files with 31 additions and 5 deletions

View file

@ -828,6 +828,11 @@ def get_expression_value(includes, expression):
env['HAS_TIMES_H'] = conf.CheckCHeader('sys/times.h', '""')
env['HAS_UNISTD_H'] = conf.CheckCHeader('unistd.h', '""')
# Determine which standard library to link to when using Fortran to
# compile code that links to Cantera
env['HAS_GLIBCXX'] = conf.CheckDeclaration('__GLIBCXX__', '#include <iostream>', 'C++')
env['HAS_LIBCPP'] = conf.CheckDeclaration('_LIBCPP_VERSION', '#include <iostream>', 'C++')
boost_version_source = get_expression_value(['<boost/version.hpp>'], 'BOOST_LIB_VERSION')
retcode, boost_lib_version = conf.TryRun(boost_version_source, '.cpp')
env['BOOST_LIB_VERSION'] = boost_lib_version.strip()

View file

@ -42,7 +42,7 @@ CANTERA_CORE_FTN=-L@ct_libdir@ -lcantera_fortran @mak_corelibs@
CANTERA_FORTRAN_MODS=$(CANTERA_INSTALL_ROOT)/include/cantera
CANTERA_FORTRAN_SYSLIBS=@mak_fort_threadflags@ -lstdc++
CANTERA_FORTRAN_SYSLIBS=@mak_fort_threadflags@ @mak_stdlib@
###############################################################################
# BOOST

View file

@ -42,6 +42,13 @@ pc_incdirs.extend(localenv['extra_inc_dirs'])
localenv['mak_extra_libdirs'] = ' '.join('-L%s' % s for s in localenv['extra_lib_dirs'])
pc_libdirs.extend(localenv['extra_lib_dirs'])
if env['HAS_GLIBCXX']:
localenv['mak_stdlib'] = '-lstdc++'
elif env['HAS_LIBCPP']:
localenv['mak_stdlib'] = '-lc++'
else:
localenv['mak_stdlib'] = ''
if localenv['system_sundials']:
# Add links to the sundials environment
localenv['mak_sundials_libs'] = ' '.join('-l%s' % s

View file

@ -3,6 +3,13 @@ from buildutils import *
Import('env', 'install', 'buildSample')
localenv = env.Clone()
if env['HAS_GLIBCXX']:
stdlib = ['stdc++']
elif env['HAS_LIBCPP']:
stdlib = ['c++']
else:
stdlib = []
# (program name, [source files])
samples = [('ctlib', ['ctlib.f']),
('isentropic', ['isentropic.f'])]
@ -13,14 +20,14 @@ for program_name, fortran_sources in samples:
buildSample(localenv.Program, program_name,
fortran_sources + ftn_demo,
CPPPATH=['#build/src/fortran', '#include'],
LIBS=env['cantera_libs']+['cantera_fortran']+['stdc++'],
LIBS=env['cantera_libs']+['cantera_fortran']+stdlib,
LIBPATH=[env['sundials_libdir'], '#build/lib'],
LINK='$F77')
# Generate SConstruct file to be installed
incdirs = (localenv['ct_incroot'], localenv['sundials_include'],
localenv['boost_inc_dir']) + tuple(localenv['extra_inc_dirs'])
libs = ['cantera_fortran'] + localenv['cantera_libs'] + ['stdc++']
libs = ['cantera_fortran'] + localenv['cantera_libs'] + stdlib
libdirs = ((localenv['ct_libdir'], localenv['sundials_libdir'],
localenv['blas_lapack_dir']) + tuple(localenv['extra_lib_dirs']))
linkflags = ('-g', localenv['thread_flags'])

View file

@ -3,18 +3,25 @@ from buildutils import *
Import('env', 'install', 'buildSample')
localenv = env.Clone()
if env['HAS_GLIBCXX']:
stdlib = ['stdc++']
elif env['HAS_LIBCPP']:
stdlib = ['c++']
else:
stdlib = []
# (program name, [source files])
samples = [('demo', ['demo.f90'])]
for programName, sources in samples:
buildSample(localenv.Program, programName, sources,
F90PATH='#build/src/fortran',
LIBS=['cantera_fortran']+env['cantera_libs']+['stdc++'],
LIBS=['cantera_fortran']+env['cantera_libs']+stdlib,
LIBPATH=[env['sundials_libdir'], '#build/lib'])
# Generate SConstruct files to be installed
incdirs = [pjoin(localenv['ct_incroot'], 'cantera')] + localenv['extra_inc_dirs']
libs = ['cantera_fortran'] + localenv['cantera_libs'] + ['stdc++']
libs = ['cantera_fortran'] + localenv['cantera_libs'] + stdlib
libdirs = ((localenv['ct_libdir'], localenv['sundials_libdir'],
localenv['blas_lapack_dir']) + tuple(localenv['extra_lib_dirs']))
linkflags = ('-g', localenv['thread_flags'])