[cmake-developers] Extracting target metadata, IDE integration

Aleix Pol aleixpol at kde.org
Mon Mar 2 21:10:04 EST 2015


On Fri, Aug 29, 2014 at 4:20 AM, Aleix Pol <aleixpol at kde.org> wrote:
> Dear cmake'rs,
> I'm rewriting the KDevelop plugin from scratch to fetch the information from
> the build directory.
>
> Now in the first implementation I'm using the compile_commands.json file
> that cmake already can generate for some time. It works quite well already,
> given how data just comes out ready to be consumed (almost). The problem now
> is that we're lacking some information, namely information about the
> targets, their location and such *.
>
> To that end, I wrote a little patch to be taken as a proof of concept, that
> generates (some of) the needed information. I would like to know if you
> think it's an approach that would be accepted in the cmake code-base or if I
> need to take a different approach.
>
> Patch http://proli.net/meu/kdevelop/cmake-targetsdata.patch
> Output: http://proli.net/meu/kdevelop/AwesomeTargets.json
>
> Cheers!
> Aleix
>
> * Yes, I'm aware of generators, but I'm not comfortable with the idea of
> tying a build directory to an editor (even if it's my editor). Our users
> usually build the projects with different tools and asking them to re-create
> their build only for being comfortable with KDevelop sometimes is a burden.
> It would be for me too!

I created a new version of the patch:
http://proli.net/meu/kdevelop/0001-cmake-Add-option-to-generate-target-metadata-for-IDE-v2.patch

Main differences are:
* Uses JsonCpp to generate json (makes the code much easier to read!).
* Adds a CMAKE_EXPORT_PROJECT_METADATA.rst file for documentation.
* Adds a test that checks some of the parameters in the file.
* Uses for directory the directory where the target was generated
rather than the output directory.

I hope this helps.
Aleix

Samples:
LLVM: https://paste.kde.org/pelr1ditp
A small random KDE project: https://paste.kde.org/pgkbecv5p


More information about the cmake-developers mailing list