문제

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.

도움이 되었습니까?

해결책

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:

-SC:\Program Files (x86)\Microsoft Visual Studio 8\VC\include
-SC:\Program Files (x86)\Microsoft Visual Studio 8\VC\PlatformSDK\Include
-D_MT
-D_MSC_VER=1400
-D_MSC_FULL_VER=140050727
-D_MSC_EXTENSIONS
-D_M_IX86

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top