Boost logo

Boost-Build :

From: Phillip Seaver (phil_at_[hidden])
Date: 2007-08-30 09:10:40

Thorsten Ottosen wrote:
> Hi all,
> Often I only want to compile a single .cpp file I'm working on.
> Thus I could add a Jamfile with an obj target for each .cpp file in my
> project. This seems a bit anoying. Is there a way to auto generate a
> target (perhaps having the same name as the .cpp file without it's
> extension)?
> Thanks in advance
> -Thorsten

You'll have to have a "project" target with the build requirements to
make sure that everything is built the same or give the same build
requirements to the "obj" and "lib" (or whatever is building the target
that uses the source files). In the example below, you would either
remove the "project" line or the "$(build_requirements)" from the "obj"
and "lib" lines.

    project foo : build-requirements $(build_requirements) ;

    local source = [ glob *.cpp ] ;
    for local s in $(source) {
        obj $(s:B) : $(s) : $(build_requirements) ;

    lib foo : $(source) : $(build_requirements) ;

Is there a reason you don't want to use my suggestion of "bjam
foo_src.obj" with msvc and "bjam foo_src.o" in most (all?) other cases?
That's how I recompile a single file (or even several files) when I'm
working on a header that affects lots of files.



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