mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[SCons] Stop using header-only version of fmt library
While using the fmt library in header-only mode was convenient, Cantera uses this library in so many separate source files that using it in this mode was noticably increasing overall compilation time.
This commit is contained in:
committed by
Bryan W. Weber
parent
ccc216d6af
commit
bae121a401
18
SConstruct
18
SConstruct
@@ -444,7 +444,12 @@ config_options = [
|
||||
'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'). If you do not want to use the Git submodule and fmt
|
||||
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'. This installation of fmt
|
||||
must include the shared version of the library, for example,
|
||||
'libfmt.so'.""",
|
||||
'default', ('default', 'y', 'n')),
|
||||
EnumVariable(
|
||||
'system_yamlcpp',
|
||||
@@ -866,8 +871,9 @@ 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]
|
||||
def get_expression_value(includes, expression, defines=()):
|
||||
s = ['#define ' + d for d in defines]
|
||||
s.extend('#include ' + i for i in includes)
|
||||
s.extend(('#define Q(x) #x',
|
||||
'#define QUOTE(x) Q(x)',
|
||||
'#include <iostream>',
|
||||
@@ -909,7 +915,7 @@ if env['system_fmt'] in ('n', 'default'):
|
||||
' git submodule update --init --recursive ext/fmt\n')
|
||||
|
||||
fmt_include = '<fmt/format.h>' if env['system_fmt'] else '"../ext/fmt/include/fmt/format.h"'
|
||||
fmt_version_source = get_expression_value([fmt_include], 'FMT_VERSION')
|
||||
fmt_version_source = get_expression_value([fmt_include], 'FMT_VERSION', ['FMT_HEADER_ONLY'])
|
||||
retcode, fmt_lib_version = conf.TryRun(fmt_version_source, '.cpp')
|
||||
try:
|
||||
fmt_lib_version = divmod(float(fmt_lib_version.strip()), 10000)
|
||||
@@ -1665,6 +1671,10 @@ else:
|
||||
linkLibs.extend(env['sundials_libs'])
|
||||
linkSharedLibs.extend(env['sundials_libs'])
|
||||
|
||||
if env['system_fmt']:
|
||||
linkLibs.append('fmt')
|
||||
linkSharedLibs.append('fmt')
|
||||
|
||||
if env['system_yamlcpp']:
|
||||
linkLibs.append('yaml-cpp')
|
||||
linkSharedLibs.append('yaml-cpp')
|
||||
|
||||
@@ -44,6 +44,10 @@ for subdir, extensions, prepFunction in libs:
|
||||
|
||||
if not env['system_fmt']:
|
||||
license_files.append(('fmtlib', 'fmt/LICENSE.rst'))
|
||||
localenv = prep_default(env)
|
||||
localenv.Prepend(CPPPATH=Dir('#ext/fmt/include'))
|
||||
libraryTargets.extend(
|
||||
localenv.SharedObject(mglob(localenv, 'fmt/src', 'cc')))
|
||||
for name in ('format.h', 'ostream.h', 'printf.h', 'core.h', 'format-inl.h'):
|
||||
build(copyenv.Command("#include/cantera/ext/fmt/" + name,
|
||||
"#ext/fmt/include/fmt/" + name,
|
||||
|
||||
@@ -7,10 +7,6 @@
|
||||
//! the same name in kinetics/Group.h
|
||||
#define FMT_NO_FMT_STRING_ALIAS
|
||||
|
||||
//! Use header-only library to avoid relocation issues with linking to the
|
||||
//! static libfmt.a
|
||||
#define FMT_HEADER_ONLY
|
||||
|
||||
//! Versions 6.2.0 and 6.2.1 of fmtlib do not include this define before they
|
||||
//! include windows.h, breaking builds on Windows. Fixed in fmtlib 7.0.0 and
|
||||
//! newer. https://github.com/fmtlib/fmt/pull/1616
|
||||
|
||||
Reference in New Issue
Block a user