protobuf-config-version.cmake 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. set(PACKAGE_VERSION "3.19.4.0")
  2. set(${PACKAGE_FIND_NAME}_VERSION_PRERELEASE "" PARENT_SCOPE)
  3. # Prerelease versions cannot be passed in directly via the find_package command,
  4. # so we allow users to specify it in a variable
  5. if(NOT DEFINED "${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE")
  6. set("${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE}" "")
  7. else()
  8. set(PACKAGE_FIND_VERSION ${PACKAGE_FIND_VERSION}-${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE})
  9. endif()
  10. set(PACKAGE_FIND_VERSION_PRERELEASE "${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE}")
  11. # VERSION_EQUAL ignores the prerelease strings, so we use STREQUAL.
  12. if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
  13. set(PACKAGE_VERSION_EXACT TRUE)
  14. endif()
  15. set(PACKAGE_VERSION_COMPATIBLE TRUE) #Assume true until shown otherwise
  16. if(PACKAGE_FIND_VERSION) #Only perform version checks if one is given
  17. if(NOT PACKAGE_FIND_VERSION_MAJOR EQUAL "3")
  18. set(PACKAGE_VERSION_COMPATIBLE FALSE)
  19. elseif(PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
  20. set(PACKAGE_VERSION_COMPATIBLE FALSE)
  21. elseif(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
  22. # Do not match prerelease versions to non-prerelease version requests.
  23. if(NOT "" STREQUAL "" AND PACKAGE_FIND_VERSION_PRERELEASE STREQUAL "")
  24. message(AUTHOR_WARNING "To use this prerelease version of ${PACKAGE_FIND_NAME}, set ${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE to '' or greater.")
  25. set(PACKAGE_VERSION_COMPATIBLE FALSE)
  26. endif()
  27. # Not robustly SemVer compliant, but protobuf never uses '.' separated prerelease identifiers.
  28. if(PACKAGE_FIND_VERSION_PRERELEASE STRGREATER "")
  29. set(PACKAGE_VERSION_COMPATIBLE FALSE)
  30. endif()
  31. endif()
  32. endif()
  33. # Check and save build options used to create this package
  34. macro(_check_and_save_build_option OPTION VALUE)
  35. if(DEFINED ${PACKAGE_FIND_NAME}_${OPTION} AND
  36. NOT ${PACKAGE_FIND_NAME}_${OPTION} STREQUAL ${VALUE})
  37. set(PACKAGE_VERSION_UNSUITABLE TRUE)
  38. endif()
  39. set(${PACKAGE_FIND_NAME}_${OPTION} ${VALUE} PARENT_SCOPE)
  40. endmacro()
  41. _check_and_save_build_option(WITH_ZLIB ON)
  42. _check_and_save_build_option(MSVC_STATIC_RUNTIME OFF)
  43. _check_and_save_build_option(BUILD_SHARED_LIBS OFF)
  44. # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
  45. if(CMAKE_SIZEOF_VOID_P AND "8")
  46. # check that the installed version has the same 32/64bit-ness as the one which is currently searching:
  47. if(NOT CMAKE_SIZEOF_VOID_P EQUAL "8")
  48. math(EXPR installedBits "8 * 8")
  49. set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
  50. set(PACKAGE_VERSION_UNSUITABLE TRUE)
  51. endif()
  52. endif()