C++
Minimum version: C++20 (GCC 11, Clang 14, AppleClang 16, MSVC 19.38 or newer) and CMake 3.20 or newer.
The C++ target is experimental.
Add cpp under targets to generate a C++ SDK.
{
"targets": {
"cpp": {
"packageName": "acme",
"options": {
"namespace": "acme"
},
"destinations": {
"production": {
"repo": "acme/acme-cpp"
}
}
}
}
}
C++ has no package registry the generator publishes to, so this target generates the library and its CI workflow but no publishing workflow. Distribute the build artifacts from your GitHub release.
packageName
Type: string
Package name the C++ SDK is published under: the default for options.libraryName, so it names the CMake project and library target, the package find_package looks for and the <name>::<name> target it imports, and the vcpkg port and Conan recipe. The value is converted to snake_case, so acme-billing becomes acme_billing. options.libraryName wins when both are set, and so does a package name passed to the generator. It does not change the namespace. A value that does not start with a letter once converted, or one CMake, a dependency or Windows reserves (such as test, install or con), fails generation.
options
Type: object
C++ emitter options.
namespace
Type: string
C++ namespace the generated client, models and resources are declared in, such as acme or acme::v2. Each :: segment is lowercase snake_case that starts with a letter, with no doubled or trailing _; a segment that C++, the C library or a dependency reserves fails generation: for example a keyword, std, a macro such as linux or min, or a C library function such as time as the first segment. The namespace also names the public include directory, the umbrella header and the macro prefix (acme::v2 gives include/acme_v2/, acme_v2.hpp and ACME_V2_). Defaults to the package name passed to the generator, else the SDK's slug, converted to snake_case.
Constraints: pattern: ^[a-z](_?[a-z0-9])*(::[a-z](_?[a-z0-9])*)*$
libraryName
Type: string
Name of the generated CMake project and library target, and of the package find_package looks for. The value is converted to snake_case. The public headers live under include/ in a directory named after namespace, not this. Defaults to the package name passed to the generator, else targets.cpp.packageName, else the SDK's slug, converted to snake_case. A value that does not start with a letter once converted, or one CMake, a dependency or Windows reserves (such as test, install or con), fails generation.
async
Type: boolean
Generates an asynchronous client beside the synchronous one (client.async()), whose methods return a std::future or take a completion callback and run on the client's executor. Set false to leave it out, with its executor runtime, its client options and its example, which shortens build times for a very large API. Defaults to true.
Default: true
preserveUnknownFields
Type: boolean
Gives every generated model an extra_fields member that keeps the JSON keys the API document does not describe, so a model decoded from a response and written back into a request round-trips them unchanged. Set false to drop the member and discard those keys on decode. Defaults to true.
Default: true
destinations
Type: object
Per-target GitHub destinations for pushing generated output.
production
Type: object
Primary repository this target's generated output is published to. Setting it turns on the generated GitHub Actions: the CI workflow, the release-please configuration, and the versioning policy. A release workflow is added too when publish enables a registry that needs one; a registry served from git tags publishes from the release tag alone. Without a production destination the target is still generated, but with no workflows.
| Property | Description |
|---|---|
repo* |
GitHub repository in owner/name form that generated output for this target is pushed to. An owner/name#branch suffix is tolerated and supplies the default branch when branch does not, but prefer setting branch on its own: not every target strips the suffix back off when it writes the repository URL into published package metadata. |
branch |
Default branch of the destination repository, which release pull requests target. Generated output is pushed to the generated branch (generatedBranch, scalar-generated by default) and merged with your custom code on the integration branch (integrationBranch, scalar-next by default); the release pull request is opened from there against this branch. Defaults to a #branch suffix on repo, then main. A value that is not a safe git branch name is skipped in favor of the next one. |
integrationBranch |
Branch where generated output is combined with your custom code; defaults to scalar-next. Commit customizations here: each regeneration is merged into it, release pull requests are opened from it, and each released version is synced back to it. An empty string means the default. The name must be a safe git branch name, and it cannot be the default branch or collide with the branches Scalar and release-please manage, such as scalar-generated. |
generatedBranch |
Branch Scalar pushes pristine generator output to before merging it into the integration branch; defaults to scalar-generated. Never commit here: every build replaces its contents. An empty string means the default. The name must be a safe git branch name, and it cannot be the default branch or the integration branch, or collide with the other branches Scalar and release-please manage, such as scalar-next and scalar-merge-conflict. |
installOrder
Type: ("fetchContent" | "findPackage" | "vcpkg" | "conan")[]
Order of the install methods in the generated README's Installation section and the agent skill's Install section. fetchContent adds the SDK to a CMake project with FetchContent (or with add_subdirectory over a checkout, when the target has no GitHub production repository to fetch from); findPackage installs the SDK once and uses it through find_package, together with the commands that build and install it; vcpkg installs it through the overlay port under packaging/vcpkg/ports, and conan packages it with the Conan 2 recipe and requires it from a consumer's conanfile.txt. vcpkg and conan are offered only when the target has a production repository (target.lifecycle), which is what emits that packaging. Listed methods come first, in the order given; any left out follow in the default order, so a one-item list only moves that method to the top. A method listed twice keeps its first position. A method the config does not publish is skipped wherever it is listed.
Default: ["fetchContent", "findPackage", "vcpkg", "conan"]
skip
Type: boolean
When true, the target is not generated.
readmeTitle
Type: string
Heading of this target's generated README, overriding the SDK-wide readme.title. Plain text: markdown in it is shown as written, not rendered.
promotion
Type: "automatic" | "manual"
When a successful build's generated output reaches this target's production destination. automatic, the default, pushes every build, which opens a release pull request. manual holds each build at the staging playground until you promote it.
This changes when the push happens, never what is generated: a manual target still gets the GitHub Actions, release-please configuration, and versioning policy that destinations.production turns on. A target with no production destination is never pushed, whatever this is set to.
Default: "automatic"
What did you think of this content?