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