[Moved from GitHub] CMake improvements and fixes for Linux, Windows and Mac - Discussion

Moved from GitHub to not clog up the pull request. See CMake improvements and fixes for Linux, Windows and Mac for the original discussion.

Last post by me:

Alright, let’s take a step back and have a look at this.

Dropping everything, this is a step-by-step guide on how to get this working properly with CLion, Linux and Mac. Go over each step and make sure you’ve done them all.

  1. Patch UBT with this pull request
  2. Delete your current CMakeLists.txt.
  3. Set the compiler to Clang by going into Settings -> Build -> Toolchains -> CMake and setting two variables:
    CLion compiler configuration
  4. When you’ve changed compilers, open CLion and invalidate the caches by going to File -> Invalidate Caches / Restart.
  5. Build UBT. Go to the root folder of the engine, and run the following command:

./ -project="<path>/<to>/<your>/<project>/<project>.uproject" -game -engine  

Make sure this is an absolute path, and that it doesn’t go through any symlinks - CLion seems to have trouble with those. Omit “-engine” if you don’t plan on building any engine targets, or if you’re generating for a game project.

  1. Open the generated CMakeLists.txt in CLion.
  2. CLion will now begin to load the project. This initial loading may take a very long time, depending on the size and scope of the project. Before it’s done, nothing will work. You can see the progress of this in the bottom bar. Grab a drink and sit back.
    Your paths will vary depending on your system, but those are valid for most Linux systems.
  3. In order to speed up loading times, you can comment out all engine-related build targets if you’ve no plans on building them (you can also omit the -engine switch from the previous command). You can also comment out any of your game targets that you don’t plan on building.
    CLion targets
  4. After the loading has fully finished, you should be good to go. If not, we can start troubleshooting.

Thanks for updating this process! I’m really hoping to get CLion working on windows - being able to use the same IDE regardless of platform is HUGE. I also find VS a strange and clunky beast.

Unfortunately running

Runs successfully(?), but does not produce a CMakeLists.txt on windows. It outputs this:

I have GitBash installed, so I can technically run ./, but that’s obviously the wrong approach on windows - it gives me a lot of errors, like I don’t have xcode, and I haven’t run, and can’t find mono… etc.

Oh success! I just needed to add the -cmakefile flag. Now I have the CMakeLists.txt. I’m trying to get CLion happy with my cmake + clang + cygwin next.

That’s a little peculiar. Could you run the effective UBT command produced by GenerateProjectFiles in debug mode and see if you can suss anything out? I don’t have any Windows computers or VMs on hand, unfortunately.

Ah, actually - it would seem whoever worked with the generated before me may have completely disabled generating CMake files on Windows by making IsWindowsFiltered return false… I’ll look into it. Debug anyway if you can, it would help a lot to see where it drops out.

I’ve had a look and pushed some more changes that should fix CMake generation on Windows. Testing now.

Thank you very much for this, looking forward to see Clion + UE4 work on windows.

Just for future reference, on Mac you still need to modify the command files to have the -cmakefile


Thanks for the pull!

I’m having troubles when trying to build the patched UBT. It throws me the following error in several lines:

error CS1056: Unexpected character `$’

Is this a mono/C# version problem? I’m using the release Unreal4 branch, is that the problem?

Thank you and best regards,


Are we supposed to be able to connect the debugger with this? I could have sworn I’ve managed to do it in the past, but can’t seem to get the debugger to attach now. As of right now, I’m just able to get the code to build, but not run from CLion.

I’ve successfully debugged both the engine and my own game code using this patchset and CLion on Linux. Are you running a target without debug symbols, or doing something else out of the ordinary?

I’m on 4.12, and I just pulled in your CMakefileGenerator.cs changes. Right now, I’m testing if I can debug the game through CodeLite. I have a feeling the package maintainer removed some key files, trying to slim the Unreal install down.

This is what he’s copying over. Can you see anything missing that should definitely be in there?

This is what I was using for the install previously, while running 4.11

Is this Arch? I can’t see anything obviously wrong, but I could easily be missing something. Could you try booting up an Ubuntu VM or something and seeing if the problems persist?

This is Arch. So, debugging is definitely working in CodeLite. Going to wait for CLion to load, and check the targets.

These are the settings I have for Run/Debug:

Alright, so I tried getting a vm up and running. Got Unreal compiled and everything set up, only to find out Opengl 4 isn’t supported yet by virtualbox. I’m just going to reinstall copying everything over to see if everything works correctly.

Ah, I see the issue. The FakeTarget is just that - a fake target. It does not work, not for compiling or running. What you need to to is browse to the output executable (Engine/Binaries/Linux/UE4Editor) and select that instead. Set the working directory to Engine/Binaries/Linux as well. I’m afraid I don’t have my main rig on hand, so I can’t show you my settings, but that’s basically it.

Anyone got a CMake settings screenshot for windows? I can’t get CLion to successfully compile the small test script it compiles to check the settings. I get all kinds of errors, ranging from access denied to flags not found (depending on how I set the path)