[cmake-developers] find_package error wording
Alexander Neundorf
neundorf at kde.org
Fri Feb 17 09:27:08 EST 2012
On Friday 17 February 2012, Brad King wrote:
> On 2/17/2012 4:29 AM, Alexander Neundorf wrote:
> > I collected the various error messages which can be produced in the
> > different cases:
> > * package not found
> > * package found, but version doesn't match
> >
> > * REQUIRED
> > * without REQUIRED
> >
> > * find_package() with no Find-module present
> > * find_package(NO_MODULE)
> >
> > * find_package() with a wrapper Find-module which does:
> > find_package(ecm QUIET NO_MODULE)
> > fphsa(ecm CONFIG_MODE)
>
> Nice. Can you code this into a test in the Tests/CMakeOnly directory?
> That way we will have a single place to reference to see all the current
> error messages and we will know if things change accidentally.
I'll try to.
> On 2/17/2012 5:48 AM, Alexander Neundorf wrote:
> > These three points and a small bug fix (error message was not printed at
> > all for an invalid CONFIGS name) are now in the
> > FindPackage_ImprovedErrorMessages branch and merged into next.
>
> From your commit message:
> > CMake Error at CMakeLists.txt:7 (find_package):
> > Could not find module Findecm.cmake or a configuration file
> >
> > for package ecm with one of the following names:
> > ecmConfig.cmake
> > ecm-config.cmake
> >
> > Adjust CMAKE_MODULE_PATH to find Findecm.cmake. To find
> > the configuration file, set CMAKE_PREFIX_PATH to the installation
> > prefix of ecm, or set ecm_DIR to the directory
> > containing a CMake configuration file for ecm.
>
> 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=ca501aa9f4c1e7adcd42accbd53538502ba50ce3&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.
Alex
More information about the cmake-developers
mailing list