CLion 2019.1 EAP: Custom Targets, Fixes for ClangFormat and Extract Refactoring

Hi,

We have a new CLion 2019.1 EAP, build 191.5849.15! You can get it from our website, Toolbox App, or through a snap package (if you are using Ubuntu). The patches will be available shortly for those of you who are using the previous EAP build.

Download CLion 2019.1 EAP

Build-system independent Build Targets and Run/Debug Configurations

Starting from v2018.2 CLion supports compilation database project format (along with CMake and Gradle for C++). The main issue was that the compilation database itself lacks the information about building and thus running the whole project. So only code editing was available for it in CLion. Earlier in 2019.1 EAP, we added the ability to configure Build/Clean tools for compilation database projects (simply configure external tools and provide them in the settings as build/clean commands).

And now the next big step – we generalized the approach and added the ability to create:

  • Custom Build Targets: find them in Settings/Preferences | Build, Execution, Deployment | Custom Build Targets
  • Custom Run/Debug Configurations: check the Custom Build Application template in Run | Edit Configurations…

The main advantage is that both of them are completely independent of any build system/project model. But of course, they are most useful in the case of compilation database projects.

How exactly does it work?

First of all, you need a custom target, so that CLion knows what to build. For this, go to Settings/Preferences | Build, Execution, Deployment | Custom Build Targets and configure one:
custom_build_target

Here build_with_make and clean_with_make are external tools we’ve configured for this project to build and clean TscanBuild target:
custom_build_external_command

Now you can Build/Rebuild your project from within CLion! But what if you’d like to Run and Debug your custom target in CLion? That’s also possible with this EAP! Open Run | Edit Configurations… dialog and create a configuration based on the Custom Build Application template:
configuration_templates

Select the custom target from the drop-down list, put in the executable you need to run/debug and add in any other options you find useful:
configuration_run

By the way, remember you were setting Toolchain in the Custom Build Target configuration above? The environment (for example, on Windows, the choice between Cygwin, MinGW, VS, WSL, or Remote) and the debugger will be taken from it and used here in the Run/Debug configuration. So, for example, if you like to debug with some custom GDB version, create a corresponding toolchain -> provide it in the Custom Build Target -> select this Custom Build Target in your Custom Build Application.

That’s it! Now you can Run, Debug, and even Profile your application from CLion.

Other improvements

Other changes include:

  • Cygwin supported version is increased to Cygwin 3.0
  • Several fixes for Extract refactoring (CPP-3085, CPP-3086, CPP-5834, CPP-12461)
  • ClangFormat: a collection of actions were updated to work with ClangFormat when enabled:
    • Reformat results of Generate actions
    • Reformat Refactoring results
    • Reformat on paste
    • Reformat block on typing }
    • Reformat on quick-fixes and intention actions

    There is one pesky issue still left (CPP-15283) with the unexpected swapping of include headers after completion in the case of ClangFormat. We hope to address it in the next EAP build.

Brief overview of 2019.1 EAP

Let’s take a quick look back at the other features and enhancements already delivered in CLion 2019.1 EAP:

And this doesn’t count the dozens of bug-fixes in various areas! Download and try the new EAP build right away! We are looking forward to your feedback!

That’s it. The full release notes are here.

Download CLion 2019.1 EAP

Your CLion Team
JetBrains
The Drive to Develop

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

22 Responses to CLion 2019.1 EAP: Custom Targets, Fixes for ClangFormat and Extract Refactoring

  1. Taw says:

    Is it possible to set different toolchain for different projects? For project A GCC 5 and for project B GCC 7?

    • Anastasia Kazakova says:

      Targets are per project, so you definitely can set different targets with different toolchains. If that’s what you mean

  2. Roman Popov says:

    Are we supposed to use Ninja with CMake this way? Or Ninja CMake generator will be supported separately?

    • Anastasia Kazakova says:

      We hope to support Ninja generator via adding CMake server support in future. And this is mostly to handle Makefiles projects and custom project models. But could work for a broad range of cases indeed.

  3. Lawrence Millar-Madigan says:

    Is there a previous post about how to setup such external tools as the “build_with_make” and “clean_with_make” shown? Would you mind linking if there is?

  4. Lawrence Millar-Madigan says:

    Is it possible to save custom build targets, configurations and then perhaps add to a repo?

    My goal is a portable project where one can merely checkout, install dependencies with Conan, and build with clion with no extra steps.

    If I used cmake for the external tools then I think the build would actually be portable, however I’m not sure how to actually keep the configurations in my repo.

    • Anastasia Kazakova says:

      Yes, custom targets and configurations are all stored in .idea subfolder inside your project. Check customTargets.xml and workspace.xml files and tools directory.

  5. In our project we use CLion as a base editing IDE we build embedded systems with 100K + line C++ code. We have several cross compile tool-chain.

    In general we missing one big feature most of our cross compile tool-chain comes with an environment setup script mostly written in bash (our host operating system is Linux). Normally this environment setup script sets environment variables but not only it also sets chroot and aliases.
    The problem is that the toolchain and the cmake configuration dialog does not allow to specify that the build / cmake generation must run in a shell where a specific script is sourced.

    Unfortunately this stop us to easy integration our toolchain / SDK to clion.

    Can we have such a feature integrated in to the toolchain / build settings ?.

    Or is there some workaround where I can do this ?.

  6. Mark Hicks says:

    Will “make” be added as a proper entry to the “Add New Configuration” list or will “make” always be a stepchild in the developer’s eye? I am looking forward to this coming to a proper release and not an EAP!

  7. Helge Penne says:

    Is there any progress on the regression reported here?
    https://youtrack.jetbrains.com/issue/CPP-15313

    Is there any hope that this will be fixed before release? You seem to be headed in the right direction with regards to quality and it would be a step in the wrong direction to release 2019.1 with a regression such as this. It will annoy users.

    • Anastasia Kazakova says:

      Indeed there is this regression, as migration to clang is not that smooth. I’ll check with the team what’s the progress and we’ll update in the ticket. That’s for pinging.

  8. Amith RC says:

    Hi, Anastasia.

    As an Example, I was trying to build with EAP version.

    I am trying to compile the nvme-cli
    https://github.com/linux-nvme/nvme-cli

    1. Used compiledb to convert makefile into command.json file
    2. Imported the json file via open and eventually opened the project, no issues and no errors.
    3. Then I got confused with Custom Build Targets, what does build_with_make and clean_with_make refers? What is the external tools how to get them?

    Amith

  9. Roman Popov says:

    Is it possible to make Clion discover unit tests in Custom Build Executable (I build gtest-based unit tests with ninja)?

    • Roman Popov says:

      In a Google Test Template in Run/Debug configurations for some reason I can’t select Custom Build Application

Leave a Reply

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