Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. CMakeLists issue
Forum Update on Monday, May 27th 2025

CMakeLists issue

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 3 Posters 7.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Andryxa
    wrote on 18 Aug 2023, 12:36 last edited by Andryxa
    #1

    Hello! Recently I've updated my qt from 6.3.2 to 6.5.2 version. But i've noticed that all my previous projects which were made by CMake have an issue. It sounds like this:
    "error: Could not find a package configuration file provided by "QT" with any of the following names: Qt6Config.cmake qt6-config.cmake Qt5Config.cmake qt5-config.cmake Add the installation prefix of "QT" to CMAKE_PREFIX_PATH or set "QT_DIR" to a directory containing one of the above files. If "QT" provides a separate development package or SDK, be sure it has been installed."
    I've searched the solution on internet and tried to set SET_PREFIX_PATH to my dirs in qt 6.5.2 folder, it solves this error, but creates another:
    "C:\Qt\6.5.2\mingw_64\lib\cmake\Qt6Core\Qt6CoreMacros.cmake:588: error: Cannot find source file: connectiondevice.h Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc C:/Qt/6.5.2/mingw_64/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:549 (_qt_internal_create_executable) C:/Qt/6.5.2/mingw_64/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:741 (qt6_add_executable) CMakeLists.txt:31 (qt_add_executable)".
    I can't find working solution for this problem.
    Here is part of my CMakeLists file:

    cmake_minimum_required(VERSION 3.5)
    
    project(Test VERSION 0.1 LANGUAGES CXX)
    
    set(CMAKE_AUTOUIC ON)
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTORCC ON)
    
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    #set(CMAKE_PREFIX_PATH "C:/Qt/6.5.2/")
    set(CMAKE_PREFIX_PATH "C:/Qt/6.5.2/mingw_64")
    #set(CMAKE_PREFIX_PATH "C:/Qt/6.5.2/msvc2019_64")
    #set(CMAKE_PREFIX_PATH "C:/Qt/6.5.2/msvc2019_arm64")
    #set(CMAKE_PREFIX_PATH "C:/Qt/6.5.2/mingw_64/lib/cmake/Qt6Core")
    #set(CMAKE_PREFIX_PATH "C:/Qt/6.5.2/msvc2019_64/lib/cmake/Qt6Core")
    #set(CMAKE_PREFIX_PATH "C:/Qt/6.5.2/msvc2019_arm64/lib/cmake/Qt6Core")
    
    find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
    find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
    

    Seems like somehow CMake can't find Qt after update.
    As you can see, I've tried different dirs in folder, but still got no success.
    I've tried to move my project from CMake to qmake, but the GUI apps started to get frozen. Somehow, even old project started to lag.
    I'm making serial port monitor from Arduino with GUI, because I'm making pictures from incoming data.

    C 1 Reply Last reply 18 Aug 2023, 13:02
    0
    • A Andryxa
      18 Aug 2023, 12:36

      Hello! Recently I've updated my qt from 6.3.2 to 6.5.2 version. But i've noticed that all my previous projects which were made by CMake have an issue. It sounds like this:
      "error: Could not find a package configuration file provided by "QT" with any of the following names: Qt6Config.cmake qt6-config.cmake Qt5Config.cmake qt5-config.cmake Add the installation prefix of "QT" to CMAKE_PREFIX_PATH or set "QT_DIR" to a directory containing one of the above files. If "QT" provides a separate development package or SDK, be sure it has been installed."
      I've searched the solution on internet and tried to set SET_PREFIX_PATH to my dirs in qt 6.5.2 folder, it solves this error, but creates another:
      "C:\Qt\6.5.2\mingw_64\lib\cmake\Qt6Core\Qt6CoreMacros.cmake:588: error: Cannot find source file: connectiondevice.h Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc C:/Qt/6.5.2/mingw_64/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:549 (_qt_internal_create_executable) C:/Qt/6.5.2/mingw_64/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:741 (qt6_add_executable) CMakeLists.txt:31 (qt_add_executable)".
      I can't find working solution for this problem.
      Here is part of my CMakeLists file:

      cmake_minimum_required(VERSION 3.5)
      
      project(Test VERSION 0.1 LANGUAGES CXX)
      
      set(CMAKE_AUTOUIC ON)
      set(CMAKE_AUTOMOC ON)
      set(CMAKE_AUTORCC ON)
      
      set(CMAKE_CXX_STANDARD 17)
      set(CMAKE_CXX_STANDARD_REQUIRED ON)
      
      #set(CMAKE_PREFIX_PATH "C:/Qt/6.5.2/")
      set(CMAKE_PREFIX_PATH "C:/Qt/6.5.2/mingw_64")
      #set(CMAKE_PREFIX_PATH "C:/Qt/6.5.2/msvc2019_64")
      #set(CMAKE_PREFIX_PATH "C:/Qt/6.5.2/msvc2019_arm64")
      #set(CMAKE_PREFIX_PATH "C:/Qt/6.5.2/mingw_64/lib/cmake/Qt6Core")
      #set(CMAKE_PREFIX_PATH "C:/Qt/6.5.2/msvc2019_64/lib/cmake/Qt6Core")
      #set(CMAKE_PREFIX_PATH "C:/Qt/6.5.2/msvc2019_arm64/lib/cmake/Qt6Core")
      
      find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
      find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
      

      Seems like somehow CMake can't find Qt after update.
      As you can see, I've tried different dirs in folder, but still got no success.
      I've tried to move my project from CMake to qmake, but the GUI apps started to get frozen. Somehow, even old project started to lag.
      I'm making serial port monitor from Arduino with GUI, because I'm making pictures from incoming data.

      C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 18 Aug 2023, 13:02 last edited by
      #2

      @Andryxa said in CMakeLists issue:

      Seems like somehow CMake can't find QT after update.

      I also not aware of any library named 'QT'. Once there was QuickTime but this was not a c++ library.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      A 1 Reply Last reply 18 Aug 2023, 13:04
      0
      • C Christian Ehrlicher
        18 Aug 2023, 13:02

        @Andryxa said in CMakeLists issue:

        Seems like somehow CMake can't find QT after update.

        I also not aware of any library named 'QT'. Once there was QuickTime but this was not a c++ library.

        A Offline
        A Offline
        Andryxa
        wrote on 18 Aug 2023, 13:04 last edited by
        #3

        @Christian-Ehrlicher I'm not using QuickTime at any point. I only use QT framework for GUI, which made by QT Widget application.

        C 1 Reply Last reply 18 Aug 2023, 13:06
        0
        • A Andryxa
          18 Aug 2023, 13:04

          @Christian-Ehrlicher I'm not using QuickTime at any point. I only use QT framework for GUI, which made by QT Widget application.

          C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 18 Aug 2023, 13:06 last edited by
          #4

          @Andryxa said in CMakeLists issue:

          QT framework

          No, you try use the Qt framework as it seems.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          A 1 Reply Last reply 18 Aug 2023, 13:18
          1
          • C Christian Ehrlicher
            18 Aug 2023, 13:06

            @Andryxa said in CMakeLists issue:

            QT framework

            No, you try use the Qt framework as it seems.

            A Offline
            A Offline
            Andryxa
            wrote on 18 Aug 2023, 13:18 last edited by
            #5

            @Christian-Ehrlicher Yeah, true, my bad. I'm pretty new to the Qt and almost all of my previous projects are lagging now.

            C 1 Reply Last reply 18 Aug 2023, 13:20
            0
            • A Andryxa
              18 Aug 2023, 13:18

              @Christian-Ehrlicher Yeah, true, my bad. I'm pretty new to the Qt and almost all of my previous projects are lagging now.

              C Offline
              C Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 18 Aug 2023, 13:20 last edited by
              #6

              CMake is case-sensitive. But I'm not completely sure how it works on non case-sensitve filesystems when looking for files - if you search for 'QT' it will actually look for a module named 'FindQt.cmake' (and similar others) - it might be found on windows but will not on linux for sure.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              A 1 Reply Last reply 18 Aug 2023, 13:32
              2
              • C Christian Ehrlicher
                18 Aug 2023, 13:20

                CMake is case-sensitive. But I'm not completely sure how it works on non case-sensitve filesystems when looking for files - if you search for 'QT' it will actually look for a module named 'FindQt.cmake' (and similar others) - it might be found on windows but will not on linux for sure.

                A Offline
                A Offline
                Andryxa
                wrote on 18 Aug 2023, 13:32 last edited by Andryxa
                #7

                @Christian-Ehrlicher I'm developing on windows. I can't understand, why does CMake look for QT files, when they were never used. I used only Qt files.

                cristian-adamC 1 Reply Last reply 18 Aug 2023, 13:42
                0
                • A Andryxa
                  18 Aug 2023, 13:32

                  @Christian-Ehrlicher I'm developing on windows. I can't understand, why does CMake look for QT files, when they were never used. I used only Qt files.

                  cristian-adamC Offline
                  cristian-adamC Offline
                  cristian-adam
                  wrote on 18 Aug 2023, 13:42 last edited by
                  #8
                  find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
                  find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
                  

                  Was used for the projects that would migrate from Qt5 to Qt6.

                  In your case change it to just:

                  find_package(Qt6 REQUIRED COMPONENTS Widgets)
                  

                  Also CMAKE_PREFIX_PATH is always without lib/cmake/Qt<PackageName>.

                  CMake will use the values from CMAKE_PREFIX_PATH and add itself the lib/cmake suffix and package names.

                  This means that only these are valid:

                  set(CMAKE_PREFIX_PATH "C:/Qt/6.5.2/mingw_64")
                  #set(CMAKE_PREFIX_PATH "C:/Qt/6.5.2/msvc2019_64")
                  #set(CMAKE_PREFIX_PATH "C:/Qt/6.5.2/msvc2019_arm64")
                  

                  The rest are not.

                  A 1 Reply Last reply 18 Aug 2023, 15:56
                  0
                  • cristian-adamC cristian-adam
                    18 Aug 2023, 13:42
                    find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
                    find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
                    

                    Was used for the projects that would migrate from Qt5 to Qt6.

                    In your case change it to just:

                    find_package(Qt6 REQUIRED COMPONENTS Widgets)
                    

                    Also CMAKE_PREFIX_PATH is always without lib/cmake/Qt<PackageName>.

                    CMake will use the values from CMAKE_PREFIX_PATH and add itself the lib/cmake suffix and package names.

                    This means that only these are valid:

                    set(CMAKE_PREFIX_PATH "C:/Qt/6.5.2/mingw_64")
                    #set(CMAKE_PREFIX_PATH "C:/Qt/6.5.2/msvc2019_64")
                    #set(CMAKE_PREFIX_PATH "C:/Qt/6.5.2/msvc2019_arm64")
                    

                    The rest are not.

                    A Offline
                    A Offline
                    Andryxa
                    wrote on 18 Aug 2023, 15:56 last edited by Andryxa
                    #9

                    @cristian-adam I've tried your solution but the error is still there. 7b37ff20-fbca-44ad-9d49-8f56e0d2df8f-image.png
                    I'm trying to build for mingw.
                    But the error is different now error: By not providing "FindQt6.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt6", but CMake did not find one. Could not find a package configuration file provided by "Qt6" with any of the following names: Qt6Config.cmake qt6-config.cmake Add the installation prefix of "Qt6" to CMAKE_PREFIX_PATH or set "Qt6_DIR" to a directory containing one of the above files. If "Qt6" provides a separate development package or SDK, be sure it has been installed.

                    cristian-adamC 1 Reply Last reply 18 Aug 2023, 18:51
                    0
                    • A Andryxa
                      18 Aug 2023, 15:56

                      @cristian-adam I've tried your solution but the error is still there. 7b37ff20-fbca-44ad-9d49-8f56e0d2df8f-image.png
                      I'm trying to build for mingw.
                      But the error is different now error: By not providing "FindQt6.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt6", but CMake did not find one. Could not find a package configuration file provided by "Qt6" with any of the following names: Qt6Config.cmake qt6-config.cmake Add the installation prefix of "Qt6" to CMAKE_PREFIX_PATH or set "Qt6_DIR" to a directory containing one of the above files. If "Qt6" provides a separate development package or SDK, be sure it has been installed.

                      cristian-adamC Offline
                      cristian-adamC Offline
                      cristian-adam
                      wrote on 18 Aug 2023, 18:51 last edited by
                      #10

                      With Qt Creator you shouldn't have to modify the CMAKE_PREFIX_PATH or CMAKE_FIND_MODULE in Qt Creator.

                      Just make sure you have a Kit with the right Qt configured.

                      That's all.

                      cristian-adamC 1 Reply Last reply 18 Aug 2023, 18:54
                      0
                      • cristian-adamC cristian-adam
                        18 Aug 2023, 18:51

                        With Qt Creator you shouldn't have to modify the CMAKE_PREFIX_PATH or CMAKE_FIND_MODULE in Qt Creator.

                        Just make sure you have a Kit with the right Qt configured.

                        That's all.

                        cristian-adamC Offline
                        cristian-adamC Offline
                        cristian-adam
                        wrote on 18 Aug 2023, 18:54 last edited by
                        #11

                        If you have installed Qt Creator standalone you need to tell it where to find Qt.

                        Under Preferences -> Kits -> Qt Versions click on Link with Qt... and then restart.

                        Afterwards you should be set, and your CMakeLists.txt projects do not need any set(CMAKE_PREFIX_PATH ...) entries.

                        Usually it's bad practice to do such things. A project needs to be configured from "outside".

                        1 Reply Last reply
                        1

                        1/11

                        18 Aug 2023, 12:36

                        • Login

                        • Login or register to search.
                        1 out of 11
                        • First post
                          1/11
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved