From 2a8ac433088fb12dff087fe6bf6a92369ecc7bb4 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Fri, 28 Oct 2016 12:37:45 -0400 Subject: [PATCH] [SCons] Add fmt.h to system.h and improve PCH dependency handling --- SConstruct | 13 +++++++++---- include/cantera/base/system.h | 1 + src/SConscript | 12 ++++++++---- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/SConstruct b/SConstruct index 149799fcc..35aea8563 100644 --- a/SConstruct +++ b/SConstruct @@ -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 # ********************* diff --git a/include/cantera/base/system.h b/include/cantera/base/system.h index e2a41d8b0..13d35240d 100644 --- a/include/cantera/base/system.h +++ b/include/cantera/base/system.h @@ -15,5 +15,6 @@ #include #include +#include "fmt.h" #endif diff --git a/src/SConscript b/src/SConscript index 3d5a7766c..7bd323b76 100644 --- a/src/SConscript +++ b/src/SConscript @@ -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)