ld unable to find iostreams functions under MSYS2

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.

@brad.king Have you seen this?