如何使用cmake自动构建第三方库 [英] How to automate building of third party library using cmake

查看:1041
本文介绍了如何使用cmake自动构建第三方库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要找什么:
下载库
提取它
应用自定义补丁
运行configure
运行构建命令
我正在尝试什么库建立是:

What I am looking for: Download library Extract It Apply custom patch Run configure Run build command What library I am trying to build are:


  • Openssl

  • Boost

  • Thrift

  • C-ares

  • 卷曲

  • Pcre

  • Nginx

  • ICU

  • JsonCPP

  • Openssl
  • Boost
  • Thrift
  • C-ares
  • Curl
  • Pcre
  • Nginx
  • ICU
  • JsonCPP

我可以使用外部模块做这些事情: http:// cmake。 org / cmake / help / v2.8.8 / cmake.html#module:ExternalProject

I think I can do these things using external module: http://cmake.org/cmake/help/v2.8.8/cmake.html#module:ExternalProject

但我有以下问题吗?


  1. 我有不同类型的构建和不同的目录。是
    要为每个不同的目标构建所有这些库吗?如果是
    这将是痛苦的,因为所有这些库需要一个小时来构建。是
    有一种方式,我可以控制它,它只构建一次。

  1. I have different type of build and with different directory. Is it going to build all these library for every different target? If yes it will be painful as all these library take one hour to build. Is there a way I can control it and it only build it once. As library remains same for all these targets.

将目录切换到不同的名称时。 Cmake强制一切到
重建。外部库是否相同。如是?如何
解决这个问题。我不想重建库,如果我不是
更改他们,并希望使用它们,而切换到不同的
分支,而不构建他们。

On switching directory to different name. Cmake force everything to be rebuild-ed. Will it be same for external library. If yes? How to solve this problem. I don't want to rebuild the library if I am not changing them and want to use them while switching to different branches without building them.


推荐答案

是的,您可以使用CMake的ExternalProject功能来完成您想要做的事。

Yes, you can use CMake's ExternalProject feature to accomplish what you want to do.

当与外部项目结合使用交叉编译时,源代码将为每个工具链建立一次。如果您将构建的结果签入源代码控制系统,并在每个新人的机器上重新检查,您可以避免重建,但我不推荐这样做。相反,有一个设置新计算机任务实际上是允许编译过夜运行,这也将作为一个测试,该机器实际上是可用的。该设置任务可以在新员工到达之前由系统管理员启动,或者根据情况需要,可以将其留给新员工。

When using cross-compilation in combination with external projects, the source code will be built once for each toolchain. You could avoid rebuilds if you checked in the results of the build into a source-control system, and re-checked it out on each new person's machine, but I do not recommend this. Instead, have one of your "set up new computer" tasks actually be allowing the compilation to run overnight, which will also act as a test that the machine is actually usable. That set-up task can be launched by a system administrator prior to a new hire's arrival, or you can leave it to the new hire, as circumstances require.

m不完全确定你在第二个问题中询问,但如果库不变,CMake将检测到它没有改变,不重新编译它。通常,源代码将在单个目录树中:每个编译版本将构建在不同的位置。因此,开发人员可以随时访问任何编译版本,只需切换目录。这特别有用,因为它允许您通过NFS将这些目录挂载到嵌入式硬件等。

I'm not completely certain what you are asking in your second question, but if the library is unchanged, CMake will detect that it is unchanged and not recompile it. Typically, the source code would be in a single directory tree: each compiled version would be built in a distinct location. Thus, developers can access any compiled version at any time just by switching directories. This is particularly helpful because it allows you to mount these directories over NFS to embedded hardware, et cetera.

这篇关于如何使用cmake自动构建第三方库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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