diff options
author | Brad King <brad.king@kitware.com> | 2020-05-01 12:32:02 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-05-01 12:33:30 (GMT) |
commit | 6556e587efa8ad954126137c6ca867f1f2797b11 (patch) | |
tree | 29942e95d7c5378b84c01012f932d47b7e0adbad /Modules | |
parent | 9026ef003de06b9dddf47bf428e19371f6251ccc (diff) | |
parent | 0b6332af6085b97830091e1f973f48481e8fa890 (diff) | |
download | CMake-6556e587efa8ad954126137c6ca867f1f2797b11.zip CMake-6556e587efa8ad954126137c6ca867f1f2797b11.tar.gz CMake-6556e587efa8ad954126137c6ca867f1f2797b11.tar.bz2 |
Merge topic 'FPHSA-handle-components'
0b6332af60 FPHSA: REQUIRED_VARS is optional if HANDLE_COMPONENTS is specified
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4690
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FindPackageHandleStandardArgs.cmake | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index a078049..4fb0825 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -57,7 +57,8 @@ valid filepaths. These may be named in the generated failure message asking the user to set the missing variable values. Therefore these should typically be cache entries such as ``FOO_LIBRARY`` and not output - variables like ``FOO_LIBRARIES``. + variables like ``FOO_LIBRARIES``. This option is mandatory if + ``HANDLE_COMPONENTS`` is not specified. ``VERSION_VAR <version-var>`` Specify the name of a variable that holds the version of the package @@ -257,7 +258,7 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) set(FPHSA_VERSION_VAR ${_NAME}_VERSION) endif() - if(NOT FPHSA_REQUIRED_VARS) + if(NOT FPHSA_REQUIRED_VARS AND NOT FPHSA_HANDLE_COMPONENTS) message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()") endif() endif() @@ -283,7 +284,9 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}") endif() - list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) + if (FPHSA_REQUIRED_VARS) + list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) + endif() string(TOUPPER ${_NAME} _NAME_UPPER) string(TOLOWER ${_NAME} _NAME_LOWER) @@ -440,7 +443,17 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) _FPHSA_HANDLE_FAILURE_CONFIG_MODE() else() if(NOT VERSION_OK) - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") + set(RESULT_MSG) + if (_FIRST_REQUIRED_VAR) + string (APPEND RESULT_MSG "found ${${_FIRST_REQUIRED_VAR}}") + endif() + if (COMPONENT_MSG) + if (RESULT_MSG) + string (APPEND RESULT_MSG ", ") + endif() + string (APPEND RESULT_MSG "${FOUND_COMPONENTS_MSG}") + endif() + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (${RESULT_MSG})") else() _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing:${MISSING_VARS}) ${VERSION_MSG}") endif() |