[英]Cmake question: How do I use vcpkg to install dependencies automatically?
I'm working on c++ project on a linux machine and it uses several boost libraries.我正在 linux 机器上研究 c++ 项目,它使用了几个 boost 库。 I've installed them on my system using vcpkg and build it using the toolchain provided by vcpkg.我已经使用 vcpkg 将它们安装在我的系统上,并使用 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.柯南有办法通过在 conanfile.txt 中定义依赖关系来做到这一点。 How do I do the same with vcpkg?我如何对 vcpkg 做同样的事情?
Edit1: 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? Edit1:我发现autovcpkg可以完成我想要做的工作,但同样可以在 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?我发现 autovcpkg 可以完成我想要做的工作,但同样可以在 cmakelists.txt 中本地完成还是由 vcpkg 本身完成?
You can write a vcpkg port for your library or executable by providing a CONTROL
and portfile.cmake
file.您可以通过提供CONTROL
和portfile.cmake
文件来为您的库或可执行文件编写 vcpkg 端口。 In the CONTROL file you define all the dependencies and possible features while the portfile contains the build instruction.在 CONTROL 文件中定义所有依赖项和可能的功能,而 portfile 包含构建指令。 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.您可以使用vcpkg create <myport> <url> <filename>
从可根据您的需要自定义的模板创建CONTROL
和portfile.cmake
。 Together with a port-overlay this port can also be used by others without being merged into vcpkg/master与端口叠加一起,此端口也可以被其他人使用,而无需合并到 vcpkg/master
If you have vcpkg as a submodule for your project, define a manifest for the libraries you want vcpkg to build, and are using the vcpkg CMake toolchain - then you will get everything you want.如果您将 vcpkg 作为项目的子模块,请为您希望 vcpkg 构建的库定义清单,并使用 vcpkg CMake 工具链 - 那么您将获得所需的一切。
$ git clone .../my_project
$ cd ./my_project
$ git submodule update --init
$ mkdir ../build
$ cd ../build
$ cmake ../my_project
-- Running vcpkg install
-- Running vcpkg install - done
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.