From bc609ce2dae1df1a40821f54fa542adf0c9bad90 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Fri, 22 Jul 2016 13:07:32 -0400 Subject: [PATCH] [SCons] Fix Makefiles generated for C++ examples - Use CXXFLAGS to pass flags to C++ compiler (not CCFLAGS) - Set CXXFLAGS based on flags that Cantera was compiled with (which will include things like -pthread and -std=c++0x as necessary - Remove incorrect / unused target for the target binary - Add the generated binary to things remove by 'make clean' --- samples/cxx/Makefile.in | 11 ++++------- samples/cxx/SConscript | 29 ++++++++++++++--------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/samples/cxx/Makefile.in b/samples/cxx/Makefile.in index 75f6255ed0..18ca914cf0 100644 --- a/samples/cxx/Makefile.in +++ b/samples/cxx/Makefile.in @@ -3,21 +3,18 @@ include @make_Cantera_dot_mak@ CC=@CC@ CXX=@CXX@ RM=rm -f -CCFLAGS=-g +CXXFLAGS=@mak_compiler_flags@ CPPFLAGS=$(CANTERA_INCLUDES) LDFLAGS= LDLIBS=$(CANTERA_LIBS) -SRCS=@make_sourcefile@ +SRCS=@tmpl_sourcename@ OBJS=$(subst .cpp,.o,$(SRCS)) -all: @make_target@ - -@make_target@: $(OBJS) - $(CXX) $(LDFLAGS) -o @make_target@ $(OBJS) $(LDLIBS) +all: @tmpl_progname@ clean: - $(RM) $(OBJS) + $(RM) $(OBJS) @tmpl_progname@ dist-clean: clean $(RM) *~ diff --git a/samples/cxx/SConscript b/samples/cxx/SConscript index 8f0c7a8f54..7a0fa5c471 100644 --- a/samples/cxx/SConscript +++ b/samples/cxx/SConscript @@ -22,21 +22,6 @@ for subdir, name, extensions in samples: # Note: These Makefiles and SConstruct files are automatically installed # by the "RecursiveInstall" that grabs everything in the cxx directory. - ## Generate Makefiles to be installed - localenv['make_sourcefile'] = '%s.cpp' % name - localenv['make_target'] = name - - mak_path = pjoin(localenv['ct_incroot'], 'cantera', 'Cantera.mak') - if ' ' in mak_path: - # There is no reasonable way to handle spaces in Makefile 'include' - # statement, so we fall back to using the relative path instead - mak_path = os.path.relpath(mak_path, pjoin(localenv['ct_sampledir'], 'cxx', subdir)) - localenv['make_Cantera_dot_mak'] = mak_path - - makefile = build(localenv.SubstFile(pjoin(subdir, 'Makefile'), 'Makefile.in')) - install(pjoin('$inst_sampledir', 'cxx', subdir), makefile) - - ## Generate SConstruct files to be installed incdirs = (localenv['ct_incroot'], localenv['sundials_include'], localenv['boost_inc_dir']) + tuple(localenv['extra_inc_dirs']) libdirs = ((localenv['ct_libdir'], localenv['sundials_libdir'], @@ -50,6 +35,8 @@ for subdir, name, extensions in samples: localenv['tmpl_progname'] = name localenv['tmpl_sourcename'] = name + '.cpp' env_args = [] + + ## Generate SConstruct files to be installed if localenv['TARGET_ARCH'] is not None: env_args.append('TARGET_ARCH={0!r}'.format(localenv['TARGET_ARCH'])) if 'MSVC_VERSION' in localenv: @@ -58,3 +45,15 @@ for subdir, name, extensions in samples: sconstruct = localenv.SubstFile(pjoin(subdir, 'SConstruct'), 'SConstruct.in') install(pjoin('$inst_sampledir', 'cxx', subdir), sconstruct) + + ## Generate Makefiles to be installed + mak_path = pjoin(localenv['ct_incroot'], 'cantera', 'Cantera.mak') + localenv['mak_compiler_flags'] = ' '.join(localenv['CCFLAGS'] + localenv['CXXFLAGS']) + if ' ' in mak_path: + # There is no reasonable way to handle spaces in Makefile 'include' + # statement, so we fall back to using the relative path instead + mak_path = os.path.relpath(mak_path, pjoin(localenv['ct_sampledir'], 'cxx', subdir)) + localenv['make_Cantera_dot_mak'] = mak_path + + makefile = build(localenv.SubstFile(pjoin(subdir, 'Makefile'), 'Makefile.in')) + install(pjoin('$inst_sampledir', 'cxx', subdir), makefile)