-
Notifications
You must be signed in to change notification settings - Fork 0
Develop KeeperFX with CMake and Visual Studio 2022
In the development branch, you can develop with CMake and Visual Studio 2022.
- Visual Studio 2022 v17.11.5 or above versions.
- Community or other commercial versions.
- (Optional) Select clang-cl tools to install. See this document for details.
- CMake 3.30.5 or above versions.
- MSYS2 (msys2-x86_64-20240727.exe or newer)
Open msys2_shell.cmd in C:\msys64 (your MSYS2 installation), and install these packages by the pacman.
pacman -S make gettext base-devel
pacman -S mingw-w64-i686-gcc
pacman -S mingw-w64-i686-gdb
-
Visual Studio 2022 is supposed to configure the CMake immediately. Please wait for it to finish.
-
If you are new to CMake and VS 2022, I suggest reading this document.
-
Now, only x86-MinGW32-Debug or x86-MinGW32-Release can build a playable game.

-
You can choose the standard or **heavylog **target.

-
Use buttons in the Build menu to build or clean the project.
-
In the Project menu, you can delete the CMake cache and re-configure.
-
All outputs are put under the out\build folder of your project root.
- You must have a playable game folder. See this page.
- Assume you built x86-MinGW32-Debug/standard configuration, you should see keeperfx.exe, keeperfx.map, and many DLL files under out\build\x86-MinGW32-Debug.
- Copy keeperfx.exe, keeperfx.map, and all DLL files to your game folder.
- If you didn't add "C:\msys64\mingw32\bin" to your PATH environment variables, copy ibgcc_s_dw2-1.dll and libwinpthread-1.dll to the game folder.
- Now you can start to play the game.
- If you want to start it with the VS debugger, create launch.vs.json under .vs folder of your project root. Enter the following content and fill in the content within <>.
{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"type": "default",
"project": "CMakeLists.txt",
"projectTarget": "<keeperfx.exe or keeperfx_hvlog.exe>",
"name": "<keeperfx.exe or keeperfx_hvlog.exe>",
"currentDir": "<your game folder>",
"cwd": "<your game folder>",
"args": [
"-level",
"00001",
"-campaign",
"personal",
"-nointro",
"-alex"
]
}
]
}
You can specify the starting arguments in the args array. The explanation of the args below.
"-alex" - enable cheat menu.
"-nointro" - Skip intro videos.
"-level", "00001", "-campaign", "personal" - Directly enter the 00001 map of the personal campaign.
"-level", "00001", "-campaign", "keeporig" - Directly enter the 00001 map of the original keeper campaign.
- In VS 2022, select the target to debug and click F5 to start debugging.
- CMake configure failed.
Try these approaches:
- Examine the Error List window. Fix all errors in CMakeLists.txt and CMakePresets.json if you modified them.
- In the Project menu, click "Delete Cache and Reconfigure".
- Close VS and delete the problematic configuration folder under out/build. Start VS again.
- The MinGW32 program additionally requires libgcc_s_dw2-1.dll and libwinpthread-1.dll, which can be found in C:\msys64\mingw32\bin. Changing "VCPKG_TARGET_TRIPLET" to "x86-mingw-static" could link these libs statically but it would also link all libs statically, resulting in very big exe files.
- FTEST_DEBUG and CUnit-related code are not built.