CMake + find a package or check and install

I just switched to CMake. And yet he proved to be very useful and implemented some simple applications and libraries. I read somewhere that you can request git to check repositories from cmake scripts.

I want to check for a package with my Find (package) .cmake. If it does not exist, I would like to run a check and add a new directory to the cmake script as a subdirectory.

Thus, all my dependencies will be installed automatically. Does anyone know how to fulfill this idea? Thanks!

Bye, Arthur

+6
c ++ git github cmake
source share
2 answers

You are probably thinking of the ExternalProject module added in CMake 2.8. It is documented at http://www.cmake.org/cmake/help/cmake-2-8-docs.html#module:ExternalProject with an introduction to it on page 14 http://www.kitware.com/products/ archive / kitware_quarterly1009.pdf . This allows you to check / download the project and automatically create it.

+4
source share

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

+1
source share

All Articles