[cmake-developers] find_package error wording
Alexander Neundorf
neundorf at kde.org
Fri Feb 17 13:28:19 EST 2012
On Friday 17 February 2012, Brad King wrote:
> On 2/17/2012 12:09 PM, Alexander Neundorf wrote:
> > But another significant part of the reason is probably that beside
> > upstreaming a module to cmake, there is no other "official" way to
> > distribute Find- modules. So if somebody wrote a libblub, it is a
> > relatively obvious choice to install FindBlub.cmake as part of the
> > library, so that whoever uses Blub, also has FindBlub.cmake available.
>
> If the Blub project is built with CMake then there should be no FindBlub
> for it at all. It should just install BlubConfig.cmake and be done.
> Perhaps your work to make the files easier to write will help with that.
Yes, but people do that all the time.
I think I saw this for more or less every library which was written in KDE,
and whenever I saw it I explained that distributing the Find-module together
with the library doesn't make sense. I'm sure I didn't get all cases.
> 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.
>
> > Additionally, the Config.cmake file feature of cmake is still relatively
> > unknown. It could use some more PR ;-)
>
> I'll have to think about how to deal with that.
>
> > By having to use NO_MODULE, or the other way round, if by not using
> > NO_MODULE it is clear to cmake that a Find-module is needed, it could
> > then print
>
> > something like:
> Adding the explicit "MODULE" mode keyword could help with that.
>
> >> > - search for FindFoo.cmake, use if found
> >> > - if not found, check new policy setting
> >> > - if not set, warn and follow OLD behavior
> >> > - if set to OLD, enter config mode and use current error if not
> >> > found - if set to NEW, present error about no FindFoo in module
> >> > path
> >
> > Yes, exactly.
>
> We can adjust it slightly to avoid the policy warning when FooConfig
> is found and Foo_DIR is set:
>
> - search for FindFoo.cmake, use if found
> - if not found, check new policy setting
> - if not set, enter config mode and emit both the policy warning
> and the current error if not found
> - if set to OLD, enter config mode and use current error if not found
> - if set to NEW, present error about no FindFoo in module path
Just to make sure I understand:
behave as described intially, but don't warn if the config file has been found
via Foo_DIR.
Right ?
Ok with me.
> One problem with the policy is that it favors module mode as the "normal"
> case and makes "config" mode look like something special. That will
> not help with the perception that the latter is preferred.
I actually prefer to have a simple 3 line wrapper Find-module within the
project:
FindFoo.cmake:
find_package(Foo NO_MODULE)
fphsa(Foo CONFIG_MODE)
set_package_feature(Foo PROPERTIES PURPOSE "Enables something in this app"
TYPE RECOMMENDED
URL http://www.foo.org )
so people get a nice short result line during the cmake run and an informative
summary at the end of the cmake run via FeatureSummary.cmake
Alex
More information about the cmake-developers
mailing list