One tool which can be used to help large projects with their compile times are pre-compiled headers. Pre-compiled headers are basically what the name says, they are header/source files pre-compiled and used in their compiled state when someone needs to compile source code in your project. Now when you need to compile 5 files in your project that all include files listed in the pre-compiled header it won't need to compile the shared files because they are already in the compiled state.
Some simple guidelines for creating pre-compiled headers:
- Include files that cause a lot of other includes, such as windows.h, STL headers and single includes for an entire API
- Add headers that are included in many different files even if they aren't very expensive to compile.
- Be careful not to add files that belong to your own project, or if you do, be aware that any change to those files will cause a full rebuild.
Some draw-backs to pre-compiled headers:
- They can be used as a "one-stop" header include file, but this will turn more of your incremental builds into rebuilds and defeat the purpose of using pre-compiled headers
- They can hide dependencies since now I don't need to include <string.h> in any cpp's, if I were to move this file to another project, unless that one also has <string.h> in it's precomipled header my code won't compile.
I am still working on setting up our project correctly at work to use pre-compiled headers correctly. If you are interested in more on the subject I suggest you check out this page:
http://gamesfromwithin.com/the-care-and-feeding-of-pre-compiled-headers