Re: [cmake-developers] Bad error message when a package could not be found - make find_package() not search config files by default
On 2/17/2012 5:07 AM, Alexander Neundorf wrote: The documentation page says: "The REQUIRED option stops processing with an error message if the package cannot be found." I interpret this as "stops processing immediately". This has always been the intended meaning. The idea is that code following the line can be written without checking whether the package was FOUND and assume certain variables are set. If you want other behavior then do not pass REQUIRED and check if(...FOUND) manually. -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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
Re: [cmake-developers] Bad error message when a package could not be found - make find_package() not search config files by default
On Friday 17 February 2012, Alexander Neundorf wrote: ... > What should be improved: ... > 2.) CMAKE_PREFIX_PATH should be mentioned > > 1.), 2.) if a version number was used, this should be printed in the error > message > > 1.) CMAKE_PREFIX_PATH should be mentioned at least. 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. Alex -- 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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
Re: [cmake-developers] Bad error message when a package could not be found - make find_package() not search config files by default
On Friday 17 February 2012, Rolf Eike Beer wrote: > > On Thursday 16 February 2012, Alexander Neundorf wrote: ... > > What should be improved: > > 1.), 2.), 4.) processing should stop if REQUIRED was used > > I disagree. Say I want to build $random package. Throw the source > somewhere, run cmake. Now I see the errors and install the packages that > are missing. If processing immediately stops on an unmet dependency I > would have to repeat that as long as there are unmet dependencies. If > processing continues but gives and error I can install all things at once. Well, at least it is inconsistent with the behaviour of all Find-modules. They all stop with FATAL_ERROR if a REQUIRED package was not found. The documentation page says: "The REQUIRED option stops processing with an error message if the package cannot be found." I interpret this as "stops processing immediately". This is what find_package_handle_standard_args() does. If this is not the intended meaning, then all the Find-modules (mostly FindPackageHandleStandardArgs) should be changed to use SEND_ERROR instead of FATAL_ERROR. Alex -- 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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
Re: [cmake-developers] Bad error message when a package could not be found - make find_package() not search config files by default
> On Thursday 16 February 2012, Alexander Neundorf wrote: >> Hi, >> >> when I use a Find-module to search for a package, I get a nice error >> message if the package could not be found. > > 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) > > > Here we go: > > package not found, REQUIRED: > > > 1.) find_package() with no Find-module present: > > CMake Error at CMakeLists.txt:4 (find_package): > Could not find module Findecm.cmake or a configuration file > for package ecm. > > Adjust CMAKE_MODULE_PATH to find Findecm.cmake or set > ecm_DIR to the directory containing a CMake configuration > file for ecm. The file will have one of the following > names: > > ecmConfig.cmake > ecm-config.cmake > * processing continues, but with error > > > > 2.) find_package(NO_MODULE): > > CMake Error at CMakeLists.txt:4 (find_package): > Could not find a configuration file for package ecm. > > Set ecm_DIR to the directory containing a CMake > configuration file for ecm. The file will have one of the > following names: > > ecmConfig.cmake > ecm-config.cmake > * processing continues, but with error > > 4.) find_package() with no Find-module present, same with NO_MODULE: > > CMake Error at CMakeLists.txt:4 (find_package): > Could not find a configuration file for package "ecm" that > is compatible with requested version "0.0.4". > > The following configuration files were considered but not accepted: > > /opt/ecm/share/ecm-0.0.2/cmake/ecm-config.cmake, version: 0.0.2 > /opt/ecm/share/ecm-0.0.3/cmake/ecm-config.cmake, version: 0.0.3 > * processing continues, but with error > What should be improved: > 1.), 2.), 4.) processing should stop if REQUIRED was used I disagree. Say I want to build $random package. Throw the source somewhere, run cmake. Now I see the errors and install the packages that are missing. If processing immediately stops on an unmet dependency I would have to repeat that as long as there are unmet dependencies. If processing continues but gives and error I can install all things at once. Eike -- 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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
Re: [cmake-developers] Bad error message when a package could not be found - make find_package() not search config files by default
On Thursday 16 February 2012, Alexander Neundorf wrote: > Hi, > > when I use a Find-module to search for a package, I get a nice error > message if the package could not be found. 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) Here we go: package not found, REQUIRED: 1.) find_package() with no Find-module present: CMake Error at CMakeLists.txt:4 (find_package): Could not find module Findecm.cmake or a configuration file for package ecm. Adjust CMAKE_MODULE_PATH to find Findecm.cmake or set ecm_DIR to the directory containing a CMake configuration file for ecm. The file will have one of the following names: ecmConfig.cmake ecm-config.cmake * processing continues, but with error 2.) find_package(NO_MODULE): CMake Error at CMakeLists.txt:4 (find_package): Could not find a configuration file for package ecm. Set ecm_DIR to the directory containing a CMake configuration file for ecm. The file will have one of the following names: ecmConfig.cmake ecm-config.cmake * processing continues, but with error 3.) find_package() with a wrapper Find-module: CMake Error at /opt/cmakeHEAD/share/cmake-2.8/Modules/ FindPackageHandleStandardArgs.cmake:91 (MESSAGE): Could NOT find ecm: found neither ecmConfig.cmake nor ecm-config.cmake (Required is at least version "0.0.4") Call Stack (most recent call first): /opt/cmakeHEAD/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:121 /opt/cmakeHEAD/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:247 Findecm.cmake:4 (find_package_handle_standard_args) CMakeLists.txt:7 (find_package) * processing stops Without REQUIRED the messages are the same (with the wrapper Find-module the callstack is not printed), but processing continues without error. Now the cases where the Config file was found, but the version didn't match: 4.) find_package() with no Find-module present, same with NO_MODULE: CMake Error at CMakeLists.txt:4 (find_package): Could not find a configuration file for package "ecm" that is compatible with requested version "0.0.4". The following configuration files were considered but not accepted: /opt/ecm/share/ecm-0.0.2/cmake/ecm-config.cmake, version: 0.0.2 /opt/ecm/share/ecm-0.0.3/cmake/ecm-config.cmake, version: 0.0.3 * processing continues, but with error 5.) find_package() with a wrapper Find-module: CMake Error at /opt/cmakeHEAD/share/cmake-2.8/Modules/ FindPackageHandleStandardArgs.cmake:91 (MESSAGE): Could NOT find ecm (Required is at least version "0.0.4"), checked the following files: /opt/ecm/share/ecm-0.0.2/cmake/ecm-config.cmake (version 0.0.2) /opt/ecm/share/ecm-0.0.3/cmake/ecm-config.cmake (version 0.0.3) Call Stack (most recent call first): /opt/cmakeHEAD/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:117 /opt/cmakeHEAD/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:247 Findecm.cmake:4 (find_package_handle_standard_args) CMakeLists.txt:7 (find_package) * processing stops What should be improved: 1.), 2.), 4.) processing should stop if REQUIRED was used 2.) CMAKE_PREFIX_PATH should be mentioned 1.), 2.) if a version number was used, this should be printed in the error message 1.) CMAKE_PREFIX_PATH should be mentioned at least. This is the one error message which is IMO problematic. It basically only says "it did not work", and I don't know whether the package is missing or whether the buildsystem of the project is broken, which are two significantly different problems - one requires installing a package, the other requires hacking the buildsystem of an unknown project. This could be avoided by making NO_MODULE required when the intention is to search for a Config file (I would have preferred from the beginning if find_package() would use only Find-modules, and for searching Config-files there would have been a separate command like find_config()). In general, I would still recommend everybody to use the small wrapper Find- modules also for packages which install a Config.file, if only for the purpose to contain some documentation or to set up information for FeatureSummary.cmake. Alex -- Powered by www.kitware.com Visit other Kitware ope
Re: [cmake-developers] Bad error message when a package could not be found - make find_package() not search config files by default
On Thu, Feb 16, 2012 at 11:57 AM, Brad King wrote: > On Thu, Feb 16, 2012 at 11:13 AM, Alexander Neundorf > wrote: > > On Thursday 16 February 2012, Brad King wrote: > >> but I do not want to require every project to change almost every > >> find_package call and generate a policy warning about every call in > >> every old project release. > > > > My impression is that config.cmake files are not yet wide spread. > [snip] > > I mean, it may not be problem yet, because maybe 90 percent of the > > find_packages() calls use Find-modules, but I am quite sure it will > become > > one. > > So your proposal when no extra find_package mode arg is given is: > > - 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 > > ? > > Separately the CONFIG and MODULE explicit mode args can be given > to be alternative to NO_MODULE. > > -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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers > I'm not seeing this as a huge problem. A failed find_package means that some package that your project depends on cannot be found. If a developer can't figure out that means he has to build/install that package correctly first, then what chance does he have building your software at all? The error message we have is very clear, although fairly verbose, giving multiple ways to attempt correcting the problem. I don't think we need to change anything in a hurry here. David -- 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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
Re: [cmake-developers] Bad error message when a package could not be found - make find_package() not search config files by default
On Thu, Feb 16, 2012 at 11:13 AM, Alexander Neundorf wrote: > On Thursday 16 February 2012, Brad King wrote: >> but I do not want to require every project to change almost every >> find_package call and generate a policy warning about every call in >> every old project release. > > My impression is that config.cmake files are not yet wide spread. [snip] > I mean, it may not be problem yet, because maybe 90 percent of the > find_packages() calls use Find-modules, but I am quite sure it will become > one. So your proposal when no extra find_package mode arg is given is: - 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 ? Separately the CONFIG and MODULE explicit mode args can be given to be alternative to NO_MODULE. -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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
Re: [cmake-developers] Bad error message when a package could not be found - make find_package() not search config files by default
On Thursday 16 February 2012, Brad King wrote: > On 2/16/2012 10:30 AM, Alexander Neundorf wrote: > >> In any of the above modes the error message can be more explicit. > >> It is up to the author of the project to choose to do this. I do > >> not want it to be required. > > > > Here we disagree. I think it should be required, to avoid the impression > > "finding packages with cmake is a total mess" among users who don't know > > the details of cmake package searching. > > I'm not opposed to trying to make the messages easier to understand, > but I do not want to require every project to change almost every > find_package call and generate a policy warning about every call in > every old project release. My impression is that config.cmake files are not yet wide spread. At least I am sure that they will become much much more widespread than they are now. E.g. what is now known as kdelibs, is currently in the process of being split into 10 or 20 separate libraries, each of them will install one config file. I mean, it may not be problem yet, because maybe 90 percent of the find_packages() calls use Find-modules, but I am quite sure it will become one. > As I said in the part of my message you did not quote in the response > the problem is the error message does not know who is reading it. If > we can solve that problem then we can make the message say what the > reader needs to see. Yes. I just couldn't imagine a useful way. Alex -- 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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
Re: [cmake-developers] Bad error message when a package could not be found - make find_package() not search config files by default
On 2/16/2012 10:59 AM, Brad King wrote: On 2/16/2012 10:30 AM, Alexander Neundorf wrote: In any of the above modes the error message can be more explicit. It is up to the author of the project to choose to do this. I do not want it to be required. Here we disagree. I think it should be required, to avoid the impression "finding packages with cmake is a total mess" among users who don't know the details of cmake package searching. I'm not opposed to trying to make the messages easier to understand, but I do not want to require every project to change almost every find_package call and generate a policy warning about every call in every old project release. As I said in the part of my message you did not quote in the response the problem is the error message does not know who is reading it. If we can solve that problem then we can make the message say what the reader needs to see. Furthermore we can recommend use of CONFIG or MODULE mode explicitly in the documentation and get nearly all of the benefit for those who want it but without making everyone else change too. -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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
Re: [cmake-developers] Bad error message when a package could not be found - make find_package() not search config files by default
On 2/16/2012 10:30 AM, Alexander Neundorf wrote: In any of the above modes the error message can be more explicit. It is up to the author of the project to choose to do this. I do not want it to be required. Here we disagree. I think it should be required, to avoid the impression "finding packages with cmake is a total mess" among users who don't know the details of cmake package searching. I'm not opposed to trying to make the messages easier to understand, but I do not want to require every project to change almost every find_package call and generate a policy warning about every call in every old project release. As I said in the part of my message you did not quote in the response the problem is the error message does not know who is reading it. If we can solve that problem then we can make the message say what the reader needs to see. -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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
Re: [cmake-developers] Bad error message when a package could not be found - make find_package() not search config files by default
On Thursday 16 February 2012, Brad King wrote: > On 2/16/2012 8:19 AM, Alexander Neundorf wrote: > > Comments, objections ? > > The entire point of find_package's interface is that the caller > does not need to care how the package is found, and the actual > method used for the find can change under the hood. > > Ideally every package would provide a package config file in its > installation and we would never need Find modules. In that case > having the extra keyword in every find_package call would be ugly. I don't think I agree with this. It should be easily visible what find_package() is looking for, otherwise you are completely lost what is missing if find_package() did not find the package. > If you don't like the error message then you are free to write > >find_package(Foo NO_MODULE) > > anywhere you want. I personally do that usually, because I know quite well how it works. The average developer doesn't do this, because for him it works, he usually has the package installed, and if it is not found, he knows why, because he is working on it. I think it should really be enforced to make explicit if a Config-file is searched. People have got used to Find-modules, and now those "new" Config.cmake files start to appear, which many developers don't know anything about. Even more so non-developers which just want to build a package. If I would try to build some downloaded package which does find_package(Foo 1.0.0) and cmake tells me that it couldn't find a FindFoo.cmake and also no FooConfig.cmake and no Foo-config.cmake, I would basically give up at this moment. Maybe the developer had wrong assumption when building on his machine, maybe he had some weird installation where some project had installed a FindFoo.cmake into a directory searched by cmake, if CMAKE_MODULE_PATH is set up e.g. from an environment variable: set(CMAKE_MODULE_PATH $ENV{MY_CMAKE_MODULE_DIR} ) or something. This is not too far fetched, there are emails from time to time how to set up such a directory so that Find-modules can be shared. Let's make cmake more strict, to avoid confusion and to make clearer what is going on. > Perhaps you can add an alternative keyword so > that this can be written > >find_package(Foo CONFIG) > > instead for those authors who want to do so. Furthermore if you > want to guarantee that a Find module is used then add a mode like > >find_package(Foo MODULE) > > so that the command knows that it is an error if FindFoo does not > exist in CMAKE_MODULE_PATH. > > In any of the above modes the error message can be more explicit. > It is up to the author of the project to choose to do this. I do > not want it to be required. Here we disagree. I think it should be required, to avoid the impression "finding packages with cmake is a total mess" among users who don't know the details of cmake package searching. Alex -- 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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
Re: [cmake-developers] Bad error message when a package could not be found - make find_package() not search config files by default
On 2/16/2012 8:19 AM, Alexander Neundorf wrote: Comments, objections ? The entire point of find_package's interface is that the caller does not need to care how the package is found, and the actual method used for the find can change under the hood. Ideally every package would provide a package config file in its installation and we would never need Find modules. In that case having the extra keyword in every find_package call would be ugly. If you don't like the error message then you are free to write find_package(Foo NO_MODULE) anywhere you want. Perhaps you can add an alternative keyword so that this can be written find_package(Foo CONFIG) instead for those authors who want to do so. Furthermore if you want to guarantee that a Find module is used then add a mode like find_package(Foo MODULE) so that the command knows that it is an error if FindFoo does not exist in CMAKE_MODULE_PATH. In any of the above modes the error message can be more explicit. It is up to the author of the project to choose to do this. I do not want it to be required. For the default case perhaps the wording can be better than it is now. Currently the wording is trying to cover both the case that the developer of the code is reading it and the case that an end user is reading it while running cmake to build a project. The two cases are very different. This is not the first time we've had to deal with messages that are readable by developers but not by users and vice versa. I wonder if we should introduce some kind of use case mode setting that tells CMake who will be reading the messages. Then they can be tailored more effectively to the context. -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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
[cmake-developers] Bad error message when a package could not be found - make find_package() not search config files by default
Hi, when I use a Find-module to search for a package, I get a nice error message if the package could not be found. If I use find_package(Foo) and rely on Config-mode, cmake produces an error message which doesn't help the user: ~/src/extra-cmake-modules/example/b$ make rebuild_cache Running CMake to regenerate build system... CMake Error at CMakeLists.txt:4 (find_package): Could not find module Findextra-cmake-modules.cmake or a configuration file for package extra-cmake-modules. Adjust CMAKE_MODULE_PATH to find Findextra-cmake-modules.cmake or set extra-cmake-modules_DIR to the directory containing a CMake configuration file for extra-cmake-modules. The file will have one of the following names: extra-cmake-modulesConfig.cmake extra-cmake-modules-config.cmake -- modules path: -- CMake Error at CMakeLists.txt:13 (ecm_use_find_modules): Unknown CMake command "ecm_use_find_modules". -- Configuring incomplete, errors occurred! make: *** [rebuild_cache] Error 1 I see several issues here, sorted by importance: 1) the user doesn't know whether his build was supposed to use a Find-module or whether it was supposed to find the Config.cmake file. Especially since there is no file present which tells him that. With Find-modules he can have a look at the Find-module and he will see which header or library cmake is looking for. In the case of a missing Config.cmake file this is not possible. This is IMO a major problem. The user has no chance to guess which file he should look for, and where it should come from: FindFoo.cmake, FooConfig.cmake or Foo-config.cmake. 2) the first thing the error message recommends is to adjust CMAKE_MODULE_PATH. But probably either Foo is not installed at all, or the user should adjust CMAKE_PREFIX_PATH so Foo can be found. But CMAKE_PREFIX_PATH is not mentioned at all. 3) cmake continues processing the CMakeLists.txt even after the REQUIRED message could not be found. IMO it should fail with FATAL_ERROR. What to do about it ? 3) should be easy to solve by failing differently. I can do that. 1) and 2): What I usually recommend is to use a tiny FindFoo.cmake file which basically contains find_package(FOO NO_MODULE). This way the user can find information what went wrong. But it doesn't seem like everybody is doing this. So it should be enforced or at least always obvious what cmake is searching. So here is my proposal: make find_package() search only for Find-modules by default, and only search for config.cmake files if NO_MODULE was used (maybe add a positive option CONFIG_MODE). If then a config.cmake file was not found, the error message can say definitely whether a Find-module was not found, and CMAKE_MODULE_PATH is wrong, or whether the Config.cmake file was not found, and CMAKE_PREFIX_PATH should be adjusted. Also, by looking at the CMakeLists.txt, the user can see whether a Find-module or a Config.cmake file should be found. I am aware that this is quite a change, but thanks to the policy system it shouldn't be able to break anything. I consider this necessary, to avoid the feeling of helplessness among users because they have no idea what went wrong in cmake's configure step. Comments, objections ? Alex -- 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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers