我正在尝试在不使用Qt库的情况下,将Qt Creator用于C++ CMake项目。我正在遵循官方指南,但完全不起作用。以下是我的步骤:
在查看配置菜单以查看是否忘记设置某些内容时,我偶然发现了编译器设置页面。当然,我也将我的编译器添加到了那里,但它什么也没做。
为什么 CMake 在使用时不使用编译器列表?
如果您在套件选择中选择正确的编译器,则会使用编译器列表。
- 将我的MinGW bin目录添加到
PATH
。 - 运行Qt Creator并设置CMake。
- 打开一个非常基本的
CMakeLists.txt
文件。 - 选择“Ninja(桌面)”作为CMake生成器。
- 从CMake中获取错误。
最终的问题是:
如何通过CMake使Qt Creator使用MinGW编译器?
已回答的问题:
根据官方指南和通常情况下,当您正确设置PATH
时,步骤5不应发生。
为什么CMake找不到在PATH
中设置的编译器?
这是Ninja Generator创建这些错误的原因,如果您手动使用CMake进行操作,同样的事情也会发生。
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER
CMake Error: Could not find cmake module file: D:/Programming/C++/Test/SupportQt/build/CMakeFiles/3.0.2/CMakeCXXCompiler.cmake
CMake Error at CMakeLists.txt:1 (project):
No CMAKE_C_COMPILER could be found.
Tell CMake where to find the compiler by setting the CMake cache entry
CMAKE_C_COMPILER to the full path to the compiler, or to the compiler name
if it is in the PATH.
CMake Error at CMakeLists.txt:1 (project):
No CMAKE_CXX_COMPILER could be found.
Tell CMake where to find the compiler by setting the CMake cache entry
CMAKE_CXX_COMPILER to the full path to the compiler, or to the compiler
name if it is in the PATH.
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER
CMake Error: Could not find cmake module file: D:/Programming/C++/Test/SupportQt/build/CMakeFiles/3.0.2/CMakeCCompiler.cmake
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.-- Configuring incomplete, errors occurred!
在查看配置菜单以查看是否忘记设置某些内容时,我偶然发现了编译器设置页面。当然,我也将我的编译器添加到了那里,但它什么也没做。
为什么 CMake 在使用时不使用编译器列表?
如果您在套件选择中选择正确的编译器,则会使用编译器列表。