[CMake] How do I generate a preprocessed file?

Piotr Wyderski piotr.wyderski at gmail.com
Sun May 10 12:38:28 EDT 2009


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

Best regards
Piotr Wyderski


More information about the CMake mailing list