Cmake question: How do I use vcpkg to install dependencies automatically?

坚强是说给别人听的谎言 提交于 2020-08-24 04:57:28

问题


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: 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?


回答1:


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?

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



来源:https://stackoverflow.com/questions/61016978/cmake-question-how-do-i-use-vcpkg-to-install-dependencies-automatically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!