Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>See <a href="https://stackoverflow.com/a/15642703/189878">this answer</a> for information on how to write a cmake Find file. As an example, here is one that I wrote for the lm-sensors library:</p> <pre><code># - Try to find the LM_SENSORS library. # # The following are set after configuration is done: # LM_SENSORS_FOUND # LM_SENSORS_INCLUDE_DIRS # LM_SENSORS_LIBRARY_DIRS # LM_SENSORS_LIBRARIES find_path(LM_SENSORS_INCLUDE_DIR NAMES sensors/sensors.h) find_library(LM_SENSORS_LIBRARY NAMES libsensors sensors) message("LM_SENSORS include dir = ${LM_SENSORS_INCLUDE_DIR}") message("LM_SENSORS lib = ${LM_SENSORS_LIBRARY}") set(LM_SENSORS_LIBRARIES ${LM_SENSORS_LIBRARY}) set(LM_SENSORS_INCLUDE_DIRS ${LM_SENSORS_INCLUDE_DIR}) include(FindPackageHandleStandardArgs) # Handle the QUIETLY and REQUIRED arguments and set the LM_SENSORS_FOUND to TRUE # if all listed variables are TRUE find_package_handle_standard_args(LM_SENSORS DEFAULT_MSG LM_SENSORS_LIBRARY LM_SENSORS_INCLUDE_DIR) mark_as_advanced(LM_SENSORS_INCLUDE_DIR LM_SENSORS_LIBRARY) </code></pre> <p>Change the above to match your library (<code>boost-numeric-bindings</code>), name the file <code>Findboost-numeric-bindings.cmake</code>, and put it in your cmake module dir (or create one of these in your source tree).</p> <p>Then in your <code>CMakeLists.txt</code> file, do this:</p> <pre><code>set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} your_cmake_module_dir) find_package (boost-numeric-bindings REQUIRED) include_directories(${BOOST_NUMERIC_BINDINGS_INCLUDE_DIR}) </code></pre> <p>Then, assuming you don't have the library installed in a standard location, run cmake as follows:</p> <p><code>cmake -D CMAKE_PREFIX_PATH:STRING="/where/you/have/installed/it/" &lt;source path&gt;</code></p> <p><strong>Edit</strong></p> <p>Make sure you have defined a project before you call <code>find_path</code> or <code>find_package</code>. Otherwise <code>CMAKE_SYSTEM_INCLUDE_PATH</code> will not be set. For example:</p> <pre><code>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) </code></pre> <p>will result in the following cmake output:</p> <pre><code>CMAKE_FIND_ROOT_PATH= CMAKE_SYSTEM_INCLUDE_PATH= CMAKE_SYSTEM_FRAMEWORK_PATH= CMAKE_PREFIX_PATH= BOOST_STATE_HPP=BOOST_STATE_HPP-NOTFOUND </code></pre> <p>whereas this:</p> <pre><code>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}") </code></pre> <p>results in sucessfully finding <code>state.hpp</code> and setting <code>BOOST_STATE_HPP</code> to <code>/usr/include</code>, as you desire:</p> <pre><code>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 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload