root/branches/Carsten_PtrWork/Tools/unittest-cpp.SConstruct

Revision 572, 1.3 kB (checked in by aronb, 2 years ago)

Fix unit test build on windows.

  • Property svn:eol-style set to native
Line 
1 #
2 # Trivial SCons build file for UnitTest++
3 #
4
5 import glob, os
6 import SCons
7 pj = os.path.join
8 import SConsAddons.Util as sca_util
9
10 base = pj("unittest-cpp","UnitTest++")
11
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()
18
19    base_env.Append(CXXFLAGS = ['/wd4530', '/MD'])
20 else:
21    base_env = Environment(ENV = os.environ)
22
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'))
27
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"))
35
36 # Build the library
37 lib_env.StaticLibrary(pj(base,"UnitTest++"), sources)
38
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)
42
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)
Note: See TracBrowser for help on using the browser.