[CMake] Misleading error message when enforcing version from foo-config-version.cmake

Adolfo Rodríguez Tsouroukdissian adolfo.rodriguez at pal-robotics.com
Wed Aug 4 11:03:22 EDT 2010


2010/8/4 Brad King <brad.king at kitware.com>

> On 08/04/2010 10:25 AM, Adolfo Rodríguez Tsouroukdissian wrote:
> > I'm writing a package config file foo-config.cmake, and I'm providing
> > version checking via the foo-config-version.cmake. Everything works
> > fine, but I've noticed that when version checking fails, the reported
> > error message is uninformative and misleading. It states:
>
> If you call
>
>  find_package(Foo NO_MODULE)
>
> you will get a better error message.
>

Different error message, but not better. I may have not been clear enough on
the situation. The foo-config.cmake file is located OK, and:

find_package(Foo REQUIRED NO_MODULE)

works as expected. Now, if I do:

find_package(Foo 6.6.6 REQUIRED NO_MODULE)

and 6.6.6 is a non-valid version (i.e., PACKAGE_VERSION_COMPATIBLE is set to
FALSE in foo-config-version.cmake), then I get the error message that
foo-config.cmake is not found, instead of something related to the request
of an incompatible version.

Cheers,

Adolfo


> > <quote>
> > Could not find module FindFoo.cmake or a configuration file for
> >   package Foo.
> >
> >   Adjust CMAKE_MODULE_PATH to find FindFoo.cmake or set Foo_DIR
> >   to the directory containing a CMake configuration file for Foo.  The
> >   file will have one of the following names:
> >
> >     FooConfig.cmake
> >     foo-config.cmake
> > <quote/>
> >
> > I would expect something more in the lines of "Unable to find a
> > compatible Foo version.", which I can still provide in my
> > foo-config-version.cmake. I guess I would just like the above message
> > not to be shown to prevent user confusion (foo-config.cmake exists and
> > can be found). Does this sound like a ticket?.
>
> No, the current behavior is intentional.  The problem is that find_package
> has two modes.  First it looks for a FindXXX.cmake file and loads that if
> it finds one (module mode).  If it does not then it looks for XXXConfig
> (config mode) with XXX_DIR.  When the command was originally created we
> assumed that anyone that wants it to use FindXXX would ensure that it is
> in the CMAKE_MODULE_PATH before calling find_package(XXX).  Therefore we
> made the default error message talk about just XXX_DIR and not mention
> the module mode at all.  This is the type of message you seem to want.
> However, people that *did* want to use FindXXX in module mode but failed
> to put it in the CMAKE_MODULE_PATH complained that the error message
> gave no information about missing FindXXX and talked only about XXX_DIR.
>
> Now the message talks about both options.
>
> -Brad
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100804/04bbb71e/attachment.htm>


More information about the CMake mailing list