2016-05-28 05:55:57 +00:00
set ( PACKAGE_VERSION "@protobuf_VERSION@" )
2016-06-09 22:38:39 +00:00
set ( ${ PACKAGE_FIND_NAME } _VERSION_PRERELEASE "@protobuf_VERSION_PRERELEASE@" PARENT_SCOPE )
# Prerelease versions cannot be passed in directly via the find_package command,
# so we allow users to specify it in a variable
2016-07-12 22:19:32 +00:00
if ( NOT DEFINED "${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE" )
2016-06-09 22:38:39 +00:00
set ( "${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE}" "" )
else ( )
set ( PACKAGE_FIND_VERSION ${ PACKAGE_FIND_VERSION } - ${ ${PACKAGE_FIND_NAME } _FIND_VERSION_PRERELEASE} )
endif ( )
set ( PACKAGE_FIND_VERSION_PRERELEASE "${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE}" )
2016-05-19 22:24:18 +00:00
2016-06-09 22:38:39 +00:00
# VERSION_EQUAL ignores the prerelease strings, so we use STREQUAL.
2016-05-28 05:55:57 +00:00
if ( PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION )
set ( PACKAGE_VERSION_EXACT TRUE )
endif ( )
2016-05-19 22:24:18 +00:00
2016-05-28 05:55:57 +00:00
set ( PACKAGE_VERSION_COMPATIBLE TRUE ) #Assume true until shown otherwise
2016-05-19 22:24:18 +00:00
2017-05-30 21:07:34 +00:00
if ( PACKAGE_FIND_VERSION ) #Only perform version checks if one is given
if ( NOT PACKAGE_FIND_VERSION_MAJOR EQUAL "@protobuf_VERSION_MAJOR@" )
2016-05-19 22:24:18 +00:00
set ( PACKAGE_VERSION_COMPATIBLE FALSE )
2017-05-30 21:07:34 +00:00
elseif ( PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION )
2016-05-28 05:55:57 +00:00
set ( PACKAGE_VERSION_COMPATIBLE FALSE )
2017-05-30 21:07:34 +00:00
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 ( )
2016-05-19 22:24:18 +00:00
endif ( )
endif ( )
2016-06-09 20:03:59 +00:00
# Check and save build options used to create this package
macro ( _check_and_save_build_option OPTION VALUE )
if ( DEFINED ${ PACKAGE_FIND_NAME } _ ${ OPTION } AND
2017-05-30 21:11:46 +00:00
N O T $ { P A C K A G E _ F I N D _ N A M E } _ $ { O P T I O N } S T R E Q U A L $ { V A L U E } )
2016-06-09 20:03:59 +00:00
set ( PACKAGE_VERSION_UNSUITABLE TRUE )
endif ( )
2017-05-30 21:56:02 +00:00
set ( ${ PACKAGE_FIND_NAME } _ ${ OPTION } ${ VALUE } PARENT_SCOPE )
2016-06-09 20:03:59 +00:00
endmacro ( )
_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 ( BUILD_SHARED_LIBS @protobuf_BUILD_SHARED_LIBS@ )
2016-05-19 22:24:18 +00:00
2016-06-09 20:03:59 +00:00
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
2017-05-30 21:09:42 +00:00
if ( CMAKE_SIZEOF_VOID_P AND "@CMAKE_SIZEOF_VOID_P@" )
2016-06-09 20:03:59 +00:00
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
2017-05-30 21:09:42 +00:00
if ( NOT CMAKE_SIZEOF_VOID_P EQUAL "@CMAKE_SIZEOF_VOID_P@" )
2016-06-09 20:03:59 +00:00
math ( EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8" )
set ( PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)" )
set ( PACKAGE_VERSION_UNSUITABLE TRUE )
endif ( )
2016-05-19 22:24:18 +00:00
endif ( )
2016-05-28 05:55:57 +00:00