Creating and using a single pre-compiled header file in a BDS 2006 project


2006-08-19 11:28:00 PM
cppbuilder37
Hello,
I'm trying to create a single pre-compiled header file so that all
other files in my project include this header. This is much like Roy
Nelson explained in the following article at Borland:
support.borland.com/entry.jspa
Either Roy forgot to mention something or I'm missing something very
simple. Please forgive me if the latter is the case. The problem I
seem to be having is getting this pre-compiled header to be compiled
first so that all other files can take advantage of the generated csm
file. Otherwise units that get compiled before the pre-compiled header
unit, don't take advantage of this.
So my precompiled header looks something like this:
Precompile.h
------------------------
#ifndef Precomple_H
#define Precompile_H
#include <vcl.h>
#include <math.h>
#pragma hdrstop
#endif
------------------------
Precompile.cpp
------------------------
#include "Precompile.h"
------------------------
Each cpp file in my project includes this Precompile.h as the first
include. For example, the Aunit.cpp looks like the following:
Aunit.cpp
------------------------
#ifndef Aunit_H
#define Aunit_H
#include "Precompile.h"
#include "Aunit.h"
class Aunit
{
// Blah
};
#endif
------------------------
My project might look like the following:
------------------------
Aunit.cpp
Bunit.cpp
Cunit.cpp
Precompile.cpp (my precompiled unit)
Xunit.cpp
Yunit.cpp
Zunit.cpp
------------------------
I have the project setup so that pre-compile options are the following:
-He -
-H=Precompile.csm
As you can see, BDS 2006 neatly organizes the project so that the units
are in alphabetical order. When I perform a build, the files are built
in alphabetical order. Therefore, my Precompile unit does not get built
until half way through the compile cycle. Once it does, the
compilation of units X, Y and Z are much faster. Units A, B, C never
get to take advantage of the precompiled unit so their compile times
are much slower than X, Y and Z.
I realize I can drag the Precompile unit in my Project Manager to the
top of the list. This definitely produces the effect I'm looking for.
However, this is a "local" change to the project file, meaning my other
colleagues could not take advantage of this because we don't submit the
.local files to source control.
Am I missing something? Is there a way to tell BDS to compile my
Precompile unit first so that all other units can take advantage of it?
Best regards,
Scott