3

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.

einpoklum
  • 118,144
  • 57
  • 340
  • 684

1 Answers1

0

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.)

fabian
  • 80,457
  • 12
  • 86
  • 114
  • What about the case of a package _being_ found? And no QUIET? – einpoklum Feb 02 '22 at 20:01
  • @einpoklum No prints by default regardless of QUIET/REQUIRED. Added the info to the answer. – fabian Feb 02 '22 at 20:08
  • IME most find modules will print the _first_ time they are found (at least if they are using FPHSA, which ~all the built-in ones do). After that, cache variables are created and the printing gets skipped. – Alex Reinking Feb 02 '22 at 20:13
  • @fabian: That means that the printing I do see is either find scripts, or package config files choosing to print, right? – einpoklum Feb 02 '22 at 20:43