如何在CMake中将字符串拆分成多行?

编程入门 行业动态 更新时间:2024-10-28 15:31:23
本文介绍了如何在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中将字符串拆分成多行?

本文发布于:2023-10-30 00:13:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1541185.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   中将   如何在   成多行   CMake

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!