CMake has a couple of functions to generate protobuf definitions: protobuf_generate_cpp and protobuf_generate_python (See the documentation). Protoc actually supports serveral more languages including javascript. (See the documentation)
protobuf_generate_cpp and protobuf_generate_python both use an undocumented function protobuf_generate. This function almost supports javascript generation, but there are a couple of problems. It doesn't allow you to set additional options for the javascript independent of the output directory (See here and here ) The two most notable options are:
--import_stye: allows you to specify the module syntax for the generated code. The default is closure which is incompatible with nodejs
binary: this allows you to include parsers for the binary representation. Without this, the generated code is almost useless.
Below is a working function that could be included in externpro to facilitate generation of javascript definitions. It is losely based on the cmake protobuf_generate function:
CMake has a couple of functions to generate protobuf definitions:
protobuf_generate_cpp
andprotobuf_generate_python
(See the documentation). Protoc actually supports serveral more languages including javascript. (See the documentation)protobuf_generate_cpp
andprotobuf_generate_python
both use an undocumented functionprotobuf_generate
. This function almost supports javascript generation, but there are a couple of problems. It doesn't allow you to set additional options for the javascript independent of the output directory (See here and here ) The two most notable options are:--import_stye
: allows you to specify the module syntax for the generated code. The default isclosure
which is incompatible with nodejsbinary
: this allows you to include parsers for the binary representation. Without this, the generated code is almost useless. Below is a working function that could be included inexternpro
to facilitate generation of javascript definitions. It is losely based on the cmakeprotobuf_generate
function: