< Documentation / Building on macOS
sudo xcode-select --installbrew install --cask cmake or get from https://cmake.org/download/brew install ninja or get it from https://github.com/ninja-build/ninja/releasesbrew install ccacheClone https://github.com/vcmi/vcmi with submodules. Example for command line:
git clone --recurse-submodules https://github.com/vcmi/vcmi.git
There're 2 ways to get dependencies automatically.
Please find detailed instructions in VCMI repository. Note that the link points to the cutting-edge state in develop branch, for the latest release check the same document in the master branch.
On the step where you need to replace PROFILE, choose:
macos-intelmacos-armNote: if you wish to build 1.0 release in non-Release configuration, you should define USE_CONAN_WITH_ALL_CONFIGS=1 environment variable when executing conan install.
brew install boost minizip sdl2 sdl2_image sdl2_mixer sdl2_ttf tbbbrew install ffmpeg@4brew install qt@5 for Qt 5 or brew install qt for Qt 6This applies only to Xcode-based toolchain. If xcrun -f clang prints errors, then use either of the following ways:
xcode-select utility to set Xcode or Xcode Command Line Tools path: for example, sudo xcode-select -s /Library/Developer/CommandLineToolsDEVELOPER_DIR environment variable pointing to Xcode or Xcode Command Line Tools path: for example, export DEVELOPER_DIR=/Applications/Xcode.appNote that if you wish to use Qt Creator IDE, you should skip this step and configure respective variables inside the IDE.
cd to the source code directorycmake -S . -B BUILD_DIR where BUILD_DIR can be any path, don't press Return-G 'Unix Makefiles'-G Ninja-G XcodeCMAKE_BUILD_TYPE option, for example: -D CMAKE_BUILD_TYPE=Release. If you don't pass this option, RelWithDebInfo will be used.-D ENABLE_LAUNCHER=OFF-Wno-dev if you're not interested in CMake developer warnings-D CMAKE_TOOLCHAIN_FILE=conan-generated/conan_toolchain.cmake where conan-generated must be replaced with your directory choice-D "CMAKE_PREFIX_PATH=" variable. See below what you can insert after = (but before the closing quote), multiple values must be separated with ; (semicolon):
$(brew --prefix ffmpeg@4)$(brew --prefix qt@5)/Users/kambala/dev/Qt-libs/5.15.2/Clang64-D "CMAKE_PREFIX_PATH=$(brew --prefix ffmpeg@4);$(brew --prefix qt@5)"-D ENABLE_CCACHE=ONYou must also install game files to be able to run the built version, see Installation on macOS.
Open VCMI.xcodeproj from the build directory, select vcmiclient scheme and hit Run (Cmd+R). To build Launcher, select vcmilauncher scheme instead.
cmake --build <path to build directory>
-- -j$(sysctl -n hw.ncpu) to the above--config <configuration name> to the above, for example: --config DebugAfter building, run cpack from the build directory. If using Xcode generator, also pass -C with the same configuration that you used to build the project.
If you use Conan, it's expected that you use conan-generated directory at step 4 of Conan package manager.
You can run VCMI from DMG, but it's will also work from your IDE be it Xcode or Qt Creator.
Alternatively you can run binaries directly from the bin directory:
CMake include commands to copy all needed assets from source directory into the bin directory on each build. They'll work when you build from Xcode too.
Anyone who might want to debug builds, but new to macOS could find following commands useful:
hdiutil attach vcmi-1.0.dmghdiutil detach /Volumes/vcmi-1.0otool -L /Volumes/vcmi-1.0/VCMI.app/Contents/MacOS/vcmiclientLC_RPATH: otool -l /Volumes/vcmi-1.0/VCMI.app/Contents/MacOS/vcmiclientIn case of troubles you can always consult our CI build scripts or contact the dev team via slack.