2013/11/26 Stephen Kelly <steve...@gmail.com>:
> Peter Kuemmel wrote:
>> So, is this the right way to improve the pch situation?
>
> I don't know anything about PCH, but Daniel Pfeifer has a branch here:
>
>  https://github.com/purpleKarrot/CMake/tree/WIP-PCH-Support

Thanks for pointing at this branch. I currently don't have much time
to invest into this.
But I want to share some of my thoughts:

PCH shall be non-intrusive: Projects that are created with the Visual
Studio Wizard often require that all sources include the "stdafx.h"
file as the first header. This affects include dependencies when
precompiled headers are not used (bad!). In a non-intrusive approach,
the source code is not PCH-aware. Instead, the appropriate header is
"force-include"d via command line iff PCH is enabled. This can be done
via "/FI" for MSVC and "-include" for GCC.

Some compilers (MSVC) require a source file to precompile the header,
others (GCC) use the header directly as input. This difference shall
be abstracted. If a source file is required, it shall be generated
internally in CMake.

It should be possible to define multiple headers to be precompiled.
While some compilers (GCC) allow only one PCH per compilation unit, it
is always possible to generate a single header that #includes the
files to be precompiled. This single header then can be used as input
for precompilation.

It would be nice to define headers to be precompiled as target usage
requirements. Like, when you link against boost::asio, you will
precompile <boost/asio.hpp>.
The two target proverties probably would be called PRECOMPILE_HEADERS
and INTERFACE_PRECOMPILE_HEADERS. Maybe a
target_precompile_headers(...PUBLIC/PRIVATE/INTERFACE...) makes sense
too.

If precompiled headers are usage requirements, linking against a
target that has the INTERFACE_PRECOMPILE_HEADERS property set will
enable precompiled headers for your target. This might not be
intended. Therefore, It shall be possible to disable precompiled
headers both globally and on a target level.

cheers, Daniel
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to