[CMake] on find_package and building dependencies

Eric Noulard eric.noulard at gmail.com
Thu Dec 29 05:00:06 EST 2011


2011/12/29 Ryan Lewis <me at ryanlewis.net>:
> Hi,
>
> I really like CMake's find_package() utility for finding dependencies,
> but for some projects I have a
> separate local copy of the installed libraries, and I want to point
> find_package at a particular directory to find the installed
> libraries.
> How can I do this?

Have a look at find_package documentation,
in particular the usage of
CMAKE_FIND_ROOT_PATH
and other
*CMAKE_FIND_ROOT_PATH_*
variables

you basically want:
set(CMAKE_FIND_ROOT_PATH "/you/local/install/dir")
before calling find_package(...)

> On that note, I also have some dependencies which themselves are build
> using CMake, it is possible to tell my CMake Project to
> build another CMake project?

Yes,
cmake --help-module ExternalProject
and the macro therein
ExternalProject_Add

note that you may simply want to "export" the target of the first project
and then "import" the targets into the referring project, on that case
have a look at:
http://www.cmake.org/Wiki/CMake/Tutorials/Exporting_and_Importing_Targets

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list