I'm using waf to build and run a gtest.
If I put everything in my root wscript like the following it works.
def build( bld ):
# build hello world lib
bld.recurse("src/cpp/hw")
# build hello world gtest app
cppUnitTest = bld.program(
target = 'test_run',
source = [ 'test/unit/test_run.cpp' ],
use = [ 'HW_static', 'GTEST_static' ],
lib = [ 'pthread' ],
includes = [ bld.env.LIBGTEST_INCLUDES ],
)
# run c++ unit test
bld(
dependsOn = [cppUnitTest],
name = 'c++ unit test',
rule = './test_run',
cwd = bld.path.find_dir( 'build' )
)
It builds a lib called HW (Hello World), it builds an application called test_run and than it will run that test application.
But if I want the application 'test_run' to be build using recurse I don't get it to work. This is one of my attempts so far.
def build( bld ):
global cppUnitTest
# build hello world lib
bld.recurse("src/cpp/hw")
# build hello world gtest app
bld.recurse("tests/unit")
# run c++ unit test
bld(
dependsOn = [cppUnitTest],
name = 'c++ unit test',
rule = './test_run',
cwd = bld.path.find_dir( 'build' )
)
and the wscript_build file from the subfolder looks like that
cppUnitTest = bld.program(
target = 'test_run',
source = [ 'test_run.cpp' ],
use = [ 'HW_static', 'GTEST_static' ],
lib = [ 'pthread' ],
includes = [ bld.env.LIBGTEST_INCLUDES ],
)
EDIT: As you can see below I found a solution especially for test applications which is fine. But I would be interested in a more general solution how to make sure certain build steps are running in the right order waiting for each other. e.g. if I had an application to build which I than use to generate some code which is used to build an other application and so on.