There is a problem with Unreal Engine 4 that it won't compile any third-party source files provided within UE4 plugins (at least it didn't work for us Mac platform). But we can make a static library that we can statically link to the UE4 plugins shipped with the Power IK bundle. The PowerIK is very cool as it requires almost none third-party dependencies, so it can be easily built for different platforms. We use CMake to generate project files for different platforms (in our case they were Win64 and Mac). So what needs to be done?
First we have to move sdk directory shipped with the source version to the different directory. So we move it from Source/PowerIKRuntime to the Source/ThirdParty directory.
Important note! We also had to adjust all the include paths for files in SDK to be relative, e.g. #include "../include/PowerIK.h"
instead of #include "PowerIKRuntime/sdk/include/PowerIK.h"
as we detached them from the direct use by the UE4. I think that it can be tinkered by cmake or something else.
Next it is required to comment out two lines from the original PowerIKRuntime.Build.cs that add SDK source files to the plugin like this:
// string SrcDir = Path.Combine(ModulePath, "sdk", "src");
// PrivateIncludePaths.Add(SrcDir);
Next add the our proxy SDK module to the PublicDependencyModuleNames of the PowerIKRuntime.Build.cs as "PowerIKRuntimeSDK". Also check that "AnimGraphRuntime" added both to PowerIKTool.Build.cs and PowerIKRuntime.Build.cs public dependencies.
As the next step we create the file named PowerIKRuntimeSDK.Build.cs and put it next to the sdk directory in the ThirdParty directory. Basically the file tells UE4 where to get the libraries to link when we link against the new intermediate cross-platform plugin. The file is attached to the gist.
Next we create the file CMakeLists.txt that will be used by cmake tool to generate project files for different platforms. The file is attached to the gist.
- Create a
_build
directory in thePowerIK/Source/ThirdParty/sdk/
directory. - Go to this directory with
cd _build
. - Run
cmake .. -G "Visual Studio 16 2019" -A x64
. Here you can change architecture or generator, e.g. for the VS 2017 you will need to use "Visual Studio 15 2017". When the command completes, you will get thePowerIK.sln
. - Open the solution in Visual Studio or Rider for UE4 and build the project
PowerIK.sln
for release. After that you will get the static library filePowerIKRuntime.lib
in thesdk/_build/Release
directory.
- Create a
_build
directory in thePowerIK/Source/ThirdParty/sdk/
directory. - Go to this directory with
cd _build
. - Run
cmake .. -GXcode -DCMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH=NO -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_OSX_DEPLOYMENT_TARGET="10.14"
. Notice that here you will probably need additional flags to specify the target architecture and deployment target. The deployment target should match the target your UE4 version is built for. The recent Xcode will build for 11.10 by default, so we had to adjust it. Changing the architecture should allow you build not only for MacOSX, but also for iOS, but we didn't test it yet. When the command completes, you will get thePowerIK.xcodeproj
that you can open and build with the Xcode. - Open the project in Xcode and build it or use
xcodebuild
command in terminal. After that you will get the static library filelibPowerIKRuntime.a
that is already configured to be used by the UE4 ModuleRules.
It should work for any other platform if you will generate and build required project files using cmake and your compiler.
Great thanks to Epic Games and Power Animated for Unreal Engine and PowerIK.
If you find this helpful, consider to support our project at Patreon https://www.patreon.com/artheon
Or you can send a tip to Bitcoin 1E6ixVkj5bG9MpBGXhZejEcGJuPQJMWV4V
or Ethereum 0xAd3c93F3F82f4bE7366E0677005c106Eaf9120df
do you know where to download the PowerIK source code now? Thanks