I do it with dockcross (which does not do anything fancy, it just sets up the toolchain in a convenient way).
Say for android-arm
(but it works for android-arm64
, android-x86
and android-x86_64
just the same):
$ git clone https://github.com/grpc/grpc --recursive
$ cd grpc
$ docker run --rm dockcross/android-arm > ./dockcross-android-arm
$ chmod +x dockcross-android-arm
$ ./dockcross-android-arm cmake -DgRPC_BUILD_CODEGEN=OFF -Bbuild -S.
$ ./dockcross-android-arm cmake --build build
It will build all the dependencies in the gRPC submodules. It should work in your project if you add gRPC as a submodule (well, up to some point depending on your transitive dependencies situation, I guess).
This said, I am not a big fan of using git submodules for dependencies with CMake. Instead I like to build the dependencies separately and have my project find them with find_package
. I explain that in more details here, and more importantly I have an example doing exactly that for gRPC here.