Boost logo

Boost-Build :

Subject: Re: [Boost-build] discovering libraries with boost at build time
From: John Maddock (boost.regex_at_[hidden])
Date: 2010-07-10 04:52:39


> 2. I want the build system to detect if library is installed or missing.
> So I
> can turn of building
> Boost.Locale or turn it on. Or just disable some features for other
> projects.
>
> It is not so critical specifically for Boost.Locale, but if I was using
> BBv2
> for my project like CppCMS
> that depends on 5-6 3rd part libraries, if I was asking a user to
> provide
> flag for each one of them...
> I would have less users.

Are you sure we're looking at the same code here?

The new check-target-builds rule can in essence *do anything that autoconf
can*.

Consider the basic AC_TRY_COMPILE macro, to emulate this in Boost.Build we'd
start by creating a source file whose compilation we want to check:

#include <utype.h> // check for ICU headers

int main() { return 0; }

Then we create a target for it in our Jamfile, and mark it as explicit so it
doesn't get built by default:

obj my_test : my_cpp_file.cpp ;
explicit my_test ;

Now we can use this in our main targets:

compile my_test_file.cpp :
[ check-target-builds path_to_jamfile//my_test
    :
    # options if test succeeds:
    <define>TEST_ICU=1
    :
    # options if test fails:
    <build>no ] ;

Of course it would be easier if this was all wrapped in in some kind of
autoconf emulation layer....

Getting back to Regex - try building it on a system that has a recent ICU
version installed in the compiler's search paths - it'll just go ahead and
detect ICU's presence and use the library. Manual configuration is only
required on platforms like Win32 where there is no standard location for
installed headers and libraries - and that's no different from the situation
with autoconf as far as I can see.

HTH, John.


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