简体   繁体   English

CMake +查找包或签出并安装

[英]CMake + find package or check out and install

I just switched to CMake. 我刚转到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. 在某处我读到可以从cmake脚本中查询git到checkout存储库。

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. 我想用我的Find(包)来检查包是否存在.cmake如果它不存在我想发起一个checkout并将新目录作为子目录添加到cmake脚本中。

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. 您可能正在考虑在CMake 2.8中添加的ExternalProject模块。 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 . 它记录在http://www.cmake.org/cmake/help/cmake-2-8-docs.html#module:ExternalProject有介绍到它在第14页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 . 我会尝试使用find_package找到包,如果没有设置package_FOUND变量,则必须使用execute_process手动调用git。 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. 如果源已经包含CMakeLists.txt,只需使用add_subdirectory添加它,否则您必须先编写自己的CMake指令来构建该包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM