My UE4 project is just one part of an overall set of projects that are otherwise CMake-driven and which live in one solution, and I’d like to make my UE4 project conform to this.
I generated a CMakeLists.txt file on Windows by invoking Engine/Binaries/DotNET/UnrealBuildTool.exe with -ProjectFiles %PathToUProjectHere% -cmakefile, but it has some problems.
${UE4_ROOT_PATH} for me was set like this
set(UE4_ROOT_PATH C:/Program Files/Epic Games/UE_4.14)
But CMake doesn’t like spaces in this format - it automatically removes them. Instead, the command should be
set(UE4_ROOT_PATH C:/Program\ Files/Epic\ Games/UE_4.14)
Once I fixed this, I managed to get the project files generated with CMake, and could open the generated solution. When I tried to build the %ProjectName% project in Debug x64, I was given the following:
1>------ Build started: Project: UE4CMakeTest, Configuration: Debug x64 ------
1> Building Custom Rule C:/Users//Documents/_programming/projects/UE4CMakeTest/CMakeLists.txt
1> CMake does not need to re-run because C:/Users//Documents/_programming/projects/UE4CMakeTest/build/CMakeFiles/generate.stamp is up-to-date.
1> 'C:/Program' is not recognized as an internal or external command,
1> operable program or batch file.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB6006: "cmd.exe" exited with code 1.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
So it seems like something is still not working with the spaces, and this is for the default installation path for UE4! I also can’t run ALL_BUILD, but I guess you shouldn’t try to build ‘FakeTarget’ anyway which it tries to do.
All of this aside, I’d like to hand-write my own CMakeLists.txt layout - linking in libs and adding includes and sources without going through the target.cs files or the plugin system. Just a standard kind of project but with some UE4 sprinkled in.
Apart from don’t, got any advice or insight? Interested in seeing what people have done.
EDIT:
Fixed the previous issues by changing ${BUILD}:
set(BUILD "cmd /c \"${UE4_ROOT_PATH}/Engine/Build/BatchFiles/Build.bat\"")
I can now build the various targets but… they don’t actually build or do anything. There aren’t any errors though! Bit of a let-down. FakeTarget still fails though.