Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] Protobuf versioning scheme and Protobuf_VERSION variables #25297

Open
lia-viam opened this issue Sep 17, 2024 · 1 comment
Open

[question] Protobuf versioning scheme and Protobuf_VERSION variables #25297

lia-viam opened this issue Sep 17, 2024 · 1 comment
Labels
question Further information is requested

Comments

@lia-viam
Copy link

lia-viam commented Sep 17, 2024

What is your question?

So the versioning schemes in protobuf are a tad confusing, see eg
https://protobuf.dev/support/version-support/#cpp
In the second table, a version like C++ version 5.26.x corresponds to protoc version 26.x.

But in a homebrew install, for example, brew info protobuf reports version 26.1, and using find_package(Protobuf CONFIG) with such an install sets Protobuf_VERSION to 26.1.0. But then include/google/protobuf/port_def.inc defines

#define PROTOBUF_VERSION 5026001

corresponding to 5.26.1.

Now compare this to a conan project which requires and tool_requires, e.g., protobuf/5.27.0. The generated FindProtobuf.cmake sets set(Protobuf_VERSION "5.27.0"), but a conan create . with a CMake project which requires protobuf/5.27.0 prints

...
-- Conan: Including build module from '/Users/lia/.conan2/p/b/proto24456bb2a2261/p/lib/cmake/protobuf/protobuf-module.cmake'

and in this file protobuf-module.cmake, we have set(Protobuf_VERSION "27.0.0"), which is also what's reported from

$ ~/.conan2/p/b/proto24456bb2a2261/p/bin/protoc --version
libprotoc 27.0

Anyway long story short, is there a canonical way to extract what we might call the [lib]protoc version from the conan installation? I do think conan may be doing the more correct thing here, but I am dealing with some existing CMake code which expected to get a 20-something variable number like the one produced by homebrew. Some options I was considering would be

  • invoke protoc --version within CMake
  • construct a new version number from <minor>.<patch>.0 from the Protobuf_VERSION
  • somehow include the protobuf-module.cmake ?
  • some other option programatically within the conanfile.py ?

Any feedback/suggestions are appreciated!

@lia-viam lia-viam added the question Further information is requested label Sep 17, 2024
@Ahajha
Copy link
Contributor

Ahajha commented Sep 19, 2024

Potential option is to add it as a conf_info define (see https://docs.conan.io/2/reference/conanfile/methods/package_info.html#conf-info). Then you can just read this value from the consumer conanfile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants