Difference between revisions of "How to build VCMI (Linux/Cmake/MXE)"
(Update deps to use qtbase instead of full qt5) |
m (remove explicit tests disabling - they're off by default) |
||
(10 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
= Compiling VCMI for Windows on Linux = | = 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 there is project called [http://mxe.cc/ MXE (M cross environment)] that make cross compilation easy and work out of box for our engine. | 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 there is project called [http://mxe.cc/ MXE (M cross environment)] that make cross compilation easy and work out of box for our engine. | ||
+ | |||
+ | = Precompiled build from CI = | ||
+ | In order to speed up MXE compilation time on CI we use precompiled MXE packages. Assuming that MXE is already installed. | ||
+ | |||
+ | <pre> | ||
+ | # Install nsis for cpack | ||
+ | sudo apt-get install nsis | ||
+ | |||
+ | #we might need this a bit outdated version of ssl | ||
+ | wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0.0_1.0.2n-1ubuntu5.6_amd64.deb | ||
+ | sudo apt install ./libssl1.0.0_1.0.2n-1ubuntu5.6_amd64.deb | ||
+ | |||
+ | # Clone VCMI repository with submodules | ||
+ | git clone --depth 1 --recursive https://github.com/vcmi/vcmi.git | ||
+ | |||
+ | mkdir build | ||
+ | cd build | ||
+ | |||
+ | # MXE repository was too slow for Travis far too often | ||
+ | wget -nv https://github.com/vcmi/vcmi-deps-mxe/releases/download/2021-02-20/mxe-i686-w64-mingw32.shared-2021-01-22.tar | ||
+ | tar -xvf mxe-i686-w64-mingw32.shared-2021-01-22.tar | ||
+ | sudo dpkg -i mxe-*.deb | ||
+ | sudo apt-get install -f --yes | ||
+ | |||
+ | # build | ||
+ | sudo apt-get install ninja-build | ||
+ | |||
+ | /usr/lib/mxe/usr/bin/mxe-i686-w64-mingw32.shared-cmake -G Ninja ../vcmi -DCMAKE_BUILD_TYPE=Release | ||
+ | ninja | ||
+ | |||
+ | # pack an installer, on CI works with regular cmake's cpack. | ||
+ | cpack -C Release -D CPACK_NSIS_EXECUTABLE=`which makensis` | ||
+ | </pre> | ||
+ | |||
+ | The full actual list of used MXE packages could be found [https://github.com/vcmi/vcmi-deps-mxe/blob/master/mirror-mxe.sh here] | ||
= Setting up a MXE cross compiler = | = Setting up a MXE cross compiler = | ||
Make sure cmake and git is installed on your system as well as all libraries and utils [http://mxe.cc/#requirements listed under requirements]. MXE website have commands that will let install everything needed for almost every distribution. | Make sure cmake and git is installed on your system as well as all libraries and utils [http://mxe.cc/#requirements listed under requirements]. MXE website have commands that will let install everything needed for almost every distribution. | ||
− | Once it done [http://mxe.cc/#download clone MXE using git]. Then you need to edit "settings.mk" file: | + | Once it done [http://mxe.cc/#download clone MXE repository using git]. |
+ | |||
+ | <pre>git clone https://github.com/mxe/mxe.git</pre> | ||
+ | |||
+ | Now just run make once to generate "settings.mk" file and then cancel build immediately with Ctrl+C: | ||
+ | |||
+ | <pre>make</pre> | ||
+ | |||
+ | Then you need to edit "settings.mk" file: | ||
<pre># "settings.mk" not exist by default | <pre># "settings.mk" not exist by default | ||
# You can create it by running "make" and then aborting it by Ctrl+C | # You can create it by running "make" and then aborting it by Ctrl+C | ||
# | # | ||
# Uncomment "MXE_TARGETS" and make it look like that: | # Uncomment "MXE_TARGETS" and make it look like that: | ||
− | MXE_TARGETS := i686-w64-mingw32.shared</pre> | + | MXE_TARGETS := i686-w64-mingw32.shared |
+ | |||
+ | # You can add this line to plugins if you want MXE to use GCC6 | ||
+ | # This is currently break NSIS though | ||
+ | #override MXE_PLUGIN_DIRS += plugins/gcc6 | ||
+ | |||
+ | # And you can add following packages list | ||
+ | LOCAL_PKG_LIST := gcc boost zlib sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_ttf ffmpeg minizip qtbase qt intel-tbb nsis # but also we need mxe-i686-w64-mingw32.static-luajit for ERM support | ||
+ | # Make sure to uncomment two lines under the list | ||
+ | .DEFAULT_GOAL := local-pkg-list | ||
+ | local-pkg-list: $(LOCAL_PKG_LIST) | ||
+ | </pre> | ||
Then you can compile it: | Then you can compile it: | ||
− | <pre>make | + | <pre>make -j 9</pre> |
Depend on your hardware that may take from 20 minutes to more than hour. | Depend on your hardware that may take from 20 minutes to more than hour. | ||
− | |||
− | |||
− | |||
= Compiling VCMI using MXE = | = Compiling VCMI using MXE = | ||
Line 27: | Line 78: | ||
mkdir vcmi-cmake && cd vcmi-cmake | mkdir vcmi-cmake && cd vcmi-cmake | ||
− | # To build with launcher: | + | # To configure build with launcher: |
− | + | /home/test/mxe/usr/bin/i686-w64-mingw32.shared-cmake ../vcmi | |
− | |||
− | |||
− | - | ||
− | |||
− | |||
− | cmake ../vcmi | ||
− | |||
− | |||
− | |||
− | |||
# Compile | # Compile | ||
− | + | /home/test/mxe/usr/bin/i686-w64-mingw32.shared-cmake --build . -- -j 9 | |
− | # | + | # To create installer |
− | + | # MXE have own patched CPack that allow to pass path to makensis as option. | |
+ | /home/test/mxe/usr/bin/i686-w64-mingw32.shared-cpack -D CPACK_NSIS_EXECUTABLE=/home/test/mxe/usr/bin/i686-w64-mingw32.shared-makensis | ||
+ | </pre> | ||
= Script for automatic builds = | = Script for automatic builds = |
Latest revision as of 09:02, 23 December 2022
Contents
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 there is project called MXE (M cross environment) that make cross compilation easy and work out of box for our engine.
Precompiled build from CI
In order to speed up MXE compilation time on CI we use precompiled MXE packages. Assuming that MXE is already installed.
# Install nsis for cpack sudo apt-get install nsis #we might need this a bit outdated version of ssl wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0.0_1.0.2n-1ubuntu5.6_amd64.deb sudo apt install ./libssl1.0.0_1.0.2n-1ubuntu5.6_amd64.deb # Clone VCMI repository with submodules git clone --depth 1 --recursive https://github.com/vcmi/vcmi.git mkdir build cd build # MXE repository was too slow for Travis far too often wget -nv https://github.com/vcmi/vcmi-deps-mxe/releases/download/2021-02-20/mxe-i686-w64-mingw32.shared-2021-01-22.tar tar -xvf mxe-i686-w64-mingw32.shared-2021-01-22.tar sudo dpkg -i mxe-*.deb sudo apt-get install -f --yes # build sudo apt-get install ninja-build /usr/lib/mxe/usr/bin/mxe-i686-w64-mingw32.shared-cmake -G Ninja ../vcmi -DCMAKE_BUILD_TYPE=Release ninja # pack an installer, on CI works with regular cmake's cpack. cpack -C Release -D CPACK_NSIS_EXECUTABLE=`which makensis`
The full actual list of used MXE packages could be found here
Setting up a MXE cross compiler
Make sure cmake and git is installed on your system as well as all libraries and utils listed under requirements. MXE website have commands that will let install everything needed for almost every distribution.
Once it done clone MXE repository using git.
git clone https://github.com/mxe/mxe.git
Now just run make once to generate "settings.mk" file and then cancel build immediately with Ctrl+C:
make
Then you need to edit "settings.mk" file:
# "settings.mk" not exist by default # You can create it by running "make" and then aborting it by Ctrl+C # # Uncomment "MXE_TARGETS" and make it look like that: MXE_TARGETS := i686-w64-mingw32.shared # You can add this line to plugins if you want MXE to use GCC6 # This is currently break NSIS though #override MXE_PLUGIN_DIRS += plugins/gcc6 # And you can add following packages list LOCAL_PKG_LIST := gcc boost zlib sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_ttf ffmpeg minizip qtbase qt intel-tbb nsis # but also we need mxe-i686-w64-mingw32.static-luajit for ERM support # Make sure to uncomment two lines under the list .DEFAULT_GOAL := local-pkg-list local-pkg-list: $(LOCAL_PKG_LIST)
Then you can compile it:
make -j 9
Depend on your hardware that may take from 20 minutes to more than hour.
Compiling VCMI using MXE
First of all create two directories: one for CMake (vcmi-cmake) and other for result build (vcmi-build). Now build would looks like that:
# Clone VCMI repository with submodules git clone --depth 1 --recursive https://github.com/vcmi/vcmi.git # Create CMake directory and cd into it mkdir vcmi-cmake && cd vcmi-cmake # To configure build with launcher: /home/test/mxe/usr/bin/i686-w64-mingw32.shared-cmake ../vcmi # Compile /home/test/mxe/usr/bin/i686-w64-mingw32.shared-cmake --build . -- -j 9 # To create installer # MXE have own patched CPack that allow to pass path to makensis as option. /home/test/mxe/usr/bin/i686-w64-mingw32.shared-cpack -D CPACK_NSIS_EXECUTABLE=/home/test/mxe/usr/bin/i686-w64-mingw32.shared-makensis
Script for automatic builds
If you want to have automatic build you can grab script that automatically compile and upload builds using MXE.