Skip to content

Develop KeeperFX with CMake and Visual Studio 2022

Evan edited this page Oct 25, 2024 · 26 revisions

In the development branch, you can develop with CMake and Visual Studio 2022.

Install tools

  1. Visual Studio 2022 v17.11.5 or above versions.
  • Community or other commercial versions.
  • (Optional) Install clang-cl tools. See this document for details.
  1. CMake 3.30.5 or above versions.
  2. MSYS2 (msys2-x86_64-20240727.exe or newer)

Install packages for MSYS2.

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

Start VS and open the keeperfx project folder.

  • 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. image

  • You can choose the standard or **heavylog **target. image

  • 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.

Run and Debugging

  • You must have a playable game folder. See this instructions.
  • 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.

{ "version": "0.2.1", "defaults": {}, "configurations": [ { "type": "default", "project": "CMakeLists.txt", "projectTarget": "<the exe you want to start - keeperfx.exe or keeperfx_hvlog.exe>", "name": "keeperfx_hvlog.exe", "currentDir": "<your game folder>", "cwd": "<your game folder>", "args": [ "-level", "00001", "-campaign", "personal", "-nointro", "-alex" ] } ] }

Clone this wiki locally