Boost logo

Boost-Build :

From: Zbynek Winkler (zwin_at_[hidden])
Date: 2004-01-31 07:36:46

Christopher Currie wrote:
> It's been a while, and I could be missing something obvious, but the
> following is giving me a duplicate targets error:
> # Jamfile
> project build/foo ;
> SOURCES = foo ;
> exe foo : $(SOURCES).cpp : <define>FOO ;
> exe bar : $(SOURCES).cpp : <define>BAR ;

I believe this is related to the fact that there are supposed to be two object
files from foo but built differently. Since <define> is a free property it
does not appear in the target's path. I've hit the same thing when I compiled
with and without a library (and its include paths). Later a realized that it
was in fact an error on my part (at least a bad design) so I was actually
happy it worked that way :-).

I guess you need to assign different names to the objects. I can think of at
least two ways how to do it. First you can name the obj by had such as:

exe foo : [ obj objfoo : foo.cpp : <define>FOO ] ;
exe bar : [ obj objfoo-bar : foo.cpp : <define>BAR ] ;

or you can create a custom composite property that expands to the two values
you have for the <define> (see the archive for an example).

IMHO reintroducing the main target directories would bring more problems than
it would solve. It is true that it would work for this example but I think it
would solve only the symptoms and not the cause. I think it would be wrong to
expect that the following would work:

obj objfoo : foo.cpp : <define>FOO ;
obj objfoo : foo.cpp : <define>BAR ;

That is really what your Jamfile is requesting. The result of this has to
differ either in path or in name. Creating directory for objfoo would not work
in this case because the target would still be objfoo/foo.obj in both cases.

But I am sure Volodya will be able to answer this much better :-)


Faculty of Mathematics and Physics, Charles University, Prague, Czech Republic

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