diff options
author | Jannik Beyerstedt <beyerstedt@consider-it.de> | 2023-07-14 08:55:32 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-07-14 13:34:13 (GMT) |
commit | 6e90d7957741975ce75edd1dcf871e6f4e760605 (patch) | |
tree | 9aae34455538f3d8b5bfe3fdd02bcd4cc139e979 | |
parent | 1f42b0299b75d92bd37b2daeaa320da40fa9cba5 (diff) | |
download | CMake-6e90d7957741975ce75edd1dcf871e6f4e760605.zip CMake-6e90d7957741975ce75edd1dcf871e6f4e760605.tar.gz CMake-6e90d7957741975ce75edd1dcf871e6f4e760605.tar.bz2 |
FindProtobuf: Fix new version number scheme
Revise the changes from commit fc7dcc6a24 (FindProtobuf: Support new
version number scheme, 2023-06-19, v3.27.0-rc3~2^2). Changing the
content of `Protobuf_VERSION` to exclude the major version of the library
might break code as it can't be used to detect breaking changes in the
library any more.
However, protoc v22 and up don't print the major version any more, so we
need to compare the against a truncated version number, too.
-rw-r--r-- | Modules/FindProtobuf.cmake | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index b2567c0..a92fb52 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -499,11 +499,7 @@ if(Protobuf_INCLUDE_DIR) math(EXPR _PROTOBUF_MAJOR_VERSION "${Protobuf_LIB_VERSION} / 1000000") math(EXPR _PROTOBUF_MINOR_VERSION "${Protobuf_LIB_VERSION} / 1000 % 1000") math(EXPR _PROTOBUF_SUBMINOR_VERSION "${Protobuf_LIB_VERSION} % 1000") - if (_PROTOBUF_MINOR_VERSION GREATER_EQUAL "21") - set(Protobuf_VERSION "${_PROTOBUF_MINOR_VERSION}.${_PROTOBUF_SUBMINOR_VERSION}") - else() - set(Protobuf_VERSION "${_PROTOBUF_MAJOR_VERSION}.${_PROTOBUF_MINOR_VERSION}.${_PROTOBUF_SUBMINOR_VERSION}") - endif() + set(Protobuf_VERSION "${_PROTOBUF_MAJOR_VERSION}.${_PROTOBUF_MINOR_VERSION}.${_PROTOBUF_SUBMINOR_VERSION}") if(Protobuf_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " @@ -524,7 +520,9 @@ if(Protobuf_INCLUDE_DIR) "${Protobuf_PROTOC_EXECUTABLE} reveals version ${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}") endif() - if(NOT "${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}" VERSION_EQUAL "${Protobuf_VERSION}") + # protoc version 22 and up don't print the major version any more + if(NOT "${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}" VERSION_EQUAL "${Protobuf_VERSION}" AND + NOT "${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}" VERSION_EQUAL "${_PROTOBUF_MINOR_VERSION}.${_PROTOBUF_SUBMINOR_VERSION}") message(WARNING "Protobuf compiler version ${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}" " doesn't match library version ${Protobuf_VERSION}") endif() |