Unable to Package UE5.0.3 project with Cesium v1.19.0

Hi folks,

I did some digging into this. Long story short, if you want to #include Cesium for Unreal headers in your own source files, you need to make sure those source files are built with these options (add them to your .Build.cs file):

PublicDependencyModuleNames.AddRange(new string[] { "CesiumRuntime", "UMG" });
CppStandard = CppStandardVersion.Cpp17;
bEnableExceptions = true;

Here’s the explanation for each of these lines:

PublicDependencyModuleNames.AddRange(new string[] { "CesiumRuntime", "UMG" });

It’s hopefully unsurprising that you need to depend on the CesiumRuntime module, since you’re trying to use its functionality. UMG is more unexpected, though. It is required because Cesium for Unreal #includes UMG from its public headers, but only declares it as a private dependency, not a public one, so its not inherited by things that depend on Cesium for Unreal.

I’ve opened a pull request to fix this, so UMG should not be required anymore in future versions (but it won’t do any harm):

CppStandard = CppStandardVersion.Cpp17;

Cesium for Unreal uses C++ 17, so there’s no way to use our header files in your source files without compiling your source files for C++ 17.

bEnableExceptions = true;

This is necessary because of a questionable choice in a third-party library used by Cesium for Unreal. On Windows, when exceptions are disabled, it does a #include <windows.h>. Including windows.h in an Unreal project is disastrous, and causes all kinds of strange compiler errors. I don’t have a fix for this one yet, but enabling exceptions in your project is an effective workaround.

Kevin

2 Likes