Added example Makefiles to install with C++ sample programs
This commit is contained in:
parent
70cdd1be3e
commit
45fe098d51
5 changed files with 153 additions and 13 deletions
19
SConstruct
19
SConstruct
|
|
@ -918,6 +918,13 @@ config_h = env.Command('include/cantera/base/config.h',
|
|||
env.AlwaysBuild(config_h)
|
||||
env['config_h_target'] = config_h
|
||||
|
||||
if env['build_thread_safe']:
|
||||
env['use_boost_libs'] = True
|
||||
env['boost_libs'] = env['boost_thread_lib']
|
||||
else:
|
||||
env['use_boost_libs'] = False
|
||||
env['boost_libs'] = []
|
||||
|
||||
# *********************
|
||||
# *** Build Cantera ***
|
||||
# *********************
|
||||
|
|
@ -977,11 +984,6 @@ if env['addInstallTargets']:
|
|||
pjoin(headerdir, name, filename), cmd)
|
||||
installTargets.extend(inst)
|
||||
|
||||
# Install C++ samples
|
||||
inst = env.RecursiveInstall(pjoin('$inst_sampledir', 'cxx'),
|
||||
'samples/cxx')
|
||||
installTargets.extend(inst)
|
||||
|
||||
# Data files
|
||||
inst = env.Install('$inst_datadir', mglob(env, pjoin('data','inputs'), 'cti', 'xml'))
|
||||
installTargets.extend(inst)
|
||||
|
|
@ -1040,11 +1042,16 @@ if env['OS'] != 'Windows':
|
|||
if env['build_docs']:
|
||||
SConscript('doc/SConscript')
|
||||
|
||||
if 'samples' in COMMAND_LINE_TARGETS:
|
||||
if 'samples' in COMMAND_LINE_TARGETS or 'install' in COMMAND_LINE_TARGETS:
|
||||
SConscript('samples/cxx/SConscript')
|
||||
if env['f90_interface'] == 'y':
|
||||
SConscript('samples/f77/SConscript')
|
||||
|
||||
# Install C++ samples
|
||||
inst = env.RecursiveInstall(pjoin('$inst_sampledir', 'cxx'),
|
||||
'samples/cxx')
|
||||
installTargets.extend(inst)
|
||||
|
||||
### Meta-targets ###
|
||||
build_samples = Alias('samples', sampleTargets)
|
||||
|
||||
|
|
|
|||
72
platform/posix/Cantera.mak.in
Normal file
72
platform/posix/Cantera.mak.in
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
###############################################################################
|
||||
# Include Snippet for Makefiles
|
||||
#
|
||||
# To create Cantera C++ applications from the install environment
|
||||
# include this file into your Makefile environment by putting
|
||||
# the line "include Cantera.mak" in your Makefile.
|
||||
#
|
||||
# Main Variables:
|
||||
#
|
||||
# CANTERA_INCLUDES = Variable containing the include path
|
||||
#
|
||||
# CANTERA_LIBS = List of libraries to include on the link line
|
||||
#
|
||||
|
||||
CANTERA_VERSION=@cantera_version@
|
||||
|
||||
###############################################################################
|
||||
# CANTERA CORE
|
||||
###############################################################################
|
||||
|
||||
# The directory where Cantera include files may be found.
|
||||
# Include files in application programs should start with:
|
||||
# #include "cantera/thermo.h"
|
||||
# #include "cantera/kernel/HMWSoln.h"
|
||||
|
||||
CANTERA_CORE_INCLUDES=-I@ct_incroot@
|
||||
|
||||
# Required Cantera libraries
|
||||
CANTERA_CORE_LIBS=-L@ct_libdir@ -lcantera
|
||||
|
||||
###############################################################################
|
||||
# BOOST
|
||||
###############################################################################
|
||||
|
||||
CANTERA_BOOST_INCLUDES=@mak_boost_include@
|
||||
CANTERA_BOOST_LIBS=@mak_boost_libdir@ @mak_boost_libs@
|
||||
|
||||
###############################################################################
|
||||
# CVODE/SUNDIALS LINKAGE
|
||||
###############################################################################
|
||||
|
||||
CANTERA_SUNDIALS_INCLUDE=@mak_sundials_include@
|
||||
CANTERA_SUNDIALS_LIBS=@mak_sundials_libdir@ @mak_sundials_libs@
|
||||
|
||||
###############################################################################
|
||||
# BLAS LAPACK LINKAGE
|
||||
###############################################################################
|
||||
|
||||
CANTERA_have_blas_lapack_dir=@mak_have_blas_lapack_dir@
|
||||
|
||||
ifeq ($(CANTERA_have_blas_lapack_dir), 1)
|
||||
CANTERA_BLAS_LAPACK_LIBS=-L@blas_lapack_dir@
|
||||
else
|
||||
CANTERA_BLAS_LAPACK_LIBS=@mak_blas_lapack_libs@
|
||||
endif
|
||||
|
||||
###############################################################################
|
||||
# COMBINATIONS OF INCLUDES AND LIBS
|
||||
###############################################################################
|
||||
|
||||
CANTERA_INCLUDES=$(CANTERA_CORE_INCLUDES) $(CANTERA_SUNDIALS_INCLUDE) \
|
||||
$(CANTERA_BOOST_INCLUDES)
|
||||
|
||||
# Add this into the compilation environment to identify the version number
|
||||
CANTERA_DEFINES = -DCANTERA_VERSION=@cantera_version@
|
||||
|
||||
CANTERA_LIBS=$(CANTERA_CORE_LIBS) $(CANTERA_SUNDIALS_LIBS) \
|
||||
$(CANTERA_BLAS_LAPACK_LIBS) $(CANTERA_BOOST_LIBS)
|
||||
|
||||
###############################################################################
|
||||
# END
|
||||
###############################################################################
|
||||
|
|
@ -26,3 +26,30 @@ if env['python_package'] == 'full':
|
|||
inst = localenv.Install('$inst_bindir', 'mixmaster')
|
||||
localenv.AddPostAction(inst, Chmod('$TARGET', 0755))
|
||||
installTargets.extend(inst)
|
||||
|
||||
# Cantera.mak include file for Makefile projects
|
||||
localenv['mak_sundials_libs'] = ' '.join('-l%s' % s
|
||||
for s in localenv['sundials_libs'])
|
||||
localenv['mak_sundials_libdir'] = ('-L' + localenv['sundials_libdir']
|
||||
if localenv['sundials_libdir'] else '')
|
||||
localenv['mak_sundials_include'] = ('-I' + localenv['sundials_include']
|
||||
if localenv['sundials_include'] else '')
|
||||
|
||||
localenv['mak_boost_include'] = ('-I' + localenv['boost_inc_dir']
|
||||
if localenv['boost_inc_dir'] else '')
|
||||
localenv['mak_boost_libdir'] = ('-L' + localenv['boost_lib_dir']
|
||||
if localenv['boost_inc_dir'] and
|
||||
localenv['use_boost_libs'] else '')
|
||||
localenv['mak_boost_libs'] = ' '.join('-l%s' % s
|
||||
for s in localenv['boost_libs'])
|
||||
|
||||
localenv['mak_have_blas_lapack_dir'] = '1' if localenv['blas_lapack_dir'] else '0'
|
||||
localenv['mak_blas_lapack_libs'] = ' '.join('-l%s' % s
|
||||
for s in localenv['blas_lapack_libs'])
|
||||
|
||||
mak = localenv.SubstFile('Cantera.mak', 'Cantera.mak.in')
|
||||
buildTargets.extend(mak)
|
||||
|
||||
if localenv['addInstallTargets']:
|
||||
inst = localenv.Install('$inst_sampledir', mak)
|
||||
installTargets.extend(inst)
|
||||
|
|
|
|||
23
samples/cxx/Makefile.in
Normal file
23
samples/cxx/Makefile.in
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
include ../../Cantera.mak
|
||||
|
||||
CC=@CC@
|
||||
CXX=@CXX@
|
||||
RM=rm -f
|
||||
CCFLAGS=-g
|
||||
CPPFLAGS=$(CANTERA_INCLUDES)
|
||||
LDFLAGS=
|
||||
LDLIBS=$(CANTERA_LIBS)
|
||||
|
||||
SRCS=@make_sourcefile@
|
||||
OBJS=$(subst .cpp,.o,$(SRCS))
|
||||
|
||||
all: @make_target@
|
||||
|
||||
@make_target@: $(OBJS)
|
||||
$(CXX) $(LDFLAGS) -o @make_target@ $(OBJS) $(LDLIBS)
|
||||
|
||||
clean:
|
||||
$(RM) $(OBJS)
|
||||
|
||||
dist-clean: clean
|
||||
$(RM) *~
|
||||
|
|
@ -2,8 +2,6 @@ from buildutils import *
|
|||
|
||||
Import('env', 'buildTargets', 'installTargets', 'sampleTargets')
|
||||
|
||||
localenv = env.Clone()
|
||||
|
||||
# (subdir, program name, [source extensions])
|
||||
samples = [('combustor', 'combustor', ['cpp']),
|
||||
('flamespeed', 'flamespeed', ['cpp']),
|
||||
|
|
@ -12,8 +10,21 @@ samples = [('combustor', 'combustor', ['cpp']),
|
|||
('rankine', 'rankine', ['cpp'])]
|
||||
|
||||
for subdir, name, extensions in samples:
|
||||
prog = localenv.Program(pjoin(subdir, name),
|
||||
mglob(localenv, subdir, *extensions),
|
||||
CPPPATH=['#include'],
|
||||
LIBS=env['cantera_libs'])
|
||||
sampleTargets.extend(prog)
|
||||
localenv = env.Clone()
|
||||
if 'samples' in COMMAND_LINE_TARGETS:
|
||||
prog = localenv.Program(pjoin(subdir, name),
|
||||
mglob(localenv, subdir, *extensions),
|
||||
CPPPATH=['#include'],
|
||||
LIBS=env['cantera_libs'])
|
||||
sampleTargets.extend(prog)
|
||||
|
||||
## Generate Makefiles to be installed
|
||||
localenv['make_sourcefile'] = '%s.cpp' % name
|
||||
localenv['make_target'] = name
|
||||
makefile = localenv.SubstFile(pjoin(subdir, 'Makefile'), 'Makefile.in')
|
||||
buildTargets.extend(makefile)
|
||||
|
||||
# Note: These Makefiles are automatically installed by the
|
||||
# "RecursiveInstall" that grabs everything in the cxx directory
|
||||
|
||||
## Generate SConstruct files to be installed
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue