Boost logo

Boost-Build :

Subject: [Boost-build] Building OpenMP targets
From: Pascal Germroth (pascal_at_[hidden])
Date: 2013-08-02 20:41:50


I'm the GSOC student for odeint, where I'm using OpenMP. To compile an
example program, GCC and ICC need a flag, Clang++ doesn't support OpenMP
and I haven't tried VC++ yet.
So I need to add the flags for the compilers that need them and disable
building the target for compilers that don't support OpenMP, which I'm
currently doing with a Jamfile like this:

     : requirements

   exe example : example.cpp ;

To prevent building the example on clang I could use

   exe example : example.cpp : <toolset>gcc ;
   exe example : example.cpp : <toolset>intel ;

But enumerating the supported compilers in multiple places doesn't seem
like a good idea.

Instead I'm feature-testing in the source like this, which builds an
empty example when OpenMP is not available (_OPENMP is defined in the
API as set by a supporting compiler)

   #ifdef _OPENMP
     int main() { the example }
     int main() { return 0; }

An earlier thread linked to
where `check-target-builds` is used for feature-testing, can I use this
here to prevent building the empty example?

Is there a way to define/use OpenMP as a feature, so that my Jamfile
wouldn't need to name every toolset but could just require OpenMP for a
target, which would magically set the flag on a supporting compiler or
ignore the target on an unsupported compiler? So that I could write:

   using openmp ;
   project : requirements … ;
   exe example : example.cpp : <openmp>yes ;

Supporting OpenMP in the global toolset definitions could benefit other
projects, too, would this be hard to implement? Where could I look for a
starting point?


Pascal Germroth

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at