Boost logo

Boost-Build :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2005-11-16 04:00:27


I am trying to get precompiled headers working. I have:

-- pch.jam --

import type ;
import feature : feature ;

type.register PCH : pch ;

feature pch : # control precompiled header (PCH) generation
     on # this file has support for using PCHs (if available)
     off # this file doesn't use PCHs
   ;

-- msvc.jam --

generators.register-standard msvc.compile.pch : HPP : OBJ PCH :
<toolset>msvc ;

actions compile.pch
{
     $(.CC) ... -Yc"$(>[1]:W)" -Fo"$(<[1]:W)" -Fp"$(<[2]:W)"
}

-----

This is the only way I can get it working without running into bjam
errors. Now, if you want to pass a source file, you will need:

    pch mypch : pch.hpp : <pch-source>pch.cpp ;

    exe hello
      :
        main.cpp demo.cpp mypch
      ;

I have temporarily modified msvc.jam to print out simplified build
commands. The above gives:

...found 26 targets...
...updating 6 targets...
msvc.compile.pch ..\..\..\build\tools\pch\msvc-7.1\release\mypch.obj
..\..\..\build\tools\pch\msvc-7.1\release\mypch.pch
cl -c -Yc"pch.hpp"
-Fo"..\..\..\build\tools\pch\msvc-7.1\release\mypch.obj"
-Fp"..\..\..\build\tools\pch\msvc-7.1\release\mypch.pch"
msvc.compile.c++ ..\..\..\build\tools\pch\msvc-7.1\release\main.obj
cl -c "main.cpp" -Fo"..\..\..\build\tools\pch\msvc-7.1\release\main.obj"
msvc.compile.c++ ..\..\..\build\tools\pch\msvc-7.1\release\demo.obj
cl -c "demo.cpp" -Fo"..\..\..\build\tools\pch\msvc-7.1\release\demo.obj"
msvc.link ..\..\..\build\tools\pch\msvc-7.1\release\hello.exe
link "..\..\..\build\tools\pch\msvc-7.1\release\main.obj"
"..\..\..\build\tools\pch\msvc-7.1\release\demo.obj"
"..\..\..\build\tools\pch\msvc-7.1\release\mypch.obj"
/out:"..\..\..\build\tools\pch\msvc-7.1\release\hello.exe"
...updated 6 targets...

Now, for each CPP target that is using PCHs (CPP/<pch>on) I need to add
-Yu"pch.hpp" and
-Fp"..\..\..\build\tools\pch\msvc-7.1\release\mypch.pch". The only way I
han think of doing this is to have a <use-pch-header> for -Yu and
<use-pch-file> for -Fp. I could then use the technique used by 'lib : :
<name>' by adding <library-file> to the list of properties. Then:

flags msvc.compile USE_PCH_HEADER : <use-pch-header> ;
flags msvc.compile USE_PCH_FILE : <use-pch-file> ;

Q: How do I get these features added into the property list via the pch
rule?

- Reece


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