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
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 ?
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 version26.1
, and usingfind_package(Protobuf CONFIG)
with such an install setsProtobuf_VERSION
to26.1.0
. But theninclude/google/protobuf/port_def.inc
definescorresponding to
5.26.1
.Now compare this to a
conan
project whichrequires
andtool_requires
, e.g.,protobuf/5.27.0
. The generatedFindProtobuf.cmake
setsset(Protobuf_VERSION "5.27.0")
, but aconan create .
with a CMake project which requiresprotobuf/5.27.0
printsand in this file
protobuf-module.cmake
, we haveset(Protobuf_VERSION "27.0.0")
, which is also what's reported fromAnyway 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 beprotoc --version
within CMake<minor>.<patch>.0
from theProtobuf_VERSION
protobuf-module.cmake
?conanfile.py
?Any feedback/suggestions are appreciated!