FindPackageMessage.cmake 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #.rst:
  2. # FindPackageMessage
  3. # ------------------
  4. #
  5. #
  6. #
  7. # FIND_PACKAGE_MESSAGE(<name> "message for user" "find result details")
  8. #
  9. # This macro is intended to be used in FindXXX.cmake modules files. It
  10. # will print a message once for each unique find result. This is useful
  11. # for telling the user where a package was found. The first argument
  12. # specifies the name (XXX) of the package. The second argument
  13. # specifies the message to display. The third argument lists details
  14. # about the find result so that if they change the message will be
  15. # displayed again. The macro also obeys the QUIET argument to the
  16. # find_package command.
  17. #
  18. # Example:
  19. #
  20. # ::
  21. #
  22. # if(X11_FOUND)
  23. # FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}"
  24. # "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]")
  25. # else()
  26. # ...
  27. # endif()
  28. #=============================================================================
  29. # Copyright 2008-2009 Kitware, Inc.
  30. #
  31. # Distributed under the OSI-approved BSD License (the "License");
  32. # see accompanying file Copyright.txt for details.
  33. #
  34. # This software is distributed WITHOUT ANY WARRANTY; without even the
  35. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  36. # See the License for more information.
  37. #=============================================================================
  38. # (To distribute this file outside of CMake, substitute the full
  39. # License text for the above reference.)
  40. function(FIND_PACKAGE_MESSAGE pkg msg details)
  41. # Avoid printing a message repeatedly for the same find result.
  42. if(NOT ${pkg}_FIND_QUIETLY)
  43. string(REPLACE "\n" "" details "${details}")
  44. set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg})
  45. if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}")
  46. # The message has not yet been printed.
  47. message(STATUS "${msg}" "${details}")
  48. # Save the find details in the cache to avoid printing the same
  49. # message again.
  50. set("${DETAILS_VAR}" "${details}"
  51. CACHE INTERNAL "Details about finding ${pkg}")
  52. endif()
  53. endif()
  54. endfunction()