[cmake-developers] Generating buildsystem metadata from CMake

Tobias Hunger tobias.hunger at gmail.com
Sun Mar 22 16:02:16 EDT 2015


On Sat, Mar 21, 2015 at 9:41 AM, Stephen Kelly <steveire at gmail.com> wrote:
> Anton Makeev wrote:
>
>> The other thing that seems troubling to me is that since file, target,
>> language compiler options are split into different parts of metadata, the
>> IDE need to know exactly how to assemble them back into the compiler’s
>> command line (e.g. what flags go first file’s or language’s), duplicating
>> CMake's logic that may be different from version to version and from
>> compiler to compiler. The exact command line is needed to get the actual
>> and precise defines, include search paths etc. from the compiler.
>
> Yes. I previously proposed the <lang>_compile_command to contain information
> about how to built it:
>
>  http://www.steveire.com/cmake-future/manual/cmake-metadata-generation.7.html#optional-properties
>
> However, I think it might be better to generate something similar to what is
> currently generated in compile-commands.json into cmake-metadata.json. That
> is, we would generate (in some context)
>
>  "include_directories" : ["/foo", "/opt"]
>  "compile_definitions" : ["DEF=\"Foo\"", "OTHER_DEF=1"]
>  "compile_command": "-c -DDEF=\"Foo\" -DOTHER_DEF=1 -I/foo -I/opt"
>
> So, "compile_command" contains approximately what you can currently get from
> compile-commands.json.
>
> The other properties contain things which are specifically known to be
> include directories or compile definitions, as javascript arrays. These
> properties are obviously redundant information, so I wonder if they should
> be generated at all? Is the compile command I wrote above easy to parse? Or
> is it sufficiently difficult to parse that this redundant information should
> be provided?


How about include_directories, compile_definitions and compile_flags?

So something along the lines of:

"include_directories" : ["/foo", "/opt"]
"compile_definitions" : ["DEF=\"Foo\"", "OTHER_DEF=1"]
"compile_flags": [ "-c" ]

Parsing things is always error prone. Is that -D for definitions or /D?

The compiler flags are definitely needed though. They are used to e.g.
decide which dialect of a language are used.

This would keep parsing simple and will also provide all the
information we need.

"linker_flags" might also be interesting...

Best Regards,
Tobias


More information about the cmake-developers mailing list