CMakeLists issue
-
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. -
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.@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.
-
@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.
@Christian-Ehrlicher I'm not using QuickTime at any point. I only use QT framework for GUI, which made by QT Widget application.
-
@Christian-Ehrlicher I'm not using QuickTime at any point. I only use QT framework for GUI, which made by QT Widget application.
-
@Christian-Ehrlicher Yeah, true, my bad. I'm pretty new to the Qt and almost all of my previous projects are lagging now.
-
@Christian-Ehrlicher Yeah, true, my bad. I'm pretty new to the Qt and almost all of my previous projects are lagging now.
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.
-
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.
@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.
-
@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.
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 withoutlib/cmake/Qt<PackageName>
.CMake will use the values from
CMAKE_PREFIX_PATH
and add itself thelib/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.
-
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 withoutlib/cmake/Qt<PackageName>
.CMake will use the values from
CMAKE_PREFIX_PATH
and add itself thelib/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.
@cristian-adam I've tried your solution but the error is still there.
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-adam I've tried your solution but the error is still there.
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.With Qt Creator you shouldn't have to modify the
CMAKE_PREFIX_PATH
orCMAKE_FIND_MODULE
in Qt Creator.Just make sure you have a Kit with the right Qt configured.
That's all.
-
With Qt Creator you shouldn't have to modify the
CMAKE_PREFIX_PATH
orCMAKE_FIND_MODULE
in Qt Creator.Just make sure you have a Kit with the right Qt configured.
That's all.
If you have installed Qt Creator standalone you need to tell it where to find Qt.
Under
Preferences -> Kits -> Qt Versions
click onLink with Qt...
and then restart.Afterwards you should be set, and your
CMakeLists.txt
projects do not need anyset(CMAKE_PREFIX_PATH ...)
entries.Usually it's bad practice to do such things. A project needs to be configured from "outside".