build: more accurate Boost lib dependencies
See also named-data/ndn-cxx@5686c51b87b6a642aa2dc8d93e061caebbb226cc
Change-Id: I28cfc24c3d8f0dd16a7bdcec092090a09c024fdf
diff --git a/examples/wscript b/examples/wscript
index e6badbf..6cb8dd2 100644
--- a/examples/wscript
+++ b/examples/wscript
@@ -6,8 +6,8 @@
# List all .cpp files (whole example in one .cpp)
for ex in bld.path.ant_glob('*.cpp'):
name = ex.change_ext('').path_from(bld.path.get_bld())
- bld.program(name='example-%s' % name,
- target='nac-%s' % name,
+ bld.program(name=f'example-{name}',
+ target=f'nac-{name}',
source=[ex],
use='libndn-nac',
install_path=None)
@@ -15,7 +15,7 @@
# List all directories (example can have multiple .cpp in the directory)
for subdir in bld.path.ant_glob('*', dir=True, src=False):
name = subdir.path_from(bld.path)
- bld.program(name='example-%s' % name,
+ bld.program(name=f'example-{name}',
target=name,
source=subdir.ant_glob('**/*.cpp'),
use='libndn-nac',
diff --git a/tests/wscript b/tests/wscript
index 9532f78..42d537d 100644
--- a/tests/wscript
+++ b/tests/wscript
@@ -4,8 +4,8 @@
def build(bld):
bld.program(
- target='../unit-tests',
+ target=f'{top}/unit-tests',
name='unit-tests',
source=bld.path.ant_glob('**/*.cpp'),
- use='libndn-nac',
+ use='BOOST_TESTS libndn-nac',
install_path=None)
diff --git a/tools/wscript b/tools/wscript
index 07de0e9..337bc7f 100644
--- a/tools/wscript
+++ b/tools/wscript
@@ -4,41 +4,47 @@
def build(bld):
# Single object tools:
- # tools/example-tool.cpp is a self-contained tool with a main() function
- # and is built as build/bin/example-tool.
- # These tools cannot be unit-tested.
+ # tools/foo.cpp is a self-contained tool with a main() function
+ # and is built as build/bin/foo. These tools cannot be unit-tested.
for tool in bld.path.ant_glob('*.cpp'):
name = tool.change_ext('').path_from(bld.path.get_bld())
bld.program(name=name,
- target='../bin/%s' % name,
+ target=f'{top}/bin/{name}',
source=[tool],
- use='NDN_CXX libndn-nac')
+ use='BOOST_TOOLS libndn-nac')
# Sub-directory tools:
- # tools/example-tool/**/*.cpp is compiled and linked into build/bin/example-tool.
- # tools/example-tool/main.cpp must exist and must contain the main() function.
+ # tools/foo/**/*.cpp are compiled and linked into build/bin/foo.
+ # tools/foo/main.cpp must exist and must contain the main() function.
# All other objects are collected into 'tools-objects' and can be unit-tested.
testableObjects = []
for subdir in bld.path.ant_glob('*', dir=True, src=False):
+ name = subdir.path_from(bld.path)
+ subWscript = subdir.find_node('wscript')
+ if subWscript:
+ # if the subdir has a wscript, delegate to it
+ bld.recurse(name)
+ continue
+
mainFile = subdir.find_node('main.cpp')
if mainFile is None:
- continue # not a C++ tool
+ # not a C++ tool, skip the subdir
+ continue
- name = subdir.path_from(bld.path)
srcFiles = subdir.ant_glob('**/*.cpp', excl=['main.cpp'])
srcObjects = ''
if srcFiles:
- srcObjects = 'tools-%s-objects' % name
+ srcObjects = f'tools-{name}-objects'
bld.objects(target=srcObjects,
source=srcFiles,
- use='NDN_CXX libndn-nac',
+ use='libndn-nac',
includes=name)
testableObjects.append(srcObjects)
bld.program(name=name,
- target='../bin/%s' % name,
+ target=f'{top}/bin/{name}',
source=[mainFile],
- use='NDN_CXX libndn-nac ' + srcObjects,
+ use=f'BOOST_TOOLS libndn-nac {srcObjects}',
includes=name)
bld.objects(target='tools-objects',
diff --git a/wscript b/wscript
index d4264d4..833277c 100644
--- a/wscript
+++ b/wscript
@@ -43,11 +43,13 @@
conf.check_cfg(package='libndn-cxx', args=['libndn-cxx >= 0.8.1', '--cflags', '--libs'],
uselib_store='NDN_CXX', pkg_config_path=pkg_config_path)
- boost_libs = ['system', 'program_options']
- if conf.env.WITH_TESTS:
- boost_libs.append('unit_test_framework')
+ conf.check_boost()
- conf.check_boost(lib=boost_libs, mt=True)
+ 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()