Skip to content

Qt5 is preferred over Qt6 when searching for one of them.

Consider this example (recommended by Qt in https://doc.qt.io/qt-6/cmake-qt5-and-qt6-compatibility.html#supporting-older-qt-5-versions )

cmake_minimum_required(VERSION 3.16)
project(test CXX)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
message("QT_VERSION: ${QT_VERSION}")

On MINGW I get:

$ cmake --version
cmake version 3.23.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).
$ cmake -B build/ucrt
-- Building for: Ninja
-- The CXX compiler identification is GNU 12.1.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: D:/Programs/msys64/ucrt64/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
QT_VERSION: 5.15.4
-- Configuring done
-- Generating done
-- Build files have been written to: D:/dev/Bugs/cmake_code/build/ucrt

and on Ubuntu 22.04 I get:

$ cmake --version
cmake version 3.22.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).
$ cmake -B build/wsl-22
-- The CXX compiler identification is GNU 11.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
QT_VERSION: 5.15.3
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/d/dev/Bugs/cmake_code/build/wsl-22

Putting Qt5 first doesn't change anything.

If I remove Qt5 from the searched NAMES then CMake finds Qt6 successfully.

If I understand well (and according to Qt docs) the first name should be searched first.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information