Use system-installed version of fmt library if available
Resolves #348.
This commit is contained in:
parent
4e23793ebd
commit
d4ddabc76c
10 changed files with 59 additions and 24 deletions
48
SConstruct
48
SConstruct
|
|
@ -412,6 +412,12 @@ config_options = [
|
|||
"""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_fmt',
|
||||
"""Select whether to use the fmt library 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
|
||||
|
|
@ -730,19 +736,32 @@ if not conf.CheckCXXHeader('cmath', '<>'):
|
|||
config_error('The C++ compiler is not correctly configured.')
|
||||
|
||||
# Check for fmt library and checkout submodule if needed
|
||||
if not os.path.exists('ext/fmt/fmt/format.h'):
|
||||
if not os.path.exists('.git'):
|
||||
config_error('fmt is missing. Install source in ext/fmt.')
|
||||
# Test for 'ostream.h' to ensure that version >= 3.0.0 is available
|
||||
if env['system_fmt'] in ('y', 'default'):
|
||||
if conf.CheckCXXHeader('fmt/ostream.h', '""'):
|
||||
env['system_fmt'] = True
|
||||
print """INFO: Using system installation of fmt library."""
|
||||
|
||||
try:
|
||||
code = subprocess.call(['git','submodule','update','--init',
|
||||
'--recursive','ext/fmt'])
|
||||
except Exception:
|
||||
code = -1
|
||||
if code:
|
||||
config_error('fmt submodule checkout failed.\n'
|
||||
'Try manually checking out the submodule with:\n\n'
|
||||
' git submodule update --init --recursive ext/fmt\n')
|
||||
elif env['system_fmt'] == 'y':
|
||||
config_error('Expected system installation of fmt library, but it '
|
||||
'could not be found.')
|
||||
|
||||
if env['system_fmt'] in ('n', 'default'):
|
||||
env['system_fmt'] = False
|
||||
print """INFO: Using private installation of fmt library."""
|
||||
if not os.path.exists('ext/fmt/fmt/format.h'):
|
||||
if not os.path.exists('.git'):
|
||||
config_error('fmt is missing. Install source in ext/fmt.')
|
||||
|
||||
try:
|
||||
code = subprocess.call(['git','submodule','update','--init',
|
||||
'--recursive','ext/fmt'])
|
||||
except Exception:
|
||||
code = -1
|
||||
if code:
|
||||
config_error('fmt submodule checkout failed.\n'
|
||||
'Try manually checking out the submodule with:\n\n'
|
||||
' git submodule update --init --recursive ext/fmt\n')
|
||||
|
||||
# Check for googletest and checkout submodule if needed
|
||||
if env['system_googletest'] in ('y', 'default'):
|
||||
|
|
@ -1242,6 +1261,7 @@ cdefine('FTN_TRAILING_UNDERSCORE', 'lapack_ftn_trailing_underscore')
|
|||
cdefine('LAPACK_NAMES_LOWERCASE', 'lapack_names', 'lower')
|
||||
cdefine('CT_USE_LAPACK', 'use_lapack')
|
||||
cdefine('CT_USE_SYSTEM_EIGEN', env['system_eigen'])
|
||||
cdefine('CT_USE_SYSTEM_FMT', 'system_fmt')
|
||||
|
||||
config_h = env.Command('include/cantera/base/config.h',
|
||||
'include/cantera/base/config.h.in',
|
||||
|
|
@ -1335,6 +1355,10 @@ if env['blas_lapack_libs']:
|
|||
linkLibs.extend(env['blas_lapack_libs'])
|
||||
linkSharedLibs.extend(env['blas_lapack_libs'])
|
||||
|
||||
if env['system_fmt']:
|
||||
linkLibs.append('fmt')
|
||||
linkSharedLibs.append('fmt')
|
||||
|
||||
# Store the list of needed static link libraries in the environment
|
||||
env['cantera_libs'] = linkLibs
|
||||
env['cantera_shared_libs'] = linkSharedLibs
|
||||
|
|
|
|||
|
|
@ -26,12 +26,11 @@ def prep_gtest(env):
|
|||
def prep_fmt(env):
|
||||
localenv = prep_default(env)
|
||||
license_files.append(('fmtlib', 'fmt/LICENSE.rst'))
|
||||
build(localenv.Command("#include/cantera/ext/fmt/format.h",
|
||||
"#ext/fmt/fmt/format.h",
|
||||
Copy('$TARGET', '$SOURCE')))
|
||||
build(localenv.Command("#include/cantera/ext/fmt/ostream.h",
|
||||
"#ext/fmt/fmt/ostream.h",
|
||||
Copy('$TARGET', '$SOURCE')))
|
||||
if not env['system_fmt']:
|
||||
for name in ('format.h', 'ostream.h'):
|
||||
build(localenv.Command("#include/cantera/ext/fmt/" + name,
|
||||
"#ext/fmt/fmt/" + name,
|
||||
Copy('$TARGET', '$SOURCE')))
|
||||
return localenv
|
||||
|
||||
# each element of libs is: (subdir, (file extensions), prepfunction)
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ typedef int ftnlen; // Fortran hidden string length type
|
|||
%(CT_USE_LAPACK)s
|
||||
|
||||
%(CT_USE_SYSTEM_EIGEN)s
|
||||
%(CT_USE_SYSTEM_FMT)s
|
||||
|
||||
//--------- operating system --------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,8 @@
|
|||
#ifndef CT_CTEXCEPTIONS_H
|
||||
#define CT_CTEXCEPTIONS_H
|
||||
|
||||
#include "cantera/base/fmt.h"
|
||||
#include <exception>
|
||||
#include <string>
|
||||
#include "cantera/ext/fmt/format.h"
|
||||
|
||||
namespace Cantera
|
||||
{
|
||||
|
|
|
|||
10
include/cantera/base/fmt.h
Normal file
10
include/cantera/base/fmt.h
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
//! @file fmt.h Wrapper for either system-installed or local headers for fmt
|
||||
#include "ct_defs.h"
|
||||
|
||||
#if CT_USE_SYSTEM_FMT
|
||||
#include "fmt/format.h"
|
||||
#include "fmt/ostream.h"
|
||||
#else
|
||||
#include "cantera/ext/fmt/format.h"
|
||||
#include "cantera/ext/fmt/ostream.h"
|
||||
#endif
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
#define CT_GLOBAL_H
|
||||
|
||||
#include "ct_defs.h"
|
||||
#include "cantera/ext/fmt/format.h"
|
||||
#include "cantera/base/fmt.h"
|
||||
|
||||
namespace Cantera
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#define CT_STRINGUTILS_H
|
||||
|
||||
#include "ct_defs.h"
|
||||
#include "cantera/ext/fmt/format.h"
|
||||
#include "cantera/base/fmt.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ if localenv['OS'] in ('Darwin', 'Windows', 'Cygwin'):
|
|||
if localenv['blas_lapack_libs']:
|
||||
localenv.Append(LIBS=localenv['blas_lapack_libs'],
|
||||
LIBPATH=localenv['blas_lapack_dir'])
|
||||
if localenv['system_fmt']:
|
||||
localenv.Append(LIBS='fmt')
|
||||
|
||||
# Build the Cantera shared library
|
||||
if localenv['layout'] != 'debian':
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
#include "cantera/kinetics.h"
|
||||
#include "cantera/kinetics/ImplicitSurfChem.h"
|
||||
#include "cantera/kinetics/solveSP.h"
|
||||
#include "cantera/ext/fmt/ostream.h"
|
||||
#include "cantera/base/fmt.h"
|
||||
#include <cstdio>
|
||||
#include <fstream>
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ static void printUsage()
|
|||
#include "cantera/kinetics.h"
|
||||
#include "cantera/kinetics/ImplicitSurfChem.h"
|
||||
#include "cantera/kinetics/solveSP.h"
|
||||
#include "cantera/ext/fmt/ostream.h"
|
||||
#include "cantera/base/fmt.h"
|
||||
#include <cstdio>
|
||||
#include <fstream>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue