Small cleanup of FindPackageHandleStandardArgs.cmake

-remove unnecessary arguments _VAR1
-move code for deciding the type of the message into helper macro
 _FPHSA_FAILURE_MESSAGE()

Alex
This commit is contained in:
Alex Neundorf 2010-08-29 18:55:25 +02:00
parent 0367245f0c
commit cc955a042b
1 changed files with 17 additions and 21 deletions

View File

@ -71,7 +71,18 @@ INCLUDE(FindPackageMessage)
INCLUDE(CMakeParseArguments)
FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG _VAR1)
MACRO(_FPHSA_FAILURE_MESSAGE _msg)
IF (${_NAME}_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "${_msg}")
ELSE (${_NAME}_FIND_REQUIRED)
IF (NOT ${_NAME}_FIND_QUIETLY)
MESSAGE(STATUS "${_msg}")
ENDIF (NOT ${_NAME}_FIND_QUIETLY)
ENDIF (${_NAME}_FIND_REQUIRED)
ENDMACRO(_FPHSA_FAILURE_MESSAGE _msg)
FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
# set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in
# new extended or in the "old" mode:
@ -83,11 +94,11 @@ FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG _VAR1)
IF(${INDEX} EQUAL -1)
SET(FPHSA_FAIL_MESSAGE ${_FIRST_ARG})
SET(FPHSA_REQUIRED_VARS ${_VAR1} ${ARGN})
SET(FPHSA_REQUIRED_VARS ${ARGN})
SET(FPHSA_VERSION_VAR)
ELSE(${INDEX} EQUAL -1)
CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${_VAR1} ${ARGN})
CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN})
IF(FPHSA_UNPARSED_ARGUMENTS)
MESSAGE(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"")
@ -112,7 +123,7 @@ FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG _VAR1)
STRING(TOUPPER ${_NAME} _NAME_UPPER)
# collect all variables which were not found, so they can be printed, so the
# collect all variables which were not found, so they can be printed, so the
# user knows better what went wrong (#6375)
SET(MISSING_VARS "")
SET(DETAILS "")
@ -183,24 +194,9 @@ FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG _VAR1)
FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG}" "${DETAILS}")
ELSE (${_NAME_UPPER}_FOUND)
IF(NOT VERSION_OK)
IF (${_NAME}_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})")
ELSE (${_NAME}_FIND_REQUIRED)
IF (NOT ${_NAME}_FIND_QUIETLY)
MESSAGE(STATUS "${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})")
ENDIF (NOT ${_NAME}_FIND_QUIETLY)
ENDIF (${_NAME}_FIND_REQUIRED)
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})")
ELSE(NOT VERSION_OK)
IF (${_NAME}_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}")
ELSE (${_NAME}_FIND_REQUIRED)
IF (NOT ${_NAME}_FIND_QUIETLY)
MESSAGE(STATUS "${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}")
ENDIF (NOT ${_NAME}_FIND_QUIETLY)
ENDIF (${_NAME}_FIND_REQUIRED)
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}")
ENDIF(NOT VERSION_OK)
ENDIF (${_NAME_UPPER}_FOUND)