Difference between revisions of "How to build VCMI (Windows/Cmake/MSVC)"
From VCMI Project Wiki
(→Create toolchain file) |
(→Compiling) |
||
Line 84: | Line 84: | ||
</pre> | </pre> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Compile VCMI == | == Compile VCMI == | ||
Line 104: | Line 90: | ||
* Select '''[VCMIBUILD_DIR]/vcmi/binary''' as binary directory | * Select '''[VCMIBUILD_DIR]/vcmi/binary''' as binary directory | ||
* click "Configure" | * click "Configure" | ||
− | * Select " | + | * Select "Visual Studio 12 2013" in combobox |
* Select "Specify toolchain file for crosscompiling" | * Select "Specify toolchain file for crosscompiling" | ||
* Select toolchain file | * Select toolchain file | ||
* Set variables: | * Set variables: | ||
** CMAKE_INSTALL_PREFIX = '''[VCMIBUILD_DIR]/vcmi/result''' | ** CMAKE_INSTALL_PREFIX = '''[VCMIBUILD_DIR]/vcmi/result''' | ||
− | |||
* click '''Configure''' | * click '''Configure''' | ||
* click '''Generate''' | * click '''Generate''' | ||
* go to '''[VCMIBUILD_DIR]/vcmi/binary''' directory | * go to '''[VCMIBUILD_DIR]/vcmi/binary''' directory | ||
− | * | + | * open '''VCMI.sln in visual studio''' |
− | * | + | * select "Release" build type in combobox |
+ | * right click on "BUILD_ALL" - build project | ||
+ | * right click on "INSTALL" - build project | ||
* Grab VCMI in '''[VCMIBUILD_DIR]/vcmi/result''' folder! | * Grab VCMI in '''[VCMIBUILD_DIR]/vcmi/result''' folder! | ||
Revision as of 16:11, 12 October 2014
Prerequisites
- HoMM 3 (can be bought at gog.com)
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
- open SourceTree
- File -> Clone
- select https://github.com/vcmi/vcmi/ as source
- select [VCMIBUILD_DIR]/vcmi/source as destination
- click Clone
Install Boost bundle
- Run installer
- Select [VCMIBUILD_DIR]/boost as destination folder
- Install
Install Qt bundle
- Run installer
- Select latest Qt for MSVC 2013 (12)
- Select [VCMIBUILD_DIR]/qt as destination folder
- Install
Unpack libraries
- Download libraries pack and unpack it in [VCMIBUILD_DIR]/depends folder
So, you should get
- [VCMIBUILD_DIR]
- depends
- bin
- include
- lib
- depends
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 cl) SET(CMAKE_CXX_COMPILER cl) set(CMAKE_RC_COMPILER rc) SET(ENV{BOOST_ROOT} ${VCMIBUILD_DIR}/boost) SET(ENV{BOOST_LIBRARYDIR} ${VCMIBUILD_DIR}/lib32-msvc-12.0) 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/msvc2013) 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 VCMI
- Open CMake-gui
- Select [VCMIBUILD_DIR]/vcmi/source as source directory
- Select [VCMIBUILD_DIR]/vcmi/binary as binary directory
- click "Configure"
- Select "Visual Studio 12 2013" in combobox
- Select "Specify toolchain file for crosscompiling"
- Select toolchain file
- Set variables:
- CMAKE_INSTALL_PREFIX = [VCMIBUILD_DIR]/vcmi/result
- click Configure
- click Generate
- go to [VCMIBUILD_DIR]/vcmi/binary directory
- open VCMI.sln in visual studio
- select "Release" build type in combobox
- right click on "BUILD_ALL" - build project
- right click on "INSTALL" - build project
- Grab VCMI in [VCMIBUILD_DIR]/vcmi/result folder!
Appendix A. Libraries compilation
How to compile ZLib yourself
- 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
How to compile FFmpeg yourself
- Download Msys (link) and unpack it to [VCMIBUILD_DIR]/msys
- Download Yasm (link) and unpack it to [VCMIBUILD_DIR]/msys/bin
- Download FFmpeg source tarball and unpack it to temp folder, for example, [VCMIBUILD_DIR]/ffmpeg/source
- Open [VCMIBUILD_DIR]/msys/msys.bat
- Go to /c/[VCMIBUILD_DIR]/ffmpeg/source folder
./configure --disable-doc --enable-shared --prefix=/c/[VCMIBUILD_DIR]/depends make make install