diff --git a/SConstruct b/SConstruct index abd406f31..6d6ff9104 100644 --- a/SConstruct +++ b/SConstruct @@ -852,6 +852,21 @@ def config_error(message): if not conf.CheckCXXHeader('cmath', '<>'): config_error('The C++ compiler is not correctly configured.') + +def get_expression_value(includes, expression): + s = ['#include ' + i for i in includes] + s.extend(('#define Q(x) #x', + '#define QUOTE(x) Q(x)', + '#include ', + '#ifndef SUNDIALS_PACKAGE_VERSION', # name change in Sundials >= 3.0 + '#define SUNDIALS_PACKAGE_VERSION SUNDIALS_VERSION', + '#endif', + 'int main(int argc, char** argv) {', + ' std::cout << %s << std::endl;' % expression, + ' return 0;', + '}\n')) + return '\n'.join(s) + # Check for fmt library and checkout submodule if needed # Test for 'ostream.h' to ensure that version >= 3.0.0 is available if env['system_fmt'] in ('y', 'default'): @@ -912,12 +927,14 @@ if env['system_googletest'] in ('n', 'default'): if env['system_eigen'] in ('y', 'default'): if conf.CheckCXXHeader('Eigen/Dense', '<>'): env['system_eigen'] = True + print("""INFO: Using system installation of Eigen.""") 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 + print("""INFO: Using private installation of Eigen.""") 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.') @@ -932,20 +949,12 @@ if env['system_eigen'] in ('n', 'default'): '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] - s.extend(('#define Q(x) #x', - '#define QUOTE(x) Q(x)', - '#include ', - '#ifndef SUNDIALS_PACKAGE_VERSION', # name change in Sundials >= 3.0 - '#define SUNDIALS_PACKAGE_VERSION SUNDIALS_VERSION', - '#endif', - 'int main(int argc, char** argv) {', - ' std::cout << %s << std::endl;' % expression, - ' return 0;', - '}\n')) - return '\n'.join(s) +eigen_include = '' if env['system_eigen'] else '"../ext/eigen/Eigen/Core"' +eigen_versions = 'QUOTE(EIGEN_WORLD_VERSION) "." QUOTE(EIGEN_MAJOR_VERSION) "." QUOTE(EIGEN_MINOR_VERSION)' +eigen_version_source = get_expression_value([eigen_include], eigen_versions) +retcode, eigen_lib_version = conf.TryRun(eigen_version_source, '.cpp') +env['EIGEN_LIB_VERSION'] = eigen_lib_version.strip() +print('INFO: Found Eigen version {}'.format(env['EIGEN_LIB_VERSION'])) # Determine which standard library to link to when using Fortran to # compile code that links to Cantera @@ -954,8 +963,8 @@ env['HAS_LIBCPP'] = conf.CheckDeclaration('_LIBCPP_VERSION', '#include '], 'BOOST_LIB_VERSION') retcode, boost_lib_version = conf.TryRun(boost_version_source, '.cpp') -env['BOOST_LIB_VERSION'] = boost_lib_version.strip() -print('INFO: Found Boost version {0!r}'.format(env['BOOST_LIB_VERSION'])) +env['BOOST_LIB_VERSION'] = '.'.join(boost_lib_version.strip().split('_')) +print('INFO: Found Boost version {0}'.format(env['BOOST_LIB_VERSION'])) if not env['BOOST_LIB_VERSION']: config_error("Boost could not be found. Install Boost headers or set" " 'boost_inc_dir' to point to the boost headers.")