Merge pull request #3157 from yeswalrus/fix-version-check

Fix CMake version check
pull/1654/merge
Adam Cozzette 8 years ago committed by GitHub
commit 656dedbf07
  1. 30
      cmake/protobuf-config-version.cmake.in

@ -17,30 +17,32 @@ endif()
set(PACKAGE_VERSION_COMPATIBLE TRUE) #Assume true until shown otherwise set(PACKAGE_VERSION_COMPATIBLE TRUE) #Assume true until shown otherwise
if(NOT PACKAGE_FIND_VERSION_MAJOR EQUAL "@protobuf_VERSION_MAJOR@") if(PACKAGE_FIND_VERSION) #Only perform version checks if one is given
set(PACKAGE_VERSION_COMPATIBLE FALSE) if(NOT PACKAGE_FIND_VERSION_MAJOR EQUAL "@protobuf_VERSION_MAJOR@")
elseif(PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
elseif(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
# Do not match prerelease versions to non-prerelease version requests.
if(NOT "@protobuf_VERSION_PRERELEASE@" STREQUAL "" AND PACKAGE_FIND_VERSION_PRERELEASE STREQUAL "")
message(AUTHOR_WARNING "To use this prerelease version of ${PACKAGE_FIND_NAME}, set ${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE to '@protobuf_VERSION_PRERELEASE@' or greater.")
set(PACKAGE_VERSION_COMPATIBLE FALSE) set(PACKAGE_VERSION_COMPATIBLE FALSE)
endif() elseif(PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
# Not robustly SemVer compliant, but protobuf never uses '.' separated prerelease identifiers.
if(PACKAGE_FIND_VERSION_PRERELEASE STRGREATER "@protobuf_VERSION_PRERELEASE@")
set(PACKAGE_VERSION_COMPATIBLE FALSE) set(PACKAGE_VERSION_COMPATIBLE FALSE)
elseif(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
# Do not match prerelease versions to non-prerelease version requests.
if(NOT "@protobuf_VERSION_PRERELEASE@" STREQUAL "" AND PACKAGE_FIND_VERSION_PRERELEASE STREQUAL "")
message(AUTHOR_WARNING "To use this prerelease version of ${PACKAGE_FIND_NAME}, set ${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE to '@protobuf_VERSION_PRERELEASE@' or greater.")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
endif()
# Not robustly SemVer compliant, but protobuf never uses '.' separated prerelease identifiers.
if(PACKAGE_FIND_VERSION_PRERELEASE STRGREATER "@protobuf_VERSION_PRERELEASE@")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
endif()
endif() endif()
endif() endif()
# Check and save build options used to create this package # Check and save build options used to create this package
macro(_check_and_save_build_option OPTION VALUE) macro(_check_and_save_build_option OPTION VALUE)
if(DEFINED ${PACKAGE_FIND_NAME}_${OPTION} AND if(DEFINED ${PACKAGE_FIND_NAME}_${OPTION} AND
NOT ${PACKAGE_FIND_NAME}_${OPTION} EQUAL VALUE) NOT ${PACKAGE_FIND_NAME}_${OPTION} STREQUAL ${VALUE})
set(PACKAGE_VERSION_UNSUITABLE TRUE) set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif() endif()
set(${PACKAGE_FIND_NAME}_${OPTION} ${VALUE}) set(${PACKAGE_FIND_NAME}_${OPTION} ${VALUE} PARENT_SCOPE)
endmacro() endmacro()
_check_and_save_build_option(WITH_ZLIB @protobuf_WITH_ZLIB@) _check_and_save_build_option(WITH_ZLIB @protobuf_WITH_ZLIB@)
_check_and_save_build_option(MSVC_STATIC_RUNTIME @protobuf_MSVC_STATIC_RUNTIME@) _check_and_save_build_option(MSVC_STATIC_RUNTIME @protobuf_MSVC_STATIC_RUNTIME@)

Loading…
Cancel
Save