CMake可以生成配置文件吗? [英] Can CMake generate a configure file?

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

问题描述

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

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,

但是我正在构建的项目使用cmake作为构建系统,并且当前(1月12日)emscripten仅支持autoconf-因此我通过生成configure并在make上进行端口来绕过它,因此从cmake创建配置文件的方法?我不是在说make文件..而是配置文件本身.

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.

推荐答案

是的,它可以:

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:

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

文档:

  • CMake 3.0
  • CMake 2.8.12

这篇关于CMake可以生成配置文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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