Now there is a CMake option KRITA_ENABLE_PCH (enabled by default) that makes build process use precompiled headers in a per-library basis. It means that every library we build in Krita (we should use kis_add_library instead of normal add_library for that) will have its own local PCH file. The same applies for all the unittests.
The choice of a PCH header is done using heuristics based on the target's dependencies.
The patch makes compilation process about 20% faster here, when building with unittests, and about 10% faster, when building without unittests.