[cmake-developers] Generating information for C++ tools in cmake (patch)
Manuel Klimek
klimek at google.com
Tue Jan 11 17:10:12 EST 2011
Hi Alexander,
On Tue, Jan 11, 2011 at 12:45 PM, Alexander Neundorf <neundorf at kde.org> wrote:
> Hi,
>
> On Tuesday 11 January 2011, Manuel Klimek wrote:
>> Hi,
>>
>> we're working on C++ tools based on clang to get the power of
>> automated refactoring and analysis that Java has known for years to
>> C++ developers.
>
> Sounds great :-)
>
>> With the attached patch I include a proposal for how we could export
>> the compile command line for C/C++ files from cmake for Unix makefile
>> generators:
>> The idea is to output a small JSON database with all C/C++ files in
>> the project, which contains
>> - the file's path
>> - the working directory in which the compile runs
>> - the compile command
>
> To me this sounds a bit like it should be a separate generator, like the
> Eclipse/CodeBlocks/KDevelop generators. They generate Makefiles and
> additionally project files.
> This one could generate the Makefiles and additionally the json file.
I thought about that, too. On the other hand, we might also want to
make that information available from other generators where it makes
sense - in my mind it is somewhat orthogonal to the generator:
- for generators that are already very tightly IDE integrated (like
VS) we probably don't need to output this information, as the IDE
already exposes this information in well-defined ways that tool users
for those IDEs would use
- for generators that are not tightly coupled to the IDE or where the
IDE doesn't make the build information easily accessible (like
Eclipse), we actually want to enable developers to make the output
"default" in their cmake build setup, so they can use command line
tools or hand-made macros in their editor/IDE.
> Do you plan to put only the compile commands into the json-file or also the
> commands needed for linking the targets etc. ?
> In this case, the json file could maybe used by itself as project file for an
> IDE...
No, I'm not planning to output the link commands - this is purely for
code understanding, not rebuilding the code - while thinking about how
to enable fast rebuilds by adding this information might have some
valid use case, it is currently completely out of scope as far as I'm
concerned.
The workflow really is:
- you use your normal cmake+(your build system) workflow for building
- you use tools that run over source files and use the little c++
compile database to be able to understand the c++ code correctly
As a user, I want to be able to do both without having to run cmake in
between. This might well be hidden behind a cmake configuration option
if you think it affects the standard generation too much.
thanks for your feedback!
/Manuel
>> Background:
>> While C++ refactoring and analysis tools are not compilers, and thus
>> don't run as part of the build system, they need the exact information
>> of a build in order to be able to correctly understand the C++ code of
>> the project. The natural candidate to export that information is the
>> build system. We chose cmake to provide a first implementation, as
>> cmake is the current open source standard build system for large scale
>> C++ projects (like clang itself), and as such it is in the best
>> position to define a standard way to make compile commands accessible
>> for tools in the open source world.
>>
>> Example tools:
>> - running clang -fsyntax-only over source code from an editor to get
>> fast syntax checks
>> - running match/replace tools over C++ code (a project we're currently
>> working on)
>>
>> Any feedback would be highly appreciated. If you think the way this is
>> implemented is a dumb idea (which it probably is), please tell me - I
>> don't have a lot of experience in the cmake architecture. Also, if you
>> object to the idea of exporting this information in general, please
>> let me know.
>
> These are only my 2 cents, what do the other cmake devs think ?
More information about the cmake-developers
mailing list