Walter Gray | 0420eab | 2016-05-27 22:55:57 -0700 | [diff] [blame] | 1 | set(PACKAGE_VERSION "@protobuf_VERSION@") |
Walter Gray | 5ebcfc1 | 2016-06-09 15:38:39 -0700 | [diff] [blame] | 2 | set(${PACKAGE_FIND_NAME}_VERSION_PRERELEASE "@protobuf_VERSION_PRERELEASE@" PARENT_SCOPE) |
Walter Gray | 02a28a8 | 2016-05-19 15:24:18 -0700 | [diff] [blame] | 3 | |
Walter Gray | 5ebcfc1 | 2016-06-09 15:38:39 -0700 | [diff] [blame] | 4 | # Prerelease versions cannot be passed in directly via the find_package command, |
| 5 | # so we allow users to specify it in a variable |
Walter Gray | 5520447 | 2016-07-12 15:19:32 -0700 | [diff] [blame] | 6 | if(NOT DEFINED "${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE") |
Walter Gray | 5ebcfc1 | 2016-06-09 15:38:39 -0700 | [diff] [blame] | 7 | set("${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE}" "") |
| 8 | else() |
| 9 | set(PACKAGE_FIND_VERSION ${PACKAGE_FIND_VERSION}-${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE}) |
| 10 | endif() |
| 11 | set(PACKAGE_FIND_VERSION_PRERELEASE "${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE}") |
| 12 | |
| 13 | # VERSION_EQUAL ignores the prerelease strings, so we use STREQUAL. |
Walter Gray | 0420eab | 2016-05-27 22:55:57 -0700 | [diff] [blame] | 14 | if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) |
| 15 | set(PACKAGE_VERSION_EXACT TRUE) |
Walter Gray | 02a28a8 | 2016-05-19 15:24:18 -0700 | [diff] [blame] | 16 | endif() |
| 17 | |
Walter Gray | 0420eab | 2016-05-27 22:55:57 -0700 | [diff] [blame] | 18 | set(PACKAGE_VERSION_COMPATIBLE TRUE) #Assume true until shown otherwise |
| 19 | |
Walter Gray | ae85cb8 | 2017-05-30 14:07:34 -0700 | [diff] [blame] | 20 | if(PACKAGE_FIND_VERSION) #Only perform version checks if one is given |
| 21 | if(NOT PACKAGE_FIND_VERSION_MAJOR EQUAL "@protobuf_VERSION_MAJOR@") |
Walter Gray | 0420eab | 2016-05-27 22:55:57 -0700 | [diff] [blame] | 22 | set(PACKAGE_VERSION_COMPATIBLE FALSE) |
Walter Gray | ae85cb8 | 2017-05-30 14:07:34 -0700 | [diff] [blame] | 23 | elseif(PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) |
| 24 | set(PACKAGE_VERSION_COMPATIBLE FALSE) |
| 25 | elseif(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) |
| 26 | # Do not match prerelease versions to non-prerelease version requests. |
| 27 | if(NOT "@protobuf_VERSION_PRERELEASE@" STREQUAL "" AND PACKAGE_FIND_VERSION_PRERELEASE STREQUAL "") |
| 28 | 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.") |
| 29 | set(PACKAGE_VERSION_COMPATIBLE FALSE) |
| 30 | endif() |
Walter Gray | 0420eab | 2016-05-27 22:55:57 -0700 | [diff] [blame] | 31 | |
Walter Gray | ae85cb8 | 2017-05-30 14:07:34 -0700 | [diff] [blame] | 32 | # Not robustly SemVer compliant, but protobuf never uses '.' separated prerelease identifiers. |
| 33 | if(PACKAGE_FIND_VERSION_PRERELEASE STRGREATER "@protobuf_VERSION_PRERELEASE@") |
| 34 | set(PACKAGE_VERSION_COMPATIBLE FALSE) |
| 35 | endif() |
Walter Gray | 0420eab | 2016-05-27 22:55:57 -0700 | [diff] [blame] | 36 | endif() |
| 37 | endif() |
Walter Gray | 02a28a8 | 2016-05-19 15:24:18 -0700 | [diff] [blame] | 38 | |
Walter Gray | 78b3498 | 2016-06-09 13:03:59 -0700 | [diff] [blame] | 39 | # Check and save build options used to create this package |
| 40 | macro(_check_and_save_build_option OPTION VALUE) |
| 41 | if(DEFINED ${PACKAGE_FIND_NAME}_${OPTION} AND |
Walter Gray | a183a0d | 2017-05-30 14:11:46 -0700 | [diff] [blame] | 42 | NOT ${PACKAGE_FIND_NAME}_${OPTION} STREQUAL ${VALUE}) |
Walter Gray | 78b3498 | 2016-06-09 13:03:59 -0700 | [diff] [blame] | 43 | set(PACKAGE_VERSION_UNSUITABLE TRUE) |
| 44 | endif() |
Walter Gray | df3f8cf | 2017-05-30 14:56:02 -0700 | [diff] [blame] | 45 | set(${PACKAGE_FIND_NAME}_${OPTION} ${VALUE} PARENT_SCOPE) |
Walter Gray | 78b3498 | 2016-06-09 13:03:59 -0700 | [diff] [blame] | 46 | endmacro() |
| 47 | _check_and_save_build_option(WITH_ZLIB @protobuf_WITH_ZLIB@) |
| 48 | _check_and_save_build_option(MSVC_STATIC_RUNTIME @protobuf_MSVC_STATIC_RUNTIME@) |
| 49 | _check_and_save_build_option(BUILD_SHARED_LIBS @protobuf_BUILD_SHARED_LIBS@) |
Walter Gray | 02a28a8 | 2016-05-19 15:24:18 -0700 | [diff] [blame] | 50 | |
Walter Gray | 78b3498 | 2016-06-09 13:03:59 -0700 | [diff] [blame] | 51 | # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: |
Walter Gray | d8c5865 | 2017-05-30 14:09:42 -0700 | [diff] [blame] | 52 | if(CMAKE_SIZEOF_VOID_P AND "@CMAKE_SIZEOF_VOID_P@") |
Walter Gray | 78b3498 | 2016-06-09 13:03:59 -0700 | [diff] [blame] | 53 | # check that the installed version has the same 32/64bit-ness as the one which is currently searching: |
Walter Gray | d8c5865 | 2017-05-30 14:09:42 -0700 | [diff] [blame] | 54 | if(NOT CMAKE_SIZEOF_VOID_P EQUAL "@CMAKE_SIZEOF_VOID_P@") |
Walter Gray | 78b3498 | 2016-06-09 13:03:59 -0700 | [diff] [blame] | 55 | math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") |
| 56 | set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") |
| 57 | set(PACKAGE_VERSION_UNSUITABLE TRUE) |
| 58 | endif() |
Walter Gray | 02a28a8 | 2016-05-19 15:24:18 -0700 | [diff] [blame] | 59 | endif() |
Walter Gray | 0420eab | 2016-05-27 22:55:57 -0700 | [diff] [blame] | 60 | |