CLion 2018.2 EAP: open project from Compilation Database

Hi,

A new CLion 2018.2 EAP (build 182.2757.13) is now available! Download it from our site, use ToolBox App or get a patch-update in the IDE in case you are using the previous EAP build. No license is required and the build is free to use, but it will expire within 30 days of the build date.

Download CLion 2018.2 EAP

Open project from compilation database

In brief, the Compilation database format is now supported in CLion as a project model. You cannot build or run for now, but code insight does work for such projects.

What’s happening with CLion lately?

For many release cycles, CLion was a CMake-only IDE, meaning it did not support any non-CMake-based projects. But recently, we’ve started decoupling CMake from CLion. Beginning with CLion 2018.1, you can open any file or folder in CLion, even if no proper CMake model is provided. However, code insight in these cases is limited as the IDE doesn’t know enough about the project.

For Rust, we supported the Cargo build system via the Rust plugin in CLion. CLion 2018.2 EAP introduces support for Gradle C++ projects.

Slowly but surely we’re supporting more build systems in CLion!

What is a compilation database?

It’s a set of all compile options used to build the files in a project. A sample file looks like this:

More detailed information on compilation databases can be found here.

How to get a compilation database json file?

There is a list of build systems, compilers, and specialized tools that support the generation of compilation database files. For example, CMake generates it when set(CMAKE_EXPORT_COMPILE_COMMANDS ON) is used (for Ninja and Makefiles generators). For Clang v5.0 and later, -MJ option does the trick. For Ninja v1.2 and later, the option is called -t compdb. Tools like bear and intercept-build help generate a compilation database json by intercepting calls to the compiler during the build. There is even an extension to Visual Studio that generates the compilation database file from VS solutions. And for make-based build systems compiledb-generator is a tool to generate compilation database.
More options can be found here.

I’ve got a compilation db json file for my project. What’s next?

Select Open in CLion and point it to your compilation database json file (or the directory containing such a file):
open_json

Click ‘Open as a project’ and you are done! The status of all commands in compile_commands.json will be provided for you in CLion:
success_compdb

The directory containing the compilation database json file is treated as the project root by default. You can change the project root later, by going to Tools | Compilation Database  and selecting Change Project Root.

Code insight, including code completion, code navigation, refactoring and code analysis, is fully available:
compilation_db_refactoring

Any known limitations?

The most important point is that due to the lack of the corresponding information in compilation database files, it’s not yet possible to build, run, or debug such projects. We do plan to add the ability to provide building and running commands for such projects.

Our first step will be to add an ability to Compile a single file using the compilation command from the compilation database (CPP-13059).

Other improvements

Other improvements and fixes include:

  • WSL support in CLion now works correctly with Ubuntu 18.04 (CPP-12968).
  • CLion can now launch Valgrind Memcheck for Gradle Native Application configuration (CPP-13013).

The full release notes are available here.

Your CLion Team
JetBrains
The Drive to Develop

This entry was posted in Announcement, Early Access Preview and tagged , , , , . Bookmark the permalink.

16 Responses to CLion 2018.2 EAP: open project from Compilation Database

  1. John says:

    clion shows “private ‘AAA::AAA(int)’ is inaccessible”, but can complie successfully (gcc 7.3).

    #include

    using namespace std;

    class AAA {
    private:
    AAA(int a) {
    }

    public:
    static void foo() {

    class BBB : public AAA {
    public:
    BBB() : AAA(22) { //private ‘AAA::AAA(int)’ is inaccessible

    cout << "aaa" << endl;
    }
    };

    BBB b;
    }
    };

    int main() {
    AAA::foo();

    return 0;
    }

  2. Иван Дмитриевич Черновалов says:

    A severe but has turned out to exist not only in EAP but in Stable build!!:
    #pragma omp for{
    When you put { right next to any word on #pragma
    The only way to use Clion then is to close it. And with other editor say notepad++ remove {

  3. Matt Hurd says:

    An infinite loop it seems. Went away and still processing an hour later… screenshot: https://imgur.com/a/RQTibje

    Using range/v3/all.hpp via conan. introspecting ranges::for_each

  4. Matt Hurd says:

    After many minutes in an existing large project that used to take a good few seconds to get ready: https://imgur.com/a/bZtQOb9

    • Anastasia Kazakova says:

      Is it possible to share the code sample, logs, or any snapshots? It’s hard to investigate by the screenshot.

  5. I’m sure you have a reason about that, but why do you make other build systems support when Makefile is most requested. Compare requests (issue stars) for Compilation database (5) and for Gradle (125) to the requests for Makefile (about 1000). And you decide to support gradle and compilation database first? Your IDE understands C language. How hard can it be to parse a make file? Well, probably it’s a bit harder than it looks because if it was that easy you would have done it already, but still… compare how many years it took to make CLion with how many years it took (after you do it) to support Makefile.

    I’m waiting for the day when I can just open Makefile project and just work on it without work-arounds, Settings and any changes to the project. Then I’ll buy CLion. It’s so annoying that the best IDE in the world does not support the basics.

    • Anastasia Kazakova says:

      Gradle was mostly supported for Kotlin/Native and only then for C++, and compilation database is a universal format you can generate out of every project model, so we prioritize is as an easy way to open any build system in CLion. Makefiles support is planned, but it has complicated technical issues, which we can’t resolve easily now, so postponed it for later.

Leave a Reply

Your email address will not be published. Required fields are marked *