See this answer for information on how to write a cmake search file. For example, here is what I wrote for the lm sensor library:
Change the above to match your library ( boost-numeric-bindings ), name the file Findboost-numeric-bindings.cmake and put it in the cmake module directory (or create one of them in the source tree).
Then in the CMakeLists.txt file do the following:
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} your_cmake_module_dir) find_package (boost-numeric-bindings REQUIRED) include_directories(${BOOST_NUMERIC_BINDINGS_INCLUDE_DIR})
Then, assuming you donβt have the library installed in the standard location, run cmake as follows:
cmake -D CMAKE_PREFIX_PATH:STRING="/where/you/have/installed/it/" <source path>
Edit
Before calling find_path or find_package make sure you define a project. Otherwise, CMAKE_SYSTEM_INCLUDE_PATH will not be set. For instance:
find_path (BOOST_STATE_HPP boost/statechart/state.hpp) message ("CMAKE_FIND_ROOT_PATH=${CMAKE_FIND_ROOT_PATH}") message ("CMAKE_SYSTEM_INCLUDE_PATH=${CMAKE_SYSTEM_INCLUDE_PATH}") message ("CMAKE_SYSTEM_FRAMEWORK_PATH=${CMAKE_SYSTEM_FRAMEWORK_PATH}") message ("CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}") message ("BOOST_STATE_HPP=${BOOST_STATE_HPP}") project (my_project)
will result in the following cmake output:
CMAKE_FIND_ROOT_PATH= CMAKE_SYSTEM_INCLUDE_PATH= CMAKE_SYSTEM_FRAMEWORK_PATH= CMAKE_PREFIX_PATH= BOOST_STATE_HPP=BOOST_STATE_HPP-NOTFOUND
then like this:
project (my_project) find_path (BOOST_STATE_HPP boost/statechart/state.hpp) message ("CMAKE_FIND_ROOT_PATH=${CMAKE_FIND_ROOT_PATH}") message ("CMAKE_SYSTEM_INCLUDE_PATH=${CMAKE_SYSTEM_INCLUDE_PATH}") message ("CMAKE_SYSTEM_FRAMEWORK_PATH=${CMAKE_SYSTEM_FRAMEWORK_PATH}") message ("CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}") message ("BOOST_STATE_HPP=${BOOST_STATE_HPP}")
results in a successful state.hpp search and setting BOOST_STATE_HPP to /usr/include , as you wish:
CMAKE_FIND_ROOT_PATH= CMAKE_SYSTEM_INCLUDE_PATH=/usr/include/w32api;/usr/X11R6/include;/usr/include/X11;/usr/pkg/include;/opt/csw/include;/opt/include;/usr/openwin/include CMAKE_SYSTEM_FRAMEWORK_PATH= CMAKE_PREFIX_PATH= BOOST_STATE_HPP=/usr/include