什么是尘土飞扬的角落初来乍到的CMake会想知道吗? [英] What are the dusty corners a newcomer to CMake will want to know?

查看:288
本文介绍了什么是尘土飞扬的角落初来乍到的CMake会想知道吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经做了很多的项目和很多不同的构建系统和CI工具。最近,我一直在接触到添加基于环境合理大小的C ++应用程序的自动工具的偶尔具有挑战性的任务。虽然我喜欢的易用性为最终用户的,我不是那么喜欢用M4和所有的汽车*工具处理从开发商的一面。

I've done a lot of projects and a lot of different build systems and CI tools. Most recently, I've been exposed to the occasionally challenging task of adding to an autotools based environment for a reasonably sized C++ application. While I love the ease of use for the end user, I'm not so fond of dealing with m4 and all of the auto* tools from the developer side.

我在我的业余时间工作的一个相当大的辅助项目,并已决定,我想借此CMake的试驾。由于我刚刚开始,我显然打算通过文档/ FAQ /维基/等挖。并通过边做边学。顺便说一句,我想餐桌的钱为掌握CMake的的书,但我在亚马逊发现意见是足以让我决定,它可能是不值得的钱。之所以这么说,任何新的东西往往有陷阱,一个新来者往往会绊倒,旧的利弊早已学会了躲避。我想知道什么那些都是基于人们对CMake的经验,我希望通过提出在这里把我的学习烦恼了一点。

I'm working on a reasonably large side project in my spare time and have decided that I'd like to take CMake for a test drive. Since I'm just starting out, I'm obviously planning on digging through the docs/FAQ/wikis/etc. and learning by doing. BTW, I'd fork over money for the "Mastering CMake" book, but the comments that I found on Amazon were enough to make me decide that it probably isn't worth the money. All that being said, in anything new there are often "gotchas" that a newcomer will often stumble over that the old pros have long since learned to avoid. I'm wondering what those are based on people's experience with CMake, and I'm hoping to cut my learning pains down a bit by asking here.

修改:我要指出,我打算建立在Linux为主,和其它联合国* X变种。 Windows是不是真的从我的POV关注。这是一个大型的服务器端应用程序与Web和CLI界面为运营商,路北REST接口与OSS工具自动化/集成,并为客户端设备一个SOAP南向接口。我将需要大量的第三方库和应用程序来获得这一切工作,除非我想借此在未来10年内全部由手工打造这一点。 :)

Edit: I should point out that I'm planning on building on Linux primarily, and other UN*X variants. Windows isn't really a concern from my POV. This is a large server side application, with a Web and CLI interface for operators, a northbound REST interface for automation/integration with OSS tooling, and a SOAP southbound interface for CPEs. I'm going to need a lot of third party libraries and apps to get this all to work unless I want to take the next 10 years to build this all by hand. :)

推荐答案

首先,我想CMake的是一个优秀的构建工具。它在我看来,目前的多平台,建立最好的支持,并有寻找第三方库的强大机制。与CPack结合它甚至还提供包装和安装合理的选择。一些提示和可能出现的问题:

First of all, I think CMake is an excellent build-tool. It has in my opinion by far the best support for multi-platform-builds and has a powerful mechanism for finding 3rd-party libraries. Combined with CPack it even provides reasonable options for packaging and installation. Some hints and possible problems:


  1. 有关外源构建始终的宗旨:一个显而易见的:它可以是很难设计用于源项目构建得到它内置外的来源。所以,如果你可以从一开始设计它,目的是为外源的基础之上。

  1. Always aim for out-of-source builds: An obvious one: It can be difficult for a project designed for in-source builds to get it built out-of-source. So, if you can design it from the start, aim for out-of-source builds.

语法:语法可奇怪的了很多奇怪的怪癖,虽然这让自2.6和2.8版本更好

Syntax: The syntax can be bizarre with a lot of strange quirks, although this is getting better since the 2.6 and 2.8 versions.

变量缓存。 CMake的保持的变量和设置一个缓存的轨道和有时重建的东西时,这可能是一个问题。尝试删除CMakeCache.txt(或清洁你的外源构建目录),并重建。这一次也被DarenW提及。

Caching of variables. CMake keeps track of a cache of variables and settings and sometimes this can be a problem when rebuilding something. Try to remove the CMakeCache.txt (or clean your out-of-source build-directory) and rebuild. This one is also mentioned by DarenW.

查找和配置的第三方库:如果你依赖于几个库(你自己或第三方)有一个大的项目,这将可能是最麻烦的。

Finding and configuring 3rd-party libraries: If you have a large project depending on several libraries (your own or 3rd-party), this will likely be the most troublesome.


  • 我认真建议潜入find_package命令。这是非常强大的,但完全依赖于FindXXX.cmake文件的质量。尤其是在多个平台(主要是Windows和Mac)构建的时候,这些文件可能需要一些调整,或者你可能需要自己编写。

  • I seriously recommend diving into the find_package command. It is very powerful, but fully depends on the quality of the FindXXX.cmake files. Especially when building on multiple platforms (mostly Windows and Mac), these files may require some tweaking or you may need to write your own.

与联像调试调试的未定义的引用或不匹配的问题库共享可能很难调试。特别是随着第三方库,这些问题可能​​是由第三方不正确FindXXX.cmake文件引起...

Problems with linking libraries like debugging "undefined references" or mismatches between debug|release or static|shared can be difficult to debug. Especially with 3rd-party libraries these problems may be caused by incorrect 3rd-party FindXXX.cmake files...

这篇关于什么是尘土飞扬的角落初来乍到的CMake会想知道吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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