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

Brad King brad.king at kitware.com
Fri Apr 17 08:01:42 EDT 2015


On 04/16/2015 05:54 AM, Tamás Kenéz wrote:
>> I think the main challenge will be how to format error messages when
>> neither mode finds anything for a REQUIRED package.
> 
> We can pretend they failed in the usual module;config order. So the
> wordings of the messages may remain as they are.

The current message says:

  By not providing Find<pkg>.cmake in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file ...

If someone sets CMAKE_FIND_PACKAGE_CONFIG_FIRST then that is what
asked CMake to find a package configuration file even if the project
does provide Find<pkg>.cmake in CMAKE_MODULE_PATH.  Therefore new
wording will be needed in this case.  It should still depend on
whether the find module was available.

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

Agreed.  We can always add such a warning in the future.

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

If the functionality is implemented through either interface it will
be easy to add the other, so I think they can just both be added
together.

Are you interested in working on a patch for this?

Thanks,
-Brad


More information about the cmake-developers mailing list