How do I use common code?

I have a level editor which is not Unreal Engine based. I have code to load and save the level data which is read by my game. This code is common to both.

The common code is in a separate repository which I bring in with a git sub-module. I figured out (after a lot of false starts) how to add the folder as an additional include path to my game module which is included in my game target. I cannot figure out how to get the additional C++ files compiled.

From my reading I need to add another module, but I have no idea how to go about this. The uproject file allows me to specify multiple module, but not where to find them. I have no idea what the file structure is meant to be. I just have this:

- my_game.uproject
- Source/
  - MyGame.Target.cs
  - my_game/
    - MyGame.Build.cs
    - Private/
    - Public/

I would prefer to just have “Common/” alongside “Private/” and “Public/” and have my main game module search those directories for the extra source code. Alternatively I could have “Common/” alongside “Source/” with its own module file, but then how will the project file know where to look for it?

So, I hoicked the “Build.cs” file up a level, and suddenly the `PrivateIncludePaths` addition I put in earlier to ensure the header files got found kicked in and the CPP files got found too.

Now my file structure looks like:

- my_game.uproject

  • Source/
    • MyGame.Target.cs
    • MyGame.Build.cs
    • Common/
    • my_game/
      • Private/
      • Public/

I think what is happening is the “Target.cs” file is looking in its own directory as well as all sub-directories to find the module, and similarly the “Build.cs” file is looking in its own directory and below, so it couldn’t find “Common” until I raised it up a level.