FindPackageMessage.cmake 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  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. FUNCTION(FIND_PACKAGE_MESSAGE pkg msg details)
  21. # Avoid printing a message repeatedly for the same find result.
  22. IF(NOT ${pkg}_FIND_QUIETLY)
  23. SET(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg})
  24. IF(NOT "${details}" STREQUAL "${${DETAILS_VAR}}")
  25. # The message has not yet been printed.
  26. MESSAGE(STATUS "${msg}")
  27. # Save the find details in the cache to avoid printing the same
  28. # message again.
  29. SET("${DETAILS_VAR}" "${details}"
  30. CACHE INTERNAL "Details about finding ${pkg}")
  31. ENDIF(NOT "${details}" STREQUAL "${${DETAILS_VAR}}")
  32. ENDIF(NOT ${pkg}_FIND_QUIETLY)
  33. ENDFUNCTION(FIND_PACKAGE_MESSAGE)