[cmake-developers] Bad error message when a package could not be found - make find_package() not search config files by default
Alexander Neundorf
neundorf at kde.org
Thu Feb 16 10:30:19 EST 2012
On Thursday 16 February 2012, Brad King wrote:
> On 2/16/2012 8:19 AM, Alexander Neundorf wrote:
> > Comments, objections ?
>
> The entire point of find_package's interface is that the caller
> does not need to care how the package is found, and the actual
> method used for the find can change under the hood.
>
> Ideally every package would provide a package config file in its
> installation and we would never need Find modules. In that case
> having the extra keyword in every find_package call would be ugly.
I don't think I agree with this.
It should be easily visible what find_package() is looking for, otherwise you
are completely lost what is missing if find_package() did not find the
package.
> If you don't like the error message then you are free to write
>
> find_package(Foo NO_MODULE)
>
> anywhere you want.
I personally do that usually, because I know quite well how it works.
The average developer doesn't do this, because for him it works, he usually
has the package installed, and if it is not found, he knows why, because he is
working on it.
I think it should really be enforced to make explicit if a Config-file is
searched.
People have got used to Find-modules, and now those "new" Config.cmake files
start to appear, which many developers don't know anything about.
Even more so non-developers which just want to build a package.
If I would try to build some downloaded package which does
find_package(Foo 1.0.0)
and cmake tells me that it couldn't find a FindFoo.cmake and also no
FooConfig.cmake and no Foo-config.cmake, I would basically give up at this
moment. Maybe the developer had wrong assumption when building on his machine,
maybe he had some weird installation where some project had installed a
FindFoo.cmake into a directory searched by cmake, if CMAKE_MODULE_PATH is set
up e.g. from an environment variable:
set(CMAKE_MODULE_PATH $ENV{MY_CMAKE_MODULE_DIR} )
or something.
This is not too far fetched, there are emails from time to time how to set up
such a directory so that Find-modules can be shared.
Let's make cmake more strict, to avoid confusion and to make clearer what is
going on.
> Perhaps you can add an alternative keyword so
> that this can be written
>
> find_package(Foo CONFIG)
>
> instead for those authors who want to do so. Furthermore if you
> want to guarantee that a Find module is used then add a mode like
>
> find_package(Foo MODULE)
>
> so that the command knows that it is an error if FindFoo does not
> exist in CMAKE_MODULE_PATH.
>
> In any of the above modes the error message can be more explicit.
> It is up to the author of the project to choose to do this. I do
> not want it to be required.
Here we disagree. I think it should be required, to avoid the impression
"finding packages with cmake is a total mess" among users who don't know the
details of cmake package searching.
Alex
More information about the cmake-developers
mailing list