cmake Test and Debug Debug find_package() errors


Example

Note: The shown CMake error messages already include the fix for "non-standard" library/tool installation paths. The following examples just demonstrate more verbose CMake find_package() outputs.

CMake internally supported Package/Module

If the following code (replace the FindBoost module with your module in question)

cmake_minimum_required(VERSION 2.8)
project(FindPackageTest)

find_package(Boost REQUIRED)

gives some error like

CMake Error at [...]/Modules/FindBoost.cmake:1753 (message):
  Unable to find the requested Boost libraries.

  Unable to find the Boost header files.  Please set BOOST_ROOT to the root
  directory containing Boost or BOOST_INCLUDEDIR to the directory containing
  Boost's headers.

And you're wondering where it tried to find the library, you can check if your package has an _DEBUG option like the Boost module has for getting more verbose output

$ cmake -D Boost_DEBUG=ON .. 

CMake enabled Package/Library

If the following code (replace the Xyz with your library in question)

cmake_minimum_required(VERSION 2.8)
project(FindPackageTest)

find_package(Xyz REQUIRED)

gives the some error like

CMake Error at CMakeLists.txt:4 (find_package):
  By not providing "FindXyz.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Xyz", but
  CMake did not find one.

  Could not find a package configuration file provided by "Xyz" with any of
  the following names:

    XyzConfig.cmake
    xyz-config.cmake

  Add the installation prefix of "Xyz" to CMAKE_PREFIX_PATH or set "Xyz_DIR"
  to a directory containing one of the above files.  If "Xyz" provides a
  separate development package or SDK, be sure it has been installed.

And you're wondering where it tried to find the library, you can use the undocumented CMAKE_FIND_DEBUG_MODE global variable for getting a more verbose output

$ cmake -D CMAKE_FIND_DEBUG_MODE=ON ..