diff options
author | Brad King <brad.king@kitware.com> | 2022-09-15 14:52:23 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-09-15 15:00:02 (GMT) |
commit | 07f0a78874e0cf8013654ff4bac5e7192a324609 (patch) | |
tree | 963c5a09903c69978de7973d639f959f6c8bff64 /Modules | |
parent | 01a25d72c69b0a9a60c1a62939d6a2c543448118 (diff) | |
download | CMake-07f0a78874e0cf8013654ff4bac5e7192a324609.zip CMake-07f0a78874e0cf8013654ff4bac5e7192a324609.tar.gz CMake-07f0a78874e0cf8013654ff4bac5e7192a324609.tar.bz2 |
FPHSA: Fix regression when VERSION_VAR is missing
If a package is found but FPHSA is called by the find module without a
`VERSION_VAR`, and the `find_package` call specifies a version, we have
previously accepted the package as found. This was accidentally
regressed by commit 8f50f135ae (FPHSA: Improve error message when
VERSION_VAR is empty or has been unset(), 2022-08-01). Restore it and
add a test case.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FindPackageHandleStandardArgs.cmake | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index 6de7dbf..56ba1e6 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -538,17 +538,21 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) # check that the version variable is not empty to avoid emitting a misleading # message (i.e. `Found unsuitable version ""`) if (DEFINED ${_NAME}_FIND_VERSION) - if(NOT "${${FPHSA_VERSION_VAR}}" STREQUAL "") - set(_FOUND_VERSION ${${FPHSA_VERSION_VAR}}) - if (FPHSA_HANDLE_VERSION_RANGE) - set (FPCV_HANDLE_VERSION_RANGE HANDLE_VERSION_RANGE) + if(DEFINED ${FPHSA_VERSION_VAR}) + if(NOT "${${FPHSA_VERSION_VAR}}" STREQUAL "") + set(_FOUND_VERSION ${${FPHSA_VERSION_VAR}}) + if (FPHSA_HANDLE_VERSION_RANGE) + set (FPCV_HANDLE_VERSION_RANGE HANDLE_VERSION_RANGE) + else() + set(FPCV_HANDLE_VERSION_RANGE NO_AUTHOR_WARNING_VERSION_RANGE) + endif() + find_package_check_version ("${_FOUND_VERSION}" VERSION_OK RESULT_MESSAGE_VARIABLE VERSION_MSG + ${FPCV_HANDLE_VERSION_RANGE}) else() - set(FPCV_HANDLE_VERSION_RANGE NO_AUTHOR_WARNING_VERSION_RANGE) + set(VERSION_OK FALSE) endif() - find_package_check_version ("${_FOUND_VERSION}" VERSION_OK RESULT_MESSAGE_VARIABLE VERSION_MSG - ${FPCV_HANDLE_VERSION_RANGE}) - else() - set(VERSION_OK FALSE) + endif() + if("${${FPHSA_VERSION_VAR}}" STREQUAL "") # if the package was not found, but a version was given, add that to the output: if(${_NAME}_FIND_VERSION_EXACT) set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") |