I am using MSYS2 + MinGW x64 + CMake as my development setup on windows. Currently, to initialize my projects, I open a "MSYS2 MinGW 64-bit" shell and invoke CMake as follows:
cmake .. -G"MinGW Makefiles"
This works nicely, but I'd like to use ninja instead of make. Therefore, I installed mingw-w64-x86_64-ninja via my MSYS2 shell, making it available in my MinGW environment. I expected
cmake .. -G"Ninja"
to work, but instead it fails with the following errors:
-- The C compiler identification is GNU 10.2.0 -- The CXX compiler identification is GNU 10.2.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - failed -- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe -- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe - broken CMake Error at C:/msys64/mingw64/share/cmake-3.20/Modules/CMakeTestCCompiler.cmake:66 (message): The C compiler "C:/msys64/mingw64/bin/gcc.exe" is not able to compile a simple test program. It fails with the following output: Change Dir: C:/projecct/build/CMakeFiles/CMakeTmp Run Build Command(s):C:/msys64/usr/bin/ninja.exe cmTC_c3f3d && [1/2] Building C object CMakeFiles/cmTC_c3f3d.dir/testCCompiler.c.obj FAILED: CMakeFiles/cmTC_c3f3d.dir/testCCompiler.c.obj C:\msys64\mingw64\bin\gcc.exe -o CMakeFiles/cmTC_c3f3d.dir/testCCompiler.c.obj -c testCCompiler.c /bin/sh: line 1: C:msys64mingw64bingcc.exe: command not found ninja: build stopped: subcommand failed. CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:2 (project) -- Configuring incomplete, errors occurred! See also "C:/project/build/CMakeFiles/CMakeOutput.log". See also "C:/project/build/CMakeFiles/CMakeError.log".
Judging from the following line
/bin/sh: line 1: C:msys64mingw64bingcc.exe: command not found
it seems that this is a / vs \ issue.
Is there a solution or workaround to this problem?
Can I use Ninja as my generator on a MSYS2 + MinGW x64 setup on Windows 10?