How to build VCMI (Linux/Cmake/Conan)
Contents
Requirements
- MinGW environment:
apt install mingw-w64
- CMake:
apt install cmake
or get from https://cmake.org/download/ - (optional) Ninja:
apt install ninja-build
or get from https://github.com/ninja-build/ninja/releases - (optional) NSIS:
apt install nsis
- Unfortunately, on Ubuntu 22.04 or less we need to fetch MinGW headers from 22.10
curl -O -L http://mirrors.kernel.org/ubuntu/pool/universe/m/mingw-w64/mingw-w64-common_10.0.0-2_all.deb && sudo dpkg -i mingw-w64-common_10.0.0-2_all.deb;
curl -O -L http://mirrors.kernel.org/ubuntu/pool/universe/m/mingw-w64/mingw-w64-x86-64-dev_10.0.0-2_all.deb && sudo dpkg -i mingw-w64-x86-64-dev_10.0.0-2_all.deb;
(for x86_64)
curl -O -L http://mirrors.kernel.org/ubuntu/pool/universe/m/mingw-w64/mingw-w64-i686-dev_10.0.0-2_all.deb && sudo dpkg -i mingw-w64-i686-dev_10.0.0-2_all.deb;
(for i686)
Compiling VCMI for Windows on Linux
Some developers may want to make Windows builds without dealing with dependencies as it may be headache when you're on Windows. It's possible to setup own cross-compiler toolkit that use MinGW, but that take time and skill. Fortunately we can use Conan Package Manager that make cross compilation easy and work out of box for our engine. Conan for cross-compiling VCMI is supported only from VCMI 1.2+
Precompiled build from CI
In order to speed up Conan cross compilation time on CI we use precompiled Conan dependencies packages for Ubuntu 22.04 x86_64. Assuming that you already install requirements, this should be easy.
curl -L "https://github.com/vcmi/vcmi-deps-windows-conan/releases/download/1.0/vcmi-deps-windows-conan-w64.tgz" | tar -C ~/.conan -xzf -
Conan package manager
Please find detailed instructions in VCMI repository. Note that the link points to the cutting-edge state in develop
branch, for the latest release check the same document in the master branch.
On the step where you need to replace PROFILE, choose:
- if you're want 64-bit:
mingw64-linux.jinja
- if you're want 32-bit:
mingw32-linux.jinja
Note: if you wish to build 1.2 release in non-Release
configuration, you should define USE_CONAN_WITH_ALL_CONFIGS=1
environment variable when executing conan install
.
Building
If you are on CMake 3.20+, simply use cmake --preset windows-mingw-conan-linux
for configure and cmake --build --preset windows-mingw-conan-linux --target package
for automatic generator of install script.
If you have CMake version incapable of doing presets, you need to use this command cmake <path> -DCMAKE_TOOLCHAIN_FILE=/home/rilian/Projects/vcmi/conan-generated/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW <additional cmake options>
and then use make package
or ninja package
(if -G Ninja) in your generated path.
Testing build
After compile, you can run generated binaries by using Wine from here (assuming, you used CMake preset):
out/build/windows-mingw-conan-linux/bin/vcmilauncher out/build/windows-mingw-conan-linux/bin/vcmiclient out/build/windows-mingw-conan-linux/bin/vcmiserver
You need to copy H3 data as with usual VCMI installation.
Troubleshooting
In case of troubles you can always consult our CI build scripts or contact the dev team via slack