[CMake] FindFoobar with non-root installation

Andreas Pakulat apaku at gmx.de
Fri Jul 2 11:26:19 EDT 2010

On 02.07.10 14:55:07, Diablo 666 wrote:
> 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().
> 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.

Usually a FindFoobar.cmake is not supplied with Foobar, but rather with any
project that wants to use Foobar.

That said, there's a better way than FindFoobar, look into the "Config"
mode of find_package. It allows your foobar project to install a few files
in specific locations alongside the library files themselves. Then any
project that wants to use the libs can do a find_package(Foobar) and cmake
will find those config-files (in worst case the user has to specify the
foobar installation prefix in CMAKE_PREFIX_PATH).


Your aim is high and to the right.

More information about the CMake mailing list