Boost logo

Boost-Build :

From: Jurko Gospodnetić (jurko.gospodnetic_at_[hidden])
Date: 2008-06-03 03:08:45

   Hi Motonari.

> I have a question: how to pass the location to generated target to other
> target's build parameter?
> My current case is an issue in C++/CLI compilation but it's not C++/CLI
> specific question. Anyway, let's see an example. Say you have these two
> files in C:\source:
> [clr_lib.cpp]
> public ref class CLRLib {
> public:
> static void Hello() {
> System::Console::WriteLine("Hello World");
> }
> };
> [main.cpp]
> #using <clr_lib.dll>
> int main(){
> CLRLib::Hello();
> }
> I can compile them with the following command line:
> 1: cd C:\source
> 2: cl clr_lib.cpp /clr /LD
> 3: cl main.cpp /clr /AIC:\source
> The /AI option in line 3 specifies the location of clr_lib.dll which is
> generated by the line (2).
> Now, I want to use bjam to compile it.
> [Jamfile]
> lib clr_lib : clr_lib.cpp
> : <cxxflags>-clr
> <asynch-exceptions>on
> <link>shared
> ;
> exe main : main.cpp
> : <clr>clr
> <cxxflags>-AI[?]
> ;
> How to find the value of [?] so that it takes the location of
> clr_lib.dll?

   The option you are trying to use is not supported out of the box. :-(

   First, I am not completely sure what the option does. It's listed
with other MSVC preprocessor commands so I assume preprocessor somehow
parses those libraries for additional preprocessor symbols.

   Second, Boost Build expects all built files to be modeled as
'targets' and then those 'targets' used to define sources for other
targets, with Boost Build using those target and dependency definitions
to fill in the actual target file paths to the actual tool command
lines. I do not believe there is a way for you to directly say: 'place
this target's path here'. I guess that could be implemented but I do not
recall seeing it around nor do I have a precise idea of what the
expected syntax for this would be or how hard it would be to implement.
Note just that the path depends on the exact property set used when
building the target so there seems little point in hard-coding just one

   One real ugly quick-fix is to hard-code paths in the command line
like you do now but condition them on the properties affecting how those
paths are constructed. This should work but would be exceedingly
difficult to maintain as your project grows.

   Another dirty quick-fix would be to not use the exe rule but instead
use the make rule (or define your own new target type or generator
class) and construct the whole command line yourself. I guess that could
be a bit cleaner than the previous solution but would still basically
require that you duplicate much of the knowledge already contained in
the msvc toolset.

   I guess the best way would be to improve the msvc toolset to know
about this option. This would be the solution thats the easiest to
maintain, however it might also be a bit tricky for someone relatively
new to Boost Build. This group can offer assistance should you choose to
do it this way, but basically you would have to:

   1. Declare a new feature, let us say <preprocessor-lib>.

   2. Use the toolset.flag rule to have this feature's values passed to
the actual build actions used in the msvc toolset. For an example see
how the library-file feature is linked to the
LIBRARIES_MENTIONED_BY_FILE flag in the msvc toolset.

   2. Make Boost Build treat that feature's values as dependencies. I
think specifying that the feature is a 'dependency' feature was meant
for this but does not work correctly so you need to use the raw Jam
DEPENDS command to make this work. For more information related to this
see an example at
or how this done in the msvc toolset's compile-c-c++ rule for the

   4. Modify the actual build actions in two ways:
     4.1. Make Jam 'bind' the new feature's values (i.e. so the actions
get actual file names corresponding to the listed targets instead of
just the target names). For an example see how the DEF_FLAG is used in
the link action in the msvc module.
     4.2. Make the actions use the new values with the /AI option.

   From taking a quick look through the msvc toolset it seems like there
are 3 relevant actions that you would need to modify but I am not
completely sure what the difference is between them:
   actions compile-c-c++
   actions compile-c-c++-pch-s
   actions compile-c-c++-pch

   There might also be some already extracted helper rule to that could
come in useful (CC_RSPLINE variable seems to hint that).

   Hope this helps.

   Best regards,
     Jurko Gospodnetić

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