|
Boost-Build : |
From: Frank Birbacher (bloodymir.crap_at_[hidden])
Date: 2008-05-06 08:33:56
Hi!
From the beginning of using BJam I repeatedly run into the following
problem:
I have several projects where sources are distributed in different
directories. These projects usually build a client and a serer
executable as well as a client shared library. These targets share
common code. I put this code into a single directory and the other
sources are split up into "server", "client", and "lib" directories.
How am I supposed to build the "common" code in a way that
(1) compiles the code only once for each build variant
(2) works regardless of link=shared or static
(3) works with gcc and msvc alike
My first guess was:
# in /common dir:
lib common : [ glob *.cpp ] /boost//filesystem ... ;
# in /server dir:
exe server : [ glob *.cpp ] ../common//common ;
This satisfies (1), but (2) only when using gcc, because for DLLs I
would have to litter the code with __declspec(dllim-/export) which I
don't want to. If I only do a static build then the boost libs will be
linked statically, too, which I don't want to. Mixing dyn boost libs
with a static common lib opens another can of worms.
Second guess:
alias common : [ glob *.cpp ] /boost//filesystem ... ;
This satisfies (2) and (3), but for each use the code is compiled again,
increasing compile times significantly: the "server", the "client", and
the "lib" each compile the code again.
Current guess:
To solve this I tried the following:
rule bundle ( name : sources + : others * : ureq * )
{
local objs ;
for s in $(sources) {
objs += [ obj $(s:S=) : $(s) $(others) ] ;
}
alias $(name) : $(objs) : : : $(ureq) ;
}
bundle common :
[ glob *.cpp ]
:
/boost//filesystem
/boost//system
:
<include>.
;
This way (1), (2), and (3) are satisfied, at least with msvc and cygwin.
And I wonder if anyone has had the same problem and I wonder why there
is no such rule in BJam already (maybe with a different name). Could
such a rule become part of bjam? Or is there another way to solve this?
Regards, Frank
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