Skip to content

Support standalone shared library builds using CMake #22953

@doganulus

Description

@doganulus

The current CMake script builds either fully static or fully shared libraries, controlled globally by the protobuf_BUILD_SHARED_LIBS variable. This means that all dependencies of libprotobuf and libprotobuf-lite, including absl, are also built with the same linkage type. Notably, linking absl as a shared library introduces a significant number of runtime dependencies into the final libprotobuf and libprotobuf-lite objects.

To reduce external dependencies and simplify deployment, it would be beneficial to support building libprotobuf and libprotobuf-lite as shared libraries independently of their dependencies. This could be achieved by introducing finer-grained control via dedicated CMake variables, such as:

  • protobuf_BUILD_SHARED_LIBS
  • protobuf_deps_BUILD_SHARED_LIBS
  • protobuf_absl_BUILD_SHARED_LIBS
  • protobuf_utf8range_BUILD_SHARED_LIBS

Note that the glibc dependency may also be worth considering, but is not covered here.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions