diff options
author | Brad King <brad.king@kitware.com> | 2022-09-09 14:06:37 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-09-09 14:06:45 (GMT) |
commit | 12de4ea2e8efc00c57c731b4a42066ef6d20e099 (patch) | |
tree | ac09264cf9dbafc6d12f64955243d202e3e804f8 /Modules | |
parent | e71605dfb44c69db6fccb7d36a58b6c9f7761ed5 (diff) | |
parent | 8f50f135aefa3f287a87c80cc8edb3deee8ee198 (diff) | |
download | CMake-12de4ea2e8efc00c57c731b4a42066ef6d20e099.zip CMake-12de4ea2e8efc00c57c731b4a42066ef6d20e099.tar.gz CMake-12de4ea2e8efc00c57c731b4a42066ef6d20e099.tar.bz2 |
Merge topic 'fphsa-error-message-empty-version-var'
8f50f135ae FPHSA: Improve error message when VERSION_VAR is empty or has been unset()
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7527
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FindPackageHandleStandardArgs.cmake | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index fbcf7cd..6de7dbf 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -535,9 +535,10 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) set(VERSION_MSG "") set(VERSION_OK TRUE) - # check with DEFINED here as the requested or found version may be "0" + # 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(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) @@ -547,6 +548,7 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) find_package_check_version ("${_FOUND_VERSION}" VERSION_OK RESULT_MESSAGE_VARIABLE VERSION_MSG ${FPCV_HANDLE_VERSION_RANGE}) else() + set(VERSION_OK FALSE) # 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}\")") |