1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-17 07:11:52 +08:00

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
This commit is contained in:
Jannik Beyerstedt
2023-06-19 17:29:47 +02:00
committed by Brad King
parent 21d409534a
commit fc7dcc6a24

View File

@@ -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} ] "