什么是CMake发电机? [英] What is a CMake generator?

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

问题描述

我阅读文档。



它说:

  CMake Generator负责为本机构建系统编写输入文件。 

这是什么意思?



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



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



为什么输入文件必须

发电机是什么?

如果发电机已经存在,发电机是否已经存在?


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



那么什么是构建系统?



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



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



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



有时,可能会在计算机上安装多个构建系统,例如对于Windows,您可以使用Visual Studio和MinGW构建系统。 CMake允许你指定这些构建系统是否生成配置文件。



CMake包括一些命令行 IDE 额外发电机。



命令行构建工具生成器



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



支持以下功能(**):




  • Borland Makefiles

  • MSYS Makefiles

  • MinGW Makefiles

  • NMake Makefiles

  • JOM

  • Ninja

  • Unix Makefiles

  • Watcom WMake

  • < >

    IDE Build Tool Generators



    这些生成器适用于集成开发环境,包括自己的编译器。



    以下是支持的(**):




    • 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

    • Green Hills MULTI

    • Xcode



    额外发电机



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



    以下是支持(**):




    • CodeBlocks

    • CodeLite

    • Eclipse CDT4

    • KDevelop3

    • Kate

    • Sublime Text 2




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


    < blockquote>

    是的,它们是部分的输入文件。对于make build系统,你还有一个MakeFile。对于Visual Studio,您有一个解决方案文件(.sln)。有了这两个系统,CMake知道如何创建一个正确的CMakeLists.txt文件需要额外的文件。


    如果我使用Linux ,什么是我的本机构建系统默认? Make?


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


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


    一些源文件可能已经存在,但是CMake能够生成头文件和源文件。如上所述,还有一些必须根据CMakeLists.txt文件中提供的源文件生成的配置文件。



    **根据文档适用于CMake 3.6版。 1


    I read the documentation.

    It says:

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

    What exactly does that mean?

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

    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?

    解决方案

    What's a generator?

    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.

    So what's a build system?

    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.

    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.

    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 includes a number of Command-Line, IDE, and Extra generators.

    Command-Line Build Tool Generators

    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 Makefiles
    • MSYS Makefiles
    • MinGW Makefiles
    • NMake Makefiles
    • NMake Makefiles JOM
    • Ninja
    • Unix Makefiles
    • Watcom WMake

    IDE Build Tool Generators

    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
    • Green Hills MULTI
    • Xcode

    Extra Generators

    These are generators 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(**):

    • CodeBlocks
    • CodeLite
    • Eclipse CDT4
    • KDevelop3
    • Kate
    • Sublime Text 2

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

    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.

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

    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?

    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.

    ** According to the documentation for CMake Version 3.6.1

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

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