Difference between revisions of "How to build VCMI (Linux/Cmake/MXE)"

From VCMI Project Wiki
Jump to: navigation, search
(Basic contents)
 
(Setting up a MXE cross compiler)
(16 intermediate revisions by the same user 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 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.
+
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.
  
 
= Setting up a MXE cross compiler =
 
= Setting up a MXE cross compiler =
Line 6: Line 6:
  
 
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 using git]. Then you need to edit "settings.mk" file:
<pre># Uncomment "MXE_TARGETS" and make it look like that:
+
<pre># "settings.mk" not exist by default
MXE_TARGETS := i686-w64-mingw32.shared</pre>
+
# 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 nsis
 +
# 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 -j 9 gcc boost zlib sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_ttf ffmpeg qt5</pre>
+
<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.
 
Removing "Qt 5" that only used for launcher will drastically reduce compile time:
 
<pre>make -j 9 gcc boost zlib sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_ttf ffmpeg</pre>
 
  
 
= Compiling VCMI using MXE =
 
= 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:
 
First of all create two directories: one for CMake (vcmi-cmake) and other for result build (vcmi-build). Now build would looks like that:
<pre>git clone https://github.com/vcmi/vcmi.git
+
<pre># Clone VCMI repository with submodules
# To build without launcher:
+
git clone --depth 1 --recursive https://github.com/vcmi/vcmi.git
cmake ../vcmi -DCMAKE_TOOLCHAIN_FILE=/home/test/mxe/usr/i686-w64-mingw32.shared/share/cmake/mxe-conf.cmake -DCMAKE_INSTALL_PREFIX=/home/test/vcmi-build -DENABLE_LAUNCHER=0
+
 
# With launcher:
+
# Create CMake directory and cd into it
cmake ../vcmi -DCMAKE_TOOLCHAIN_FILE=/home/test/mxe/usr/i686-w64-mingw32.shared/share/cmake/mxe-conf.cmake -DCMAKE_INSTALL_PREFIX=/home/test/vcmi-build
+
mkdir vcmi-cmake && cd vcmi-cmake
 +
 
 +
# To configure build with launcher:
 +
/home/test/mxe/usr/bin/i686-w64-mingw32.shared-cmake ../vcmi -DENABLE_TEST=0
 +
 
 +
# 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 =
 +
If you want to have automatic build you can grab script that automatically compile and upload builds using MXE.
  
make -j 9</pre>
+
*[https://gist.github.com/ArseniyShestakov/39261e5d268cd7c021b0 Download it from Github Gist].
Now you can see build
 

Revision as of 22:24, 20 August 2017

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.

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 using git. 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 nsis
# 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 -DENABLE_TEST=0

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