如何在CMake中将字符串拆分成多行? [英] How to split strings across multiple lines in CMake?

查看:461
本文介绍了如何在CMake中将字符串拆分成多行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常在我的项目中有一项政策,即永远不要在文本文件中创建超过80行长度的行,因此可以在各种编辑器中轻松编辑它们(您知道这很重要)。但是,有了CMake,我遇到了一个问题,我不知道如何将一个简单的字符串拆分为多行,以避免出现一条大行。考虑以下基本代码:

I usually have a policy in my project, to never create lines in text files that exceed a line length of 80, so they are easily editable in all kinds of editors (you know the deal). But with CMake I get the problem that I do not know how to split a simple string into multiple lines to avoid one huge line. Consider this basic code:

set(MYPROJ_VERSION_MAJOR "1")
set(MYPROJ_VERSION_MINOR "0")
set(MYPROJ_VERSION_PATCH "0")
set(MYPROJ_VERSION_EXTRA "rc1")
set(MYPROJ_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_EXTRA}")

它已经超过了80行限制。那么,如何在CMake中将一行分成多行而不引起冗长(多个 list(APPEND ...)等)?

It already exeeds the 80 line limit. So how do I break a line in CMake into multiple lines without getting to verbose (multiple list(APPEND ...) or the like)?

推荐答案

CMake 3.0及更高版本的更新

行继续是 \ 可能。参见 cmake-3.0-doc

message("\
This is the first line of a quoted argument. \
In fact it is the only line but since it is long \
the source code uses line continuation.\
")



CMake版本的可用性:



Debian Wheezy(2013):2.8.9

Debian Wheezy-backports:2.8.11

Debian Jessy(2015):3.0.2

Ubuntu 14.04(LTS):2.8.12

Ubuntu 15.04: 3.0.2

Mac OSX:cmake-3可通过自制软件 Macports 查找

Windows:cmake-3可通过巧克力

这篇关于如何在CMake中将字符串拆分成多行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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