Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

qt

qmake

moc

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)

like image 627
F'x Avatar asked Dec 13 '11 09:12

F'x


1 Answers

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
like image 56
Tatu Lahtela Avatar answered Sep 19 '22 02:09

Tatu Lahtela