本文介绍了如何在Qmake项目中向MOC添加特定标志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在以下project.pro文件上使用qmake && make编译Qt可执行文件:

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

但是,在编译时,moc阻塞了它无法解析的boost宏.要解决此错误,我需要将标志-DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED传递给moc,但是我无法管理为此.

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.

如何编辑我的.pro文件以将给定标志传递给moc? (但不是g++那样,g++一样)

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

推荐答案

有点黑,但是如果您覆盖moc编译器,使其包含该标志,该怎么办?在.pro中:

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

这篇关于如何在Qmake项目中向MOC添加特定标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-25 17:11