README.md
1# Building Warzone for macOS
2
3## Prerequisites:
4
5> For convenience, you will probably want either [Homebrew](https://brew.sh) or [Macports](https://www.macports.org/install.php) installed for setting up certain prerequisites. If you don't have either yet, **Homebrew** is recommended.
6
7| Building on macOS 10.12-10.14 | Building on macOS 10.15+ |
8| -------------------------------| ------------------------- |
9| Xcode 8 / 9 / 10 | Xcode 11+ |
10| CMake 3.14.1+ | CMake 3.15+ |
11| Gettext | Gettext |
12| Asciidoctor | Asciidoctor |
13| GCC 7+* | |
14
151. **macOS 10.12+**
16 - While building may work on prior versions of macOS, it is only tested on macOS 10.12+.
17
182. **Xcode 8+** (tested w/: Xcode 8.3 - Xcode 11.x)
19 - If you do not have Xcode 8.3+ you can get it for free at the [Mac App Store](https://itunes.apple.com/us/app/xcode/id497799835?mt=12) or [Apple's website](http://developer.apple.com/technology/xcode.html).
20
213. **CMake 3.14.1+** (required to generate the Xcode project)
22 - If you do not have CMake 3.14+, you can [download the latest stable version for free at CMake.org](https://cmake.org/download/#latest).
23
244. **Gettext** (required to compile the translations and language files)
25 - If you have [Homebrew](https://brew.sh) installed, you can use the following command in Terminal:
26 ```shell
27 brew install gettext
28 ```
29 > The build scripts work perfectly with the default (keg-only) Homebrew install of gettext.
30 - If you have [Macports](https://www.macports.org/install.php) installed, you can use the following command in Terminal:
31 ```shell
32 sudo port install gettext
33 ```
34
355. **Asciidoctor** (required to build the documentation / help files)
36 - If you have [Homebrew](https://brew.sh) installed, you can use the following command in Terminal:
37 ```shell
38 brew install asciidoctor
39 ```
40 - If you have [Macports](https://www.macports.org/install.php) installed, you can use the following command in Terminal:
41 ```shell
42 sudo port install asciidoctor
43 ```
44 - Or, via `gem install`:
45 ```shell
46 gem install asciidoctor --no-document
47 ```
48 > Depending on system configuration, `sudo gem install` may be required.
49
506. **GCC** (\*currently required to build vcpkg on macOS < 10.15, and with Xcode < 11)
51 - If you have [Homebrew](https://brew.sh) installed, you can use the following command in Terminal:
52 ```shell
53 brew install gcc
54 ```
55
56## Setup & Configuration:
57
58Generating the macOS port's build environment & configuration requires the following steps in **Terminal**:
59
60### 1. Create a build directory
61
62The recommended place for the build directory is outside of the Git repo / source code.
63
64For example,
65- if you wanted to create a build directory one level up from the Git repo / source code
66- and you cloned the Git repo to `~/src/warzone2100`
67
68you could use the following commands:
69
70```shell
71cd ~/src/
72mkdir wz_build
73```
74
75### 2. Run _configure_mac.cmake_ from the build directory
76
771. `cd` into the build directory you created in the step above
78 ```shell
79 cd wz_build
80 ```
81
822. Run the `configure_mac.cmake` script:
83 ```shell
84 cmake -P "../warzone2100/configure_mac.cmake"
85 ```
86 Where the `../warzone2100/configure_mac.cmake` path should be modified to point to `configure_mac.cmake` inside the Git repo / source code directory.
87
88The `configure_mac.cmake` script will automatically:
89 - Download + extract the Vulkan SDK _(on macOS 10.14+ only - required for Vulkan / Metal support)_
90 - Download + build [vcpkg](https://github.com/microsoft/vcpkg)
91 - Build required dependencies
92 - Run CMake to generate the Xcode project
93
94
95## Building:
96
97The macOS port is built using the Xcode project generated by CMake. If following the instructions above, this will be located in your build directory:
98`<path_to_build_directory>/warzone2100.xcodeproj`
99
100**To build the game from the command-line:**
101
1021. `cd` into your build directory that contains the generated `warzone2100.xcodeproj`
103
1042. Run the following command:
105 ```shell
106 xcodebuild -project warzone2100.xcodeproj -target warzone2100 -configuration Release -destination "platform=macOS"
107 ```
108
109You can also simply open the project in Xcode, and build the `warzone2100` scheme. (You may want to tweak it to build in a Release configuration - the default for that scheme in "Run" mode is Debug, for easier development.)
110
111
112## Deployment:
113
114The macOS port produces a 64-bit [self-contained application bundle](https://developer.apple.com/library/content/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW13) that requires **macOS 10.10+**\* to run.
115
116> \* See _Setup & Configuration_ for how to set the minimum deployment target.
117
118If built on macOS 10.14+, the application will support both the OpenGL and Vulkan (Metal) backends on macOS.
119
120## Additional Information:
121
122The macOS port supports [sandboxing](https://developer.apple.com/library/content/documentation/Security/Conceptual/AppSandboxDesignGuide/AboutAppSandbox/AboutAppSandbox.html), but this requires [code-signing](https://developer.apple.com/library/content/documentation/Security/Conceptual/CodeSigningGuide/Introduction/Introduction.html) to be configured in the Xcode project.
123(By default, code-signing is disabled in the Xcode project.)
124