1、bat脚本,可根据自己的实际需求进行修改
::ANDROID_ABI:arm64-v8a, armeabi-v7a ,x86,x86_64
::E:\develop\Android\SDK\cmake\3.10.2.4988404\bin\ninja.exe
set toolchain=E:/develop/Android/android-ndk-r21/build/cmake/android.toolchain.cmake
set android_ndk=E:/develop/Android/android-ndk-r21
set build_type=Release
set gernerator="Ninja"
set build_dir="build"
set build_abi="armeabi-v7a"
if exist %build_dir% rd %build_dir% /s /q
md %build_dir%
cd %build_dir%
::if not exist %1 md %1
::cd %1
if not exist %build_abi% md %build_abi%
cmake .. -DANDROID=1 -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_BUILD_STATIC_LIBS=ON -DCMAKE_VERBOSE_MAKEFILE=ON -Dprotobuf_BUILD_TEST=OFF -Dprotobuf_BUILD_EXAMPLES=OFF -DCMAKE_TOOLCHAIN_FILE=%toolchain% -DCMAKE_BUILD_TYPE=%build_type% -DCMAKE_INSTALL_PREFIX=%build_abi% -DANDROID_NDK=%android_ndk% -DANDROID_TOOLCHAIN=clang -DANDROID_ABI=%build_abi% -DANDROID_NATIVE_API_LEVEL=16 -DANDROID_STL=c++_shared -DANDROID_LINKER_FLAGS="-landroid -llog" -DANDROID_CPP_FEATURES="rtti exceptions" -DCMAKE_GENERATOR=%gernerator% -DANDROID_PLATFORM=android-21
ninja
ninja install
最终编译产物: