Syntax error when build MongoDB C++ Driver on Windows with CMake

I followed the MongoDB C++ Driver official document but got no luck. The build failed at:

cmake --build . --config RelWithDebInfo

I’ve configured the CMake with: cmake .. -G "Visual Studio 17 2022" -A "x64" -DBOOST_ROOT=C:\boost_1_84_0 -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver

Please help!

I can build on VS 2022 with these commands in Powershell (Note: Boost is not needed since VS 2022 supports C++17):

cmake -B cmake-build -S . -DCMAKE_CXX_STANDARD=17 -G "Visual Studio 17 2022" -A "x64" -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver
cmake --build cmake-build --target INSTALL

I expect the issue is caused by the C:\msys64 headers being included. I do not expect Visual Studio builds to work with headers from msys2. I suggest checking the output of the cmake .. -G "Visual Studio 17 2022" to see if anything suggests why the msys2 headers are being found.