CMake可以生成配置文件吗?

发布于 2024-12-27 11:32:07 字数 251 浏览 6 评论 0原文

我需要配置文件从 C++ 转换为 JS,我正在尝试在项目中使用 emscripten。 Emscripten 附带了一个名为 emconfigure 的工具,它取代了 autoconf 配置,

但我正在构建的项目使用 cmake 作为构建系统,目前(12 日)emscripten 仅支持 autoconf - 所以我通过生成配置来绕过它并在 make 上进行移植,因此有一种方法可以从 cmake 创建配置文件?我不是在谈论 make 文件......而是配置文件本身。

I need the configure file to transpile from C++ to JS, I'm trying to use emscripten in a project. Emscripten comes with a tool called emconfigure, that replaces the autoconf configure,

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 ?? I'm not talking about the make files.. but the configure file itself.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

时光礼记 2025-01-03 11:32:07

是的,它可以:

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

Example.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 */

在您的 cmake 文件中:

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

configure_file(Example.h.in 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 */

文档:

Yes, it can:

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

Example.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:

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

configure_file(Example.h.in Example.h)

Configured 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:

岁月苍老的讽刺 2025-01-03 11:32:07

是的,cmake 会根据您的目标平台生成构建项目所需的文件。但是您需要自己为 CMake 编写 CMakelist.txt 文件,或者必须从其他人那里获取它们。如果 emscripten 有它们并且您已经安装了 cmake,请转到您的 cource 目录的根目录并启动 cmake 以查看您可以使用的参数列表

yes cmake generates you the files you need to build the project depending on your target platform. however you need to write the CMakelist.txt's files for CMake by yourself or you have to get them from someone else. 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

风追烟花雨 2025-01-03 11:32:07

事实上,不要生成“集合”,但您可以使用函数来完成他所做的所有事情,例如 vereficação 数据类型、vereficar 标头等。

好吧,我将点击包含所有这些功能的项目的链接。我建议对其进行研究,任何东西都可以给我发电子邮件或其他东西来回答您的问题。

此处

也检查 /deps/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.

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.

胡大本事 2025-01-03 11:32:07

Cmake 是一个构建系统。它生成 Makefile。有关详细信息,请参阅此处。但简单地回答你的问题不,你不能使用 cmake 生成配置文件。

Cmake is a build system. It generates Makefiles. Look here for more information on that. But to answer your question briefly no, you cannot generate configure files with cmake.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文