[CMake] Obtaining info about the compiler command arguments
Chris Wolf
cw10025 at gmail.com
Thu Aug 12 14:51:40 EDT 2010
On 8/12/10 1:30 PM, Óscar Fuentes wrote:
> 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.
You can also set this:
set( CMAKE_VERBOSE_MAKEFILE on )
...that way you can see each command line invocation of the compiler and linker,
so you can check what's being passed.
-Chris
More information about the CMake
mailing list