问题描述
我正在Linux机器上进行c ++项目,它使用了几个Boost库。我已使用vcpkg将它们安装在系统上,并使用vcpkg提供的工具链进行了构建。我的问题是:
如何定义依赖关系,以便在构建依赖项时将它们自动安装在其他系统上?
Conan通过在conanfile.txt中定义依赖项来做到这一点。如何使用vcpkg进行相同操作?
I'm working on c++ project on a linux machine and it uses several boost libraries. I've installed them on my system using vcpkg and build it using the toolchain provided by vcpkg. My question is:How do I define the dependencies so that they automatically install on a different system, if they were to build it?Conan has a way of doing it by defining the dependencies in conanfile.txt. How do I do the same with vcpkg?
Edit1:我发现可以完成我想做的工作,但是可以在cmakelists.txt内部还是由vcpkg本身完成相同的工作?
I've found autovcpkg which does the job I'm looking to do but can the same be done natively inside cmakelists.txt or by vcpkg itself?
推荐答案
您可以通过提供 CONTROL
为库或可执行文件编写vcpkg端口 portfile.cmake
文件。在CONTROL文件中,您定义所有依赖项和可能的功能,而portfile包含构建指令。您可以使用 vcpkg create< myport> < url> < filename>
可以通过模板创建 CONTROL
和 portfile.cmake
根据您的需求进行定制。
加上端口覆盖层,该端口也可以供其他人使用,而无需合并到vcpkg / master中。
You can write a vcpkg port for your library or executable by providing a CONTROL
and portfile.cmake
file. In the CONTROL file you define all the dependencies and possible features while the portfile contains the build instruction. You can use vcpkg create <myport> <url> <filename>
to create the CONTROL
and portfile.cmake
from a template which can be customized to your needs.Together with a port-overlay this port can also be used by others without being merged into vcpkg/master
这篇关于CMake问题:如何使用vcpkg自动安装依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!