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

Adam Strzelecki ono at java.pl
Tue Mar 3 07:43:18 EST 2015


> Could we rename this? Currently target_* functions are all related to
> usage requirements and these are not usage requirements.

Honestly I don't understand your request. What would be then the name that better represents what the function does.

Also please note this is proposed API to be handled directly by CMake, once there is a green light I'll propose patches to CMake itself.


In meantime https://github.com/nanoant/CMakePCHCompiler is just an implementation that "emulates" desired behavior using many tricks. But I don't want this to be a part of CMake, but instead I want this to be handled natively adding some extra variables:

	CMAKE_<LANG>_PRECOMPILE_HEADER
	
		GCC, Clang: same as CMAKE_<LANG>_COMPILE_OBJECT
		MSVC: CMAKE_<LANG>_COMPILE_OBJECT with "-c" replaced with "/FoNUL /Yc /Fp"

	CMAKE_<LANG>_PRECOMPILED_HEADER_EXTENSION

		GCC: .gch
		MSVC, Clang: .pch

	CMAKE_PRECOMPILED_HEADER_FLAG_<LANG>

		GCC, Clang: -include <PATH>
		MSVC: /Yu<BASENAME> /Fp<PATH> /FI$<BASENAME>

And extending CMake to generate proper build commands for Makefile, Ninja targets, and also Xcode, MSVC generators.

-- Adam


More information about the cmake-developers mailing list