+
+  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
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to