Using cmake 3.5.2 installed through MSYS2 under Wi

2019-04-16 04:16发布

问题:

I'm trying an hello world test to make cmake under Windows, using MinGW as compiler. This answer suggests to run cmake with the -G flag as following:

 cmake -G "MinGW Makefiles" .

However, if I do this, I get a message saying that that is not a known generator. Indeed, running cmake --help, under the Generators section it lists the following generators:

and as you can see, "MinGW Makefiles" is not listed.

If this is relevant, I have MinGW installed and working on my system in the usual folder C:\MinGW. I also have MinGW-w64 installed through WinBuilds and MSYS2, again in the default installation folders. I'm using cmake version 3.5.2, installed through MSYS2.

Why is "MinGW Makefiles" not listed among the generators?

回答1:

Only the Windows version of CMake does know the MinGW Makefiles and MSYS Makefiles generators.

If you have downloaded the MinGW/MSYS CMake version try using the Unix Makefiles generator or don't use the -G option (to auto-detect your compiler toolchain).

If you still get errors, please see the references below.

References

  • cmake MSYS Makefiles generator missing
  • CMake Error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found