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

From VCMI Project Wiki
Jump to: navigation, search
(Build VCMI)
Line 27: Line 27:
 
* C:\Program Files (x86)\VCMI (write protection)
 
* C:\Program Files (x86)\VCMI (write protection)
  
= Clone VCMI =
+
= Preparing place =
 +
== Clone VCMI ==
 
* open SourceTree
 
* open SourceTree
 
* File -> Clone
 
* File -> Clone
Line 34: Line 35:
 
* click '''Clone'''
 
* click '''Clone'''
  
= Install Qt bundle =
+
== Install Qt bundle ==
 
* Run installer
 
* Run installer
 
* Select latest Qt for mingw and mingw 4.8.2 from tools
 
* Select latest Qt for mingw and mingw 4.8.2 from tools
Line 40: Line 41:
 
* Add '''[VCMIBUILD_DIR]/Qt/Tools/mingw482_32/bin''' to '''PATH''' system variable.
 
* Add '''[VCMIBUILD_DIR]/Qt/Tools/mingw482_32/bin''' to '''PATH''' system variable.
  
= Build boost =
+
== Build boost ==
 
* Unpack boost archive
 
* Unpack boost archive
 
<pre>
 
<pre>
Line 54: Line 55:
 
***lib
 
***lib
  
= Unpack SDL2 =
+
== Unpack SDL2 ==
 
* Unpack all SDL2* archives
 
* Unpack all SDL2* archives
 
* Copy content of '''i686-w64-mingw32''' folders from each archive to '''[VCMIBUILD_DIR]/depends'''
 
* Copy content of '''i686-w64-mingw32''' folders from each archive to '''[VCMIBUILD_DIR]/depends'''
Line 65: Line 66:
 
***lib
 
***lib
  
= Create toolchain file =
+
= Compiling =
 +
== Create toolchain file ==
 
Create [VCMIBUILD_DIR]/toolchain.txt
 
Create [VCMIBUILD_DIR]/toolchain.txt
 
<pre>
 
<pre>
Line 85: Line 87:
 
</pre>
 
</pre>
  
= Build ZLib =
+
== Compile ZLib ==
 
* Unpack archive to temp folder, for example, '''[VCMIBUILD_DIR]/zlib/src'''
 
* Unpack archive to temp folder, for example, '''[VCMIBUILD_DIR]/zlib/src'''
 
* Open CMake-gui
 
* Open CMake-gui
Line 106: Line 108:
 
* execute '''mingw32-make install'''
 
* execute '''mingw32-make install'''
  
= Build VCMI =
+
== Compile VCMI ==
 
* Open CMake-gui
 
* Open CMake-gui
 
* Select '''[VCMIBUILD_DIR]/vcmi/source''' as source directory
 
* Select '''[VCMIBUILD_DIR]/vcmi/source''' as source directory

Revision as of 15:15, 10 July 2014

Prerequisites



Create initial directory

Create a directory for VCMI development, eg. C:\VCMI We will call this directory as [VCMIBUILD_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)

Preparing place

Clone VCMI

Install Qt bundle

  • Run installer
  • Select latest Qt for mingw and mingw 4.8.2 from tools
  • Select [VCMIBUILD_DIR]/qt as destination folder
  • Add [VCMIBUILD_DIR]/Qt/Tools/mingw482_32/bin to PATH system variable.

Build boost

  • Unpack boost archive
bootstrap.bat gcc
b2 toolset=gcc --without-python --stage
  • copy stage/lib to [VCMIBUILD_DIR]/boost/lib
  • copy boost dir to [VCMIBUILD_DIR]/boost/boost

So, you should get

  • [VCMIBUILD_DIR]
    • boost
      • boost
      • lib

Unpack SDL2

  • Unpack all SDL2* archives
  • Copy content of i686-w64-mingw32 folders from each archive to [VCMIBUILD_DIR]/depends

So, you should get

  • [VCMIBUILD_DIR]
    • depends
      • bin
      • include
      • lib

Compiling

Create toolchain file

Create [VCMIBUILD_DIR]/toolchain.txt

SET(CMAKE_SYSTEM_NAME Windows)
SWT(VCMIBUILD_DIR [ENTER YOUR VCMIBUILD_DIR PATH])

SET(CMAKE_C_COMPILER   ${VCMIBUILD_DIR}/Qt/Tools/mingw482_32/bin/gcc.exe)
SET(CMAKE_CXX_COMPILER ${VCMIBUILD_DIR}/Qt/Tools/mingw482_32/bin/g++.exe)

SET(ENV{BOOST_ROOT} ${VCMIBUILD_DIR}/boost)

SET(CMAKE_FIND_ROOT_PATH  ${VCMIBUILD_DIR}/depends)
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_FIND_ROOT_PATH})
list(APPEND CMAKE_PREFIX_PATH ${VCMIBUILD_DIR}/Qt/5.3/mingw482_32)

SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)

Compile ZLib

  • Unpack archive to temp folder, for example, [VCMIBUILD_DIR]/zlib/src
  • Open CMake-gui
  • Select [VCMIBUILD_DIR]/zlib/src as source directory
  • Select [VCMIBUILD_DIR]/zlib/bin as binary directory
  • click "Configure"
  • Select "MinGW makefiles" in combobox
  • Select "Specify toolchain file for crosscompiling"
  • Select toolchain file
  • Set variables:
    • INSTALL_BIN_DIR = [VCMIBUILD_DIR]/depends/bin
    • INSTALL_INC_DIR = [VCMIBUILD_DIR]/depends/include
    • INSTALL_LIB_DIR = [VCMIBUILD_DIR]/depends/lib
    • INSTALL_MAN_DIR = [VCMIBUILD_DIR]/depends/share/man
    • INSTALL_PKGCONFIG_DIR = [VCMIBUILD_DIR]/depends/share/pkgconfig
  • click Configure
  • click Generate
  • go to [VCMIBUILD_DIR]/zlib/bin directory
  • execute mingw32-make
  • execute mingw32-make install

Compile VCMI

  • Open CMake-gui
  • Select [VCMIBUILD_DIR]/vcmi/source as source directory
  • Select [VCMIBUILD_DIR]/vcmi/binary as binary directory
  • click "Configure"
  • Select "MinGW makefiles" in combobox
  • Select "Specify toolchain file for crosscompiling"
  • Select toolchain file
  • Set variables:
    • CMAKE_INSTALL_PREFIX = [VCMIBUILD_DIR]/vcmi/result
    • ENABLE_PCH = OFF (because of cc1plus.exe crash)
  • click Configure
  • click Generate
  • go to [VCMIBUILD_DIR]/vcmi/binary directory
  • execute mingw32-make
  • execute mingw32-make install
  • Grab VCMI in [VCMIBUILD_DIR]/vcmi/result folder!