aboutsummaryrefslogtreecommitdiffstats
path: root/scons
diff options
context:
space:
mode:
Diffstat (limited to 'scons')
-rw-r--r--scons/SConscript19
-rw-r--r--scons/SConscript.common18
-rw-r--r--scons/SConstruct2
3 files changed, 39 insertions, 0 deletions
diff --git a/scons/SConscript b/scons/SConscript
index 25220eea..a2c31dc1 100644
--- a/scons/SConscript
+++ b/scons/SConscript
@@ -292,6 +292,25 @@ if BUILD_TESTS:
GtestBinary(env_without_rtti, 'gtest_no_rtti_test', gtest_main_no_rtti,
['../test/gtest_unittest.cc'])
+ # Tests that gtest works when built as a DLL on Windows.
+ # We don't need to actually run this test.
+ # Note: this is not supported under VC 7.1.
+ if env['PLATFORM'] == 'win32' and env.get('GTEST_BUILD_DLL_TEST', None):
+ test_env = EnvCreator.Create(env, EnvCreator.DllBuild)
+ dll_env = test_env.Clone()
+ dll_env.Append(LINKFLAGS=['-DEF:../src/gtest.def'])
+
+ gtest_dll = dll_env.SharedLibrary(
+ target='gtest_dll',
+ source=[dll_env.SharedObject('gtest_all_dll',
+ '../src/gtest-all.cc'),
+ dll_env.SharedObject('gtest_main_dll',
+ '../src/gtest_main.cc')])
+ # TODO(vladl@google.com): Get rid of the .data[1] hack. Find a proper
+ # way to depend on a shared library without knowing its path in advance.
+ test_env.Program('gtest_dll_test_',
+ ['../test/gtest_dll_test_.cc', gtest_dll.data[1]])
+
############################################################
# Sample targets.
diff --git a/scons/SConscript.common b/scons/SConscript.common
index 7fda32e1..7943e77c 100644
--- a/scons/SConscript.common
+++ b/scons/SConscript.common
@@ -132,6 +132,24 @@ class EnvCreator:
env.Append(CPPDEFINES='GTEST_HAS_RTTI=0')
NoRtti = classmethod(NoRtti)
+ def DllBuild(cls, env):
+ """Enables building gtets as a DLL."""
+
+ env['OBJ_SUFFIX'] = '_dll'
+ # -MT(d) instructs MSVC to link to the static version of the C++
+ # runtime library; -MD(d) tells it to link to the DLL version.
+ flags = env['CCFLAGS']
+ if '-MTd' in flags:
+ flags.remove('-MTd')
+ flags.append('-MDd')
+ elif '-MT' in flags:
+ flags.remove('-MT')
+ flags.append('-MD')
+
+ # Disables the "non dll-interface class 'stdext::exception' used as
+ # base for dll-interface class" warning triggered by the STL code.
+ env.Append(CCFLAGS=['/wd4275'])
+ DllBuild = classmethod(DllBuild)
sconscript_exports = {'EnvCreator': EnvCreator}
Return('sconscript_exports')
diff --git a/scons/SConstruct b/scons/SConstruct
index c749d6a8..f4f82374 100644
--- a/scons/SConstruct
+++ b/scons/SConstruct
@@ -56,6 +56,8 @@ win_base = sconstruct_helper.MakeWinBaseEnvironment()
# setting for our users.
if win_base.get('MSVS_VERSION', None) == '7.1':
sconstruct_helper.EnableExceptions(win_base)
+else:
+ win_base['GTEST_BUILD_DLL_TEST'] = True
sconstruct_helper.MakeWinDebugEnvironment(win_base, 'win-dbg')
sconstruct_helper.MakeWinOptimizedEnvironment(win_base, 'win-opt')