IMP logo
IMP Manual  for IMP version 2.16.0
uselibrary.md
1 Using the library in other projects {#uselibrary}
2 ===================================
3 
4 The %IMP C++ library can be used in other projects. When %IMP is built or
5 installed, it creates a [CMake](https://cmake.org) file called
6 `IMPConfig.cmake` which contains information about how %IMP was configured
7 and where all the parts of %IMP can be found. This can be used to easily
8 add %IMP as a dependency to other C++ projects using CMake.
9 When built from source, this
10 file is placed in the CMake build directory; when installed, it is placed
11 under the library directory, for example in `/usr/lib64/cmake/IMP/`.
12 
13 The `IMPConfig.cmake` file defines a number of CMake variables:
14 
15 - `IMP_USE_FILE`: the path to a CMake file which can be
16  [included into other CMake scripts](https://cmake.org/cmake/help/v3.13/command/include.html)
17  to make %IMP-related CMake functions available.
18 - `IMP_INCLUDE_DIR`: the path containing %IMP C++ headers.
19 - `IMP_xxx_LIBRARY`: the full path to the dynamic library for the `xxx` module
20  (for example `IMP_kernel_LIBRARY` points to the IMP kernel and
21  `IMP_atom_LIBRARY` to the IMP::atom library).
22 - `RMF_INCLUDE_PATH`: the path containing RMF C++ headers (if RMF is
23  bundled with %IMP).
24 - `IMP_DATA_DIR`: the path containing %IMP data files.
25 - `IMP_SWIG_DIR`: the path containing SWIG `.i` files for all %IMP modules.
26 
27 The paths to all %IMP dependent libraries and headers are also present in
28 this file - for example `EIGEN3_INCLUDE_DIR` and `Boost_INCLUDE_DIR`.
29 
30 A [FindIMP.cmake](https://github.com/salilab/pmi/blob/develop/tools/FindIMP.cmake)
31 file is provided to help CMake find this %IMP configuration (using the
32 [find_package](https://cmake.org/cmake/help/v3.13/command/find_package.html)
33 command), and can be used in other CMake projects.
34 
35 If you also need to use [RMF](https://integrativemodeling.org/rmf/)
36 this should be searched for separately using a
37 [FindRMF.cmake](https://github.com/salilab/npctransport/blob/develop/tools/FindRMF.cmake) file. See the [npctransport repository](https://github.com/salilab/npctransport/blob/develop/CMakeLists.txt) for example usage.
38 
39 See also the tutorial on
40 [using IMP as a C++ library](https://integrativemodeling.org/tutorials/using_cpp/)
41 for a worked example of using %IMP in a CMake project.
42 
43 This functionality can also be used to build an %IMP module "out of tree",
44 that is to build the module by itself and link to an existing pre-built
45 %IMP installation. See the [out of tree](@ref outoftree) page for more
46 information.