build: allow toggling benchmark/integration/unit tests independently

Change-Id: I88f7816c97a9884f328bf05b6c7e47b2e918ccf0
diff --git a/tests/benchmarks/wscript b/tests/benchmarks/wscript
index 02ca4f0..3c1e532 100644
--- a/tests/benchmarks/wscript
+++ b/tests/benchmarks/wscript
@@ -8,5 +8,5 @@
         bld.program(name=f'test-{name}',
                     target=name,
                     source=[test],
-                    use='tests-common',
+                    use='BOOST_TESTS ndn-cxx',
                     install_path=None)
diff --git a/tests/unit/wscript b/tests/unit/wscript
index 6b4e2b8..591353f 100644
--- a/tests/unit/wscript
+++ b/tests/unit/wscript
@@ -3,20 +3,20 @@
 top = '../..'
 
 def build(bld):
-    tmpdir = 'UNIT_TESTS_TMPDIR="%s"' % bld.bldnode.make_node('tmp-files')
+    tmpdir = 'UNIT_TESTS_TMPDIR="%s"' % bld.bldnode.make_node('tests-tmp')
 
-    # unit test objects
     srcFiles = bld.path.ant_glob('**/*.cpp',
                                  excl=['main.cpp',
                                        '**/*-osx.t.cpp',
                                        '**/*-sqlite3.t.cpp'])
 
-    if bld.env['HAVE_OSX_FRAMEWORKS']:
+    if bld.env.HAVE_OSX_FRAMEWORKS:
         srcFiles += bld.path.ant_glob('**/*-osx.t.cpp')
 
     # In case we want to make it optional later
     srcFiles += bld.path.ant_glob('**/*-sqlite3.t.cpp')
 
+    # unit test objects
     bld.objects(
         target='unit-tests-objects',
         source=srcFiles,
diff --git a/tests/wscript b/tests/wscript
index 7ab65d1..7277402 100644
--- a/tests/wscript
+++ b/tests/wscript
@@ -3,14 +3,19 @@
 top = '..'
 
 def build(bld):
-    # common objects that can be shared among all tests
-    bld.objects(
-        target='tests-common',
-        source=bld.path.ant_glob('*.cpp'),
-        features='pch',
-        headers='tests-pch.hpp',
-        use='BOOST_TESTS ndn-cxx')
+    if bld.env.WITH_INTEGRATION_TESTS or bld.env.WITH_UNIT_TESTS:
+        bld.objects(
+            target='tests-common',
+            source=bld.path.ant_glob('*.cpp'),
+            features='pch',
+            headers='tests-pch.hpp',
+            use='BOOST_TESTS ndn-cxx')
 
-    bld.recurse('benchmarks')
-    bld.recurse('integration')
-    bld.recurse('unit')
+    if bld.env.WITH_BENCHMARKS:
+        bld.recurse('benchmarks')
+
+    if bld.env.WITH_INTEGRATION_TESTS:
+        bld.recurse('integration')
+
+    if bld.env.WITH_UNIT_TESTS:
+        bld.recurse('unit')
diff --git a/wscript b/wscript
index a55e483..2d75f2d 100644
--- a/wscript
+++ b/wscript
@@ -47,7 +47,13 @@
                    help='Build examples')
 
     opt.add_option('--with-tests', action='store_true', default=False,
-                   help='Build tests')
+                   help='Build all tests (benchmarks, integration tests, unit tests)')
+    opt.add_option('--with-benchmarks', action='store_true', default=False,
+                   help='Build benchmarks')
+    opt.add_option('--with-integration-tests', action='store_true', default=False,
+                   help='Build integration tests')
+    opt.add_option('--with-unit-tests', action='store_true', default=False,
+                   help='Build unit tests')
 
     opt.add_option('--without-tools', action='store_false', default=True, dest='with_tools',
                    help='Do not build tools')
@@ -76,7 +82,9 @@
                'doxygen', 'sphinx_build'])
 
     conf.env.WITH_EXAMPLES = conf.options.with_examples
-    conf.env.WITH_TESTS = conf.options.with_tests
+    conf.env.WITH_BENCHMARKS = conf.options.with_benchmarks or conf.options.with_tests
+    conf.env.WITH_INTEGRATION_TESTS = conf.options.with_integration_tests or conf.options.with_tests
+    conf.env.WITH_UNIT_TESTS = conf.options.with_unit_tests or conf.options.with_tests
     conf.env.WITH_TOOLS = conf.options.with_tools
 
     conf.find_program('dot', mandatory=False)
@@ -134,7 +142,7 @@
 
     conf.check_boost(lib=boost_libs, mt=True)
 
-    if conf.env.WITH_TESTS:
+    if any((conf.env.WITH_BENCHMARKS, conf.env.WITH_INTEGRATION_TESTS, conf.env.WITH_UNIT_TESTS)):
         conf.check_boost(lib='unit_test_framework', mt=True, uselib_store='BOOST_TESTS')
 
     if conf.env.WITH_TOOLS:
@@ -153,7 +161,7 @@
         conf.env.prepend_value('STLIBPATH', ['.'])
 
     conf.define_cond('HAVE_STACKTRACE', conf.env.HAVE_STACKTRACE)
-    conf.define_cond('HAVE_TESTS', conf.env.WITH_TESTS)
+    conf.define_cond('HAVE_TESTS', conf.env.WITH_INTEGRATION_TESTS or conf.env.WITH_UNIT_TESTS)
     conf.define_cond('WITH_OSX_KEYCHAIN', conf.env.HAVE_OSX_FRAMEWORKS and conf.options.with_osx_keychain)
     conf.define_cond('DISABLE_SQLITE3_FS_LOCKING', not conf.options.with_sqlite_locking)
     conf.define('SYSCONFDIR', conf.env.SYSCONFDIR)
@@ -227,8 +235,7 @@
             name='ndn-cxx-static' if bld.env.enable_shared else 'ndn-cxx',
             **libndn_cxx)
 
-    if bld.env.WITH_TESTS:
-        bld.recurse('tests')
+    bld.recurse('tests')
 
     if bld.env.WITH_TOOLS:
         bld.recurse('tools')