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
|
"""Select whether to use Eigen from a system installation ('y'), from
|
||||||
a git submodule ('n'), or to decide automatically ('default').""",
|
a git submodule ('n'), or to decide automatically ('default').""",
|
||||||
'default', ('default', 'y', 'n')),
|
'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(
|
EnumVariable(
|
||||||
'system_sundials',
|
'system_sundials',
|
||||||
"""Select whether to use Sundials from a system installation ('y'), from
|
"""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.')
|
config_error('The C++ compiler is not correctly configured.')
|
||||||
|
|
||||||
# Check for fmt library and checkout submodule if needed
|
# Check for fmt library and checkout submodule if needed
|
||||||
if not os.path.exists('ext/fmt/fmt/format.h'):
|
# Test for 'ostream.h' to ensure that version >= 3.0.0 is available
|
||||||
if not os.path.exists('.git'):
|
if env['system_fmt'] in ('y', 'default'):
|
||||||
config_error('fmt is missing. Install source in ext/fmt.')
|
if conf.CheckCXXHeader('fmt/ostream.h', '""'):
|
||||||
|
env['system_fmt'] = True
|
||||||
|
print """INFO: Using system installation of fmt library."""
|
||||||
|
|
||||||
try:
|
elif env['system_fmt'] == 'y':
|
||||||
code = subprocess.call(['git','submodule','update','--init',
|
config_error('Expected system installation of fmt library, but it '
|
||||||
'--recursive','ext/fmt'])
|
'could not be found.')
|
||||||
except Exception:
|
|
||||||
code = -1
|
if env['system_fmt'] in ('n', 'default'):
|
||||||
if code:
|
env['system_fmt'] = False
|
||||||
config_error('fmt submodule checkout failed.\n'
|
print """INFO: Using private installation of fmt library."""
|
||||||
'Try manually checking out the submodule with:\n\n'
|
if not os.path.exists('ext/fmt/fmt/format.h'):
|
||||||
' git submodule update --init --recursive ext/fmt\n')
|
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
|
# Check for googletest and checkout submodule if needed
|
||||||
if env['system_googletest'] in ('y', 'default'):
|
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('LAPACK_NAMES_LOWERCASE', 'lapack_names', 'lower')
|
||||||
cdefine('CT_USE_LAPACK', 'use_lapack')
|
cdefine('CT_USE_LAPACK', 'use_lapack')
|
||||||
cdefine('CT_USE_SYSTEM_EIGEN', env['system_eigen'])
|
cdefine('CT_USE_SYSTEM_EIGEN', env['system_eigen'])
|
||||||
|
cdefine('CT_USE_SYSTEM_FMT', 'system_fmt')
|
||||||
|
|
||||||
config_h = env.Command('include/cantera/base/config.h',
|
config_h = env.Command('include/cantera/base/config.h',
|
||||||
'include/cantera/base/config.h.in',
|
'include/cantera/base/config.h.in',
|
||||||
|
|
@ -1335,6 +1355,10 @@ if env['blas_lapack_libs']:
|
||||||
linkLibs.extend(env['blas_lapack_libs'])
|
linkLibs.extend(env['blas_lapack_libs'])
|
||||||
linkSharedLibs.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
|
# Store the list of needed static link libraries in the environment
|
||||||
env['cantera_libs'] = linkLibs
|
env['cantera_libs'] = linkLibs
|
||||||
env['cantera_shared_libs'] = linkSharedLibs
|
env['cantera_shared_libs'] = linkSharedLibs
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,11 @@ def prep_gtest(env):
|
||||||
def prep_fmt(env):
|
def prep_fmt(env):
|
||||||
localenv = prep_default(env)
|
localenv = prep_default(env)
|
||||||
license_files.append(('fmtlib', 'fmt/LICENSE.rst'))
|
license_files.append(('fmtlib', 'fmt/LICENSE.rst'))
|
||||||
build(localenv.Command("#include/cantera/ext/fmt/format.h",
|
if not env['system_fmt']:
|
||||||
"#ext/fmt/fmt/format.h",
|
for name in ('format.h', 'ostream.h'):
|
||||||
Copy('$TARGET', '$SOURCE')))
|
build(localenv.Command("#include/cantera/ext/fmt/" + name,
|
||||||
build(localenv.Command("#include/cantera/ext/fmt/ostream.h",
|
"#ext/fmt/fmt/" + name,
|
||||||
"#ext/fmt/fmt/ostream.h",
|
Copy('$TARGET', '$SOURCE')))
|
||||||
Copy('$TARGET', '$SOURCE')))
|
|
||||||
return localenv
|
return localenv
|
||||||
|
|
||||||
# each element of libs is: (subdir, (file extensions), prepfunction)
|
# 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_LAPACK)s
|
||||||
|
|
||||||
%(CT_USE_SYSTEM_EIGEN)s
|
%(CT_USE_SYSTEM_EIGEN)s
|
||||||
|
%(CT_USE_SYSTEM_FMT)s
|
||||||
|
|
||||||
//--------- operating system --------------------------------------
|
//--------- operating system --------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,8 @@
|
||||||
#ifndef CT_CTEXCEPTIONS_H
|
#ifndef CT_CTEXCEPTIONS_H
|
||||||
#define CT_CTEXCEPTIONS_H
|
#define CT_CTEXCEPTIONS_H
|
||||||
|
|
||||||
|
#include "cantera/base/fmt.h"
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <string>
|
|
||||||
#include "cantera/ext/fmt/format.h"
|
|
||||||
|
|
||||||
namespace Cantera
|
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
|
#define CT_GLOBAL_H
|
||||||
|
|
||||||
#include "ct_defs.h"
|
#include "ct_defs.h"
|
||||||
#include "cantera/ext/fmt/format.h"
|
#include "cantera/base/fmt.h"
|
||||||
|
|
||||||
namespace Cantera
|
namespace Cantera
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#define CT_STRINGUTILS_H
|
#define CT_STRINGUTILS_H
|
||||||
|
|
||||||
#include "ct_defs.h"
|
#include "ct_defs.h"
|
||||||
#include "cantera/ext/fmt/format.h"
|
#include "cantera/base/fmt.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,8 @@ if localenv['OS'] in ('Darwin', 'Windows', 'Cygwin'):
|
||||||
if localenv['blas_lapack_libs']:
|
if localenv['blas_lapack_libs']:
|
||||||
localenv.Append(LIBS=localenv['blas_lapack_libs'],
|
localenv.Append(LIBS=localenv['blas_lapack_libs'],
|
||||||
LIBPATH=localenv['blas_lapack_dir'])
|
LIBPATH=localenv['blas_lapack_dir'])
|
||||||
|
if localenv['system_fmt']:
|
||||||
|
localenv.Append(LIBS='fmt')
|
||||||
|
|
||||||
# Build the Cantera shared library
|
# Build the Cantera shared library
|
||||||
if localenv['layout'] != 'debian':
|
if localenv['layout'] != 'debian':
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
#include "cantera/kinetics.h"
|
#include "cantera/kinetics.h"
|
||||||
#include "cantera/kinetics/ImplicitSurfChem.h"
|
#include "cantera/kinetics/ImplicitSurfChem.h"
|
||||||
#include "cantera/kinetics/solveSP.h"
|
#include "cantera/kinetics/solveSP.h"
|
||||||
#include "cantera/ext/fmt/ostream.h"
|
#include "cantera/base/fmt.h"
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ static void printUsage()
|
||||||
#include "cantera/kinetics.h"
|
#include "cantera/kinetics.h"
|
||||||
#include "cantera/kinetics/ImplicitSurfChem.h"
|
#include "cantera/kinetics/ImplicitSurfChem.h"
|
||||||
#include "cantera/kinetics/solveSP.h"
|
#include "cantera/kinetics/solveSP.h"
|
||||||
#include "cantera/ext/fmt/ostream.h"
|
#include "cantera/base/fmt.h"
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue