Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

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

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

INCLUDEPATH *= ../../dependencies/boost
QT *= opengl xml
CONFIG *= qt opengl static

TARGET = myexe
HEADERS = Viewer.hpp MainWindow.hpp Inspector.hpp
SOURCES = main.cpp Viewer.cpp MainWindow.cpp Inspector.cpp

However, when compiling, moc chokes on a boost macro which it cannot parse. To work around this bug, I need to pass the flag -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED to moc, but I cannot manage to do so.

How to I edit my .pro file to pass a given flag to moc? (but not to g++, as QMAKE_CXXFLAGS does)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

A bit hackish, but what about if you overwrite the moc compiler so that it includes the flag. In the .pro:

QMAKE_MOC = $$QMAKE_MOC -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...