gpt4 book ai didi

android - cmake 与 waf : mainly for c++ windows/linux and android

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:29:24 24 4
gpt4 key购买 nike

经过大量搜索和阅读大量资料后,我无法决定应该使用哪种工具来编译我的代码。我的代码库主要是 C++。我主要使用 Linux 作为我的开发机器。

根据我之前阅读的意见,我的最终候选人是 wafcmake , 但我自己无法决定哪一个更合适。

我的主要要求是:

  1. 必须能够在windows/linux和android中编译软件。
  2. 必须准备好运行测试。
  3. 必须能够与必须使用其他构建系统编译但很可能必须从源代码编译的其他库很好地配合使用。
  4. 必须能够添加自定义步骤,例如,在编译之前从一些文件(主要是图形)生成一些数据,所有这些都集成在构建系统中。

一些强烈的偏好是:

  1. 准备支持 MAC 编译。
  2. 能够从 linux 交叉编译尽可能多的平台(可能是 windows/linux/android 但不能是 MAC?)
  3. 能够在需要时添加对 iOS 编译的支持。
  4. 如果调用接口(interface)与 autotools 的调用接口(interface)类似,那就太好了,因为它是许多人都知道的接口(interface),并且有详细的文档记录。

一些问题:

  1. 如果我有一些罕见的需求,哪个构建系统更适合扩展?
  2. 两者目前都维护良好吗? (我想知道的主要是 waf)。
  3. 社区:如果我发现问题,根据您的经验,两个社区都足够大以支持我?

目前我的感觉是,我更喜欢 waf 作为一种工具,但无论出于何种原因,cmake 似乎都相当成功。

最佳答案

不太了解 waf,但 CMake 非常适合您的要求。我知道 waf 是用 Python 编写的,这是我个人最喜欢的 ATM 编程语言。

My primary requirements are:

Must be able to compile software in windows/linux and android.

CMake 可以很好地处理 Windows 和 Linux,但其他值得一提的构建系统也是如此。 Someone wrote some Android scripts for CMake.找不到与 waf 类似的东西(我的 Google-fu 什么也没找到。)

Must be ready to run tests.

CMake 有一个兄弟 testing framework .

Must be able to play nicely with other libraries that must be compiled with another build system but most likely will have to be compiled from source.

CMake has good integration with pkg-config ,并且可以链接到任意共享库。

Must be able to add custom steps, like for example, generating some data from some files (mainly graphics) before compiling, all integrated in the build system.

CMake can generate custom rules .

Some strong preferences are:

Being ready to support MAC compilation.

CMake 对 Mac 的支持很好。如果你愿意,它甚至可以让你成为一个 Xcode 项目,但它也可以进行命令行构建。

Being able to cross-compile from linux as many platforms as I can (maybe windows/linux/android but cannot MAC?)

Cross-compiling is supported in CMake . CMake 不会成为交叉编译的主要痛苦来源——实际上其他一切都会。

特别是关于 Mac 的交叉编译。有可能,但不值得针对该平台进行交叉编译,考虑到您无论如何都需要访问 Mac 来获取库和头文件,您需要修补 GCC 和 clang 以及 LLVM 等。我唯一合理的理由听说经历了这么多痛苦是运行一个自动构建服务器。无论如何,如果你有一个工作的 Linux -> Mac 工具链,你应该能够与 CMake 交叉编译,就好像它是任何其他 Unix 平台一样。

Being able to add support for iOS compilation if the need arises.

iOS cross-compilation can be done ,但您需要一台 Mac。

Would be nice if the invocation interface was similar to that of autotools, since it is the one many people know and it is well documented.

编写一个仅调用 CMake (cmake .) 的配置脚本。然后您的用户可以在有意义的平台上执行 ./configure && make && make install。还有 CPack它允许您生成 DEB、RPM、NSIS (Windows) 和 DMG (Mac) 安装程序/包。

Some questions:

If I have some rare requirement, which build system would be more ready to be extended?

CMake 的可扩展性很强。它可以扩展以支持新的语言和目标平台。 (鉴于 waf 是用 Python 编写的,它也很容易破解。)

Are both currently well maintained? (I wonder about waf mainly).

CMake 成熟且维护良好。

Community: if I find a problem, both communities are big enough to support me, in your experience?

老实说,社区和可用的扩展是让我从 bakefile 之类的东西回到 CMake 的原因。

关于android - cmake 与 waf : mainly for c++ windows/linux and android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19238420/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com