[Cmake] Precompiled headers with VC++

Lorensen, William E (CRD) lorensen at crd.ge.com
Thu Feb 21 10:07:35 EST 2002


Please do not require perl to build vtk or itk.

Bill

-----Original Message-----
From: Sebastien BARRE [mailto:sebastien.barre at kitware.com]
Sent: Wednesday, February 20, 2002 1:45 PM
To: John Biddiscombe
Cc: Alexander Fiksel; cmake at public.kitware.com
Subject: Re: [Cmake] Precompiled headers with VC++


At 2/20/2002 06:16 PM, John Biddiscombe wrote:
> > I am wondering how difficult it would be to add "precomplied headers"
>feature, which can dramatically decrease the rebuild time?
>
>Its been brought up many times here. The upshot is that its very esy to
>implement, simply add
>#ifdef VTK_USE_PRECOMPILED_HEADERS
>   #include "PrecompiledHeader.h"
>#endif
>
>to every cxx file.
>
>The problem is that because classes get added and removed from the various
>directories as the code changes that someone has to remember to update the
>pch file.  Not a big issue really and I still can't understand why it isn't
>in use. (Note that from vtk4 several directories are used and each would
>have a slightly different pch set)

I do agree with John.

I have used PCH file in my own CMake files for my PhD project last year. 
This decreased compilation time dramatically.

At this time I was using CMake 0.x, so it has to be reworked, but it looked 
like this:

OPTION(USE_PRECOMPILED_HEADERS "Use precompiled headers" ON)

IF (USE_PRECOMPILED_HEADERS)
   IF (CMAKE_CXX_COMPILER MATCHES "^VC\\+\\+60$")
     SET (PCH_FILE ${SBVTK_BINARY_DIR}/Utilities/Pch/vc60.pch CACHE FILEPATH
          "Name of the precompiled header.")
     INCLUDE_DIRECTORIES(${SBVTK_SOURCE_DIR}/Utilities/Pch)
     SET (CMAKE_CXX_FLAGS
          "${CMAKE_CXX_FLAGS} /YX /D \"USE_PCH\" /Fp\"${PCH_FILE}\"")
     CONFIGURE_FILE(${SBVTK_SOURCE_DIR}/Utilities/Pch/build_pch.pl.in
                    ${SBVTK_BINARY_DIR}/Utilities/Pch/build_pch.pl)
   ENDIF (CMAKE_CXX_COMPILER MATCHES "^VC++60$")
ENDIF (USE_PRECOMPILED_HEADERS)

the build_pch.pl Perl script was used to generate a header file listing the 
"most dependent VTK headers" (see at the end of this email). I guess a 
ADD_CUSTOM_TARGET or ADD_CUSTOM_COMMAND could be used now to generate it.

The special header file had to be carefully written. For example, it only 
lists the 50 most dependent headers. I made a lot of tests to find the 
right compromise, and the result of these tests was discussed in this list 
last year:
http://public.kitware.com/pipermail/vtkusers/2000-October/004519.html


--
Sebastien Barre

_______________________________________________
Cmake mailing list
Cmake at public.kitware.com
http://public.kitware.com/mailman/listinfo/cmake



More information about the CMake mailing list