BuildingOnMac.wiki
author Wuzzy
Wed, 18 Sep 2019 00:31:55 +0100
changeset 1976 c764a1bf5795
parent 1975 05c417d4d891
child 1977 12b6619171bb
permissions -rw-r--r--
BuildingOnMac: Formatting tweaks
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
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    19
  * Xcode command line tools
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    20
  * CMake 3.9 or later
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    21
  * fpc 2.6.x OR fpc 3.1.1+ (nothing in between, due a crashing bug)
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
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    27
  * Qt 5.9.x or later (unified installer works)
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    28
  * SDL2
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    29
  * SDL2_image (2.0.4 works, 2.0.5 might be buggy)
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    30
  * SDL2_mixer
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    31
  * SDL2_net
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    32
  * SDL2_ttf
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    33
  * Ogg
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    34
  * Vorbis
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    35
  * libpng 1.6.x
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    36
  * physfs 3.0.x
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 ====
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    40
# Other dependencies are linked with the SDL2 libraries, but not specifically used in Hedgewars. They may include:
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    41
  * FreeType
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    42
  * FLAC
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    43
  * Opus
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    44
  * GLEW
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    45
  * modplug
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    46
  * mpg123
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    47
  * webp
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    48
# 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`
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    49
# Another good place for the frameworks/libraries are in the Hedgewars.app of a previous version (E.g. Hedgewars 1.0.0 Beta 2)
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    50
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    51
=== Optional Dependencies ===
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    52
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    53
By default, the following optional features are turned on in the build system, and require the following dependencies.
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    54
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    55
  * Video recording
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    56
    * ffmpeg 4.2 (later versions are untested)
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    57
      * yasm 1.3+
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    58
  * Automatic updates
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    59
    * Sparkle
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    60
  * hedgewar-server
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    61
    * ghc, cabal (Haskell)
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    62
      * xz
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    63
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    64
==== Haskell Installation ====
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    65
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    66
Steps to get the Haskell environment set up for compiling hedgewars-server:
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    67
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    68
# Install ghc, cabal with instructions at https://www.haskell.org/ghcup/
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    69
# Load ghc environment: `source ~/.ghcup/env`
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    70
# Install cabal-uninstall: `cabal install cabal-uninstall`
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    71
# 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`
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    72
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    73
`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
    74
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    75
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    76
== Building Hedgewars ==
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    77
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    78
=== Environment Setup ===
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    79
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    80
  * Set macOS version to target for Xcode tools. The earlier the better:
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    81
{{{
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    82
export MACOSX_DEPLOYMENT_TARGET=10.8
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    83
}}}
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    84
  * (Optional) Load haskell environment:
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    85
{{{
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    86
source ~/.ghcup/env
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    87
}}}
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    88
  * Create (mkdir) a `build` subdirectory in the hedgewars source code
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    89
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    90
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    91
=== Build ===
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    92
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    93
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
    94
1976
c764a1bf5795 BuildingOnMac: Formatting tweaks
Wuzzy
parents: 1975
diff changeset
    95
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
    96
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    97
Steps to build:
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    98
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
    99
# `cd /path/to/hg/hedgewars/build`
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
   100
# `cmake .. -DCMAKE_PREFIX_PATH=/Users/user/Qt/5.9.8/clang_64/ -DCMAKE_BUILD_TYPE=Release`
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
   101
# `make -j2`
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
   102
# `make install`
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
   103
1976
c764a1bf5795 BuildingOnMac: Formatting tweaks
Wuzzy
parents: 1975
diff changeset
   104
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
   105
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
   106
To build the DMG, also run:
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
   107
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
   108
# `make dmg`
25
4f6f055c0848 Created wiki page through web user interface.
vittorio.giovara@gmail.com
parents:
diff changeset
   109
755
7ba641398b3e BuildingOnMac: Add title, fix header levels
Wuzzy
parents: 335
diff changeset
   110
==== Notes ====
116
1c3643e4f6c5 Edited wiki page BuildingOnMac through web user interface.
vittorio.giovara@gmail.com
parents: 113
diff changeset
   111
1975
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
   112
# To build a debug build, use the flag `-DCMAKE_BUILD_TYPE=Debug` instead of the `Release` one
05c417d4d891 Update macOS building instructions
raptor
parents: 1963
diff changeset
   113
# 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.
1976
c764a1bf5795 BuildingOnMac: Formatting tweaks
Wuzzy
parents: 1975
diff changeset
   114
# 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
   115
1963
1175d2f6f198 Rename “Mac OS” to “macOS”
Wuzzy <almikes@aol.com>
parents: 1497
diff changeset
   116
Enjoy!