mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 14:08:35 +08:00
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.
This commit is contained in:

committed by
Brad King

parent
1f42b0299b
commit
6e90d79577
@@ -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()
|
||||
|
Reference in New Issue
Block a user