向CMake介绍一个新的编译器 [英] Introduce a new compiler to CMake

查看:157
本文介绍了向CMake介绍一个新的编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用一个特定的编译器,称为Cadul。它有自己的库,目标等。问题是,CMake不支持它像GNU,Intel,Clang等这样的标准编译器。

We work with a specific compiler, which is called Cadul. It has its own libraries, targets etc. The problem is that CMake does not support it in contrast to such "standard" compilers as GNU, Intel, Clang etc.

我想使用交叉编译,但它没有工作,因为主机和目标平台是相同的。

Firstly I thought to use cross compiling but it didn't work, since the host and target platforms are the same.

然后我查看了模块,我找到了一个名为Compiler的目录,其中包含了为每个编译器和每种语言指定的很多.cmake文件。我试图用Cadul替换单词GNU,并希望看到任何更改,如CXX编译器标识是Cadul ...。但它没有发生。

Then I looked into Modules, where I found the directory named "Compiler" which contains a lot of ".cmake" files specified for each compiler and each enabled language. I tried to substitute the word "GNU" by "Cadul" and hoped to see any changes, such as "The CXX compiler identification is Cadul ...". But it didn't happen.

然后我刚刚删除了整个目录模块从cmake,并希望看到它不工作了。令人惊讶的是它。

Then I just removed the whole directory "Modules" from cmake and hoped to see that it doesn't work anymore. Surprisingly it did.

那么有没有人将新的编译器集成到Cmake?有自己的功能等。

So has anyone ever integrated a new compiler to Cmake? With its own features, etc.

推荐答案

看起来像这是在评论中推荐,一个答案。

It looks like this has been recommended in the comments, but no one has condensed it to an answer yet.

您可以通过将这些行添加到CMakeLists.txt来选择一个编译器( source ):

You can choose a compiler by adding these lines to your CMakeLists.txt (source):

SET(CMAKE_C_COMPILER /path/to/c/compiler)
SET(CMAKE_CXX_COMPILER /path/to/cpp/compiler)

如果需要进一步自定义,使用工具链文件效果很好。 此处的文档中有一些示例。

If you need to customize further, using a toolchain file works well. There are some examples in the documentation here.

这篇关于向CMake介绍一个新的编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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