ThirdParty/Eigen inaccessible for plugins in foreign C++ Unreal Projects?

We’ve created a plugin (MyPlugin) for quite some time and this is done in a c++ source project. So this plugin is located inside the Project folder where the Engine folder is a sibling.

  • UE5 folder
    • Engine
      • Source
    • MyProject
      • Plugins
        • MyPlugin

MyPlugin requires the use of Eigen library, so as per all the info we found in the internet, we followed it by adding in MyProject.Build.cs the line:

AddEngineThirdPartyPrivateStaticDependencies(Target, “Eigen”);

This works for the project above set up.

But we have a problem on a different project, where the Unreal Engine it uses is in a different location, and the new C++ Unreal Project created through it is on a different location entirely. Making the Unreal Project as “foreign”.

  • UE5 folder
    • Engine
      • Source
        • ThirdParty
  • MyProjects folder
    • ForeignUnrealProject (C++)
      • Plugins
        • MyPlugin

When we build the solution of ForeignUnrealProject, we get errors in compilation on not being able to find “Eigen/Core”.

My guess is the AddEngineThirdPartyPrivateStaticDependencies is not giving it the right path to the Engine/Source.

Am I correct that the issue here is due to having a ForeignUnrealProject (folder location is not desirable relative to the Engine that owns it)?

Is there a solution such that MyPlugin could always compile and work while being able to access Engine/Source/ThirdParty regardless if the project using it is foreign or not?