BuildingOnMac.wiki
author Wuzzy
Sat, 12 Oct 2019 16:27:19 +0100
changeset 2030 1c0077fa2f65
parent 1978 8aa416c2647a
permissions -rw-r--r--
GameStyles: Pointless!
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1963
1175d2f6f198 Rename “Mac OS” to “macOS”
Wuzzy <almikes@aol.com>
parents: 1497
diff changeset
     1
#summary Instructions for building Hedgewars on macOS
117
5c10784de5cb notes added
vittorio.giovara@gmail.com
parents: 116
diff changeset
     2
#labels Phase-Implementation,Phase-Deploy,Phase-Support
25
4f6f055c0848 Created wiki page through web user interface.
vittorio.giovara@gmail.com
parents:
diff changeset
     3
1963
1175d2f6f198 Rename “Mac OS” to “macOS”
Wuzzy <almikes@aol.com>
parents: 1497
diff changeset
     4
= Building on macOS =
1975
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
     5
Also known as OS X or Mac OS X.
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
     6
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
     7
*Note:* These instructions were run on OS X 10.11 and backwards compiled for OS X 10.8 (Aug 2019). Newer versions will likely work but may require some adaptation.
1497
7a5b840a3dd4 BuildingOnMac: Warning about outdated info
Wuzzy
parents: 1080
diff changeset
     8
755
7ba641398b3e BuildingOnMac: Add title, fix header levels
Wuzzy
parents: 335
diff changeset
     9
== Prerequisites ==
25
4f6f055c0848 Created wiki page through web user interface.
vittorio.giovara@gmail.com
parents:
diff changeset
    10
1975
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    11
=== Required Build Dependencies ===
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    12
1976
c764a1bf5795 BuildingOnMac: Formatting tweaks
Wuzzy
parents: 1975
diff changeset
    13
