Files
cantera/ext/SConscript
Ray Speth 7edc16d7c1 [SCons] Use more generic flag for warning suppression
Older versions of Clang don't support '-Wno-unused-result'.
2014-02-24 03:25:15 +00:00

148 lines
4.6 KiB
Python

from buildutils import *
Import('env', 'build', 'install', 'libraryTargets')
localenv = env.Clone()
def prep_default(env):
localenv = env.Clone()
# Suppress warnings from external code and auto-generated code
if 'g++' in localenv['CXX'] or 'clang' in localenv['CXX']:
localenv.Append(CCFLAGS='-w')
return localenv
def prep_fortran(env):
localenv = prep_default(env)
localenv.Prepend(CPPPATH='#include/cantera/base') # for config.h
return localenv
def prep_f2c(env):
localenv = prep_default(env)
localenv.Prepend(CPPPATH=Dir('#ext/f2c_libs'))
if not localenv['HAS_TIMES_H']:
localenv.Append(CPPDEFINES=['USE_CLOCK'])
if not localenv['HAS_UNISTD_H']:
localenv.Append(CPPDEFINES=['MSDOS'])
if env['VERBOSE']:
print "INFO 2: prep_f2c: adding MSDOS to CPPDEFINES"
print "INFO 2: CPPDEFINES ", localenv['CPPDEFINES']
return localenv
def prep_sundials(env):
localenv = prep_default(env)
localenv.Prepend(CPPPATH=Dir('#ext/cvode/include'))
return localenv
def prep_gtest(env):
localenv = prep_default(env)
localenv.Prepend(CPPPATH=[Dir('#ext/gtest'),
Dir('#ext/gtest/include')],
CPPDEFINES={'GTEST_HAS_PTHREAD': 0})
return localenv
# libs is a list of length 3
# 0 subdir for execution
# 1 file extension
# 2 function pointer
# (subdir, (file extensions), prepfunction)
libs = [('libexecstream', ['cpp'], prep_default)]
if env['build_with_f2c']:
libs.append(('f2c_math', ['cpp','c'], prep_f2c))
# Create arith.h using the arithchk program
if not os.path.exists('arith.h'):
arithenv = prep_f2c(env)
# TODO: make link flag more general
arithenv.Append(CPPFLAGS='-DNO_FPINIT')
arithenv.Program('f2c_libs/arithchk/arithchk', source='f2c_libs/arithchk/arithchk.c',
LIBS=env['LIBM'])
arithenv.Command('#ext/f2c_libs/arith.h', 'f2c_libs/arithchk/arithchk$PROGSUFFIX',
'$SOURCE > $TARGET')
libs.append(('f2c_libs', 'c', prep_f2c))
if env['BUILD_BLAS_LAPACK']:
libs.append(('f2c_blas', ['c'], prep_f2c))
libs.append(('f2c_lapack', ['c'], prep_f2c))
else:
libs.append(('math', ['cpp','c','f'], prep_fortran))
if env['BUILD_BLAS_LAPACK']:
libs.append(('blas', ['f'], prep_default))
libs.append(('lapack', ['f'], prep_default))
if env['use_sundials'] == 'n':
libs.append(('cvode/source', ['c'], prep_sundials))
for subdir, extensions, prepFunction in libs:
if env['VERBOSE']:
print 'INFO 2: Prep the environment for ', subdir,
print ' with extensions ', extensions,
print ' by calling func ', prepFunction.__name__
localenv = prepFunction(env)
if localenv['single_library']:
objects = localenv.SharedObject(mglob(localenv, subdir, *extensions))
libraryTargets.extend(objects)
else:
libName = 'ct' + subdir
if libName == 'ctf2c_blas':
libName = 'ctblas'
if libName == 'ctf2c_lapack':
libName = 'ctlapack'
if libName == 'ctf2c_math':
libName = 'ctmath'
if libName == 'ctcvode/source':
libName = 'cvode'
if libName == 'ctlibexecstream':
libName = 'execstream'
if libName == 'ctf2c_libs':
libName = 'ctf2c'
if localenv['renamed_shared_libraries']:
sharedLibName = libName + '_shared'
else:
sharedLibName = libName
if env['VERBOSE']:
print "INFO 2:", subdir, ' with ', extensions
print " libName = ", libName, " sharedLibName = ", sharedLibName
objects = localenv.SharedObject(mglob(localenv, subdir, *extensions))
# Build the static library
lib = build(localenv.StaticLibrary(pjoin('..', 'lib', libName), objects))
install('$inst_libdir', lib)
# Build the shared library
liby = build(localenv.SharedLibrary(pjoin('..', 'lib', sharedLibName), objects))
install('$inst_libdir', liby)
# Google Test: Used internally for Cantera unit tests. Optionally, the headers
# and compiled library can be installed alongside Cantera using the scons
# option 'install_gtest=y'.
localenv = prep_gtest(env)
gtest = build(localenv.Library(pjoin('../lib', 'gtest'),
source=['gtest/src/gtest-all.cc']))
if localenv['install_gtest']:
# install the static library
install('$inst_libdir', gtest)
# install the header files
install(localenv.RecursiveInstall, '$inst_incroot', '#/ext/gtest/include')