欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

QtCreator创建CMake工程

程序员文章站 2022-07-14 22:10:18
...

一、MinGw

确保cmake已经安装并且添加到了系统环境变量(Qtcreator会自动检测),或者Qtcreator中手动添加。

QtCreator创建CMake工程
  使用Mingw编译器的话创建很简单,新建工程-Non-Qt Project-Plain C++ Application:
QtCreator创建CMake工程
QtCreator创建CMake工程
选择Cmake:
QtCreator创建CMake工程
选择Mingw编译器即可。
QtCreator创建CMake工程

二、MSVC

  如果使用vs编译器的话,需要准备:
1、vs已经安装。
2、win10 SDK(本人使用的是win10)已经安装。
3、将D:\Qt\Qt5.9.6\Tools\QtCreator\bin(根据自己的实际情况)添加到系统环境变量,不然会报错:

Running "D:\tools\cmake-3.11.0-rc3-win64-x64\cmake-3.11.0-rc3-win64-x64\bin\cmake.exe -E server "--pipe=\\.\pipe\{b2aa12d0-6e73-49b3-8b91-b084356be455}" --experimental" in C:\Users\84465\AppData\Local\Temp\QtCreator-P1XkOA\qtc-cmake-XXBA6dX1.
Starting to parse CMake project, using: "-DCMAKE_CXX_COMPILER:STRING=D:/vs2015/VC/BIN/amd64_x86/cl.exe", "-DCMAKE_C_COMPILER:STRING=D:/vs2015/VC/BIN/amd64_x86/cl.exe", "-DCMAKE_PREFIX_PATH:STRING=D:/Qt/Qt5.9.6/5.9.6/msvc2015", "-DQT_QMAKE_EXECUTABLE:STRING=D:/Qt/Qt5.9.6/5.9.6/msvc2015/bin/qmake.exe".
The C compiler identification is MSVC 19.0.24210.0
The CXX compiler identification is MSVC 19.0.24210.0
Check for working C compiler: D:/vs2015/VC/BIN/amd64_x86/cl.exe
CMake Error: Generator: execution of make failed. Make command was: "jom" "/NOLOGO" "cmTC_9a64b\fast"
Check for working C compiler: D:/vs2015/VC/BIN/amd64_x86/cl.exe -- broken
CMake Error at D:/tools/cmake-3.11.0-rc3-win64-x64/cmake-3.11.0-rc3-win64-x64/share/cmake-3.11/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "D:/vs2015/VC/BIN/amd64_x86/cl.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/Users/84465/AppData/Local/Temp/QtCreator-P1XkOA/qtc-cmake-XXBA6dX1/CMakeFiles/CMakeTmp

    Run Build Command:"jom" "/NOLOGO" "cmTC_9a64b\fast"
    系统找不到指定的文件。
    Generator: execution of make failed. Make command was: "jom" "/NOLOGO" "cmTC_9a64b\fast"




  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)


Configuring incomplete, errors occurred!
See also "C:/Users/84465/AppData/Local/Temp/QtCreator-P1XkOA/qtc-cmake-XXBA6dX1/CMakeFiles/CMakeOutput.log".
See also "C:/Users/84465/AppData/Local/Temp/QtCreator-P1XkOA/qtc-cmake-XXBA6dX1/CMakeFiles/CMakeError.log".
CMake Project parsing failed.

其余步骤与MinGw一致。
QtCreator创建CMake工程

相关标签: Cmake Qtcreator