Homebrew ([https://brew.sh/]) can be used to gather many of these dependencies, but is not required. All can be found as installers, frameworks, or built manually without Homebrew.
1975
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    14
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    15
Unless otherwise specified, latest versions of the following dependencies can be used.
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    16
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    17
==== Compilers and Environment ====
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    18
1977
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    19
 * Xcode command-line tools
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    20
 * CMake 3.9 or later
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    21
 * fpc 2.6.x OR fpc 3.1.1+ (nothing in between, due a crashing bug)
1975
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    22
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    23
==== Libraries ====
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    24
1976
c764a1bf5795 BuildingOnMac: Formatting tweaks
Wuzzy
parents: 1975
diff changeset
    25
Libraries can be dynamically linked libraries (`.dylib`) or Apple frameworks (`.framework`). All must be on the system library or framework paths for CMake to find them. Frameworks can be put in your home directory at `~/Library/Frameworks`.
1975
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    26
1977
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    27
 * Qt 5.9.x or later (unified installer works)
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    28
 * SDL2
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    29
 * SDL2_image (2.0.4 works, 2.0.5 might be buggy)
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    30
 * SDL2_mixer
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    31
 * SDL2_net
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    32
 * SDL2_ttf
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    33
 * Ogg
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    34
 * Vorbis
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    35
 * libpng 1.6.x
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    36
 * physfs 3.0.x
1975
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    37
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    38
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    39
==== Notes ====
1977
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    40
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    41
 # Other dependencies are linked with the SDL2 libraries, but not specifically used in Hedgewars. They may include:
1978
8aa416c2647a BuildingOnMac: More formatting (3)
Wuzzy
parents: 1977
diff changeset
    42
  * !FreeType
1975
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    43
  * FLAC
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    44
  * Opus
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    45
  * GLEW
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    46
  * modplug
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    47
  * mpg123
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    48
  * webp
1977
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    49
 # Good places to find required frameworks are found in the development packages for the various SDL2 libraries. They are found in the `Frameworks` subdirectory within the .framework itself. Example: `SDL2_ttf.framework/Frameworks/FreeType.framework`
1978
8aa416c2647a BuildingOnMac: More formatting (3)
Wuzzy
parents: 1977
diff changeset
    50
 # Another good place for the frameworks/libraries are in the `Hedgewars.app` of a previous version (E.g. Hedgewars 1.0.0 Beta 2)
1975
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    51
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    52
=== Optional Dependencies ===
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    53
1978
8aa416c2647a BuildingOnMac: More formatting (3)
Wuzzy
parents: 1977
diff changeset
    54
By default, the following optional features are turned on in the build system, and require the following dependencies:
1975
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    55
1977
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    56
 * Video recording
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    57
   * ffmpeg 4.2 (later versions are untested)
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    58
     * yasm 1.3+
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    59
 * Automatic updates
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    60
   * Sparkle
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    61
 * hedgewar-server
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    62
   * ghc, cabal (Haskell)
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    63
     * xz
1975
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    64
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    65
==== Haskell Installation ====
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    66
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    67
Steps to get the Haskell environment set up for compiling hedgewars-server:
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    68
1977
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    69
 # Install ghc, cabal with instructions at https://www.haskell.org/ghcup/
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    70
 # Load ghc environment: `source ~/.ghcup/env`
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    71
 # Install cabal-uninstall: `cabal install cabal-uninstall`
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    72
 # Install haskell packages: `cabal install vector bytestring 'network < 2.7' time mtl sandi 'hslogger < 1.3' process utf8-string SHA entropy zlib random regex-tdfa deepseq`
1975
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    73
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    74
`cabal-uninstall` is for when you accidentally install newer package versions that don't work with hedgewars-server (e.g. hslogger-1.3.0.0)
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    75
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    76
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    77
== Building Hedgewars ==
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    78
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    79
=== Environment Setup ===
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    80
1977
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    81
 * Set macOS version to target for Xcode tools. The earlier, the better:
1975
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    82
{{{
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    83
export MACOSX_DEPLOYMENT_TARGET=10.8
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    84
}}}
1977
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
    85
 * (Optional) Load haskell environment:
1975
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    86
{{{
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    87
source ~/.ghcup/env
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    88
}}}
1978
8aa416c2647a BuildingOnMac: More formatting (3)
Wuzzy
parents: 1977
diff changeset
    89
 * Create (`mkdir`) a `build` subdirectory in the Hedgewars source code
1975
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    90
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    91
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    92
=== Build ===
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    93
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    94
CMake is used to manage the build process, and is run with different flags depending on which optional dependencies you have elected to install.
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    95
1976
c764a1bf5795 BuildingOnMac: Formatting tweaks
Wuzzy
parents: 1975
diff changeset
    96
Take note of where Qt is installed; it is a required build flag (see below).
1975
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    97
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    98
Steps to build:
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    99
1977
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
   100
 # `cd /path/to/hg/hedgewars/build`
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
   101
 # `cmake .. -DCMAKE_PREFIX_PATH=/Users/user/Qt/5.9.8/clang_64/ -DCMAKE_BUILD_TYPE=Release`
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
   102
 # `make -j2`
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
   103
 # `make install`
1975
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
   104
1976
c764a1bf5795 BuildingOnMac: Formatting tweaks
Wuzzy
parents: 1975
diff changeset
   105
A `Hedgewars.app` file will be created in the same folder you ran CMake.
1975
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
   106
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
   107
To build the DMG, also run:
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
   108
1977
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
   109
 * `make dmg`
25
4f6f055c0848 Created wiki page through web user interface.
vittorio.giovara@gmail.com
parents:
diff changeset
   110
755
7ba641398b3e BuildingOnMac: Add title, fix header levels
Wuzzy
parents: 335
diff changeset
   111
==== Notes ====
116
1c3643e4f6c5 Edited wiki page BuildingOnMac through web user interface.
vittorio.giovara@gmail.com
parents: 113
diff changeset
   112
1977
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
   113
 * To build a debug build, use the flag `-DCMAKE_BUILD_TYPE=Debug` instead of the `Release` one
12b6619171bb BuildingOnMac: More formatting (2)
Wuzzy
parents: 1976
diff changeset
   114
 * To build a minimum-features build, use the additional flags of `-DNOSERVER=1`, `-DNOVIDEOREC=1`, and `-DNOAUTOUPDATE=1`, for disabling of hedgewars-server, video recording, and Sparkle autoupdating, respectively.
1978
8aa416c2647a BuildingOnMac: More formatting (3)
Wuzzy
parents: 1977
diff changeset
   115
 * The build uses CMake !BundleUtilities which automatically deploys all libraries and dependencies  into the `.app`, and repairs the `RPATH` of each library and binary as needed. If there is a missing dependency, the `make install` portion of the build will fail. The fix is usually to find the correct `.framework` and put in on library path, then run `make dmg` again.
25
4f6f055c0848 Created wiki page through web user interface.
vittorio.giovara@gmail.com
parents:
diff changeset
   116
1963
1175d2f6f198 Rename “Mac OS” to “macOS”
Wuzzy <almikes@aol.com>
parents: 1497
diff changeset
   117
Enjoy!