Difference between revisions of "How to build VCMI (Windows/Vcpkg)"

From VCMI Project Wiki
Jump to: navigation, search
(Update instruction with only [VCMI_DIR] to make it less confusing.)
Line 1: Line 1:
 
= Prerequisites =
 
= Prerequisites =
 +
* Windows Vista or newer.
 
* Microsoft Visual Studio [https://www.visualstudio.com/vs/older-downloads/ 2015] or [http://www.visualstudio.com/downloads/download-visual-studio-vs 2017]
 
* Microsoft Visual Studio [https://www.visualstudio.com/vs/older-downloads/ 2015] or [http://www.visualstudio.com/downloads/download-visual-studio-vs 2017]
 
* Git or git GUI, for example, SourceTree [http://www.sourcetreeapp.com/download download]
 
* Git or git GUI, for example, SourceTree [http://www.sourcetreeapp.com/download download]
Line 6: Line 7:
 
* To create installer: [http://nsis.sourceforge.net/Main_Page NSIS]
 
* To create installer: [http://nsis.sourceforge.net/Main_Page NSIS]
  
= Install dependencies =
+
= Choose directory =
== Choose directory for Vcpkg ==
+
 
 +
Create a directory for VCMI development, eg. '''C:\VCMI'''
 +
We will call this directory as '''[VCMI_DIR]'''
 +
 
 +
'''Warning!''' Replace '''[VCMI_DIR]''' with path you chosen in following commands of this instruction.
  
Choose a directory for Vcpkg, eg. '''C:\vcpkg'''. We will call this directory as '''[VCPKG_DIR]'''.
+
== How to choose good directory ==
  
It is recommended to avoid non-ascii characters in the path to your vcpkg folder. The folder should not be write-protected by system.  
+
It is recommended to avoid non-ascii characters in the path to your working folders. The folder should not be write-protected by system.  
 
Good location:
 
Good location:
* '''C:\vcpkg'''
+
* '''C:\VCMI'''
 
Bad locations:
 
Bad locations:
* '''C:\Users\Michał\vcpkg''' (non-ascii character)
+
* '''C:\Users\Michał\VCMI''' (non-ascii character)
* '''C:\Program Files (x86)\vcpkg''' (write protection)
+
* '''C:\Program Files (x86)\VCMI''' (write protection)
  
 +
= Install dependencies =
  
'''Warning!''' Replace '''[VCPKG_DIR]''' with path you choosen in following commands of this instruction.
+
You have two options: to use pre-built libraries or build your own. We strongly recommend start with using pre-built ones.
  
 
== Option A. Usu pre-built Vcpkg ==
 
== Option A. Usu pre-built Vcpkg ==
You might save a time by using Vcpkg packages pre-built by VCMI team.
+
So you decide to start using Vcpkg packages pre-built by VCMI team.
  
 
Package guaranteed to work since they tested with every commit by [https://ci.appveyor.com/project/vcmi/vcmi AppVeyor]
 
Package guaranteed to work since they tested with every commit by [https://ci.appveyor.com/project/vcmi/vcmi AppVeyor]
Line 41: Line 47:
 
Once extracted "vcpkg" directory will appear with "installed" and "scripts" inside it.
 
Once extracted "vcpkg" directory will appear with "installed" and "scripts" inside it.
  
Move extracted "vcpkg" directory to where you decide to keep your '''[VCPKG_DIR]'''.
+
Move extracted "vcpkg" directory into your '''[VCMI_DIR]'''.
  
 
== Option B. Build Vcpkg on your own ==
 
== Option B. Build Vcpkg on your own ==
Line 52: Line 58:
 
* File -> Clone
 
* File -> Clone
 
* select '''https://github.com/microsoft/vcpkg/''' as source
 
* select '''https://github.com/microsoft/vcpkg/''' as source
* select '''[VCPKG_DIR]''' as destination
+
* select '''[VCMI_DIR]/vcpkg''' as destination
 
* click '''Clone'''
 
* click '''Clone'''
  
From command line cd into '''[VCMI_DIR]''' and use:
+
From command line use:
 
<pre>
 
<pre>
git clone https://github.com/microsoft/vcpkg.git
+
git clone https://github.com/microsoft/vcpkg.git [VCMI_DIR]/vcpkg
 
</pre>
 
</pre>
  
Line 63: Line 69:
 
* Run  
 
* Run  
 
<pre>
 
<pre>
[VCPKG_DIR]/bootstrap-vcpkg.bat
+
[VCMI_DIR]/vcpkg/bootstrap-vcpkg.bat
 
</pre>
 
</pre>
  
Line 69: Line 75:
 
* For 32-bit build run:
 
* For 32-bit build run:
 
<pre>
 
<pre>
[VCPKG_DIR]/vcpkg.exe install minizip:x86-windows sdl2:x86-windows sdl2-image:x86-windows sdl2-ttf:x86-windows sdl2-mixer:x86-windows boost:x86-windows qt5:x86-windows ffmpeg:x86-windows fuzzylite:x86-windows
+
[VCMI_DIR]/vcpkg/vcpkg.exe install minizip:x86-windows sdl2:x86-windows sdl2-image:x86-windows sdl2-ttf:x86-windows sdl2-mixer:x86-windows boost:x86-windows qt5:x86-windows ffmpeg:x86-windows fuzzylite:x86-windows
 
</pre>
 
</pre>
 
* For 64-bit build run
 
* For 64-bit build run
 
<pre>
 
<pre>
[VCPKG_DIR]/vcpkg.exe install minizip:x64-windows sdl2:x64-windows sdl2-image:x64-windows sdl2-ttf:x64-windows sdl2-mixer:x64-windows boost:x64-windows qt5:x64-windows ffmpeg:x64-windows fuzzylite:x64-windows
+
[VCMI_DIR]/vcpkg/vcpkg.exe install minizip:x64-windows sdl2:x64-windows sdl2-image:x64-windows sdl2-ttf:x64-windows sdl2-mixer:x64-windows boost:x64-windows qt5:x64-windows ffmpeg:x64-windows fuzzylite:x64-windows
 
</pre>
 
</pre>
  
 
= Build VCMI =
 
= Build VCMI =
 
== Create initial directory ==
 
Create a directory for VCMI development, eg. '''C:\VCMI'''
 
We will call this directory as '''[VCMI_DIR]'''
 
 
It is recommended to avoid non-ascii characters in the path to your VCMI development folder. The folder should not be write-protected by system.
 
Good location:
 
* '''C:\VCMI'''
 
Bad locations:
 
* '''C:\Users\Michał\VCMI''' (non-ascii character)
 
* '''C:\Program Files (x86)\VCMI''' (write protection)
 
  
 
== Clone VCMI ==
 
== Clone VCMI ==
Line 108: Line 103:
 
'''Visual Studio 2015 - 32-bit build'''
 
'''Visual Studio 2015 - 32-bit build'''
 
<pre>
 
<pre>
cmake ../source -DCMAKE_TOOLCHAIN_FILE=[VCPKG_DIR]/scripts/buildsystems/vcpkg.cmake -G "Visual Studio 14 2015"
+
cmake ../source -DCMAKE_TOOLCHAIN_FILE=[VCMI_DIR]/vcpkg/scripts/buildsystems/vcpkg.cmake -G "Visual Studio 14 2015"
 
</pre>
 
</pre>
  
 
'''Visual Studio 2015 - 64-bit build'''
 
'''Visual Studio 2015 - 64-bit build'''
 
<pre>
 
<pre>
cmake ../source -DCMAKE_TOOLCHAIN_FILE=[VCPKG_DIR]/scripts/buildsystems/vcpkg.cmake -G "Visual Studio 14 2015 Win64"
+
cmake ../source -DCMAKE_TOOLCHAIN_FILE=[VCMI_DIR]/vcpkg/scripts/buildsystems/vcpkg.cmake -G "Visual Studio 14 2015 Win64"
 
</pre>
 
</pre>
  
 
'''Visual Studio 2017 - 32-bit build'''
 
'''Visual Studio 2017 - 32-bit build'''
 
<pre>
 
<pre>
cmake ../source -DCMAKE_TOOLCHAIN_FILE=[VCPKG_DIR]/scripts/buildsystems/vcpkg.cmake -G "Visual Studio 15 2017"
+
cmake ../source -DCMAKE_TOOLCHAIN_FILE=[VCMI_DIR]/vcpkg/scripts/buildsystems/vcpkg.cmake -G "Visual Studio 15 2017"
 
</pre>
 
</pre>
  
 
'''Visual Studio 2017 - 64-bit build'''
 
'''Visual Studio 2017 - 64-bit build'''
 
<pre>
 
<pre>
cmake ../source -DCMAKE_TOOLCHAIN_FILE=[VCPKG_DIR]/scripts/buildsystems/vcpkg.cmake -G "Visual Studio 15 2017 Win64"
+
cmake ../source -DCMAKE_TOOLCHAIN_FILE=[VCMI_DIR]/vcpkg/scripts/buildsystems/vcpkg.cmake -G "Visual Studio 15 2017 Win64"
 
</pre>
 
</pre>
 
   
 
   

Revision as of 08:33, 5 September 2017

Prerequisites

  • Windows Vista or newer.
  • Microsoft Visual Studio 2015 or 2017
  • Git or git GUI, for example, SourceTree download
  • CMake download
  • To unpack pre-build Vcpkg: 7-zip
  • To create installer: NSIS

Choose directory

Create a directory for VCMI development, eg. C:\VCMI We will call this directory as [VCMI_DIR]

Warning! Replace [VCMI_DIR] with path you chosen in following commands of this instruction.

How to choose good directory

It is recommended to avoid non-ascii characters in the path to your working folders. The folder should not be write-protected by system. Good location:

  • C:\VCMI

Bad locations:

  • C:\Users\Michał\VCMI (non-ascii character)
  • C:\Program Files (x86)\VCMI (write protection)

Install dependencies

You have two options: to use pre-built libraries or build your own. We strongly recommend start with using pre-built ones.

Option A. Usu pre-built Vcpkg

So you decide to start using Vcpkg packages pre-built by VCMI team.

Package guaranteed to work since they tested with every commit by AppVeyor

Download and unpack archive

Archives are available from GitHub: https://github.com/vcmi/vcmi-deps-windows/releases

Only download latest version available.

  • vcpkg-export-x86-windows-v140.7z to build for 32-bit
  • vcpkg-export-x64-windows-v140.7z to build for 64-bit

Extract archive by right clicking on it and choosing "7-zip -> Extract Here".

Move dependencies to target directory

Once extracted "vcpkg" directory will appear with "installed" and "scripts" inside it.

Move extracted "vcpkg" directory into your [VCMI_DIR].

Option B. Build Vcpkg on your own

Be aware that building Vcpkg might take a lot of time depend on your CPU model and 10-20GB of disk space.

Create initial directory

Clone vcpkg

From command line use:

git clone https://github.com/microsoft/vcpkg.git [VCMI_DIR]/vcpkg

Build vcpkg

  • Run
[VCMI_DIR]/vcpkg/bootstrap-vcpkg.bat

Build dependencies

  • For 32-bit build run:
[VCMI_DIR]/vcpkg/vcpkg.exe install minizip:x86-windows sdl2:x86-windows sdl2-image:x86-windows sdl2-ttf:x86-windows sdl2-mixer:x86-windows boost:x86-windows qt5:x86-windows ffmpeg:x86-windows fuzzylite:x86-windows
  • For 64-bit build run
[VCMI_DIR]/vcpkg/vcpkg.exe install minizip:x64-windows sdl2:x64-windows sdl2-image:x64-windows sdl2-ttf:x64-windows sdl2-mixer:x64-windows boost:x64-windows qt5:x64-windows ffmpeg:x64-windows fuzzylite:x64-windows

Build VCMI

Clone VCMI

From command line cd into [VCMI_DIR] and use:

git clone -b develop --depth 1 --recursive https://github.com/vcmi/vcmi.git source

Generate solution for VCMI

  • create [VCMI_DIR]/build
  • open [VCMI_DIR]/build in terminal
  • execute command to generate project for:

Visual Studio 2015 - 32-bit build

cmake ../source -DCMAKE_TOOLCHAIN_FILE=[VCMI_DIR]/vcpkg/scripts/buildsystems/vcpkg.cmake -G "Visual Studio 14 2015"

Visual Studio 2015 - 64-bit build

cmake ../source -DCMAKE_TOOLCHAIN_FILE=[VCMI_DIR]/vcpkg/scripts/buildsystems/vcpkg.cmake -G "Visual Studio 14 2015 Win64"

Visual Studio 2017 - 32-bit build

cmake ../source -DCMAKE_TOOLCHAIN_FILE=[VCMI_DIR]/vcpkg/scripts/buildsystems/vcpkg.cmake -G "Visual Studio 15 2017"

Visual Studio 2017 - 64-bit build

cmake ../source -DCMAKE_TOOLCHAIN_FILE=[VCMI_DIR]/vcpkg/scripts/buildsystems/vcpkg.cmake -G "Visual Studio 15 2017 Win64"

Compile VCMI with Visual Studio

  • open [VCMI_DIR]/build/VCMI.sln in Visual Studio
  • select "Release" build type in combobox
  • right click on BUILD_ALL project - build project
  • grab VCMI in [VCMI_DIR]/build/bin folder!

Compile VCMI from command line

From [VCMI_DIR]/build execute followding commands.

For release build

cmake --build . --config Release

For debug build

cmake --build . --config Debug

Debug will be used by default even "--config" if not specified.

Create VCMI installer

Make sure NSIS is installed to default directory or have registry entry so CMake can find it.

After you build VCMI execute following command from [VCMI_DIR]/build.

Execute following if you build for Release:

cpack

If you want debug build:

cpack -C Debug