Use header-only form of libfmt

Avoids problems when trying to link to static versions of libfmt.a which were
built without -fPIC.
This commit is contained in:
Ray Speth
2018-05-29 20:47:47 -04:00
parent 51d0d43a45
commit 309871ae88
3 changed files with 11 additions and 18 deletions

View File

@@ -1684,10 +1684,6 @@ 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

View File

@@ -36,30 +36,23 @@ def prep_gmock(env):
def prep_fmt(env):
localenv = prep_default(env)
if not env['system_fmt']:
localenv.Prepend(CPPPATH=Dir('#include/cantera/ext'))
license_files.append(('fmtlib', 'fmt/LICENSE.rst'))
for name in ('format.h', 'ostream.h', 'printf.h', 'core.h', 'format-inl.h', 'posix.h'):
build(copyenv.Command("#include/cantera/ext/fmt/" + name,
"#ext/fmt/include/fmt/" + name,
Copy('$TARGET', '$SOURCE')))
return localenv
# each element of libs is: (subdir, (file extensions), prepfunction)
libs = [('libexecstream', ['cpp'], prep_default)]
# fmtlib versions less than 5.0.0 had the source files for the library in a different folder.
# Also, we expect system-installed versions of fmtlib >= 5.0.0 to have a library already compiled
if LooseVersion(env['FMT_VERSION']) < LooseVersion('5.0.0'):
libs.append(('fmt/fmt', ['cc'], prep_fmt))
elif not env['system_fmt']:
libs.append(('fmt/src', ['cc'], prep_fmt))
for subdir, extensions, prepFunction in libs:
localenv = prepFunction(env)
objects = localenv.SharedObject(mglob(localenv, subdir, *extensions))
libraryTargets.extend(objects)
if not env['system_fmt']:
license_files.append(('fmtlib', 'fmt/LICENSE.rst'))
for name in ('format.h', 'ostream.h', 'printf.h', 'core.h', 'format-inl.h', 'posix.h'):
build(copyenv.Command("#include/cantera/ext/fmt/" + name,
"#ext/fmt/include/fmt/" + name,
Copy('$TARGET', '$SOURCE')))
if env['system_sundials'] == 'n':
localenv = prep_default(env)
localenv.Prepend(CPPPATH=Dir('#include/cantera/ext'))

View File

@@ -7,6 +7,10 @@
//! 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
#if CT_USE_SYSTEM_FMT
#include "fmt/format.h"
#if defined(FMT_VERSION) && FMT_VERSION >= 40000