I'm trying to use Qt Creator for C++ CMake project which doesn't use the Qt libraries.
我正在尝试使用Qt的创建者为c++ CMake项目,它不使用Qt库。
I'm following the official guide, but it does not work at all. Here are my steps:
我在听官方的指导,但根本就不工作。这是我的步骤:
- Add my MinGW bin directory to
PATH
. - 将我的MinGW bin目录添加到PATH中。
- Run QtCreator and setup CMake.
- 运行QtCreator和setup CMake。
- Open a a very basic
CMakeLists.txt
file. - 打开一个非常基本的CMakeLists。txt文件。
- Select "Ninja (Desktop)" as CMake generator.
- 选择“忍者(桌面)”作为CMake生成器。
- Getting errors from CMake.
- 得到CMake的错误。
You may have noticed that step 4 is actually not mentioned at all in the official guide. I'm quite used to CMake and as such I'm asking myself:
您可能已经注意到,在官方指南中实际上没有提到步骤4。我很习惯CMake,所以我问自己:
Why doesn't the Qt Creator offer the normal "MinGW Makefiles" generator?
为什么Qt创建者不提供正常的“MinGW makefile”生成器?
And finally the ultimate question:
最后的问题是
How can I make the Qt Creator use a MinGW compiler through CMake?
如何使Qt创建者通过CMake使用一个MinGW编译器?
Answered questions:
回答问题:
According to the official guide and as usual when you set PATH
correctly, step 5 should not happen.
根据官方指南,当您正确设置路径时,步骤5不应该发生。
Why doesn't CMake find the compiler set in PATH
?
为什么CMake不能找到路径中的编译器?
It's the Ninja Generator that creates these errors, the same thing happens if you do it manually with CMake.
它是制造这些错误的忍者生成器,如果你用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!
Looking at the configuration menu to see whether I have forgotten to setup something, I stumbled across the compiler setup page. I then of course added my compiler there as well, but it did nothing.
查看配置菜单,看看是否忘记设置一些东西,我偶然发现了编译器设置页面。我当然也添加了我的编译器,但它什么也没做。
Why doesn't CMake use the compiler list when using CMake?
使用CMake时,为什么CMake不使用编译器列表?
It does use the compiler list, IF you pick the right compiler in the kits selection.
它确实使用了编译器列表,如果您在包选择中选择了正确的编译器。
1 个解决方案
#1
5
As usually if you ask for help only to shortly after figure it out, I feel quite stupid now...
通常情况下,如果你只是在发现之后才寻求帮助,我现在觉得自己很愚蠢……
Why doesn't the Qt Creator use the compiler list when using CMake?
为什么Qt创建者在使用CMake时不使用编译器列表?
It does, but only if you set the Kit to use the right compiler!
它确实是这样,但前提是您要设置工具包来使用正确的编译器!
Why doesn't CMake find the compiler set in PATH?
为什么CMake不能找到路径中的编译器?
This is actually the problem of the Ninja Generator with CMake. The same thing happens if you use CMake directly.
这实际上是CMake的忍者发电机的问题。如果直接使用CMake也会发生同样的情况。
Why doesn't the Qt Creator offer the normal "MinGW Makefiles" generator?
为什么Qt创建者不提供正常的“MinGW makefile”生成器?
It does, but only if you picked a MinGW compiler in your Kit!
它确实如此,但前提是您在您的工具包中选择了一个MinGW编译器!
How can I make the Qt Creator use a MinGW compiler through CMake?
如何使Qt创建者通过CMake使用一个MinGW编译器?
By setting everything up correctly and not relying too heavily on the official guide.
通过正确的设置,而不是过于依赖官方指南。
#1
5
As usually if you ask for help only to shortly after figure it out, I feel quite stupid now...
通常情况下,如果你只是在发现之后才寻求帮助,我现在觉得自己很愚蠢……
Why doesn't the Qt Creator use the compiler list when using CMake?
为什么Qt创建者在使用CMake时不使用编译器列表?
It does, but only if you set the Kit to use the right compiler!
它确实是这样,但前提是您要设置工具包来使用正确的编译器!
Why doesn't CMake find the compiler set in PATH?
为什么CMake不能找到路径中的编译器?
This is actually the problem of the Ninja Generator with CMake. The same thing happens if you use CMake directly.
这实际上是CMake的忍者发电机的问题。如果直接使用CMake也会发生同样的情况。
Why doesn't the Qt Creator offer the normal "MinGW Makefiles" generator?
为什么Qt创建者不提供正常的“MinGW makefile”生成器?
It does, but only if you picked a MinGW compiler in your Kit!
它确实如此,但前提是您在您的工具包中选择了一个MinGW编译器!
How can I make the Qt Creator use a MinGW compiler through CMake?
如何使Qt创建者通过CMake使用一个MinGW编译器?
By setting everything up correctly and not relying too heavily on the official guide.
通过正确的设置,而不是过于依赖官方指南。