mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-13 10:04:13 +02:00
4caefc048f
Building QET is dominated by re-parsing Qt's headers. A 214-line source file expands to roughly 198,000 preprocessed lines, and compiling one translation unit costs ~4.1 s, of which only ~0.35 s is optimisation -- switching -O3 to -O0 saves just 8%, so the usual "build Debug for faster compiles" advice does not help here. A precompiled header caches the parsed header state, which is the part that actually costs. Measured on a 24-thread Xeon E5-2650 v4 with Qt 5.15.18 and GCC 15.2, same build tree, only the option differing: compile one translation unit 4.12 s -> 1.21 s edit one .cpp -> linked binary 5.22 s -> 1.65 s Deliberately OFF by default. A PCH satisfies includes that a source file neglected to make for itself, so code written with it enabled can fail to compile for everyone else. Leaving the default off keeps CI and contributors on the strict behaviour; only developers who opt in trade that away for the speed. Two details in the implementation are load-bearing: - The generator expressions are not decoration. This target also compiles the 18 C files of the bundled LZMA decoder, and an unguarded header list applies to every language in the target, so the Qt headers would be fed to the C compiler and fail with "unknown type name 'namespace'". $<ANGLE-R> is needed because a literal '>' would end the generator expression. - target_precompile_headers() requires CMake 3.16 while the project still declares a 3.5 minimum, so the block warns and skips rather than raising the project-wide requirement for an opt-in developer feature. Verified both ways: with the option off no PCH artefacts are generated and the build is byte-for-byte the previous behaviour; with it on, all 18 C files still compile, the generated PCH is C++-only (cmake_pch.hxx, with no cmake_pch.h), the C compile commands carry no PCH, and the resulting binary runs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>