protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Version specification using cmake find_package with protobuf does not seem right

Open johnfb opened this issue 5 months ago • 1 comments

https://github.com/protocolbuffers/protobuf/blob/65ab2a2584757ac67a9858dff37b1d2e4db059e5/cmake/protobuf-config-version.cmake.in#L21

Compares the MAJOR version with the passed in version, and if it does not match says incompatible

protobuf_MAJOR_VERSION is set here (currently set to 6) https://github.com/protocolbuffers/protobuf/blob/65ab2a2584757ac67a9858dff37b1d2e4db059e5/CMakeLists.txt#L106-L107

But the very next line in the protobuf-config-version.cmake https://github.com/protocolbuffers/protobuf/blob/65ab2a2584757ac67a9858dff37b1d2e4db059e5/cmake/protobuf-config-version.cmake.in#L23 then compares the find package version string against protobuf_VERSION which is the library version as defined here: https://github.com/protocolbuffers/protobuf/blob/65ab2a2584757ac67a9858dff37b1d2e4db059e5/CMakeLists.txt#L120-L121

This means that in one place it is expecting the version string to be like "6.31.1" and in the very next line it is assuming the version string to be like "31.1.0".

This will result in situations where if I say find_package(protobuf "6.31.0") but 6.30 is what is installed, it will accept that version as 6 is less than 30.

This does not seem right.

Also, using the version range specification of find package is not supported at all. This would be rather nice to have for a dependent library to be able to say that it does not yet support a version.

johnfb avatar Jul 30 '25 16:07 johnfb

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago. This issue will be closed and archived after 14 additional days without activity.

github-actions[bot] avatar Oct 29 '25 10:10 github-actions[bot]

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.

This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.

github-actions[bot] avatar Nov 12 '25 10:11 github-actions[bot]