为什么要在CMake中使用程序包管理器? [英] Why use a package manager with CMake?

查看:39
本文介绍了为什么要在CMake中使用程序包管理器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在评估一个正在工作的项目的C ++程序包管理器,并且开始怀疑为什么当CMake和远程DVCS服务器似乎可以解决问题时,为什么需要它们.

I'm currently evaluating C++ package managers for a project at work and am starting to wonder why do I need them when CMake and a remote DVCS server seem to do the trick just fine.

在我的个人项目中,我使用 ExternalProject 拉动并构建任何我有依赖性.同时,柯南,vcpkg,猎人和其他人可能声称也做同样的事情.

On my personal projects I use ExternalProject to pull and build any dependencies I have. Meanwhile Conan, vcpkg, hunter and possibly others claim to do the same thing.

vcpkg似乎要求每个项目都有一个.cmake文件,以便它可以与CMake find_package一起使用.

vcpkg for example seems to require each project to have a .cmake file so it can be used with CMake find_package.

那么,为什么要完全使用包管理器?

So, why use a package manager at all?

推荐答案

直接使用CMake的 ExternalProject_Add 可以具有诸如完全匹配的编译标志之类的优点,正确配置软件包并不总是那么简单.此外,包管理器允许您在项目之间重用依赖源和二进制文件,从而大大减少了存储需求.即使从源构建的vcpkg之类的程序包管理器也是如此,因为它们仅下载源一次(并且每个配置生成一次以生成二进制文件),而不是每个每个构建文件夹(以及每个二进制配置)一次..而且这些节省可能是可观的,尤其是对于Qt之类的依赖项,其大小为数GB.类似地,您还节省了很多时间.

While using CMake's ExternalProject_Add directly can have advantages such as compile flags that match exactly, correctly configuring packages is not always trivial. Furthermore, package managers allow you to reuse dependency sources and binaries between projects, leading to massively reduced storage requirements. This is true even in package managers like vcpkg that build from source, as they only download sources once (and build once per configuration to generate binaries) and not once per build folder (and per configuration for binaries). And those savings can be significant, especially with dependencies like Qt that are several gigabytes in size. Analogously, you also save a lot of time.

TL; DR:

  • 易于使用
  • 减少的存储要求(如果您多次使用一个库)
  • 减少了构建时间(如果程序包管理器具有二进制程序包,或者您多次使用一个库)

这篇关于为什么要在CMake中使用程序包管理器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