Suppress warnings from Qt headers with clang more cleanly

  • Hi all,

    On a mac using clang, I'm am making solid progress suppressing Qt warnings that occur as I'm building my code.

    The answer, I think, is to add the -isystem <dir> argument as a CXX_FLAGS (unfortunately -isystem-prefix appears unsupported by macx clang).

    Here is something I tried:

    @LIBS_USED_FOR_QT = QtCore QtSql QtMultimediaWidgets QtSensors QtSvg QtXml QtPrintSupport QtWidgets QtQuick QtQml QtPositioning QtGui QtWebKitWidgets

    for(somelib, $$list($$LIBS_USED_FOR_QT)) {
    QMAKE_CXXFLAGS += -isystem $$(QTDIR)/lib/$${somelib}.framework/Versions/5/Headers
    QMAKE_CXXFLAGS += -isystem $$(QTDIR)/lib/$${somelib}.framework/Headers

    I did both /Versions/5/Headers and /Headers because I see both show up in warning systems.

    You also have to be careful to not do this:

    #include <QtCore/QStringList>

    and instead do

    #include <QStringList>

    ... I have no idea why on that point.

    But I still have 2 problems with my approach:

    I'm listing out all the libraries I'm using, but I believe there is a Qt variable that has this information. The docs lead me to believe QMAKE_LIBS_QT should have them, but it's always empty as far as I can tell (I replace QMAKE_LIBS_QT with LIBS_USED_FOR_QT, and nothing at all added to the clang command line).

    The moc compilation still emits warnings, because mocs use the #include <QtCore/QObject> syntax, which as I mentioned is a problem, but I have no idea why.

    Any thoughts on how I can do this better? Is someone else doing this already and figured out a better way?

  • I have a problem with Boost warnings I'm working through now. Boost has a ton of folders from where headers may be located, so I really need a way to recursively grab all folders in the root boost include folder, and add them all to -isystem. I see no way of doing that though...

Log in to reply