Question about force inclusion with precompiled header

Hello everyone,

I am successfully using precompiled header in my project to speed up build times. I noticed while reading the documentation about target_precompile_headers the following:

The list of header files is used to generate a header file named cmake_pch.h|xx which is used to generate the precompiled header file (.pch , .gch , .pchi ) artifact. The cmake_pch.h|xx header file will be force included (-include for GCC, /FI for MSVC) to all source files, so sources do not need to have #include "pch.h" .

Is there a way to avoid the forced inclusion of the precompiled header? I am wondering if it is possible to avoid that in such a way that the source files that make use of the precompiled header explicitly have to #include "pch.h".

Thank you very much for any help or clarification.

Alex

AFAIK, there is no way to do that. The main issue that comes to mind is that the wrong pch.h may be found if include paths are blindly trusted.