Today I used cmake to manage the Qt project and encountered some errors. I will record them here.
Table of contents
1. Qtcreator creates a cmake type console program
2. Use Cmake-gui to build vs2012 project
1. Qtcreator creates a cmake type console program
I installed qt city 6.4.1 and 6.5.0 versions
Using MSVC2019 compiler
Because the msvc2019 compiler is not installed on this machine, problems occur in the project
Switch compiler
The program executes normally after switching
2. Use Cmake-gui to build vs2012 project
2.1 Create build directory
2.2 CMake-gui build
2.3 Error reporting
The error message is as follows:
The error shows that the following cmake file cannot be found
Qt6Config.cmake
qt6-config.cmake
Qt5Config.cmake
qt5-config.cmake
The solution is also given. I installed qt6, so I only need to find
the path where Qt6Config.cmake or qt6-config.cmake is located.
qt6-config.cmake cannot be found
Qt6Config.cmake was found, and the corresponding compiler found was C:\Qt\6.5.0\mingw_64\lib\cmake\Qt6
(1) Solution 1
Add path C:\Qt\6.5.0\mingw_64\lib\cmake\Qt6 to CMAKE_PREFIX_PATH
Compile OK and generate vs2012 project
(2) Solution 2
QT_DIR and Qt6_DI settings C:\Qt\6.5.0\mingw_64\lib\cmake\Qt6
Generate OK