[CMake] Obtaining info about the compiler command arguments

Óscar Fuentes ofv at wanadoo.es
Thu Aug 12 13:30:06 EDT 2010


Michael Wild <themiwi at gmail.com> writes:

>>> How to know the compiler arguments set by include_directories,
>>> add_definitions, etc?
>>> 
>>> CMAKE_<LANG>_FLAGS (with and whitout the uppercase build_type suffix)
>>> doesn't contain anything that was set by the cmake commands mentioned
>>> above.
>> 
>> I guess that the lack of response indicates that there is no way to do
>> that. Why so basic feature is missing? Something with the internals of
>> cmake that makes it hard to implement?
>
> Well, your question isn't very clear. Are you interested in the
> compiler flag (i.e. -I or -D) or would you like to query the active
> include directories and definitions?

I'm interested on the literal parameters as they are passed to the
compiler.

> The former are available through the variables CMAKE_INCLUDE_FLAG_C
> and CMAKE_<lang>_DEFINE_FLAG, although AFAIK the latter may not be set
> and defaults to -D.
>
> The latter are available through the directory properties
> INCLUDE_DIRECTORIES and DEFINITIONS. But doing some RTFM would have
> told you that...

Yes, I RTFM. My test code contained a typo on the variable's name :-(
This remembers me why, being a bad typist, I try to avoid so much the
languages that accept undefined variables.



More information about the CMake mailing list