Search code examples
c++qtqmake

Select different kit in QMake from CLI


When I develop in Qt Creator I can easily select my build kit from the left kit icon. However, I want to try to do the same from the command line.

In particular, I will be compiling using either Qt5 or Qt6, using the same project file (using qmake). Is there a way to tell qmake what kit to use (qt5 vs qt6)?

My qmake file doesn't currently specify a compiler/linker/debugger so I'm not sure how to tell qmake what kit to use.


Solution

  • "way to tell qmake what kit to use (qt5 vs qt6)?"

    Qt Creator does based on selected Qt-Kit,
    choose which qmake.exe to run. Which we could do manually.

    But, then Qt Creator does also based on compiler,
    choose what make-spec to pass in QMake's command-line.

    The result of said choices can be seen in Qt Creator's "Projects" section/ tab, which's something like:

    path/to/qt-5/bin/qmake.exe path/to/my-project.pro -r -spec win32-msvc2015 "CONFIG+=declarative_debug"
    

    Note that the "-spec win32-msvc2015" part tells QMake to load the file at:

    path/to/qt-5/mkspecs/win32-msvc2015/qmake.conf
    

    Now, the above pointed mkspecs folder contains one folder for each compiler that QMake supports, pick what works for you, and pass that in command-line (instead of win32-msvc2015).