-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Consider reworking how PCHs are used #324
Description
As discussed in #208 (comment):
PCHs in current form are problematic to use due to varying support of build systems. While the most common setup I imagine would be with the MSVS project files included in the repository, #211 adds CMake support and when preparing #212 I manually invoked the compiler, which causes inclusion of many unnecessary header files, which leads to prolonged compilation times.
I can suggest a simple solution to that issue: make the leaf .cpp files #include the minimal set of what they truly need, leave pch.{h,cpp} files intact, then upon building:
- Compile the PCH, e.g.
g++ -std=c++17 -x c++-header src/CalcManager/pch.cpp -c -o src/CalcManager/pch.h.gch
- When compiling each of leaf
.cppfiles, inject the header via compiler, e.g.
g++ -std=c++17 -I src/CalcManager -I src/CalcManager/Header\ Files -c src/CalcManager/CEngine/calc.cpp -include pch.h
This way you can have regular PCHs without forcing half of STL into each translation unit even when they don't need it.
I'm sure there are other ways of solving that issue as well.