Boost logo

Boost-Build :

Subject: Re: [Boost-build] Link test class to built library
From: Johan Nilsson (r.johan.nilsson_at_[hidden])
Date: 2010-03-05 02:34:36


Steven Watanabe wrote:
> AMDG
>
> Siim wrote:
>> I'm really new to Boost Build and I have a project which contains of
>> a few libraries, each library has test classes. Now, I can compile a
>> library into a dll (on Windows for example) using something like
>> this: project MyProject
>> : requirements <include>include
>> : build-dir bin
>> ;
>>
>> lib MyLib1 : [ glob src/*.cpp ] ;
>>
>> How can I build and link the test classes (so they would use the
>> library includes and link against the just-built library)?
>>
>> # Builds the tests
>> #exe test-mylub : test/test-mylib.cpp <- HOW?
>>
>
> Add <include>include/directory/for/library to the usage requirements
> of MyLib1. Then add MyLib1 to the sources of test-mylib.

Assuming that the include requirement in the project's requirements is
enough for building the library, the usage-requirements shouldn't be
strictly necessary in this case (even though strongly recommended). This
should be enough:

---
project MyProject
    : requirements <include>include
    : build-dir bin
    ;
lib MyLib1 : [ glob src/*.cpp ] ;
exe test-mylub : MyLib1 test/test-mylib.cpp ;
---
If you want to run the test executable automatically, one could use the 
unit-test rule instead:
---
import testing ;
project MyProject
    : requirements <include>include
    : build-dir bin
    ;
lib MyLib1 : [ glob src/*.cpp ] ;
unit-test test-mylib : MyLib1 test/test-mylib.cpp ;
---
HTH / Johan 

Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk