CMAKE中LANGUAGE变量的可能值是什么 [英] What are the possible values for the LANGUAGE variable in CMAKE

查看:184
本文介绍了CMAKE中LANGUAGE变量的可能值是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在CMAKE.org网站或其他任何位置上找到LANGUAGE变量的可能值列表。有人可以列举CMAKE认可的价值观吗?我特别需要指定Objective C ++。

I haven't been able to find a list of possible values for the LANGUAGE variable on the CMAKE.org site or anywhere else. Would someone please enumerate the values CMAKE recognises? I specifically need to specify Objective C++.

推荐答案

针对CMake 3.16和更高版本的更新: CMake 在3.16版中添加了对Objective-C的原生支持。相应的语言字符串是 OBJC OBJCXX 。感谢squareskittles 指出这一点

Update for CMake 3.16 and later: CMake added native support for Objective-C in version 3.16. The corresponding language strings are OBJC and OBJCXX. Thanks to squareskittles for pointing this out.

原始答案:对语言的支持因平台而异。

Original answer: The support for languages varies across platforms.

当前,CMake在大多数平台上都支持C,CXX和Fortran。在某些平台上还支持某些汇编程序。有关完整列表,请查看 Modules的内容/ Platform 文件夹

Currently CMake supports C, CXX and Fortran out of the box on most platforms. There is also support for certain Assemblers on some platforms. For a complete list, check out the contents of the Modules/Platform folder.

想法是给 LANGUAGE project 命令或 enable_language 命令的$ c>字段只是一个字符串,然后将由CMake使用连同该语言因变量来设置构建系统。 CMake附带的平台脚本针对C和C ++进行此配置。从理论上讲,只需设置正确的变量即可添加自己的语言(尽管这很复杂,而且我不知道有人能成功做到这一点)。

The idea is that the language given to the LANGUAGE field of the project command or the enable_language command is just a string, which will then be used by CMake together with the language dependent variables to setup the build system. The Platform scripts shipping with CMake do this configuration for C and C++. In theory, one can add their own language simply by setting the correct variables (although this is quite involved and I do not know of anyone ever successfully doing this).

用于增加对Objective-C的支持的方法:由于大多数工具链针对C和Objective-C使用相同的编译器,因此您无需配置新的语言。只需将您的代码编译为纯C语言,然后添加适当的编译器标志即可获得Objective-C支持。

As for adding support for Objective-C: Since most toolchains use the same compiler for C and Objective-C, you do not need to configure a new language. Simply compile your code as if it was plain C and add the appropriate compiler flags for Objective-C support.

不幸的是,这种方法使用起来不太舒服,在角落情况下很容易折断。但是,除非CMake明确支持对Objective-C作为一流的语言,否则恐怕还是一样。

Unfortunately, this is not very comfortable to use and can easily break in corner cases. But until CMake adds explicit support for Objective-C as a first class language, I'm afraid this is as good as it gets.

这篇关于CMAKE中LANGUAGE变量的可能值是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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