Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-29828

Default CMake template prefers Qt5 over Qt6

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • Qt Creator 11.0.3

      The default project template for CMake tries to setup a project that works both with Qt5 and Qt6. If both Qt5 and Qt6 are installed to the same prefix, as it occurs with the Qt packages bundled with MSYS2, this template doesn't work as expected: It happens, that CMake finds /clang64/lib/cmake/Qt5Core/Qt5CoreConfig.cmake first and then stops without even trying to find for Qt6CoreConfig.cmake.

      cmake --debug-find-pkg=Qt5,Qt6 ...
      ...
        find_package considered the following locations for Qt5's Config module:
      
          C:/msys64/clang64/Qt5Config.cmake
          C:/msys64/clang64/qt5-config.cmake
          C:/msys64/clang64/lib/cmake/Qt5/Qt5Config.cmake
      
        The file was found at
      
          C:/msys64/clang64/lib/cmake/Qt5/Qt5Config.cmake
      

      This can be fixed by explicitly sorting the package directories CMake is scanning:

      set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)
      set(CMAKE_FIND_PACKAGE_SORT_ORDER NAME)
      

      With that change CMake always finds Qt6 if both Qt5 and Qt6 are installed with MSYS2.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            cadam Cristian Adam
            hasselmm Mathias Hasselmann
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes