CMake bootstrap fails under Windows with error: 'KWSYS_ENCODING_DEFAULT_CODEPAGE' was not declared in this scope

Hey there,
I am trying to build CMake master branch from scratch as described here:
https://gitlab.kitware.com/cmake/cmake/-/blob/master/README.rst#building-cmake
I am on Windows 10 and try to build with MSYS2 & MinGW.

I installed the necessary MSYS packages with
pacman -S --needed git base-devel mingw-w64-x86_64-gcc

Unfortunately the bootstrap script fails with the following error:

C:/Projects/cmake/Source/cmProcessOutput.cxx:12:3: error: 'KWSYS_ENCODING_DEFAULT_CODEPAGE' was not delared in this scope

Do I have to define that manually when calling bootstrap?
It seems to get set to ‘CP_UTF8’ in the top level CMakeLists.txt, but I do not know if and when this gets executed when calling bootstrap…

During bootstrap, KWSYS_ENCODING_DEFAULT_CODEPAGE is supposed to be defined here. The condition guarding it is that uname’s output contains MINGW.

To use the mingw-w64-x86_64-gcc toolchain and build for MinGW, rather than the MSYS2 runtime, be sure to bootstrap in MinGW development environment:

$ echo $MSYSTEM
MINGW64

That brings me a big step further, thank you very much!
(What I ended up doing was to simply start mingw64.exe instead of msys2.exe in my msys installation which starts the MinGW environment and automatically sets the right environment variables.)

When I use that environment, bootstrap and make succeeds.
Unfortunately, that is when I run into a new problem.

When trying to run build/cmake.exe, an error message appears, stating that
" The Procedure Entry Point “ZNKSt7codecvtlcciE5do_inERiPKcS3_RS3_PcS5_RS5” Could Not Be Located in the Dynamic Link Library “C:\Projects\cmake\build\bin\cmake.exe”.

I guess I miss some DLL?
The following DLLs have been copied to the build dir, but it seems they are insufficient or the incorrect libs:

libcmake.dll.a
libcmcldeps.dll.a
libcpack.dll.a
libctest.dll.a