[cmake-developers] find_package error wording
Alexander Neundorf
neundorf at kde.org
Fri Feb 17 11:37:50 EST 2012
On Friday 17 February 2012, Alexander Neundorf wrote:
> On Friday 17 February 2012, Brad King wrote:
...
> > Perhaps we can make the distinction between user and developer right
> > in the message. When there is no Find module the proper message that
> > a user sees should talk about ecm_DIR and CMAKE_PREFIX_PATH only.
> > This should be the focus. We can then add an extra note to help
> >
> > developers use Find modules. Consider:
> > CMake Error at CMakeLists.txt:7 (find_package):
> > No package configuration file for "ecm" found by names:
> > ecmConfig.cmake
> > ecm-config.cmake
> >
> > Add the installation prefix of "ecm" to CMAKE_PREFIX_PATH or
> > set "ecm_DIR" to a directory containing one of the above files.
> >
> > (If you are a developer expecting this find_package to load a
> >
> > Findecm.cmake module then ensure it lies in CMAKE_MODULE_PATH.)
>
> I'm still not convinced.
> Just today I found this commit from last October in kdelibs:
> http://quickgit.kde.org/index.php?p=kdelibs.git&a=commitdiff&h=ca501aa9f4c1
> e7adcd42accbd53538502ba50ce3&hp=3186e7a5f3acfaa5b5ac1b5cce9315eb53f54655
>
> Commit message: on win32 we need access to the installed cmake modules dir
>
> --- a/cmake/modules/FindKDE4Internal.cmake
> +++ b/cmake/modules/FindKDE4Internal.cmake
> @@ -736,6 +736,7 @@ endif(${CMAKE_MAJOR_VERSION}.${CMAKE_MIN
> option(KDE4_ENABLE_FPIE "Enable platform supports PIE linking")
>
> if (WIN32)
> + list(APPEND CMAKE_MODULE_PATH
> "${CMAKE_INSTALL_PREFIX}/share/apps/cmake/modules")
> find_package(KDEWin REQUIRED)
> option(KDE4_ENABLE_UAC_MANIFEST "add manifest to make..." OFF)
> if (KDE4_ENABLE_UAC_MANIFEST)
>
>
> This looks really wrong (I mean this directory is not guaranteed to exist
> at all at cmake time, so it can't help finding a module file), and it was
> committed by a developer who is using cmake now already since 2006 at
> least.
>
> If I would build this, I would get exactly to case 1) - neither Find-module
> nor config-file found.
> As user I should assume that there should be a config file, and I should
> install the package or set CMAKE_PREFIX_PATH. But this wouldn't help,
> because actually the Find-module is missing, because in some way the
> buildsystem expects something wrong.
> So when I (as user) would assume the package is not installed because the
> config has not been found, I would be wrong, but I couldn't see this from
> the code.
> If config-file searching would have to be enabled, I would know from the
> error message (which would then say "Find-module not found") that the
> buildsystem is broken, and not some package is missing or
> CMAKE_PREFIX_PATH is not set.
IOW: it's a quite common error to install a FindFoo.cmake as part of the
package Foo into the prefix where foo is installed.
So if cmake knows that really the Find-module should have been found, it can
produce a very clear error message that the missing Find-module must be part
of the project itself or provided by another previously found package, and
that the buildsystem is broken.
Alex
More information about the cmake-developers
mailing list