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
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.
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.
精彩评论