commander.trout
commander.trout

Reputation: 537

Use bjam to build two libraries with same sources

I'm using Boost's bjam and I'm trying to build two different versions of the same library from the same Jamfile. One version of the library need to be built with a macro defined to enable special functionality. I'm hoping to achieve two different names libraries in the same final location.

By way of example,

lib a
: [glob a.cpp]
;

lib a_special
: [glob a.cpp]
: <define>SPECIAL_FUNCTIONALITY
;

The problem is that a.o, the object file being produced from a.cpp, is being produced twice - once by each target. The actual error I'm getting from bjam is

error: Name clash for '<pbin/gcc-5.2.1/debug/link-static>a.o'
error: 
error: Tried to build the target twice, with property sets having 
error: these incompatible properties:
error: 
error:     -  none
error:     -  <define>SPECIAL_FUNCTIONALITY
error: 

Does anyone know of a way to get a target's intermediate files to go to a different location? Can anyone think of a better way to achieve what I'm trying to do?

Upvotes: 1

Views: 219

Answers (1)

GrafikRobot
GrafikRobot

Reputation: 3049

Defines are free, and incidental, features and do not impact the build variant. What you need to do is create a non-incidental feature that describes the property that varies your resulting build. For example:

import feature : feature ;
feature special : off on : propagated ;

lib a : a.cpp : <special>off ;
lib a_special : a.cpp : <special>on <special>on:<define>SPECIAL_FUNCTIONALITY ;

The above uses target requirements to define which library gets built when you ask for the special functionality. And it also uses a conditional property to define the predef symbol on the special library. There are other ways of getting the equivalent result once you have the feature defined.

Upvotes: 1

Related Questions