INTERFACE_PRECOMPILE_HEADERS seems questionable
Looking at the current docs for the PCH feature and searching back through the mail archives for the historical discussions around its evolution (back to 2012, thanks to @purpleKarrot!), I'm questioning the wisdom of supporting INTERFACE behavior for precompiled headers. The
INTERFACE_... properties are generally meant to be about usage requirements, but precompiled headers can never be a usage requirement. The code should always be able to be built just fine without them (this has been stated explicitly in the history of the feature's evolution). PCH is only a build optimisation.
A target cannot know all the different ways that its consumers might want to use PCH. If a dependency target sets an
INTERFACE_PRECOMPILE_HEADERS property, then every source file in the consuming target will now be exposed to all of those headers' contents, whether they are needed or not. In the worst case, it could break the consuming target if there are symbol clashes. I had the unfortunate recent experience in real world projects where heavily used dependencies defined symbols they shouldn't have in their headers, so we had to carefully minimise the places those headers were included to avoid those symbols clashing with other things. If those heavily used dependencies had elected to use a feature like what
INTERFACE_PRECOMPILE_HEADERS seeks to offer, we would have to resort to manually clearing that property just to be able to link to that target, or disabling PCH for our own target altogether.
I'd be interested if there's a genuine use case that provides strong motivation for
INTERFACE_PRECOMPILE_HEADERS. About the only potential use case I've seen mentioned so far is for header-only libraries, but they can't rely on PCH because it might not be available/supported everywhere, so again it can't be a requirement, only an optimisation.
If there is no strong argument for
INTERFACE_PRECOMPILE_HEADERS, I'd have to reluctantly suggest that we may want to pull this property from the 3.16.0 release until we can convince ourselves it actually makes sense. To be clear, the
PRECOMPILE_HEADERS property is fine, I'm only talking here about