summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2020-11-25 16:36:12 +0100
committerMarc Chevrier <marc.chevrier@gmail.com>2020-11-25 16:36:12 +0100
commit14ecf9c2f6edfae4033d9311f79d79d0d07fc1cf (patch)
tree82b9014fb2b5812ab4e69d9c36cb5dcee071d524 /Modules
parentb4c994f69c6e62ab95a5746db237d0237bc87bc1 (diff)
downloadcmake-14ecf9c2f6edfae4033d9311f79d79d0d07fc1cf.tar.gz
FPHSA: ensure it can be used outside 'find_package'
Fixes: #21505
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindPackageHandleStandardArgs.cmake9
1 files changed, 7 insertions, 2 deletions
diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake
index 7af017136d..7e172779e4 100644
--- a/Modules/FindPackageHandleStandardArgs.cmake
+++ b/Modules/FindPackageHandleStandardArgs.cmake
@@ -275,8 +275,10 @@ function(FIND_PACKAGE_CHECK_VERSION version result)
unset (${FPCV_RESULT_MESSAGE_VARIABLE} PARENT_SCOPE)
endif()
- if (CMAKE_FIND_PACKAGE_NAME)
- set (package ${CMAKE_FIND_PACKAGE_NAME})
+ if (_CMAKE_FPHSA_PACKAGE_NAME)
+ set (package "${_CMAKE_FPHSA_PACKAGE_NAME}")
+ elseif (CMAKE_FIND_PACKAGE_NAME)
+ set (package "${CMAKE_FIND_PACKAGE_NAME}")
else()
message (FATAL_ERROR "find_package_check_version(): Cannot be used outside a 'Find Module'")
endif()
@@ -436,6 +438,9 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
"will be used.")
endif()
+ # to propagate package name to FIND_PACKAGE_CHECK_VERSION
+ set(_CMAKE_FPHSA_PACKAGE_NAME "${_NAME}")
+
# now that we collected all arguments, process them
if("x${FPHSA_FAIL_MESSAGE}" STREQUAL "xDEFAULT_MSG")