PRECOMPILED_HEADER and the Subtirs pattern on Qt

I have a large Qt project, divided into several static libraries (about 70) and one application, and for this I use the .pro file with the subdirs template.

To speed up compilation time, I want to use precompiled headers and found that using PRECOMPILED_HEADER in each subproject does the trick, BUT, each project compiles the precompiled header separately (and the very slowest step).

Is there a way to “split” a precompiled header between all subprojects included in the subdirs? Template, so can a precompiled header be created once and used by all subprojects?

Hello

+5
source share
5 answers

After some experimentation, I did not find a way to share the precompiled header between subprojects. I think the rationale for the lack of this functionality is that each subproject can change the compiler / preprocessor flags, which will make precompiled headers built for one subproject incompatible with other subprojects.

A common precompiled header may be useful for some simple projects that also use common compiler flags, but I think that detecting and handling deviations from this condition will be too complicated for qmake.

+2
source

, . , , , PCH.

PRECOMPILED_HEADER = ../includes.h

, .pch, "" PRECOMPILED_HEADER - .pri . . VS - :

QMAKE_CXXFLAGS += /FIincludes.h /Yuincludes.h /Fppath/to/1stproj/intdir/projname_pch.pch
#QMAKE_CXXFLAGS += /wd4651
QMAKE_LFLAGS += path/to/1stproj/intdir/projname_pch.obj

, .

  • (. wd4651 ).
  • ootb pdb. /Z 7.
  • gcc -fpIC.
  • .
+1

pch, . , , ++ , . , , : , , , .

0

- cmake. qt, pch, pch . , pch, , pch . qt.

0

, qmake.exe. qmake binary , CREATE (-Yc) pch . .

0

All Articles