[CMake] How do I generate a preprocessed file?

Bill Hoffman bill.hoffman at kitware.com
Mon May 11 08:35:41 EDT 2009


Piotr Wyderski wrote:
> Tyler Roscoe wrote:
> 
>> Thinking about this more, is there anything handed off to the compiler
>> that affects the preprocessor other than definitions (-D flags)?
> 
> Yes, a lot of them: include directories specification,
> optimization flags (they also work as -D directives,
> e.g. they define __SSE2__ or not), language error
> handling mode (e.g. --Wno-pmf-conversion) etc.
> In fact I need the entire command line with option -E
> attached at the end. I would be happy to grab it from
> any C++-dependent object file (as they all use the
> same set of options).
> 
>> What other flags do you really need?
> 
> Well, pretty everything except "-o". Perfect matching
> is of key importance, as the result of preprocessing
> is a form of environment for a dynamic code generator.
> I need precisely the same set of interface definitions
> as the hand-compiled objects use.
> 
> I am also very surprised that this problem is so hard
> in CMake -- I thought there is a single variable specifying
> a template for a given target, e.g. *.cpp => *.o
> 

You do know about make foo.i where CMake will do this for you, right?

If you run make help in any binary directory, it will give the list of 
.i targets.

-Bill


More information about the CMake mailing list