C++ game development is strongly linked with Unreal Engine 4, one of the most popular and widely spread C++ game engines. It is no surprise that we are getting lots of requests about UE4 setup within CLion. In this blog post we’ll share our own experience along with a couple of tips and useful links.
*Upd* This post is valid for UE4 v4.18 and less. v4.19 has an integration in UBT to generated CMake out of it directly, but not all the PRs have been accepted for now, so it’s currently broken. When the things work, we’ll update the post. Sorry for the inconvenience.
The story started some time ago when one of our team members decided to try UE4. As you may know, CLion relies heavily on CMake project model, so it was crucial to get a CMake-based UE4 project. The official Linux-only CMake generator for UE4 projects had existed for some time, but it wasn’t perfect and more importantly, limited to Linux. Philipp Smorygo from the AppCode/CLion team investigated the source of this problem and contributed to Unreal Engine repository with his CMake + UE4 changes. You can read about his experience in his own blog.
While this approach worked, it still brought lots of performance problems. Mostly because the CMakeLists.txt used
add_custom_target() commands for nearly everything, making it impossible for CLion to understand the project structure correctly. Also, with this approach CLion has to index and build symbols for the entire engine sources, not just necessary headers and source files, which leads to high CPU usage and really long initial project indexing stage.
Recently we found out some good work had been done by the community and decided to give UE4 another try. And guess what, things are much simpler now! There is even a 3rd-party plugin (thanks to our users!) that creates a fully flushed out CMakeList file for use with CLion, adding intellisense, compiler definitions, etc.
Short instructions on how to get started with UE4 in CLion:
- Get the engine
- Register at Epic Games and download the Epic Games Launcher.
- Run it and let it download all the necessary Unreal Engine 4 binaries for you.
- Create or open your project with UE4 Editor to generate an *.uproject file.
- Get Mono
- Download and install Mono to be able to launch on Linux and macOS.
- Get CLionSourceCodeAccess plugin for UE4
- Download the plugin sources from GitHub.
- Follow the instructions on the plugin’s wiki to setup the plugin. After the plugin is built, you’ll need to provide paths to C/C++ compilers, CLion itself and Mono:
Then you can set it up as source code accessor:
- Now simply call Open CLion from the UE4 Editor menu. CMake project structure will be generated for you automatically on this step.
Now you can use CLion for your UE4 project and enjoy all of its features!
Plugin also generates custom targets for building and cleaning your game. Fake target is added for CLion needs to make all the intellisense possible.
Unreal Engine 4 SDK Support plugin
If you write games with UE4 in CLion, you may also find useful an Unreal Engine 4 SDK Support plugin from Philipp, our team member. To install it, go to Preferences/Settings | Plugins and Browse repository to search for it:
The plugin adds extra completion options for reflection specifiers, which CLion is unable to provide by default:
Performance and known issues
Our experience shows that initial indexing time is acceptable, as the CMake project model generated this way allows CLion not to index and build symbols for the entire engine source, but only for necessary engine headers and source files.
Besides, recent CLion 2016.3 EAP build brought a significant performance improvement for reopening the project that was already indexed once in CLion. As our tests show it takes seconds instead of minutes on Unreal Engine sources themselves.
However, we still recommend that you increase the amount of memory used by CLion, or at least check the real usage by switching on the memory indicator (Preferences/Settings | Appearance & Behavior | Appearance | Show memory indicator).
As for the CLionSourceCodeAccess plugin, we’ve tested it on macOS. On Windows there is an issue for MinGW and Cygwin toolchains. CLion’s part will be addressed in CLion 2017.1 EAP, but there is still some internal command line length limitation coming from the toolchain. Probably, MSVC support, which we plan for 2017.1, will resolve this as well.
We’ll appreciate your feedback on the whole workflow and both plugins! Let us know in the comments section below.