Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake + find package or check out and install

I just switched to CMake. And yet found it very useful and realized some simple apps and libs. Somewhere I read that it's possible to query git to checkout repositories from within cmake scripts.

I'd like to check for the existence of a package with my Find(package).cmake If it doesn't exist i'd like to initiate a checkout and add the new directory to the cmake script as subdirectory.

That way all my dependencies will get installed automatically. Does somebody know how to accomplish this idea? Thank you!

Bye, Arthur

like image 512
Arthur Andersen Avatar asked Feb 10 '10 11:02

Arthur Andersen


2 Answers

You're probably thinking about the ExternalProject module added in CMake 2.8. It's documented at http://www.cmake.org/cmake/help/cmake-2-8-docs.html#module:ExternalProject with an intro to it at page 14 of http://www.kitware.com/products/archive/kitware_quarterly1009.pdf. It allows you checkout/download a project and build it automatically.

like image 72
Milliams Avatar answered Sep 30 '22 08:09

Milliams


I would try to find the package with find_package and if the package_FOUND variable is not set you have to call git manually with execute_process. If the source already contains a CMakeLists.txt simply add it by using add_subdirectory otherwise you have to write your own CMake instructions to build that package first.

like image 35
Christian Avatar answered Sep 30 '22 08:09

Christian