[cmake-developers] Review request: Ninja-EXPORT_COMPILE_COMMANDS

Peter Collingbourne peter at pcc.me.uk
Wed May 9 18:47:14 EDT 2012


On Sun, May 06, 2012 at 03:20:59PM +0200, Stephen Kelly wrote:
> 
> Hi, 
> 
> I've pushed a new branch to my clone for review to make the 
> CMAKE_EXPORT_COMPILE_COMMANDS option work with the Ninja generator.
> 
> https://gitorious.org/~steveire/cmake/steveires-cmake
> 
> Thanks,
> 
> Steve.

Hi Steve,

Thanks for working on this. 

I think the main problem with your changes is that they do not respect
the CMAKE_*_COMPILE_OBJECT variable, so the output will be wrong for
non-C++ compilers or compilers that do not take the conventional set
of command line parameters.

Furthermore, there is no need to make paths within the build directory
absolute.  Each command must be invoked from the home output directory
(i.e. the build "root" directory), so each command's "directory"
attribute should be set to that directory, rather than the start
output directory as in your patch.

I am not sure if this is the best approach for building JSON files
from Ninja CMake builds.  A few weeks ago I spoke with the folks at
Google who are working on Clang tooling, and I believe the current
thinking is that it may be best to teach Ninja to output JSON files
based on the provided build.ninja files.  The advantage of this is
that it will work for any build system with a Ninja generator, and
there would be no need to add functionality to CMake which may impose
an additional maintenance burden and get out of sync with the
"real" build commands.

Thanks,
-- 
Peter



More information about the cmake-developers mailing list