[SCons] Make Eigen available to Cantera

Check for a system copy of Eigen, and if that is not found, install
Eigen's headers with the Cantera headers. Add the header 'eigen_dense.h'
to provide a single header to include from other locations.
This commit is contained in:
Ray Speth
2016-04-09 22:31:40 -04:00
parent 41a357aec0
commit bf67cce25f
4 changed files with 42 additions and 0 deletions

View File

@@ -407,6 +407,11 @@ config_options = [
'sphinx_cmd',
"""Command to use for building the Sphinx documentation.""",
'sphinx-build', PathVariable.PathAccept),
EnumVariable(
'system_eigen',
"""Select whether to use Eigen from a system installation ('y'), from
a git submodule ('n'), or to decide automatically ('default').""",
'default', ('default', 'y', 'n')),
EnumVariable(
'system_sundials',
"""Select whether to use Sundials from a system installation ('y'), from
@@ -771,6 +776,30 @@ if env['system_googletest'] in ('n', 'default'):
'Try manually checking out the submodule with:\n\n'
' git submodule update --init --recursive ext/googletest\n')
# Check for Eigen and checkout submodule if needed
if env['system_eigen'] in ('y', 'default'):
if conf.CheckCXXHeader('Eigen/Dense', '<>'):
env['system_eigen'] = True
elif env['system_eigen'] == 'y':
config_error('Expected system installation of Eigen, but it '
'could not be found.')
if env['system_eigen'] in ('n', 'default'):
env['system_eigen'] = False
if not os.path.exists('ext/eigen/Eigen/Dense'):
if not os.path.exists('.git'):
config_error('Eigen is missing. Install Eigen in ext/eigen.')
try:
code = subprocess.call(['git','submodule','update','--init',
'--recursive','ext/eigen'])
except Exception:
code = -1
if code:
config_error('Eigen not found and submodule checkout failed.\n'
'Try manually checking out the submodule with:\n\n'
' git submodule update --init --recursive ext/eigen\n')
def get_expression_value(includes, expression):
s = ['#include ' + i for i in includes]
@@ -1222,6 +1251,7 @@ cdefine('LAPACK_FTN_TRAILING_UNDERSCORE', 'lapack_ftn_trailing_underscore')
cdefine('FTN_TRAILING_UNDERSCORE', 'lapack_ftn_trailing_underscore')
cdefine('LAPACK_NAMES_LOWERCASE', 'lapack_names', 'lower')
configh['CT_USE_LAPACK'] = 0 if env['BUILD_BLAS_LAPACK'] else 1
cdefine('CT_USE_SYSTEM_EIGEN', env['system_eigen'])
config_h = env.Command('include/cantera/base/config.h',
'include/cantera/base/config.h.in',

View File

@@ -111,6 +111,10 @@ if env['system_sundials'] == 'n':
[f for f in mglob(localenv, 'sundials/src/'+subdir, 'c')
if '_klu' not in f.name and '_superlumt' not in f.name]))
if not env['system_eigen']:
build(localenv.Command('#include/cantera/ext/Eigen', '#ext/eigen/Eigen',
Copy('$TARGET', '$SOURCE')))
# Google Test: Used internally for Cantera unit tests.
if not env['system_googletest']:
localenv = prep_gtest(env)

View File

@@ -42,6 +42,8 @@ typedef int ftnlen; // Fortran hidden string length type
%(LAPACK_FTN_TRAILING_UNDERSCORE)s
%(CT_USE_LAPACK)s
%(CT_USE_SYSTEM_EIGEN)s
//--------- operating system --------------------------------------
// The configure script defines this if the operating system is Mac

View File

@@ -0,0 +1,6 @@
#include "cantera/base/ct_defs.h"
#if CT_USE_SYSTEM_EIGEN
#include <Eigen/Dense>
#else
#include "cantera/ext/Eigen/Dense"
#endif