CMake如何选择gcc和g ++进行编译? [英] How does CMake choose gcc and g++ for compiling?

查看:600
本文介绍了CMake如何选择gcc和g ++进行编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是CMake的新手,我想知道一个C ++ / C项目在LINUX环境如何CMake可以选择gcc和g ++之间的编译器。更具体地说,我的问题如下:


  1. 如果项目由.c和.cpp文件组成, $ b .c文件将由gcc编译,而.cpp文件将由g ++编译

  2. 如果项目只有c文件或cpp文件, default
    CMake的编译操作?是否可以更改?


解决方案

>

你可以用几乎所有的东西。有一些标志和变量绑定到语言的扩展;然后将语言定义为定义工具集和构建目标的编译器选项/可执行文件。



检查以下文档链接。


  1. 更改编译器/工具集

  2. 每种语言的扩展

  3. LANGUAGE变量

注意:维基可能已过时,但在重要和教育问题。



PS。有很多相关的选项。对于更长的阅读,您可以查看以下文档部分:源文件上的属性语言的变量。 2.和3.来自这些部分。


I am newbie of CMake, and I was wondering for a C++/C project in the LINUX environmental how CMake can choose compilers between gcc and g++. More specifically, my questions are as follows:

  1. If a project is consisted of .c and .cpp file, is it true that the .c files will be compiled by gcc while the .cpp files will be compiled by g++?
  2. If a project has only c files or cpp files, what's the default compiling operation for CMake? Will it be possible to change it?

解决方案

Shortly, yes to both.

You can mangle with pretty much everything. There are flags and variables that bind extensions to language; and then language to compiler options/executables that define toolsets and build targets.

Check following links to documentation. Those are some pleasant short readings.

  1. Change compiler/toolset
  2. Per-language extensions
  3. LANGUAGE variable

Note: The wiki might be outdated but it should hold in case of important and educational matter.

PS. There is whole bunch of related options. For some longer read you can check following sections of documentation: Properties on Source Files and Variables for Languages. 2. and 3. come from these sections.

这篇关于CMake如何选择gcc和g ++进行编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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