获取源代码
git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf/
git submodule update --init --recursive
cmake配置
mkdir build
cd build
cmake -G "Visual Studio 17 2022" -DCMAKE_INSTALL_PREFIX=.\install ..
执行完上面的命令后,在当前文件夹中生成了protobuf.sln,打开后即可编译,或者使用以下命令构建
cmake --build . --config Release
cmake --build . --config Release --target install