[cmake-developers] [CMake 0015231]: find_package: should be a simple way to alter the order of the config/module lookups

Tamás Kenéz tamas.kenez at gmail.com
Thu Apr 16 05:54:49 EDT 2015


The https://public.kitware.com/Bug/view.php?id=15231 feature request
proposes a new feature to make find_package to attempt CONFIG mode
first.

On 10/31/2014 01:30 PM, Brad King wrote:

> I think the main challenge will be how to format error messages when
> neither mode finds anything for a REQUIRED package. It took years to
> get the current messages to a state that minimizes confusion among users
> that do not understand the two modes.

I think when neither mode finds anything it doesn't matter in which
order they failed.
We can pretend they failed in the usual module;config order. So the
wordings of the messages may remain as they are.

We should however think about what to do when
CMAKE_FIND_PACKAGE_WARN_NO_MODULE is ON and both modes are enabled
(and we're in CONFIG_FIRST mode). Should we check the missing
find-module *after* we've found a config-module and print the warning?

I think no, because the user has explicitly expressed the preference
towards the CONFIG mode by specifying CONFIG_FIRST (either as a
find_package option or as CMAKE_FIND_PACKAGE_CONFIG_FIRST).

About the proposed change: The feature request proposes two ways to
enable the CONFIG_FIRST mode: a new option for the find_package and a
global variable (which I think should be called
CMAKE_FIND_PACKAGE_CONFIG_FIRST).

I think the find_package option is less important since the same
effect can be achieved by creating a custom
find_package_config_first() macro.
To simulate the effect of the global variable is much more difficult
and heavy-weight.

Tamas


More information about the cmake-developers mailing list