[Cmake] Precompiled headers with VC++

John Biddiscombe jbiddiscombe at skippingmouse.co.uk
Thu Feb 21 13:01:46 EST 2002


> Why put the pch files into CVS at all?

This may have stemmed from my using a shorthand notation. The actual pch
binaries should not not not be in cvs.

When someone adds a file to vtkCommon or Gaaphics etc, the list of
Precompiled #includes needs to be updated. This is what I meant. not the pch
inaray, but the PrecompiledHeader 'include list.

As for compiler compatibility, Borland has a nuance - the
#ifdef VTK_Use...
 #include "PrecompiledHeaders.h"
 #pragma hdrstop
#endif

has to be identical in every cxx file within a project, otherwise, it stops
and rebuilds (defeating the object).

It is therefore wise to have a "PrecompiledHeader.h" file in each directory,
and each should be different.
In common, we would put The most common (or all) *.h in vtkCommon
In Filtering, we want the best of common and filtering
in Graphics, the best of c,f &g etc etc
The dependencies should follow the already mapped out structure of things.

Each target will need to have a different binary pch file (not in cvs)
This is also a nuance of (in this case) Borland again.
The names would be in my case
vtkCommon.csm
vtkFiltering.csm etc etc
and each would get a bit bigger. This actually means we'd need 6 or 8
precompiled binaries for the whole of vtk, losing a bit of performance, but
still a huge gain.
This strategy would also carry over fine to other projects, like all of our
vtkLocal stuff

Rules would be
For each Target
  1 Find list of desireable #includes and insert them into
TargetPrecompiledHeaders.h in correct build directory (eg cxx version of
sebastiens perl script (most of the dep[endency info is already computed
elswhere, so maybe it could be used in some way)
  2 Generate a symbol table name (eg TargetPrecompiledHeaders.csm or
whatever MSVC uses)
  3 Add -Hc="TargetPrecompiledHeaders.csm" flag to (eg Borland compiler
options)
  4 sit backand enjoy faster builds
end

I can't see why this relatively simple strategy can't be used on any
platform, and if not wanted, skipped. Please enlighten me if there's a flaw.
None of the Generated headers or binaries need be in cvs, CMake can compute
them on the fly (at the expense of some extra time, but I'm sure Sebastien
can do it nice and fast :)

JB








More information about the CMake mailing list