FindPackageMessage.cmake 2.0 KB

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