适用于 Windows 和 Linux 编译的 Autotools 与 CMake
我一直在寻找专业人士和专业人士。 Autotools 和 CMake 的缺点。但我想了解在项目中使用过其中一种(或两种)工具的人们的意见。
一年前我基本上使用了 Autotools,我知道它的一个优点是它依赖于 shell 脚本,因此不需要安装即可运行并使用可移植的 shell 脚本。但看起来它太面向unix了,在Windows上运行配置文件是不可能的。
我现在必须为开源项目选择一个构建系统工具,该工具必须是至少为 Linux 和 Linux 编译视窗。它是用 C++ 编写的,并使用 Qt GUI 前端,其余部分是“通用的”。
谢谢你的帮助。
I have been looking for pros & cons of Autotools and CMake. But I would like to know opinions from people having used one (or both) of these tools for projects.
I used Autotools very basically a year ago and I know that one of the good points is that it relies on shell scripting, thus it does not need to be installed to be run and uses portable shell scripting. But it looks like it is too unix oriented, and it would not be possible to run the configure file on Windows.
I have now to choose a build system tool for an open source project that will have to be compiled for at least Linux & Windows. It is written in C++, and uses a Qt GUI front-end, the rest of it is "generic".
Thanks for you help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
2019 年 1 月 16 日更新:随着工具的发展完善建议。
我之前已经使用过自动工具相当长一段时间了。
目前,我仅在需要时才大量使用 meson 和 cmake。
一些个人建议:
对于大型团队,如果您想使用 XCode 的生成器,请坚持使用 CMake。如果你不需要它,我会直接使用Meson。 Meson,从版本 0.49 开始,还支持查找 CMake 配置文件(尽管我还没有测试它的效果如何)。另外,Visual Studio 目前似乎得到了足够好的支持,尽管我自己没有尝试过。 CMake 的优势在于它与 Visual Studio 集成。
删除自动工具。介子已经很好地涵盖了一切。他们的交叉编译模型非常容易理解。在 CMake 中,我上次检查时,一切都变得更加困难。
我还尝试过 scons, waf 和 tup。
功能最齐全的跨平台系统是
CMake
,但是 meson 的 DSL 对于习惯 python 和其他语言的人来说会更容易使用。 Meson 也开始支持 VS(VS2015 生成器),并且一些项目已经对其提供了实验性支持,例如 gstreamer。 Gstreamer 在 Windows 中也可以使用 meson 编译。现在有 VS2015 生成器和 VS2017,但我最近没有尝试自己使用生成器。截至介子 0.37.1 需要一些工作,但他们正在改进它们,当前版本已经是 0.40。介子
优点:
他在设计构建系统时谈得很好。
缺点:
Cmake
优点:
缺点:
Autotools
优点:
重命名二进制文件...
缺点:
关于学习曲线,有两个非常好的来源可以学习:
第一个来源将使您更快地启动和运行。本书对此进行了更深入的讨论。
从 Scons、waf 和 tup 来看,Scons 和 tup 更像 make。 Waf 更像是 CMake 和自动工具。我一开始尝试了waf而不是cmake。我认为它是过度设计的,因为它具有完整的 OOP API。这些脚本看起来一点也不短,而且工作目录的内容和相关的内容确实让我感到困惑。最后,我发现autotools和CMake是更好的选择。这 3 个构建系统中我最喜欢的是 tup。
Tup
优点
缺点
doc
之类的目标的方法,因为它们生成我不知道的文件,并且它们必须在生成之前列在输出中,或者至少,这是我现在的结论。如果是的话,这真是一个令人烦恼的限制,因为我不确定。
总而言之,我现在对于新项目唯一考虑的是 Cmake 和 Meson。当我有机会时,我也会尝试 tup,但它缺少配置框架,这意味着当您需要所有这些东西时,它会让事情变得更加复杂。另一方面,它的速度确实很快。
Updated 16th of January 2019: Refined advice as tools evolve.
I have used autotools before for a considerable amount of time.
Currently I make intensive use of meson and cmake only when I need it.
Some personal advice:
for big teams, stick to CMake if you want to make use of the generators for XCode. If you do not need it, I would use Meson directly. Meson, as of version 0.49, also supports finding CMake configuration files (though I did not test yet how well this works). Also, Visual Studio seems to be sufficiently well-supported at this point in time, though, again, I did not try myself. The advantage of CMake is that it has Visual Studio integration.
Drop autotools. Meson covers well everything already. Their cross-compilation model is amazingly understandable. In CMake, last time I checked, everything was quite more difficult.
I have also tried scons, waf, and tup.
The most full-featured, cross-platform system, is
CMake
, but the DSL from meson will be easier to use for people used to python and others. Meson is starting to support VS also (a VS2015 generator) and some projects already have experimental support for it, for example gstreamer. Gstreamer is compiled in windows as well with meson. Right now there is VS2015 generator and VS2017 but I did not try myself the generators lately. As of meson 0.37.1 needed some work, but they are improving them and current version is already 0.40.Meson
Pros:
he talks about very well when designing a build system.
Cons:
Cmake
Pros:
Cons:
Autotools
Pros:
renaming binaries...
Cons:
About the learning curve, there are two very good sources to learn from:
The first source will get you up and running faster. The book is a more in-depth discussion.
From Scons, waf and tup, Scons and tup are more like make. Waf is more like CMake and the autotools. I tried waf instead of cmake at first. I think it is overengineered in the sense that it has a full OOP API. The scripts didn't look short at all and it was really confusing for me the working directory stuff and related things. At the end, I found that autotools and CMake are a better choice. My favourite from these 3 build systems is tup.
Tup
Pros
Cons
doc
, sincethey generate files I don't know of and they must be listed in the output before being generated, or at least, that's my conclusion for now. This was a really annoying limitation, if it is, since I am not sure.
All in all, the only things I am considering right now for new projects is are Cmake and Meson. When I have a chance I will try tup also, but it lacks the config framework, which means that it makes things more complex when you need all of that stuff. On the other hand, it is really fast.
我不推荐 Windows 下的自动工具。使用 CMake。
为什么? Windows 没有原生的 sh.exe,并且模拟速度很慢。配置也很容易出错。我并不是说这在 CMake 中是不可能的,但 CMake 肯定会抽象出更多内容,因此您担心的事情会更少。 CMake 文档可能有点难以阅读,但一旦设置完毕,您应该可以轻松使用 CMake 支持的所有工具链。 CMake 还集成了测试、打包等...
Autotools 在 Windows 上速度很慢,不能轻松地与 MSVC 一起工作,并且与 Windows(和其他操作系统)有奇怪的怪癖,难以调试和修复。 libtool 在 Windows 上也很糟糕,即使你认为它应该并且可以,它也经常拒绝构建共享库。工具链重定位问题在 libtool 中也很普遍,它可能会查看用户工具链中的错误文件。 CMake 在这方面要容易得多。它假设目标平台的正常情况并创建通用且良好的构建指令。
此外,CMake 还具有彩色输出:) 和不错的进度百分比。
PS:作为用户,我只是对 Windows 上的 CMake 和 autotools 有一些经验。 CMake 往往会工作,自动工具往往会在你不看的时候咬掉你的耳朵,当它由于一些奇怪的错误而失败时会对你微笑......
I would not recommend autotools for Windows. Use CMake.
Why? Windows doesn't have a native sh.exe, and the emulation is slow. It's also very easy to get configury stuff wrong. I'm not saying it's impossible in CMake, but CMake surely abstracts more away, so you worry about less. CMake documentation can be a bit hard to read, but once it's set up, you should be fine for all toolchains ever supported by CMake. CMake also integrates testing, packaging etc...
Autotools is slow on Windows, does not work easily with MSVC, and has weird quirks with Windows (and other OSes) that are hard to debug, and hard to fix. libtool also sucks on Windows, where it often refuses to build a shared library even, if you think it should and could. Toolchain relocation issues are also prevalent with libtool, which may look at the wrong files in a user's toolchain. CMake is a lot easier in this regard. It assumes normal things about the target platform and creates generic and good build instructions.
Also, CMake has coloured output :) and nice progress percentages.
PS: I just have some experience with CMake and autotools on Windows as a user. CMake tends to work, autotools tends to bite your ear off when you're not looking, and smile at you when it fails due to some strange error...