How to add specific flags to moc in a qmake project?

前端 未结 7 1150
春和景丽
春和景丽 2020-12-19 03:09

I compile a Qt executable using qmake && make on the following project.pro file:

INCLUDEPATH *= ../../dependencies/boost
QT         


        
7条回答
  •  萌比男神i
    2020-12-19 03:34

    The best way I found to do this is based on a comment on the accepted solution from David Faure:

    QMAKE_MOC_OPTIONS += -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED
    

    The other proposed methods that involve load(moc) and manipulating the QMAKE_MOC variable itself have an unfortunate side effect: they prevent qmake from automatically adding INCLUDEPATH variables (and maybe others) that would normally be on moc's command line, if INCLUDEPATH is set up after the call to load(moc).

    This approach composes easier if you have your qmake configuration split up to multiple files; you don't need to ensure that the change to the moc command line comes after all INCLUDEPATH directories are set.

提交回复
热议问题