Boost logo

Boost-Build :

Subject: Re: [Boost-build] discovering libraries with boost at build time
From: Vladimir Prus (ghost_at_[hidden])
Date: 2010-07-12 03:44:32


On Saturday 10 July 2010 12:52:39 John Maddock wrote:

>
> > 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....

Of course, I can add some higher-level wrapper. However, an important question
is whether we want to try linking against the found library, or not.
autoconf, I believe, generally tries to link. CMake, on the other hand,
basically searches for a file in some locations and that it -- it does not
try linking. Which behaviour seems more useful?

Thanks,

--
Vladimir Prus
http://vladimir_prus.blogspot.com
Boost.Build: http://boost.org/boost-build2

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