简体   繁体   English

CMake 可以生成配置文件吗?

[英]Can CMake generate a configure file?

I need the configure file to transpile from C++ to JS, I'm trying to use emscripten in a project.我需要将配置文件从 C++ 转换为 JS,我正在尝试在项目中使用 emscripten。 Emscripten comes with a tool called emconfigure, that replaces the autoconf configure, Emscripten 带有一个叫做 emconfigure 的工具,它取代了 autoconf 配置,

But the project I'm building uses cmake as build system and currently (Jan-12) emscripten has only support for autoconf - so I'm bypassing it by generating the configure and doing a port on the make, so there a way to create the configure file from the cmake ??但是我正在构建的项目使用 cmake 作为构建系统,目前(1 月 12 日)emscripten 仅支持 autoconf - 所以我通过生成配置并在 make 上做一个端口来绕过它,所以有一种方法可以创建来自 cmake 的配置文件 ?? I'm not talking about the make files.. but the configure file itself.我不是在谈论 make 文件……而是在谈论配置文件本身。

Yes, it can:是的,它可以:

configure_file(<input> <output>
               [COPYONLY] [ESCAPE_QUOTES] [@ONLY]
               [NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ])

Example.h.in例子.h.in

#ifndef EXAMPLE_H
#define EXAMPLE_H

/*
 * These values are automatically set according to their cmake variables.
 */
#define EXAMPLE "${EXAMPLE}"
#define VERSION "${VERSION}"
#define NUMBER  ${NUMBER}

#endif /* EXAMPLE_H */

In your cmake file:在您的 cmake 文件中:

set(EXAMPLE "This is an example")
set(VERSION "1.0")
set(NUMBER 3)

configure_file(Example.h.in Example.h)

Configured Example.h :配置的Example.h

#ifndef EXAMPLE_H
#define EXAMPLE_H

/*
 * These values are automatically set according to their cmake variables.
 */
#define EXAMPLE "This is an example"
#define VERSION "1.0"
#define NUMBER  3

#endif /* EXAMPLE_H */

Documentation:文档:

yes cmake generates you the files you need to build the project depending on your target platform.是的,cmake 会根据您的目标平台为您生成构建项目所需的文件。 however you need to write the CMakelist.txt's files for CMake by yourself or you have to get them from someone else.但是,您需要自己为 CMake 编写 CMakelist.txt 文件,或者您必须从其他人那里获取它们。 if emscripten has them and you have cmake installed, go to the root of your cource directory and launch cmake to see a list of arguments you can use如果 emscripten 有它们并且您已经安装了 cmake,请转到源目录的根目录并启动 cmake 以查看您可以使用的参数列表

In fact, do not generate a "set", but you can use functions that do everything he does, as is the case of vereficação data types, vereficar headers and more.实际上,不要生成“集合”,但是您可以使用可以完成他所做的一切的函数,就像 vereficação 数据类型、vereficar 标头等一样。

Well, I'll go down a link to my project that contains all those functions.好吧,我将找到包含所有这些功能的项目的链接。 I suggest that a study of it, anything send me an email or something to take your questions.我建议研究一下,有什么事情可以给我发电子邮件或其他东西来回答你的问题。

Here 这里

Check too the /deps/cmake folder to view the functions created by us.也检查 /deps/cmake 文件夹以查看我们创建的函数。

Cmake is a build system. Cmake 是一个构建系统。 It generates Makefiles.它生成 Makefile。 Look here for more information on that. 在这里查看更多信息。 But to answer your question briefly no, you cannot generate configure files with cmake.但是要简短地回答您的问题,不,您无法使用 cmake 生成配置文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM