CMake - shivamvats/notes GitHub Wiki
This has two modes:
-
module: This is useful when you have the
FindFoo.cmake
file for the target package and is the default mode. Most popular libraries have this file. In fact, CMake itself ships with cmake files for some packages. Append (or set)CMAKE_MODULE_PATH
to modify the list of places where cmake looks for this file. -
config: CMake looks for
foo-config.cmake
orfooConfig.cmake
file for the required package. It looks into places specified byCMAKE_PREFIX_PATH
for this file.
Note that both these modes set a bunch of useful variables as well (Foo_INCLUDE_DIRS
etc.) if they are correctly written. Hence, it is advisable to use one of these modes instead of hardcoding the absolute address.
-
CMAKE_PREFIX_PATH: Append to this to modify the directories cmake look into while executing
find_package
. Note This prefix is prefixed to all the paths that are searched. Hence, to ensure that the root directories are searched as well, you need to ensure that there is a root:/
path in this list as well. -
CMAKE_INSTALL_PATH: Set this while running
cmake -DCMAKE_INSTALL_PATH=/what/ever ../
to set where the current library will be installed (if it has an install definition.) - CMAKE_MODULE_PATH: See above.
- RPATH: https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
To link with a locally compiled library, it is advisable to not install it in /usr/local
. I have created a separate ~/bin
folder for this purpose. Use