[cmake-developers] [PATCH] FindProtobuf: check version
Antonio Pérez Barrero
apbarrero at gmail.com
Mon Feb 8 10:29:50 EST 2016
Hi,
thanks for feedback, I'll rework the patch. I was planning to actually
submit three patches covering the following:
* Version checking
* Interface variables rename, keeping backwards compatibility.
* Fix a bug when setting Protobuf_LIBRARIES on Un*x systems.
So what's the best way to submit them:
* A separate format-patch for each.
* An all together patch.
* Fork github's repo, create a branch and send a link here.
Thanks,
Antonio
El mar., 2 feb. 2016 a las 16:18, Rolf Eike Beer (<eike at sf-mail.de>)
escribió:
> > +
> > + set(Protobuf_VERSION 0)
>
> Just set it to an empty string.
>
> > + set(Protobuf_LIB_VERSION "")
> > + file(STRINGS ${_Protobuf_COMMON_HEADER} _Protobuf_COMMON_H_CONTENTS
> > REGEX "#define GOOGLE_PROTOBUF_VERSION ")
>
> I would replace the spaces with "[ \t]+" so a formatting change will not
> break the extraction, also below.
>
> > + set(_Protobuf_VERSION_REGEX "([0-9]+)")
>
> No need for that variable, just put it into the matches argument below.
>
> > + if("${_Protobuf_COMMON_H_CONTENTS}" MATCHES "#define
> > GOOGLE_PROTOBUF_VERSION ${_Protobuf_VERSION_REGEX}")
> > + set(Protobuf_VERSION "${CMAKE_MATCH_1}")
> > + endif()
> > + unset(_Protobuf_COMMON_H_CONTENTS)
> > +
> > + math(EXPR Protobuf_MAJOR_VERSION "${Protobuf_VERSION} / 1000000")
> > + math(EXPR Protobuf_MINOR_VERSION "${Protobuf_VERSION} / 1000 %
> > 1000")
> > + math(EXPR Protobuf_SUBMINOR_VERSION "${Protobuf_VERSION} % 1000")
>
> You are not required to export these variables, only if you expect it to
> be useful for something beyond version checking. If anyone needs
> specific version fiddling Protobuf_VERSION can be used.
>
> Eike
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20160208/d20c9ee6/attachment-0001.html>
More information about the cmake-developers
mailing list