How to install your custom CMake-Find module

goocreations picture goocreations · May 26, 2012 · Viewed 72k times · Source

I configure and package my library using CMake and CPack. I have written my own find-module: FindMyLib.cmake.

How do I tell CMake/CPack to add this file to the CMake module directory, so that future developers can simply specify FIND_PACKAGE(MyLib) to use my library?

Answer

simont picture simont · May 26, 2012

You can set CMAKE_MODULE_PATH and distribute your custom FindFoo.cmake with your project. For example:

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")