Boost logo

Boost-Build :

Subject: Re: [Boost-build] BJam "Duplicate name of actual target" problem
From: Gevorg Voskanyan (v_gevorg_at_[hidden])
Date: 2011-07-15 11:24:10


Hite, Christopher wrote:

> I want to compile two variants of the same program with overlapping
> subsets of cpps. I've split up my code so that I don't need any
> annoying ifdefs. So my Jamfile looks something like this:
>
> alias shared : [ glob *.cpp ] ;
>
> alias x : [ glob x/*.cpp ] ../libs/xlib//xlib ;
> alias y : [ glob y/*.cpp ] ../libs/ylib//ylib ;
>
> exe prog_x : shared x : <include>. ;
> exe prog_y : shared y : <include>. ;
>
> 1) "Duplicate name of actual target" - The reason why is that xlib/ylib
> infect the compilation of files in shared. All the cpps for an exe are
> compiled with the same include path.
>
> Yes I've read the faq:
> http://www.boost.org/boost-build2/doc/html/bbv2/faq/s02.html
>
> 2) I tried was defining shared as a lib. The problem with this is that
> shared and x(or y) are circularly dependent.
> ??? Can I get bjam to pass --start-group --end-group through g++ to ld?
>
> 3) A solution would be to define an shared as an obj. The problem here
> is if shared has 50 cpp files, each one needs a separate obj in the
> Jamfile.
> !!! Feature request - and objgroup which would work like lib, so cpp
> files in shared wouldn't get settings from x or y.

# WARNING: untested

rule objgroup ( sources + )
{
   local g = ;
   for s in $(sources) {
      local name = $(s:B) ;
      obj $(name) : $(s) ;
      g += $(name) ;
   }
   return $(g) ;
}

alias shared : [ objgroup [ glob *.cpp ] ] ;

> 4) I could try things like feature.feature or variant, but they would
> envolve compiling shared twice.
>
> Chris

HTH,
Gevorg


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