[SCons] Add fmt.h to system.h and improve PCH dependency handling

This commit is contained in:
Ray Speth 2016-10-28 12:37:45 -04:00
parent e3dfc35ca1
commit 2a8ac43308
3 changed files with 18 additions and 8 deletions

View file

@ -60,6 +60,7 @@ if 'clean' in COMMAND_LINE_TARGETS:
removeDirectory('.sconf_temp')
removeFile('.sconsign.dblite')
removeFile('include/cantera/base/config.h')
removeFile('include/cantera/base/config.h.build')
removeFile('include/cantera/base/system.h.gch')
removeFile('include/cantera/base/system.pch')
removeFile('include/cantera/base/system.obj')
@ -1308,11 +1309,15 @@ 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',
config_h_build = env.Command('include/cantera/base/config.h.build',
'include/cantera/base/config.h.in',
ConfigBuilder(configh))
env.AlwaysBuild(config_h)
# This separate copy operation, which SCons will skip of config.h.build is
# unmodified, prevents unnecessary rebuilds of the precompiled header
config_h = env.Command('include/cantera/base/config.h',
'include/cantera/base/config.h.build',
Copy('$TARGET', '$SOURCE'))
env.AlwaysBuild(config_h_build)
env['config_h_target'] = config_h
# *********************

View file

@ -15,5 +15,6 @@
#include <memory>
#include <boost/algorithm/string.hpp>
#include "fmt.h"
#endif

View file

@ -34,24 +34,28 @@ if env['CC'] == 'cl' and env['debug']:
if env['use_pch']:
if env['CC'] == 'cl':
localenv['PCH'], pchobj = localenv.PCH('#include/cantera/base/system.cpp')
pch = localenv['PCH']
libraryTargets.append(pchobj)
localenv['PCHSTOP'] = 'cantera/base/system.h'
else:
localenv['precompiled_header'] = File('#include/cantera/base/system.h')
pch = build(localenv.GchSh('#include/cantera/base/system.h.gch',
localenv['precompiled_header']))
# To force early compilaton of the precompiled header
localenv.Depends(env['config_h_target'], pch)
pch = localenv.GchSh('#include/cantera/base/system.h.gch',
localenv['precompiled_header'])
# # To force early compilaton of the precompiled header
# localenv.Depends(env['config_h_target'], pch)
else:
removeFile('include/cantera/base/system.h.gch')
env['pch_flags'] = []
pch = None
for subdir, extensions, setup in libs:
env2 = localenv.Clone()
source = setup(env2, subdir, extensions)
objects = env2.SharedObject(source)
env2.Depends(objects, env2['config_h_target'])
if pch:
env2.Depends(objects, pch)
libraryTargets.extend(objects)