Boost logo

Boost :

From: Jens Seidel (jensseidel_at_[hidden])
Date: 2008-01-07 11:49:07


Hi Gennadiy,

On Mon, Jan 07, 2008 at 04:26:46PM +0000, Gennadiy Rozental wrote:
> > On Dec 18, 2007, at 11:16 AM, Benoit Sigoure wrote:
> > so I'm about to fix my BOOST_TEST macro that tests whether
> > Boost.Tests can be used and linked against. Hubert Figuiere
> > contributed the following fix. He suggested that I add:
> > using boost::unit_test::test_suite;
> > test_suite* init_unit_test_suite(int argc, char ** argv)
> > {
> > return NULL;
> > }
> > Before my `main' (which reads: int main() { BOOST_CHECK(2 == 2);
> > return 0; })
>
> I can't say I understand 100% what you are trying to do here, but using

let me reply instead of Benoit.

The aim of the code above is to be used in boost.m4 (M4 is the GNU
macro package) to be used itself in configure scripts which are started
on each system before the compilation starts to test the system, look
for the compiler and available libraries ... Using this information a
system specific Makefile is written and the build system is portable.

So Benoit tries to find an easy way to test a system whether Boost.Test
is available. Considering the many different system configurations (think
about the CRT mess on Windows!!!) such system tests for projects using
autotools are a very important step. It is in general not possible to
hardcode paths, compiler options, ... as it will break on some exotic
systems.

With autotools compiling code is as simple as:
./configure [optional options such as --prefix=/usr/local or
             --with-boost=path ...]
make
make install

This works everywhere (yes, even on the proprietary system you're using).

Gennadiy, I don't understand the following:

> Testing tools outside of the UnitTest framework might not be a good idea. In
> 1.35 I've implemented a check against it and it may throw an exception.

What does "outside of UnitTest framework" mean? Do you refer to a
special namespace, the requirement to link against the boost-unittest
library or what?

Benoit: As Gennadiy pointed out (thanks) it is possible to define the macro
whether shared or static libraries are used directly in the Makefile.
I'm sorry to note that I consider it now your job to determine whether
you link against the shared or static library and to set BOOST_CXXFLAGS
accordingly. You probably have to check whether test code compiled with
or without a user specified main function to determine this. Maybe Gennadiy
can help even more by providing a single (two or three lines only) check
for both?

Jens


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk