fixed: auto_ptr -> unique_ptr
[opensg.git] / Tools / unittest-cpp.SConstruct
blob89203d5755880e8a29c428a78327e8329e3f4d9a
2 # Trivial SCons build file for UnitTest++
5 import glob, os
6 import SCons
7 pj = os.path.join
8 import SConsAddons.Util as sca_util
10 base = pj("unittest-cpp","UnitTest++")
12 # We need to make this work with variants.
13 if sca_util.GetPlatform() == "win32":
14    if ARGUMENTS.has_key("MSVS_VERSION"):
15       base_env = Environment(MSVS_VERSION=ARGUMENTS["MSVS_VERSION"])
16    else:
17       base_env = Environment()
19    base_env.Append(CXXFLAGS = ['/wd4530', '/MD'])
20 else:
21    base_env = Environment(ENV = os.environ)
23 # Create a library environment because we do not want to link default libs.
24 lib_env = base_env.Copy()
25 if sca_util.GetPlatform() == "win32":
26    lib_env.Append(ARFLAGS = SCons.Util.CLVar('/nodefaultlib'))
28 # Collect the sources. This assumes everything in the directory is needed
29 sources=glob.glob(pj(base, "src", "*.cpp"))
30 if os.name == "nt":
31     os_dir = "Win32"
32 else:
33     os_dir = "Posix"
34 sources += glob.glob(pj(base, "src", os_dir, "*.cpp"))
36 # Build the library
37 lib_env.StaticLibrary(pj(base,"UnitTest++"), sources)
39 # Build the Tests
40 testsources=glob.glob(pj(base, "src", "tests", "*.cpp"))
41 base_env.Program(pj(base, "TestUnitTest++"), testsources, LIBS="UnitTest++", LIBPATH=base)
43 # Run the Test once the program is built
44 def runTest(target, source, env):
45     os.system(str(target[0]))
46     
47 base_env.AddPostAction(pj(base, "TestUnitTest++"), runTest)