Debian Codegraph @

cmake_modules/FindPackageMessage.cmake

raw
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 #=============================================================================
30 # Copyright 2008-2009 Kitware, Inc.
31 #
32 # Distributed under the OSI-approved BSD License (the "License");
33 # see accompanying file Copyright.txt for details.
34 #
35 # This software is distributed WITHOUT ANY WARRANTY; without even the
36 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
37 # See the License for more information.
38 #=============================================================================
39 # (To distribute this file outside of CMake, substitute the full
40 # License text for the above reference.)
41
42 function(FIND_PACKAGE_MESSAGE pkg msg details)
43 # Avoid printing a message repeatedly for the same find result.
44 if(NOT ${pkg}_FIND_QUIETLY)
45 string(REPLACE "\n" "" details "${details}")
46 set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg})
47 if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}")
48 # The message has not yet been printed.
49 message(STATUS "${msg}")
50
51 # Save the find details in the cache to avoid printing the same
52 # message again.
53 set("${DETAILS_VAR}" "${details}"
54 CACHE INTERNAL "Details about finding ${pkg}")
55 endif()
56 endif()
57 endfunction()