| 1 | # Building with CMake |
| 2 | |
| 3 | ## Linux and macOS |
| 4 | |
| 5 | [**fheroes2**](README.md) can be built with CMake buildsystem. First, you need to install dependencies. |
| 6 | For Linux and macOS follow to instructions as described above. |
| 7 | |
| 8 | Next, you can configure the project with following commands: |
| 9 | |
| 10 | ```shell |
| 11 | cmake -B build |
| 12 | ``` |
| 13 | |
| 14 | After configuration let's build the project: |
| 15 | |
| 16 | ```shell |
| 17 | cmake --build build |
| 18 | ``` |
| 19 | |
| 20 | After building, executable can be found in `build` directory. |
| 21 | |
| 22 | ## Windows / Visual Studio |
| 23 | |
| 24 | For Windows you'll need Visual Studio 2019 with C++ support and |
| 25 | [vcpkg package manager](https://vcpkg.readthedocs.io/en/latest/) for dependency management. |
| 26 | Here quick and short instruction for deployment: |
| 27 | |
| 28 | ```shell |
| 29 | # Clone vcpkg repository. For convenient, let's place it in C:\vcpkg directory, but it can be anywhere. |
| 30 | git clone https://github.com/microsoft/vcpkg.git |
| 31 | # Now initialize manager |
| 32 | .\vcpkg\bootstrap-vcpkg.bat |
| 33 | ``` |
| 34 | |
| 35 | Your vcpkg is ready to install external libraries. Assuming that you use x64 system, let's install all needed dependencies: |
| 36 | |
| 37 | ```shell |
| 38 | .\vcpkg\vcpkg --triplet x64-windows install sdl2 sdl2-image sdl2-mixer zlib |
| 39 | ``` |
| 40 | |
| 41 | If you planning to develop fheroes2 with Visual Studio, you may want to integrate vcpkg with it (requires elevated admin privileges). |
| 42 | After following command Visual Studio automagically will find all required dependencies: |
| 43 | |
| 44 | ```shell |
| 45 | .\vcpkg\vcpkg integrate install |
| 46 | ``` |
| 47 | |
| 48 | Now you are ready to configure the project. cd to fheroes2 directory and run `cmake` command (note for `-DCMAKE_TOOLCHAIN_FILE` and |
| 49 | `-DVCPKG_TARGET_TRIPLET` options): |
| 50 | |
| 51 | ```shell |
| 52 | cmake -B build -DCMAKE_TOOLCHAIN_FILE="C:\vcpkg\scripts\buildsystems\vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows |
| 53 | ``` |
| 54 | |
| 55 | After configuration let's build the project: |
| 56 | |
| 57 | ```shell |
| 58 | cmake --build build --config Release |
| 59 | ``` |
| 60 | |
| 61 | After building, executable can be found in `build\Release` directory. |
| 62 | |
| 63 | ## Using Demo Data |
| 64 | |
| 65 | CMake project allows to download and install original HoMM II Demo files which used by fheroes2 project. |
| 66 | To do this please add `-DGET_HOMM2_DEMO=ON` to configuration options. For example: |
| 67 | |
| 68 | ```shell |
| 69 | cmake -B build -DGET_HOMM2_DEMO=ON <some other options> |
| 70 | ``` |