github的一些开源项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.4 KiB

  1. # FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME (DEFAULT_MSG|"Custom failure message") VAR1 ... )
  2. # This macro is intended to be used in FindXXX.cmake modules files.
  3. # It handles the REQUIRED and QUIET argument to FIND_PACKAGE() and
  4. # it also sets the <UPPERCASED_NAME>_FOUND variable.
  5. # The package is found if all variables listed are TRUE.
  6. # Example:
  7. #
  8. # FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR)
  9. #
  10. # LibXml2 is considered to be found, if both LIBXML2_LIBRARIES and
  11. # LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to TRUE.
  12. # If it is not found and REQUIRED was used, it fails with FATAL_ERROR,
  13. # independent whether QUIET was used or not.
  14. # If it is found, the location is reported using the VAR1 argument, so
  15. # here a message "Found LibXml2: /usr/lib/libxml2.so" will be printed out.
  16. # If the second argument is DEFAULT_MSG, the message in the failure case will
  17. # be "Could NOT find LibXml2", if you don't like this message you can specify
  18. # your own custom failure message there.
  19. MACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FAIL_MSG _VAR1 )
  20. IF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
  21. IF (${_NAME}_FIND_REQUIRED)
  22. SET(_FAIL_MESSAGE "Could not find REQUIRED package ${_NAME}")
  23. ELSE (${_NAME}_FIND_REQUIRED)
  24. SET(_FAIL_MESSAGE "Could not find OPTIONAL package ${_NAME}")
  25. ENDIF (${_NAME}_FIND_REQUIRED)
  26. ELSE("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
  27. SET(_FAIL_MESSAGE "${_FAIL_MSG}")
  28. ENDIF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
  29. STRING(TOUPPER ${_NAME} _NAME_UPPER)
  30. SET(${_NAME_UPPER}_FOUND TRUE)
  31. IF(NOT ${_VAR1})
  32. SET(${_NAME_UPPER}_FOUND FALSE)
  33. ENDIF(NOT ${_VAR1})
  34. FOREACH(_CURRENT_VAR ${ARGN})
  35. IF(NOT ${_CURRENT_VAR})
  36. SET(${_NAME_UPPER}_FOUND FALSE)
  37. ENDIF(NOT ${_CURRENT_VAR})
  38. ENDFOREACH(_CURRENT_VAR)
  39. IF (${_NAME_UPPER}_FOUND)
  40. IF (NOT ${_NAME}_FIND_QUIETLY)
  41. MESSAGE(STATUS "Found ${_NAME}: ${${_VAR1}}")
  42. ENDIF (NOT ${_NAME}_FIND_QUIETLY)
  43. ELSE (${_NAME_UPPER}_FOUND)
  44. IF (${_NAME}_FIND_REQUIRED)
  45. MESSAGE(FATAL_ERROR "${_FAIL_MESSAGE}")
  46. ELSE (${_NAME}_FIND_REQUIRED)
  47. IF (NOT ${_NAME}_FIND_QUIETLY)
  48. MESSAGE(STATUS "${_FAIL_MESSAGE}")
  49. ENDIF (NOT ${_NAME}_FIND_QUIETLY)
  50. ENDIF (${_NAME}_FIND_REQUIRED)
  51. ENDIF (${_NAME_UPPER}_FOUND)
  52. ENDMACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS)