What is the CMake command line you’re using? I would guess that you’re probably using a Windows CMake build which is trying to use MSBuild internally. Rather than setting the compilers in the CMake source directly, it is recommended that you instead just run CMake from a MinGW environment and let it discover things on its own.
Yes, I use a Windows CMake. Run it by the simplest command:
cmake .
Current directory is source files directory, of course.
How can I use CMake from a MinGW environment? I do not use graphic interfaces, just command line tools. Should I run something from mingw bin directory to do it?
By the way, I think there must be a way to explicitly point to CMake which build tool to use.
That will probably use a Visual Studio generator. Trying to get that to use MinGW is certainly doomed to failure. Your MinGW source should have a package manager to be able to get its cmake (pacman?).