Under what conditions does find_package() print a message?

516 views Asked by At

The CMake find_package() command sometimes prints a message, indication that the package has been found, and possibly the found version.

What are the condition(s) for this message being printed, other than QUIET not being used?

Note: Asking about CMake 3.22 in case it matters.

Edit: I have now filed a bug against CMake asking for the ability to print a message even when this is not currently mandated.

1

There are 1 answers

4
fabian On

I've tested this with a few configurations and made the following observations:

  1. The version script and the package configuration script or the find script can ignore quiet and print as much as they like; the presence of the QUIET option seems more like a suggestion than something enforced by cmake.
  2. CMake itself seems to print the version number of unsuitable packages automatically, if no suitable package is found and
    • REQUIRED is specified, or
    • QUIET isn't specified
  3. If a suitable version of the package is found, nothing is printed, regardless of whether REQUIRED and/or QUIET are present.

(Tested with the Windows version of CMake 3.22.1. The "basic signature" was used in all tests.)