I don’t, and setting it doesn’t seem to change the behavior of cmake. But in the MSYS2 MinGW shell /mingw64/bin/cc.exe -v indicates that it should be the same compiler. Looking at the compiler invocation I can’t see anything that would change behavior.
Some programs look at the name they are called with and change behavior based on that. For example, gcc foo.cxx works for compilation and fails at the link step just like here:
$ cat foo.cxx
#include <iostream>
int main(int argc, char* argv[]) {
return 0;
}
$ gcc foo.cxx
/usr/bin/ld: /tmp/cc6G9wwR.o: in function `__static_initialization_and_destruction_0(int, int)':
foo.cxx:(.text+0x35): undefined reference to `std::ios_base::Init::Init()'
/usr/bin/ld: foo.cxx:(.text+0x44): undefined reference to `std::ios_base::Init::~Init()'
collect2: error: ld returned 1 exit status
So I think figuring out why CMake thinks cc.exe is your C++ compiler is what needs investigated.
On one MSYS2 installation this works but on another it doesn’t. I can’t figure out why cc.exe is being run, and the environments were prepared more or less the same way using MSYS2’s package manager.
On one environment, the files properties changed the behavior.
The problem with linker could be caused by using unaligned versions of cmake and gcc. If you want to use mingw64 gcc you must also use mingw64 cmake.
If cmake is not alligned with gcc, you get following error in configure phase:
-- The CXX compiler identification is GNU 11.2.0
System is unknown to cmake, create:
Platform/MINGW64_NT-6.1-7601 to use this system, please post your config file on discourse.cmake.org so it can be added to cmake