mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
Add option to compile yaml-cpp or use system library
This commit is contained in:
36
SConstruct
36
SConstruct
@@ -440,6 +440,14 @@ config_options = [
|
||||
('y'), from a Git submodule ('n'), or to decide automatically
|
||||
('default').""",
|
||||
'default', ('default', 'y', 'n')),
|
||||
EnumVariable(
|
||||
'system_yamlcpp',
|
||||
"""Select whether to use the yaml-cpp library from a system installation
|
||||
('y'), from a Git submodule ('n'), or to decide automatically
|
||||
('default'). If yaml-cpp is not installed directly into system
|
||||
include and library directories, then you will need to add those
|
||||
directories to 'extra_inc_dirs' and 'extra_lib_dirs'.""",
|
||||
'default', ('default', 'y', 'n')),
|
||||
EnumVariable(
|
||||
'system_sundials',
|
||||
"""Select whether to use SUNDIALS from a system installation ('y'), from
|
||||
@@ -908,6 +916,33 @@ elif env['system_googletest'] == 'y':
|
||||
elif env['system_googletest'] == 'n':
|
||||
env['googletest'] = 'submodule'
|
||||
|
||||
# Check for yaml-cpp library and checkout submodule if needed
|
||||
if env['system_yamlcpp'] in ('y', 'default'):
|
||||
if conf.CheckCXXHeader('yaml-cpp/yaml.h', '""'):
|
||||
env['system_yamlcpp'] = True
|
||||
print("""INFO: Using system installation of yaml-cpp library.""")
|
||||
|
||||
elif env['system_yamlcpp'] == 'y':
|
||||
config_error('Expected system installation of yaml-cpp library, but it '
|
||||
'could not be found.')
|
||||
|
||||
if env['system_yamlcpp'] in ('n', 'default'):
|
||||
env['system_yamlcpp'] = False
|
||||
print("""INFO: Using private installation of yaml-cpp library.""")
|
||||
if not os.path.exists('ext/yaml-cpp/include/yaml-cpp/yaml.h'):
|
||||
if not os.path.exists('.git'):
|
||||
config_error('yaml-cpp is missing. Install source in ext/yaml-cpp.')
|
||||
|
||||
try:
|
||||
code = subprocess.call(['git', 'submodule', 'update', '--init',
|
||||
'--recursive', 'ext/yaml-cpp'])
|
||||
except Exception:
|
||||
code = -1
|
||||
if code:
|
||||
config_error('yaml-cpp submodule checkout failed.\n'
|
||||
'Try manually checking out the submodule with:\n\n'
|
||||
' git submodule update --init --recursive ext/yaml-cpp\n')
|
||||
|
||||
# Check for googletest and checkout submodule if needed
|
||||
if env['googletest'] in ('system', 'default'):
|
||||
has_gtest = conf.CheckCXXHeader('gtest/gtest.h', '""')
|
||||
@@ -1444,6 +1479,7 @@ cdefine('LAPACK_NAMES_LOWERCASE', 'lapack_names', 'lower')
|
||||
cdefine('CT_USE_LAPACK', 'use_lapack')
|
||||
cdefine('CT_USE_SYSTEM_EIGEN', 'system_eigen')
|
||||
cdefine('CT_USE_SYSTEM_FMT', 'system_fmt')
|
||||
cdefine('CT_USE_SYSTEM_YAMLCPP', 'system_yamlcpp')
|
||||
|
||||
config_h_build = env.Command('build/src/config.h.build',
|
||||
'include/cantera/base/config.h.in',
|
||||
|
||||
@@ -82,6 +82,24 @@ if env['system_sundials'] == 'n':
|
||||
libraryTargets.extend(localenv.SharedObject(
|
||||
[f for f in mglob(localenv, 'sundials/src/'+subdir, 'c')]))
|
||||
|
||||
if not env['system_yamlcpp']:
|
||||
localenv = prep_default(env)
|
||||
localenv.Prepend(CPPPATH=Dir('#include/cantera/ext'))
|
||||
license_files.append(('YAML-CPP', 'yaml-cpp/LICENSE'))
|
||||
|
||||
# Copy header files into common include directory
|
||||
for subdir in ('', 'contrib', 'node', 'node/detail'):
|
||||
for header in mglob(env, 'yaml-cpp/include/yaml-cpp/'+subdir, 'h'):
|
||||
h = build(localenv.Command('#include/cantera/ext/yaml-cpp/{}/{}'.format(subdir, header.name),
|
||||
'#ext/yaml-cpp/include/yaml-cpp/{}/{}'.format(subdir, header.name),
|
||||
Copy('$TARGET', '$SOURCE')))
|
||||
|
||||
# Compile yaml-cpp source files
|
||||
for subdir in ('', 'contrib'):
|
||||
libraryTargets.extend(localenv.SharedObject(
|
||||
[f for f in mglob(localenv, 'yaml-cpp/src/'+subdir, 'cpp')]))
|
||||
|
||||
|
||||
if not env['system_eigen']:
|
||||
license_files.append(('Eigen', 'eigen/COPYING.MPL2'))
|
||||
h = build(copyenv.Command('#include/cantera/ext/Eigen', '#ext/eigen/Eigen',
|
||||
|
||||
@@ -44,6 +44,7 @@ typedef int ftnlen; // Fortran hidden string length type
|
||||
|
||||
%(CT_USE_SYSTEM_EIGEN)s
|
||||
%(CT_USE_SYSTEM_FMT)s
|
||||
%(CT_USE_SYSTEM_YAMLCPP)s
|
||||
|
||||
//--------- operating system --------------------------------------
|
||||
|
||||
|
||||
6
include/cantera/base/yaml.h
Normal file
6
include/cantera/base/yaml.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#include "cantera/base/ct_defs.h"
|
||||
#if CT_USE_SYSTEM_YAMLCPP
|
||||
#include "yaml-cpp/yaml.h"
|
||||
#else
|
||||
#include "cantera/ext/yaml-cpp/yaml.h"
|
||||
#endif
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "cantera/kinetics/Reaction.h"
|
||||
#include "cantera/base/stringUtils.h"
|
||||
#include "cantera/base/ctml.h"
|
||||
#include "cantera/base/yaml.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user