[CMake] How to query compiler definitions?

SF Markus Elfring elfring at users.sourceforge.net
Wed Jan 19 08:41:14 EST 2011


> You don't seem to understand the difference between CMake-time and Make-
> (or build-) time.

I understand that there can be differences between the time of configuration and 
the applied generation. I guess that we have got different expectations about 
the introspection capabilities of the CMake build system.


> Build-time is when the actual build system runs.
> Everything is static here (except for custom commands).

I do not want it this way for my use case.


> In particular, you can't change the list of source files any more.

I imagine that the build system can still accommodate to some changes from other 
sources like preprocessor symbols.


> The problem is, you want to assemble that list at build-time, which is
> not possible, because then CMake wouldn't know about them.

Can instructions from CMake scripts also be executed at generation time?


> I don't quite understand why it is so important to you that these files
> aren't passed to the compiler. If you exclude all of their contents with
> "#ifndef NDEBUG", then each file should take less than a second to
> compile, so you'd need a lot of those debug-only files for it to matter.

I hope that a more detailed description will clarify my use case.

Example:
A source file "toy.cxx" contains already the preprocessor switch that you 
mentioned. The marked debug code works with objects from a C++ class library for 
XML processing which has got its bunch of source files bundled in this project. 
Now I would like to omit this dependency if the software will be built for 
"release" mode. I would also like to be sure and want to check before the call 
of a compiler if this special symbol is really set.

Regards,
Markus


More information about the CMake mailing list