mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-16 12:11:04 -06:00
FPHSA: use more localized _FOUND_VERSION instead of VERSION.
This fixes the failing unit tests in which a cache variable VERSION is present or the found version is 0.
This commit is contained in:
@@ -289,15 +289,15 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
|
|||||||
# version handling:
|
# version handling:
|
||||||
set(VERSION_MSG "")
|
set(VERSION_MSG "")
|
||||||
set(VERSION_OK TRUE)
|
set(VERSION_OK TRUE)
|
||||||
set(VERSION ${${FPHSA_VERSION_VAR}})
|
|
||||||
|
|
||||||
# check with DEFINED here as the requested or found version may be "0"
|
# check with DEFINED here as the requested or found version may be "0"
|
||||||
if (DEFINED ${_NAME}_FIND_VERSION)
|
if (DEFINED ${_NAME}_FIND_VERSION)
|
||||||
if(DEFINED ${FPHSA_VERSION_VAR})
|
if(DEFINED ${FPHSA_VERSION_VAR})
|
||||||
|
set(_FOUND_VERSION ${${FPHSA_VERSION_VAR}})
|
||||||
|
|
||||||
if(${_NAME}_FIND_VERSION_EXACT) # exact version required
|
if(${_NAME}_FIND_VERSION_EXACT) # exact version required
|
||||||
# count the dots in the version string
|
# count the dots in the version string
|
||||||
string(REGEX REPLACE "[^.]" "" _VERSION_DOTS "${VERSION}")
|
string(REGEX REPLACE "[^.]" "" _VERSION_DOTS "${_FOUND_VERSION}")
|
||||||
# add one dot because there is one dot more than there are components
|
# add one dot because there is one dot more than there are components
|
||||||
string(LENGTH "${_VERSION_DOTS}." _VERSION_DOTS)
|
string(LENGTH "${_VERSION_DOTS}." _VERSION_DOTS)
|
||||||
if (_VERSION_DOTS GREATER ${_NAME}_FIND_VERSION_COUNT)
|
if (_VERSION_DOTS GREATER ${_NAME}_FIND_VERSION_COUNT)
|
||||||
@@ -312,31 +312,31 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
|
|||||||
else ()
|
else ()
|
||||||
set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*\\.[^.]*")
|
set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*\\.[^.]*")
|
||||||
endif ()
|
endif ()
|
||||||
string(REGEX REPLACE "^(${_VERSION_REGEX})\\..*" "\\1" _VERSION_HEAD "${VERSION}")
|
string(REGEX REPLACE "^(${_VERSION_REGEX})\\..*" "\\1" _VERSION_HEAD "${_FOUND_VERSION}")
|
||||||
unset(_VERSION_REGEX)
|
unset(_VERSION_REGEX)
|
||||||
if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _VERSION_HEAD)
|
if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _VERSION_HEAD)
|
||||||
set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
|
set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
|
||||||
set(VERSION_OK FALSE)
|
set(VERSION_OK FALSE)
|
||||||
else ()
|
else ()
|
||||||
set(VERSION_MSG "(found suitable exact version \"${VERSION}\")")
|
set(VERSION_MSG "(found suitable exact version \"${_FOUND_VERSION}\")")
|
||||||
endif ()
|
endif ()
|
||||||
unset(_VERSION_HEAD)
|
unset(_VERSION_HEAD)
|
||||||
else ()
|
else ()
|
||||||
if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL VERSION)
|
if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL VERSION)
|
||||||
set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
|
set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
|
||||||
set(VERSION_OK FALSE)
|
set(VERSION_OK FALSE)
|
||||||
else ()
|
else ()
|
||||||
set(VERSION_MSG "(found suitable exact version \"${VERSION}\")")
|
set(VERSION_MSG "(found suitable exact version \"${_FOUND_VERSION}\")")
|
||||||
endif ()
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
unset(_VERSION_DOTS)
|
unset(_VERSION_DOTS)
|
||||||
|
|
||||||
else() # minimum version specified:
|
else() # minimum version specified:
|
||||||
if (${_NAME}_FIND_VERSION VERSION_GREATER VERSION)
|
if (${_NAME}_FIND_VERSION VERSION_GREATER _FOUND_VERSION)
|
||||||
set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"")
|
set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"")
|
||||||
set(VERSION_OK FALSE)
|
set(VERSION_OK FALSE)
|
||||||
else ()
|
else ()
|
||||||
set(VERSION_MSG "(found suitable version \"${VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")")
|
set(VERSION_MSG "(found suitable version \"${_FOUND_VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")")
|
||||||
endif ()
|
endif ()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -351,13 +351,14 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
|
|||||||
|
|
||||||
endif()
|
endif()
|
||||||
else ()
|
else ()
|
||||||
if(VERSION)
|
# Check with DEFINED as the found version may be 0.
|
||||||
set(VERSION_MSG "(found version \"${VERSION}\")")
|
if(DEFINED ${FPHSA_VERSION_VAR})
|
||||||
|
set(VERSION_MSG "(found version \"${${FPHSA_VERSION_VAR}}\")")
|
||||||
endif()
|
endif()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if(VERSION_OK)
|
if(VERSION_OK)
|
||||||
string(APPEND DETAILS "[v${VERSION}(${${_NAME}_FIND_VERSION})]")
|
string(APPEND DETAILS "[v${${FPHSA_VERSION_VAR}}(${${_NAME}_FIND_VERSION})]")
|
||||||
else()
|
else()
|
||||||
set(${_NAME}_FOUND FALSE)
|
set(${_NAME}_FOUND FALSE)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
Reference in New Issue
Block a user