[cmake-developers] RFC: CMake precompiled header support and custom compiler based implementation

Amine Khaldi amine.khaldi at reactos.org
Fri Mar 20 16:08:33 EDT 2015


> That is an implementation detail. It should not make a difference
> whether the precompiled header is used through your existing header or
> through an autogenerated header that forward includes your existing
> header. This forward inclusion is important at least for GCC: The
> compiler searches for a .gch file in the same directory as the header
> file. Since we do not want this .gch file to be generated in the
> source directory for out-of-source builds, we need to put the header
> file into the build directory.
>
> Did I misunderstand your request and you meant "use an existing
> *precompiled* header", ie. provide a .pch or .gch file?
> My approach currently does not support that. Please let me know if
> that is what you meant.
Right now Peter Kümmel's solution works perfectly for us, with GCC, thanks to the object location property. A similar concept can easily solve this implementation detail without the need for a CMake generated header. We really hope we will have the option of not having these headers in the binary folder.

By existing precompiled header I mean: https://git.reactos.org/?p=reactos.git;a=blob;f=reactos/base/applications/calc/CMakeLists.txt;h=85332bd76ea9f1e6cbcfee7d09929a3460083f50;hb=HEAD#l23

As you can see, calc.h is a header perfectly suitable for PCH creation. All our targets (that use PCH) have headers like that.

Here's the GCC bit BTW: https://git.reactos.org/?p=reactos.git;a=blob;f=reactos/cmake/gcc.cmake;h=25c451ccd2979efeddd721784c12fed68b1ed604;hb=HEAD#l395

> One request that I can add:
>
> * It shall be visible in the IDE's settings that precompiled headers are used.
Sounds good. We already have that for VS so far (the VS flags mappings in CMake show you PCH use in the VS projects' properties) and we don't use any other IDEs so I can't speak of the rest.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20150320/0b963f21/attachment.html>


More information about the cmake-developers mailing list