Since the code is from a third party inside our company we need to keep the complex structure of this module we need to link against. I cannot change the structure nor add “Private/Public” folders.
I just want the Build.cs to detect my .cpp files correctly in another, explicite existing folder. But all I find online are copy scripts and even more complex solutions. I also tried PublicAdditionalLibraries but this works only for .lib I found out (and cpp did not work).
Project/Source/MyModule/AComponentFromOutside/include and
Project/Source/MyModule/AComponentFromOutside/src both with many files and many folders in between, heavily using the struture inside as well (e.g. in include “../MyModule/MyFolder/mySecondFolder/” so structure MUST remain.)
The only thing you should have to do in this case if to add a directive so the headers of the 3rd party lib is part of the “search” path when compiling. In MyModule.build.cs add the following:
`public class Custom54 : ModuleRules
{
public Custom54(ReadOnlyTargetRules Target) : base(Target)
{
…
//If the headers are to be exposed to other modules
PublicIncludePaths.AddRange(new string { Path.Combine(ModuleDirectory, “AComponentFromOutside/include”) });
//If the headers are to be exclusive to MyModule
PrivateIncludePaths.AddRange(new string { Path.Combine(ModuleDirectory, “AComponentFromOutside/include”) });
…
}
}`
Any cpp and c files should be picked up automatically by UnrealBuildTool. I should warn you that this will apply all of our compiler and linker flags to the code. You might need some fiddling of the settings if the code is not compatible with our defaults.
The problem is, that the src data is not in the include folder.
So the header are found, but the linker cannot see the cpp files. They are completely independent in another folder. Since the project is very complex and originally done via a CMake which sets the paths right, I want to avoid copying the cpp files into the include folder, the structure is just as it is.
I ran some local test and the cxx extension is not picked up by UnrealBuildTool. I will need to discuss with the owner of UBT to clear that up but he’s on the west coast of the US so I wanted to provide a quick return.
Have you considered pre-compiling the external lib and integrating it using headers and libs? There are lots of examples of this in the engine code and plugins.
As I suspected, the owner of UBT confirmed that cxx files are not supported in version 5.4. He added the support for it in the main stream so the extension will be supporting starting with version 5.6. The commit was not replicated to GH yet but should be within the next few hours.