Q: How do I use the protobuf compiler and embed it in my build system?
A: It depends. But here are some tips:
We’ve found that it’s best to standardize around a specific version of the protobuf compiler and keep it within the project (it’s pretty small), instead of relying on a system package or centralized version.
You can download protobuf releases directly from github.
We often use a bash script, get_protobuf.sh, typically placed in the project under a scripts/ folder:
Then we typically create a bash script called generate.sh that runs the protobuf compiler. It looks slightly different depending on the platform. Here are some examples:
For C++, we usally use CMake and the Protobuf package with the target_compile_definitions() directive.