build: decouple handling of boost libs not needed by libndn-cxx

Refs: #5210
Change-Id: Ia8e3d80dd92b5e8a7bd7d79ea811332220a883ed
diff --git a/tests/wscript b/tests/wscript
index d7401ca..2d83303 100644
--- a/tests/wscript
+++ b/tests/wscript
@@ -8,7 +8,7 @@
                 source=bld.path.ant_glob('*.cpp'),
                 features='pch',
                 headers='tests-pch.hpp',
-                use='ndn-cxx BOOST')
+                use='BOOST_TESTS ndn-cxx')
 
     bld.recurse('benchmarks')
     bld.recurse('integration')
diff --git a/tools/ndnsec/wscript b/tools/ndnsec/wscript
index e27c1e8..4ff1c5c 100644
--- a/tools/ndnsec/wscript
+++ b/tools/ndnsec/wscript
@@ -7,7 +7,7 @@
                 source=bld.path.ant_glob('*.cpp', excl=['main.cpp']),
                 features='pch',
                 headers='ndnsec-pch.hpp',
-                use='ndn-cxx')
+                use='BOOST_TOOLS ndn-cxx')
 
     bld.program(name='tool-ndnsec',
                 target=top + 'bin/ndnsec',
diff --git a/wscript b/wscript
index af7203e..0c185a2 100644
--- a/wscript
+++ b/wscript
@@ -103,7 +103,7 @@
     conf.check_sqlite3()
     conf.check_openssl(lib='crypto', atleast_version='1.1.1')
 
-    boost_libs = ['system', 'program_options', 'chrono', 'date_time', 'filesystem', 'thread', 'log']
+    boost_libs = ['system', 'chrono', 'date_time', 'filesystem', 'thread', 'log']
 
     stacktrace_backend = conf.options.with_stacktrace
     if stacktrace_backend is None:
@@ -120,9 +120,6 @@
         conf.env.append_unique('DEFINES_BOOST', ['BOOST_STACKTRACE_DYN_LINK'])
         boost_libs.append(f'stacktrace_{stacktrace_backend}')
 
-    if conf.env.WITH_TESTS:
-        boost_libs.append('unit_test_framework')
-
     conf.check_boost(lib=boost_libs, mt=True)
     if conf.env.BOOST_VERSION_NUMBER < 106501:
         conf.fatal('The minimum supported version of Boost is 1.65.1.\n'
@@ -135,6 +132,12 @@
 
     conf.env.append_unique('DEFINES_BOOST', ['BOOST_FILESYSTEM_NO_DEPRECATED'])
 
+    if conf.env.WITH_TESTS:
+        conf.check_boost(lib='unit_test_framework', mt=True, uselib_store='BOOST_TESTS')
+
+    if conf.env.WITH_TOOLS:
+        conf.check_boost(lib='program_options', mt=True, uselib_store='BOOST_TOOLS')
+
     conf.check_compiler_flags()
 
     # Loading "late" to prevent tests from being compiled with profiling flags