Search code examples
qmake

How to use precompiled header for many sub-directories in qmake?


I've read http://qt-project.org/doc/qt-4.8/qmake-precompiledheaders.html

My source directory is like

common  # here will generated common.pch/
srcdir1
srcdir2
srcdir3

I'm trying to let my srcdir1 srcdir2 srcdir3 use the common precompiled headers, but how to write the correct .pro files?


Solution

  • You could use something like this from the project root where there is a foo.pro:

    CONFIG += ordered
    TEMPLATE = subdirs
    SUBDIRS = common srcdir1 srcdir2 srcdir3
    

    from the documentation:

    When using the subdirs template, this option specifies that the directories listed should be processed in the order in which they are given.

    Variable values then will be preserved so what you set in common should be available in srcdir1, and so forth.

    Even if that was not working, you could still put the PRECOMPILED_HEADER = foo.h definition into a precompiled-header.pri project include file which is included from several places.

    Does this help?