什么是 CMake 生成器? [英] What is a CMake generator?

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

问题描述

我阅读了文档.

它说:

A CMake Generator is responsible for writing the input files for a native build system. 

这到底是什么意思?

如果我的项目中有一组 C++ 文件,这些是输入文件吗?

If I have a set of C++ files in my project, are these the input files?

如果我使用 Linux,默认情况下我的本机构建系统是什么?制作?

If I'm using Linux, what is my native build system by default? Make?

如果输入文件已经存在,为什么必须由生成器编写?

Why do the input files have to be written by the generator if they already exist?

推荐答案

什么是生成器?

要了解生成器是什么,我们首先需要了解什么是构建系统.CMake 不编译或链接任何源文件.它使用生成器为构建系统创建配置文件.构建系统使用这些文件来编译和链接源代码文件.

To understand what a generator is, we need to first look at what is a build system. CMake doesn't compile or link any source files. It used a generator to create configuration files for a build system. The build system uses those files to compile and link source code files.

那么什么是构建系统?

构建系统是一个广义的术语,它将一组通常用于编译和链接源代码的工具组合在一起,但它也可以包括在构建过程中使用的辅助工具.

A build system is a broad term that groups together a set of tools used to generally compile and link source code, but it can also include auxiliary tools used during a build process.

例如,在多阶段构建系统中,可能会构建一个可执行文件以在另一个构建的构建过程中使用.

For example, in a multi-stage build system, one executable might be built to be used in the build process of another build.

根据系统上使用的工具链,CMake 会生成多个文件和文件夹,以允许构建 CMakeLists.txt 中引用的源文件并支持 .cmake 文件.

Depending on the tool chain used on a system, CMake will generate multiple files and folders to allow the building of the source files referenced in the CMakeLists.txt and supporting .cmake files.

有时一台计算机上可能会安装多个构建系统,例如对于 Windows,您可以拥有 Visual Studio 和 MinGW 构建系统.CMake 允许您指定这些构建系统要为其生成配置文件.

Sometimes multiple build systems may be installed on a computer, like for Windows you could have a Visual Studio and MinGW build system. CMake allows you to specify which if these build systems to generate configuration files for.

CMake 包括许多 Command-LineIDEExtra 生成器.

CMake includes a number of Command-Line, IDE, and Extra generators.

命令行构建工具生成器

这些生成器用于命令行构建工具,例如 Make 和 Ninja.必须在使用 CMake 生成构建系统之前配置所选工具链.

These generators are for command-line build tools, like Make and Ninja. The chosen tool chain must be configured prior to generating the build system with CMake.

支持以下内容(**):

The following are supported(**):

  • Borland 生成文件
  • MSYS 生成文件
  • MinGW 生成文件
  • NMake 生成文件
  • NMake Makefiles JOM
  • 忍者
  • Unix 生成文件
  • Watcom WMake

IDE 构建工具生成器

这些生成器适用于包含自己的编译器的集成开发环境.示例是 Visual Studio 和 Xcode,它们本机包含编译器.

These generators are for Integrated Development Environments that include their own compiler. Examples are Visual Studio and Xcode which include a compiler natively.

支持以下内容(**):

The following are supported(**):

  • Visual Studio 6
  • Visual Studio 7
  • Visual Studio 7 .NET 2003
  • Visual Studio 8 2005
  • Visual Studio 9 2008
  • Visual Studio 10 2010
  • Visual Studio 11 2012
  • Visual Studio 12 2013
  • Visual Studio 14 2015
  • Visual Studio 15 2017
  • Visual Studio 16 2019
  • Green Hills MULTI
  • Xcode

额外的发电机

这些生成器用于创建配置以使用替代 IDE 工具,并且必须包含在 IDE 或命令行生成器中.

These are generators that create a configuration to work with an alternative IDE tool and must be included with either an IDE or Command-Line generator.

支持以下内容(**):

The following are supported(**):

  • 代码块
  • CodeLite
  • Eclipse CDT4
  • KDevelop3(v3.10.3 后不支持)
  • 凯特
  • Sublime Text 2

如果我的项目中有一组 C++ 文件,这些是输入文件吗?

If I have a set of C++ files in my project, are these the input files?

是的,它们是一些的输入文件.对于 make 构建系统,您还有一个 MakeFile.对于 Visual Studio,您有一个解决方案文件 (.sln).对于这两个系统,CMake 需要知道如何在给定适当的 CMakeLists.txt 文件的情况下创建其他文件.

Yes, they are some of the input files. For a make build system you also have a MakeFile. For Visual Studio you have a solution file (.sln). With both systems there are additional files needed that CMake knows how to create given a proper CMakeLists.txt file.

如果我使用 Linux,默认情况下我的本机构建系统是什么?制作?

If I'm using Linux, what is my native build system by default? Make?

一般来说,是的,但可以像 Ninja 一样设置其他构建系统.

Generally, yes, but other build systems could be setup like Ninja.

如果输入文件已经存在,为什么必须由生成器写入?

Why do the input files have to be written by the generator if they already exist?

某些源文件可能已经存在,但 CMake 具有生成头文件和源文件的能力.同样如上所述,必须生成依赖于 CMakeLists.txt 文件中提供的源文件的配置文件.

Some source files may already exist, but CMake has the ability to generate header and source files. Also as mentioned above, there are configuration files that must be generated that depend on the source files supplied in the CMakeLists.txt file.

** 根据 CMake 版本的文档 3.9 &3.15

** According to the documentation for CMake Version 3.9 & 3.15

这篇关于什么是 CMake 生成器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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