如何使用 cmake 使用 boost.wave 作为预处理器
我正在尝试使用 boost.wave 作为预处理器,而不是编译器附带的预处理器。我无法弄清楚如何实现这一目标。
我使用 CMake 作为构建系统生成器,如何指定我的预处理器是 boost.wave。这应该适用于 Windows (MSVC) 和 Linux (gcc)。
谷歌搜索和搜索 Stack Overflow 档案没有得到任何答案,
编译器无论如何都会预处理该文件。所以看起来这里涉及了两个预处理步骤。
I'm trying to use boost.wave as a preprocessor instead of the preprocessor which comes with the compiler. I'm unable to figure out how to achieve this.
I'm using CMake as the build system generator and how can I specify my preprocessor is boost.wave. This should be working on both windows (MSVC) and linux (gcc).
Googling and searching Stack Overflow archives did not yield any answer
Compiler will anyway preprocess the file. So it looks like two steps of preprocessing is involved here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个两步过程。
首先,您必须告诉 CMake 使用 Wave 作为自定义命令:使用 CMake 的
add_custom_command
。定义此命令后,只要您为自定义命令指定的依赖项匹配,就会调用该命令。其次,您必须找出编译器通常使用的所有预定义宏和(系统)包含路径。 Wave 对特定编译器一无所知。因此,为了为特定编译器正确预处理文件,在调用时需要传递所有(相关)预定义宏(通常由编译器预定义)和所有系统包含路径(默认情况下编译器通常已知)海浪。如果将所有这些选项放入 Wave 的命令行太乏味(而且可能确实如此),您可以创建一个 Wave 的选项文件(使用
@cfgfile
将其添加到命令行)。以下是 MSVC 2005 的示例:当然,您也可以在此处为 Wave 添加其他选项。为不同的编译器提供不同的配置文件应该可以更轻松地从 CMake 内部进行管理。
This is a two step process.
First, you'll have to tell CMake to use Wave as a custom command: use CMake's
add_custom_command
. Once you defined this command it will be invoked whenever the dependencies you specified for the custom command are matched.Second, you'll have to figure out all predefined macros and the (system) include paths your compiler normaly uses. Wave does not know anything about a specific compiler. Therefore, in order to preprocess a file properly for a particular compiler all (relevant) predefined macros (which are normally predefined by the compiler) and all system include paths (which are normally known to the compiler by default) need to be passed while invoking Wave. If putting all of those options onto Wave's command line is too tedious (and it probably is), you can create a options file for Wave (add it to the command line with
@cfgfile
). Here is an example for MSVC 2005:Certainly, you can add other options for Wave here as well. Having different configuration files for different compilers should make it easier to manage from inside CMake.