Boost logo

Boost :

Subject: [boost] [build][test][gsoc] question about compiling tests with multiple compile params using b2
From: Damian Vicino (damian.vicino_at_[hidden])
Date: 2015-05-21 19:19:47


Hi,
I’m working in the safe_float library for the GSOC.

For testing I’m using the boost.test library and for building I’m using b2.

The implementation have several pieces that are implemented in two flavours, one for compilers supporting FLOAT_ENV and one for those not supporting it. (this is a C++11 feature missed in at least clang and gcc compilers)

Right now, the implementation is selected with an #ifdef and I #define them with a -D parameter.

My config file for test is:
using testing ;
lib boost_unit_test_framework ;
unit-test test : main-test.cpp [ glob *_test.cpp ] boost_unit_test_framework ;

I guess I can generate 2 different executables using 2 targets, duplicating last line and adding something to tell it to pass -DFENV_AVAILABLE, but I couldn’t find how to do that.
Having 2 executables for the tests and running them both will provide testing for both compilation paths (when using a compiler supporting FENV).

Also, I’m wondering if B2 has the inteligence detect and pass a parameter when using a compiler supporting FENV.

Is there any common approach for these situations where conditionally compiling based on a c++ feature support?

In the case a Boost.Build needs to define a test for detecting if the compiler supports the feature (autoconf-like) it can be tested compiling a one-liner file: test.fenv.cpp
#pragma STDC FENV_ACCESS ON
When compiled:
clang++ -c test.fenv.cpp
test.clang.cpp:1:14: warning: pragma STDC FENV_ACCESS ON is not supported, ignoring pragma [-Wunknown-pragmas]
#pragma STDC FENV_ACCESS ON
The warning means the feature is not supported.

Thanks for any guidance in this area, I’m pretty newbie with the b2 system.

Best regards,
Damian


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