1 # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
4 #[=======================================================================[.rst:
10 find_package_message(<name> "message for user" "find result details")
12 This function is intended to be used in FindXXX.cmake modules files.
13 It will print a message once for each unique find result. This is
14 useful for telling the user where a package was found. The first
15 argument specifies the name (XXX) of the package. The second argument
16 specifies the message to display. The third argument lists details
17 about the find result so that if they change the message will be
18 displayed again. The macro also obeys the QUIET argument to the
26 find_package_message(X11 "Found X11: ${X11_X11_LIB}"
27 "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]")
31 #]=======================================================================]
33 function(find_package_message pkg msg details)
34 # Avoid printing a message repeatedly for the same find result.
35 if(NOT ${pkg}_FIND_QUIETLY)
36 string(REPLACE "\n" "" details "${details}")
37 set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg})
38 if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}")
39 # The message has not yet been printed.
40 string(STRIP "${msg}" msg)
41 message(STATUS "${msg}")
43 # Save the find details in the cache to avoid printing the same
45 set("${DETAILS_VAR}" "${details}"
46 CACHE INTERNAL "Details about finding ${pkg}")