A CMake module providing precompiled header support via custom CXXPCH/CPCH compiler extensions, now obsolete since CMake 3.16.
CMakePCHCompiler is a CMake module that adds precompiled header (PCH) support to CMake projects by defining custom CXXPCH and CPCH meta-compilers. It compiles header files into precompiled headers, speeding up build times by reusing parsed headers across source files. The project is now obsolete as native PCH support was added in CMake 3.16.
C/C++ developers using CMake 3.0–3.15 who need precompiled header support to accelerate compilation times in large projects.
It provides a simpler, more transparent alternative to other PCH modules by ensuring compiler flag consistency and requiring no source code changes, though it's no longer maintained due to native CMake support.
CMake precompiled header support via custom PCH compiler extension
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Automatically applies all C/C++ language flags, definitions, and settings to precompiled headers by patching compiler command templates, avoiding manual flag management and mismatches.
Provides a straightforward target_precompiled_header() function that enables PCH with no source code changes, requiring only CMake configuration for the header file.
Tested on Windows with MSVC, OSX with Clang/GCC, and Linux with GCC, supporting a wide range of toolchains for CMake 3.0+ projects.
Allows sharing precompiled headers across multiple targets using the REUSE option, compiling them only once to reduce build times in complex projects.
The project is deprecated since CMake 3.16 introduced native PCH support; no bug fixes, updates, or PRs will be accepted, making it risky for long-term use.
Forces the /Z7 compiler flag on MSVC to avoid PCH deletion bugs, storing debug info in .obj files instead of .pdb databases, which is a suboptimal workaround.
Admitted by the authors as neither official nor the proper way to handle PCH in CMake, limiting its reliability and integration with CMake's ecosystem.
Designed as a proof-of-concept with meta-compilers that can be harder to debug and understand compared to native CMake features, especially for teams unfamiliar with CMake internals.