🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
3.0 KiB

  1. # EnTT and Unreal Engine
  2. <!--
  3. @cond TURN_OFF_DOXYGEN
  4. -->
  5. # Table of Contents
  6. * [Enable Cpp17](#enable-cpp17)
  7. * [EnTT as a third party module](#entt-as-a-third-party-module)
  8. * [Include EnTT](#include-entt)
  9. <!--
  10. @endcond TURN_OFF_DOXYGEN
  11. -->
  12. ## Enable Cpp17
  13. As of writing (Unreal Engine v4.25), the default C++ standard of Unreal Engine
  14. is C++14.<br/>
  15. On the other hand, note that `EnTT` requires C++17 to compile. To enable it, in
  16. the main module of the project there should be a `<Game Name>.Build.cs` file,
  17. the constructor of which must contain the following lines:
  18. ```cs
  19. PCHUsage = PCHUsageMode.NoSharedPCHs;
  20. PrivatePCHHeaderFile = "<PCH filename>.h";
  21. CppStandard = CppStandardVersion.Cpp17;
  22. ```
  23. Replace `<PCH filename>.h` with the name of the already existing PCH header
  24. file, if any.<br/>
  25. In case the project doesn't already contain a file of this type, it's possible
  26. to create one with the following content:
  27. ```cpp
  28. #pragma once
  29. #include "CoreMinimal.h"
  30. ```
  31. Remember to remove any old `PCHUsage = <...>` line that was previously there. At
  32. this point, C++17 support should be in place.<br/>
  33. Try to compile the project to ensure it works as expected before following
  34. further steps.
  35. Note that updating a *project* to C++17 doesn't necessarily mean that the IDE in
  36. use will also start to recognize its syntax.<br/>
  37. If the plan is to use C++17 in the project too, check the specific instructions
  38. for the IDE in use.
  39. ## EnTT as a third party module
  40. Once this point is reached, the `Source` directory should look like this:
  41. ```
  42. Source
  43. | MyGame.Target.cs
  44. | MyGameEditor.Target.cs
  45. |
  46. +---MyGame
  47. | | MyGame.Build.cs
  48. | | MyGame.h (PCH Header file)
  49. |
  50. \---ThirdParty
  51. \---EnTT
  52. | EnTT.Build.cs
  53. |
  54. \---entt (GitHub repository content inside)
  55. ```
  56. To make this happen, create the folder `ThirdParty` under `Source` if it doesn't
  57. exist already. Then, add an `EnTT` folder under `ThirdParty`.<br/>
  58. Within the latter, create a new file `EnTT.Build.cs` with the following content:
  59. ```cs
  60. using System.IO;
  61. using UnrealBuildTool;
  62. public class EnTT: ModuleRules {
  63. public EnTT(ReadOnlyTargetRules Target) : base(Target) {
  64. Type = ModuleType.External;
  65. PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "entt", "src", "entt"));
  66. }
  67. }
  68. ```
  69. The last line indicates that the actual files will be found in the directory
  70. `EnTT/entt/src/entt`.<br/>
  71. Download the repository for `EnTT` and place it next to `EnTT.Build.cs` or
  72. update the path above accordingly.
  73. Finally, open the `<Game Name>.Build.cs` file and add `EnTT` as a dependency at
  74. the end of the list:
  75. ```cs
  76. PublicDependencyModuleNames.AddRange(new[] {
  77. "Core", "CoreUObject", "Engine", "InputCore", [...], "EnTT"
  78. });
  79. ```
  80. Note that some IDEs might require a restart to start recognizing the new module
  81. for code-highlighting features and such.
  82. ## Include EnTT
  83. In any source file of the project, add `#include "entt.hpp"` or any other path
  84. to the file from `EnTT` to use it.<br/>
  85. Try to create a registry as `entt::registry registry;` to make sure everything
  86. compiles fine.