[CMake] Misleading error message when enforcing version from foo-config-version.cmake
Brad King
brad.king at kitware.com
Wed Aug 4 10:42:46 EDT 2010
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.
> <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
More information about the CMake
mailing list