[CMake] FindFoobar with non-root installation

Michael Hertling mhertling at online.de
Fri Jul 2 11:29:21 EDT 2010


On 07/02/2010 02:55 PM, Diablo 666 wrote:
> 
> Hi,
> 
> the last problem for today :)
> 
> Assuming I develop a project called Foobar, which consists of some libraries only. To make using these libraries easier, I'd like to create a FindFoobar.cmake file to use with FIND_PACKAGE().

You should use a config file, e.g. foobar-config.cmake, instead of a
find module FindFoobar.cmake; the latters are intended as third party
contributions if one hasn't control over the concerned project's code
base while the formers are delivered as part of the project. From the
user's perpective, both behave quite the same, but config files are
searched using a more sophisticated procedure than find modules.

> The problem is that I have a lot of clients which can't install the libraries as root, so have to support non-root installations. How can I use my FindFoobar.cmake file from other projects without having it installed as root? It should be as easy to use as possible.

If you stick to a find module other projects can set CMAKE_MODULE_PATH
to locate FindFoobar.cmake outside of ${CMAKE_ROOT}/Modules, but if you
provide a config file FIND_PACKAGE() in other projects' CMakeLists.txt
files looks at various convenient locations, and that should be of a
particular interest to you w.r.t. non-root installations.

Regards,

Michael


More information about the CMake mailing list