[cmake-developers] Patch: Don't emit warning when config file not found

Brad King brad.king at kitware.com
Thu Apr 27 08:11:23 EDT 2017


On 04/26/2017 04:38 PM, Brad King wrote:
> Thanks.  This is a good start
> 
> * Reject use of OPTIONAL and REQUIRED together.
> * What about OPTIONAL and QUIET together?
> * Document _FIND_OPTIONAL for find modules.

Having thought about these more, I think perhaps my suggestion to
add an `OPTIONAL` argument is too complex and not necessary:

* The lack of `REQUIRED` already indicates optional.
* The unclear argument combinations may cause more confusion.
* The find modules have no clear use for _FIND_OPTIONAL.
* The find modules already handle the not-found case as a
  one-line status message or with REQUIRED a full error.

As I posted previously one of the reasons the default message is
so long is because we don't know whether we are supposed to have
a find module or not.  If the call uses arguments exclusive to
Config mode then we don't necessarily need the full explanation.

Another reason for the long message is that when the package is not
found we try to give the user instructions on how to resolve the
problem.  The "missing: <var>..." part of the find module messages
serves that role nicely, but was introduced more recently than we
last visited the config-mode wording.  Based on our last few posts
in this thread I think that wording can work well for config-mode
too.

I propose that when the find_package call uses arguments exclusive
to the config-mode (e.g. CONFIG, NO_MODULE, or some of the others)
and the call does *not* specify REQUIRED, then we can use the
one-line wording if the package is not found:

    -- Could NOT find Foo (missing: Foo_DIR)

The "missing: Foo_DIR" provides a hint of a path forward for users.
The fact that a config-mode argument was given to the call indicates
that the project author is not expecting a find module to be used,
so we don't need the full explanation.

When REQUIRED is specified we should continue to produce the same
full error message we do now.  It provides more detail on how to
resolve the problem, which is important when the package is required.

The above approach should be a much simpler change.  It will allow
you to use the `find_package(Vc CONFIG)` form of the call I suggested
much earlier in the thread, but give a more concise message than it
does now (and with no warning or stack trace).

Thanks,
-Brad



More information about the cmake-developers mailing list