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.
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:
Here build_with_make and clean_with_make are external tools we’ve configured for this project to build and clean TscanBuild target:
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:
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:
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:
- Clangd: code highlighting and quick-fixes on Clangd
- Embedded Development: OpenOCD debugger support and integration with STM32CubeMX
- Code style:
- Debugger:
- Other:
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.
Your CLion Team
JetBrains
The Drive to Develop
Taw says:
February 27, 2019Is it possible to set different toolchain for different projects? For project A GCC 5 and for project B GCC 7?
Anastasia Kazakova says:
February 27, 2019Targets are per project, so you definitely can set different targets with different toolchains. If that’s what you mean
Roman Popov says:
February 27, 2019Are we supposed to use Ninja with CMake this way? Or Ninja CMake generator will be supported separately?
Anastasia Kazakova says:
February 27, 2019We 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.
Jan says:
February 28, 2019Is Ninja support finally coming this year?
Anastasia Kazakova says:
February 28, 2019We can’t provide any estimations. Ninja generator will likely be implemented via CMake server, and we still need to find resources for this task.
Lawrence Millar-Madigan says:
February 28, 2019Is 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?
Anastasia Kazakova says:
February 28, 2019No, as it’s the pretty old and standard feature. Find the description in our webhelp https://www.jetbrains.com/help/clion/2019.1/configuring-third-party-tools.html
Lawrence Millar-Madigan says:
February 28, 2019Is 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:
February 28, 2019Yes, custom targets and configurations are all stored in .idea subfolder inside your project. Check customTargets.xml and workspace.xml files and tools directory.
Richard Szabo says:
March 1, 2019In 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 ?.
Anastasia Kazakova says:
March 1, 2019Indeed, this is missing for now. Related to the following tickets:
1. https://youtrack.jetbrains.com/issue/CPP-11768
2. https://youtrack.jetbrains.com/issue/CPP-10731
3. https://youtrack.jetbrains.com/issue/CPP-7388
Mark Hicks says:
March 1, 2019Will “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!
Anastasia Kazakova says:
March 1, 2019Can you please explain the use case? If you wish to work with a Makefiles project, you can do that now via compilation_database: https://www.jetbrains.com/help/clion/using-file-watchers.html#CompDBExample. And create custom targets to build/clion with make and make clean as in the blog sample.
Helge Penne says:
March 4, 2019Is 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:
March 4, 2019Indeed 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.
Amith RC says:
March 6, 2019Hi, 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
Amith RC says:
March 6, 2019Sorry, Never mind. I was able to fix it.
Thank you for your help, I am able to build, Run and debug now.
You guys are great.
Amith
Anastasia Kazakova says:
March 6, 2019Great! Happy to know you got it to work!
Roman Popov says:
March 8, 2019Is it possible to make Clion discover unit tests in Custom Build Executable (I build gtest-based unit tests with ninja)?
Roman Popov says:
March 8, 2019In a Google Test Template in Run/Debug configurations for some reason I can’t select Custom Build Application
Anastasia Kazakova says:
March 8, 2019It’s not possible now. Google Test configurations works only with CMake targets now.