Skip to content

Consider reworking how PCHs are used #324

@janisozaur

Description

@janisozaur

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:

  1. Compile the PCH, e.g.
g++ -std=c++17 -x c++-header src/CalcManager/pch.cpp -c -o src/CalcManager/pch.h.gch
  1. When compiling each of leaf .cpp files, 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.

Metadata

Metadata

Labels

codebase qualityIssues that are not bugs, but still might be worth improving (eg, code hygiene or maintainability)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions