[cmake-developers] find_package error wording

Stephen Kelly steveire at gmail.com
Sun Feb 19 10:41:08 EST 2012


On Sunday, February 19, 2012 16:18:00 Alexander Neundorf wrote:
> On Sunday 19 February 2012, Stephen Kelly wrote:
> > > The only reason to distribute FindBlub for a CMake-aware project is
> > > to wrap up find_package NO_MODULE to produce a nicer message, but
> > > that
> > > is totally optional.  If a project does want to distribute one for
> > > reference it should go in the -doc package, not in -dev, and should
> > > be
> > > put in share/doc/blub or the distro's equivalent.
> > 
> > Good point.
> 
> ...but nobody does it or knows it.

Not many KDE developers at least. But KDE developers aren't really known for 
CMake knowledge anyway. They generally get exposed to as little CMake as 
possible, so I'm not sure they make a good target usecase.

> > However, your suggestion above seems to indicate that that is exactly
> > what's being done?
> > 
> > That will make this an error:
> > 
> > cmake_required_version(2.8.8)
> > find_package(Qt5Core)
> > 
> > Instead this more noisy version would need to be used:
> > 
> > cmake_required_version(2.8.8)
> > find_package(Qt5Core CONFIG_MODE)
> 
> Yes.
> And this is good.

I disagree :)

> Then the error message is "Could not find config file". Above it has to
> guess, and the developers will think that FindQt5.cmake is missing.
> How should they know that Qt5 ships Qt5Config.cmake files ?

feature_summary() should tell them that they have to install the development 
package for Qt5. 

Whether they need a Find module or a Config file, they still need to install 
that, so they might as well do it first.

> We always had FindFoo.cmake files for everything, including FindQt4.cmake.
> They will not think "oh, probably a Qt5Config.cmake could not be found".
> I am 99% sure with this.
> 
> Somebody complained on google+ that cmake is a mess.
> If you don't know what to make of an error message, this won't help the
> perception.

Without knowing what specifically they think is a mess, I don't know. I 
expect that wasn't part of the + post. Specifics rarely are :)

> Just yesterday when I was trying to build parts of kdelibs, and got all 
the
> complaints that neither a Find-module could be found nor a config-file 
could
> be found, I completely didn't know what the right way to fix them is. Is
> the Find-module missing, and I should add it, or is the package missing,
> because it should have installed a config file.

It is usually easy at least with a package manager too see if libfoo-dev is 
installed. 

That at least reduces the scope of the error to either CMake not finding the 
config file (unlikely if a distro package is used, and if you installed it 
yourself then you might know if you installed it) or requiring a 
FindFoo.cmake in your CMAKE_MODULE_PATH (and then you have to figure out 
where it should come from).

> I would have to check the sources of each of the missing packages to 
figure
> out whether it installs a config file or not.
> 
> Making this explicit helps.
> This will also help in making the Config mode more visible, since it will
> not be "hidden" anymore.
> You know, people will see
> find_package(Qt5 CONFIG_MODE)
> and they might have a look what that "CONFIG_MODE" means.
> Without it, they won't.

Maybe.

The current branch isn't my preferred solution. Even after everyone has a 
firm understanding of what CONFIG_MODE means, we'll still always need it. 
Maybe another policy in the future would be able to make it the default?

I don't know if there's a better solution, but I just wanted to raise my 
concerns.

Thanks,

Steve





More information about the cmake-developers mailing list