capnproto.cpp

Provides support for Cap'n Proto for the C++ language. More...

Since: Qbs 1.17

Properties

Detailed Description

The capnproto.cpp module provides support for generating C++ headers and sources from proto definition files using the capnpc tool.

A simple qbs file that uses Cap'n Proto can be written as follows:

 CppApplication {
     Depends { name: "capnproto.cpp" }
     files: ["foo.capnp", "main.cpp"]
 }

A generated header now can be included in the C++ sources:

 #include <foo.capnp.h>

 int main(int argc, char* argv[]) {
     ::capnp::MallocMessageBuilder message;

     auto foo = message.initRoot<Foo>();
     foo.setAnswer(42);
     return 0;
 }

Relevant File Tags

TagAuto-tagged File NamesSinceDescription
"capnproto.input"*.capnp1.17.0Source files with this tag are considered inputs to the capnpc compiler.

Dependencies

This module depends on the capnp module and on the capnp-rpc module if useRpc property is true. These modules are created by the Module Providers via the pkg-config tool.

Property Documentation

compilerName : string

The name of the capnp binary.

Default: "capnpc"


compilerPath : string

The path to the protoc binary.

Use this property to override the auto-detected location.

Default: auto-detected


importPaths : pathList

The list of import paths that are passed to the capnpc tool via the --import-path option.

Default: []


[read-only] outputDir : string

The directory where the capnpc compiler generated files are placed.

The value of this property is automatically set by Qbs and cannot be changed by the user.


useRpc : bool

Use this property to enable support for the RPC framework.

A simple qbs file that uses rpc can be written as follows:

 import qbs.Host

 Project {
     CppApplication {
         Depends { name: "capnproto.cpp"; required: false }
         name: "server"
         condition: capnproto.cpp.present && qbs.targetPlatform === Host.platform()
         consoleApplication: true
         capnproto.cpp.useRpc: true

         files: [
             "calculator.capnp",
             "calculator-server.cpp"
         ]
     }
     CppApplication {
         Depends { name: "capnproto.cpp"; required: false }
         name: "client"
         condition: capnproto.cpp.present && qbs.targetPlatform === Host.platform()
         consoleApplication: true
         capnproto.cpp.useRpc: true

         files: [
             "calculator.capnp",
             "calculator-client.cpp"
         ]
     }
 }

Default: false