diff options
author | Feng Xiao <xiaofeng@google.com> | 2016-06-17 13:15:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-17 13:15:49 -0700 |
commit | 4f93098eb35b4868543b73d6023b07cb169c5a3a (patch) | |
tree | a8bef1b0bfbf36d713a979351c65e2e1b4e75249 /cmake | |
parent | b7560df598f1c7c443b724403fbf102a2bbf75ba (diff) | |
parent | 5ebcfc1cfdf9665171044a48c267ed2d7136b356 (diff) |
Merge pull request #1666 from yeswalrus/cmake-prerelease-examples
CMake Fix up prerelease version handling
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/examples.cmake | 1 | ||||
-rw-r--r-- | cmake/protobuf-config-version.cmake.in | 36 |
2 files changed, 22 insertions, 15 deletions
diff --git a/cmake/examples.cmake b/cmake/examples.cmake index 5c6a1afd..83d0e988 100644 --- a/cmake/examples.cmake +++ b/cmake/examples.cmake @@ -11,6 +11,7 @@ include(ExternalProject) # Internal utility function: Create a custom target representing a build of examples with custom options.
function(add_examples_build NAME)
+
ExternalProject_Add(${NAME}
PREFIX ${NAME}
SOURCE_DIR "${examples_dir}"
diff --git a/cmake/protobuf-config-version.cmake.in b/cmake/protobuf-config-version.cmake.in index 96650552..3b8ced2d 100644 --- a/cmake/protobuf-config-version.cmake.in +++ b/cmake/protobuf-config-version.cmake.in @@ -1,28 +1,35 @@ set(PACKAGE_VERSION "@protobuf_VERSION@") +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 +if(NOT DEFINED "${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE}") + 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}") +# VERSION_EQUAL ignores the prerelease strings, so we use STREQUAL. if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) set(PACKAGE_VERSION_EXACT TRUE) endif() set(PACKAGE_VERSION_COMPATIBLE TRUE) #Assume true until shown otherwise -# Handle prerelease versions -set(PACKAGE_FIND_VERSION_PRERELEASE "${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE}") -if(NOT "@protobuf_VERSION_PRERELEASE@" STREQUAL "") - if(NOT ${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE) +if(NOT PACKAGE_FIND_VERSION_MAJOR EQUAL "@protobuf_VERSION_MAJOR@") + set(PACKAGE_VERSION_COMPATIBLE FALSE) +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) - message(AUTHOR_WARNING "To use this prerelease version of ${PACKAGE_FIND_NAME}, set ${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE to '@protobuf_VERSION_PRERELEASE@'.") endif() - if(NOT "${PACKAGE_FIND_VERSION}-${PACKAGE_FIND_VERSION_PRERELEASE}" STREQUAL "${PACKAGE_VERSION}") - set(PACKAGE_VERSION_COMPATIBLE FALSE) - else() - set(PACKAGE_VERSION_EXACT TRUE) - endif() -else() - if(NOT PACKAGE_FIND_VERSION_MAJOR EQUAL "@protobuf_VERSION_MAJOR@") - set(PACKAGE_VERSION_COMPATIBLE FALSE) - 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) endif() endif() @@ -49,4 +56,3 @@ if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "" AND NOT "@CMAKE_SIZEOF_VOID_P@" STRE endif() endif() -set(${PACKAGE_FIND_NAME}_VERSION_PRERELEASE "@protobuf_VERSION_PRERELEASE@" PARENT_SCOPE) |