diff --git a/SConstruct b/SConstruct index 52293483f..ce8a0e791 100644 --- a/SConstruct +++ b/SConstruct @@ -554,6 +554,11 @@ config_options = [ static libaries and avoids a bug with using valgrind with the -static linking flag.""", True), + BoolVariable( + 'install_gtest', + """Determines whether to install the Google Test library and headers + alongside Cantera's libraries. Not recommended.""", + False), BoolVariable( 'single_library', """If set, include code from the 'ext' folder in the cantera library diff --git a/ext/SConscript b/ext/SConscript index b4b4beea5..45916f9d7 100644 --- a/ext/SConscript +++ b/ext/SConscript @@ -151,32 +151,21 @@ for subdir, extensions, prepFunction in libs: # Build the shared library liby = build(localenv.SharedLibrary(pjoin('..', 'lib', sharedLibName), objects)) install('$inst_libdir', liby) -# --------------------------------------------------- -# GTEST -# --------------------------------------------------- -# OK, handle the construction of the gtest library. Gtest applications require the construction of -# a library object that will get linked in at link time and a set of include files that will available -# at compile time. -# -# Create a local environment for creating the libgtest.a static library -# -> we need to the gtest include files -# -> I don't know about pthreads within gtest. + +# Google Test: Used internally for Cantera unit tests. Optionally, the headers +# and compiled library can be installed alongside Cantera using the scons +# option 'install_gtest=y'. localenv = env.Clone() localenv.Prepend(CPPPATH=[Dir('#ext/gtest'), Dir('#ext/gtest/include')], CPPDEFINES={'GTEST_HAS_PTHREAD': 0}) -# -# Create a build object for libgtest.a and a source file, gtest-all.cc that includes all of the gtest sources -# -llib = build(localenv.Library(pjoin('../lib', 'gtest'), - source=['gtest/src/gtest-all.cc'])) -# -# Add libgtest.a to the install directions -# -install('$inst_libdir', llib) -# -# Add all of the gtest include files to the install directions -# -install(localenv.RecursiveInstall, '$inst_incroot', '#/ext/gtest/include') -# --------------------------------------------------- +gtest = build(localenv.Library(pjoin('../lib', 'gtest'), + source=['gtest/src/gtest-all.cc'])) + +if localenv['install_gtest']: + # install the static library + install('$inst_libdir', gtest) + + # install the header files + install(localenv.RecursiveInstall, '$inst_incroot', '#/ext/gtest/include')