CLion: Get cmake output directory

Hi,

I'm developing a plugin for CLion, which needs to know, where cmake stores it's generated files.
Currently I'm using CMakeWorkspace.getEffectiveConfigurationGenerationDir, but this method was changing a lot during the last releases, so I want to ask, if there's a more reliable way to get this path.

If not, is there any documentation for this method? Since Release 2016.3.x this method requires a File parameter, which purpose I do not know.

Thanks for the help,
Christian

0

Christian, 

First of all, please keep in mind that since CLion doesn't provide a public API, we cannot guaranty that it will be stable across versions.

In 2017.1 there might me many configurations configured in one project, so there is no singe generation dir. Depending on the context, there are several ways of getting the generation dirs. What exactly does your plugin need to do and at what moment?

 

0

Hi,

thank you for your reply.

 

My plugin is this one:

https://plugins.jetbrains.com/plugin/8301-clion-clang-tidy-integration

 

For clang-tidy, I need the "compile_commands.json" file, which is generated by cmake. Since 2016.3 I take the list of configurations and just take the first one. Taking the user's active configuration would be a bonus, but not really necessary, so multiple configurations should not be a problem.

My major problem is the method to receive cmake's output directory (like 'cmake-build-debug'). The method to receive the directory was changed in 2016.3, 2016.3.2 and 2017.1, while the other part of the API I'm using was stable, so I hope to find a more reliable way :-)

 

My current approach can be found here: https://bitbucket.org/baldur/clion-clangtidy/src/90fce1e5642c3762d0863b7329430f329a764c53/src/de/wieselbau/clion/clangtidy/tidy/Scanner.java?at=default#Scanner.java-126

(the 2016.3 version. I've already changed it for 2017.1, but not published yet)

0

I see; since clang-tidy is run on per-file basis, you need to do the following for every file: 

OCResolveConfiguration configuration = OCInclusionContextUtil.getActiveConfiguration(file)

if (configuration != instance CMakeResolveConfiguration) return;

File configDir = configuration.getConfiguration().getConfigurationGenerationDir()l

Though, note that we are working on a built-in clang-tidy integration at the moment: CPP-8476

0

thank you for the code, it works great.

If I'm right, CMakeResolveConfiguration.getConfiguration() is only available with CL2017.1?

 

I have already noticed the issues about your clang-tidy integration. But since my plugin was released about one year ago, I'll keep it updated until the official support is done and then decide what's my next step.

Are you developing a full integration of an external clang-tidy tool or do you "just" create new inspections similar to clang-tidy?

0

The methods in the code example are only available in 2017.1.

We are working on fully-integrated clang-tidy support.

0

sounds great... looking forward to it :-)

0

请先登录再写评论。