Skip to content

Add CMake packages for schemas and C++ bindings - #642

Draft
fruffy wants to merge 1 commit into
p4lang:mainfrom
fruffy:cmake-package
Draft

fruffy wants to merge 1 commit into
p4lang:mainfrom
fruffy:cmake-package

Conversation

@fruffy

@fruffy fruffy commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Work in progress.

LLM (GPT Astra) text:

P4Runtime currently has no CMake package, so consumers such as P4C must locate its schemas themselves. This adds find_package(p4runtime CONFIG) with a relocatable schema directory and p4runtime::schemas, without requiring Protobuf or a compiler for schema-only use.

Optional C++ generation provides p4runtime::cpp for messages and p4runtime::grpc for service bindings. Installed consumers request COMPONENTS cpp or grpc; dependencies are discovered only for those components. Parent projects can reuse their existing Protobuf/gRPC targets, installation defaults off for subprojects, and cross builds can supply host code-generation tools.

Validation:

  • Schema-only, C++, and gRPC builds, relocated installs, and add_subdirectory() consumers pass locally; the same matrix is added to CI.
  • C++ and gRPC consumers compile, link, and run with distribution Protobuf 3.21.12 / gRPC 1.51.1.
  • Schema-only and full gRPC integration checks also pass with CMake 3.16.9, exercising the minimum-version and top-level fallback paths.
  • A CPM parent supplying Protobuf 25.3 builds and runs the C++ consumer.
  • P4C's dependency discovery consumes the installed schema package without downloading P4Runtime.

Fixes #641.

Install relocatable P4Runtime schemas without requiring a compiler or Protobuf. Provide optional C++ message and gRPC libraries, exported targets, and component-aware dependency discovery for installed and parent-project consumers.

Exercise schema-only, C++, and gRPC builds, relocated installations, and add_subdirectory consumers in CI. Fixes p4lang#641.

Signed-off-by: fruffy <fruffy@nyu.edu>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CMake support for P4Runtime

1 participant