From fc7dcc6a24ffd33b780104ebd9dbb115d306827e Mon Sep 17 00:00:00 2001 From: Jannik Beyerstedt Date: Mon, 19 Jun 2023 17:29:47 +0200 Subject: FindProtobuf: Support new version number scheme Protobuf changed it's version number scheme with version 21. The first number (usually the major version) is not synchronized between compiler and library version, but the second and third number are. See https://protobuf.dev/news/2022-05-06/ for more details. Fixes: #24847 --- Modules/FindProtobuf.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index c73a2d8..b046fcc 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -499,7 +499,11 @@ 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") - set(Protobuf_VERSION "${_PROTOBUF_MAJOR_VERSION}.${_PROTOBUF_MINOR_VERSION}.${_PROTOBUF_SUBMINOR_VERSION}") + 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() if(Protobuf_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " -- cgit v0.12