Qmake include order
-
On windows, I install many libraries with vcpkg. One of the libraries I use installs some Qt components into it's include folder. (including many things in QtCore and QtWidgets). The vcpkg installation is using Qt5, whereas most of my development is in Qt6. If I include another library installed through vcpkg (in my case zeromq, but it doesn't matter) the order of the includes causes QMake to use files from the wrong Qt installation (In my case Qt5 instead of Qt6.2.1). This breaks many things with changes between 5 and 6, including QJsonobject, and Qmetaproperty, etc.. Below is an excerpt from a makefile.debug showing what I mean.
INCPATH = -I..\CompileTest -I. -IC:\src\vcpkg\installed\x64-windows\include -IC:\Qt\6.2.1\msvc2019_64\include -IC:\Qt\6.2.1\msvc2019_64\include\QtCore -Idebug -IC:\Qt\6.2.1\msvc2019_64\mkspecs\win32-msvc
The vcpkg include comes from adding the following line to my .pro file:
INCLUDEPATH += C:/src/vcpkg/installed/x64-windows/include
Because the vcpkg include folder (which includes a QtCore folder) appears before the correct QtCore folders for Qt6, I get problems. If I edit the file so that the normal Qt install includes show up first everything is fine. Is there an easy way to force QMake to include it's own directories first? Doesn't seem to matter in what order I put things in the .pro file. This feels like a bug, or at least not desirable behavior? I'd like for a lot of people to be able to easily compile what I am working on, so manually editing the makefiles seems like a clumsy solution.
-
@Dan-Bumbarger said in Qmake include order:
This feels like a bug, or at least not desirable behavior?
Since you must not mix Qt5 and Qt6 I don't see a problem here.
-
I guess the problem is that rather than putting the Qt6 include locations first (specified by Qt Creator), it puts the Qt5 ones first (specified by a separate include folder of vcpkg that also has QtCore(qt5) as well as the library I actually want to include (zeromq). This is causing Qmake to find the Qt5 files first on things that are not included in the .pro file. By that I mean things like QtGui and Qt Widgets end up coming from Qt6, and other things inluded by QtWidgets end up coming from the Qt5 (obviously not desired). This is fixed if I manually change the order of INCPATH in the makefile.debug. If QMake instead put it's own includes first, or at least in the order they appear in the .pro file, then there would not be a problem. Does this make sense? As it is now, it appears that QMake put's things like the include directory for QtCore (-IC:\Qt\6.2.1\msvc2019_64\include\QtCore in my case) at the END of the includes, even if I explicitly include it at the beginning of my .pro file.