Thursday, January 2, 2014

Qt5 DEPENDPATH Breaking Changes

Today when trying to build an old project with Qt5, I got a lot of warning and errors like the one below.

WARNING: Failure to find: foo.cpp
...
Error: dependent 'foo.cpp' does not exist.

The warnings and errors are about the lines in a foo.pri file.

INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
HEADERS += foo.h
SOURCES += foo.cpp

In my project, foo.pri exists in the same directory of foo.cpp and foo.h. With Qt4, wherever the foo.pri is included, the foo.cpp and foo.h will be added to source file list and header file list respectfully.

But obviously this won’t work with Qt5. After some googling, I found this post. Basically there is breaking changes of DEPENDPATH in qmake that shipped with Qt5.

Though it is far from being an elegant solution, the following lines fix the issue.

INCLUDEPATH += $$PWD
HEADERS += $$PWD/foo.h
SOURCES += $$PWD/foo.cpp

No comments:

Post a Comment