-
Notifications
You must be signed in to change notification settings - Fork 355
Compiling for MacOS for distribution purposes
This page details how to compile CorsixTH on MacOS so that the resulting .app can be distributed for use by others which involves the process of manually downloading, compiling and installing all dependencies from the command line using Terminal.
Do not use Homebrew as doing so will result in a CorsixTH.app
that will not run on other machines that do not have the dependencies installed.
Xcode and Cmake can just be downloaded and the command line activated.
- Xcode - installed from the App Store
- Xcode command line - installed from the terminal by running
xcode-select --install
- CMake
- Cmake command line - installed from terminal by running
sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install
The source code must be downloaded for the below dependencies. Do not download any pre-compiled binaries intended to be part of a release for MacOS
All downloads can be performed via the command line using Curl or via the GUI using a web browser. Extraction can be performed using tar zxf <name of archive>
or via the GUI. Please note that certain types of archives may require an extractor such as The Unarchiver to be downloaded from the App Store.
- SDL2
- MikMod - must be installed before SDL2 mixer
- ogg - must be installed before Vorbis
- vorbis - must be installed before SDL2 mixer
- flac - must be installed before SDL2 mixer
- mpg123 - must be installed before SDL2 mixer
- SDL2 mixer
- OpenSSL
- Lua
- LuaRocks
- wxWidgets - only for Animview
- FreeType2
- yasm - must be installed before ffmpeg
- ffmpeg
The below are downloaded and installed using Luarocks once that dependency has been installed
- LuaFileSystem
- LPeg
- LuaSocket
Once all dependencies are downloaded and extracted, the source code for each will need to be configured, compiled and installed. In most cases, this is a simple process via the command line using the following commands:
- Move into the extracted directory:
cd /path/to/dependency/directory/
- Configure the source code so it is ready to compile:
./configure
- Compile the source code. Note - the
-j4
flag is used to specify how many CPU cores/thread will be utilised for compiling:
make -j4
- Install the compiled code.
sudo make install
In order for certain dependencies to configure, compile and install correctly, the following amendments to the above steps need to be made:
ogg & vorbis
Use the following command instead of ./configure
:
cmake .
OpenSSL
Use the following command instead of ./configure
:
./Configure darwin64-x86_64-cc no-shared -mmacosx-version-min=10.13
or for Apple Silicon
./Configure darwin64-arm64-cc no-shared -mmacosx-version-min=10.13
Lua
Do not use the ./configure
command and instead of make -j4
, use the command:
MACOSX_DEPLOYMENT_TARGET=10.10 make -j4 macosx test
wxWidgets
Use the following command instead of ./configure
:
CXXFLAGS="-stdlib=libc++ -std=c++11" OBJCXXFLAGS="-stdlib=libc++ -std=c++11" LDFLAGS="-stdlib=libc++" ./configure
FFmpeg
Use the following command instead of ./configure
:
./configure --disable-everything --enable-asm --enable-x86asm --disable-doc --enable-debug --disable-ffmpeg --enable-decoder=smacker --enable-decoder=smackaud --enable-demuxer=smacker --enable-protocol=file --enable-protocol=cache --enable-protocol=pipe --enable-runtime-cpudetect --enable-shared
or for Apple Silicon
./configure --arch=arm64 --disable-everything --enable-asm --disable-doc --enable-debug --disable-ffmpeg --enable-decoder=smacker --enable-decoder=smackaud --enable-demuxer=smacker --enable-protocol=file --enable-protocol=cache --enable-protocol=pipe --enable-runtime-cpudetect --enable-shared
LuaFileSystem, Lpeg and LuaSocket
After installing Luarocks run the following to install all 4 Lua dependencies, adjusting the lua install path if necessary.
sudo -H luarocks install luafilesystem
sudo -H luarocks install lpeg
sudo -H luarocks install luasocket
sudo -H luarocks install luasec
To make universal binary builds in luarocks, enter the following.
luarocks config variables.CC "MACOSX_DEPLOYMENT_TARGET=11.0 SDKROOT=$(xcrun --show-sdk-path) clang -arch x86_64 -arch arm64"
luarocks config variables.LD "MACOSX_DEPLOYMENT_TARGET=11.0 clang -arch x86_64 -arch arm64"
Download and extract the latest version of the source code from from https://github.com/CorsixTH/CorsixTH/releases
or
Get the most up to date source code by running:
git clone https://github.com/CorsixTH/CorsixTH
- Open Cmake.
- Click Browse Source to set the source code directory. This is the directory that was created when the source code was extracted or git-cloned.
- Click Browse Build to set the build directory. This should be an empty or non-existent folder that will be created in the next step.
- Click Configure. If a non-existent directory was specified in the previous step, click Yes in the warning prompt to create it.
- In the window that appears, select Xcode as the generator and leave Use default native compilers selected and click Done.
- A check will then be performed to ensure all dependencies are met. Once this has completed, change the option for
CMAKE_INSTALL_PREFIX
from/usr/local
to/Applications
. - Add to the option
CMAKE_OSX_DEPLOYMENT_TARGET
the value10.13
. - Tick the option
WITH_LUAROCKS
. -
OPTIONAL: Tick the box for
BUILD_ANIMVIEW
if a build of Animview build is also desired. - Click Configure again so all the values become populated and are valid.
- Click Generate and then click Open Project.
- In the menu bar, select Product > Scheme > ALL_BUILD
- Click the Play button in the top left of the Xcode window to build CorsixTH
- If no errors are generated (warnings are fine), in the menu bar, select Product > Scheme > install
- Click the Play button again in the top left of the Xcode window to install CorsixTH (and Animview if selected in Cmake)
-
CorsixTH.app
should now be located in/Applications
.
NOTE: To force a code signature to make CorxixTH run, you may need to run
codesign --force --deep --sign - /Applications/CorsixTH.app