[cmake-developers] Generating information for C++ tools in cmake (patch)

Manuel Klimek klimek at google.com
Mon Jan 10 21:46:12 EST 2011


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.

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

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.

Thanks a lot,
/Manuel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmake.patch
Type: text/x-patch
Size: 11172 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20110110/1badc53f/attachment-0002.bin>


More information about the cmake-developers mailing list