# Building MeshMC ## Prerequisites ### Required Tools | Tool | Minimum Version | Purpose | |---|---|---| | CMake | 3.28 | Build system generator | | Ninja | Any recent | Build executor (recommended) | | C++ Compiler | GCC ≥ 13, Clang ≥ 17, MSVC ≥ 19.36 | C++23 compilation | | JDK | 17 | Building Java launcher components | | Git | Any recent | Submodule management | | pkg-config | Any | Dependency discovery | ### Required Qt6 Modules MeshMC requires Qt 6 with the following modules, as specified in the root `CMakeLists.txt`: ```cmake find_package(Qt6 REQUIRED COMPONENTS Core Widgets Concurrent Network NetworkAuth Test Xml ) ``` ### Required External Libraries | Dependency | Purpose | pkg-config / CMake Name | |---|---|---| | Qt 6 Base | GUI framework | `Qt6Core`, `Qt6Widgets`, etc. | | Qt 6 NetworkAuth | OAuth2 authentication | `Qt6NetworkAuth` | | QuaZip (Qt6) | ZIP archive support | `quazip1-qt6` | | zlib | Compression | `zlib` | | Extra CMake Modules | KDE CMake utilities | `ECM` | | cmark | Markdown rendering | — | | tomlplusplus | TOML parsing | — | | libarchive | Archive extraction | `LibArchive` (CMake) | | libqrencode | QR code generation | — | | scdoc | Man page generation (optional) | — | ## Quick Start with Bootstrap The fastest path to building MeshMC is the bootstrap script at the repository root. It detects your platform, installs missing dependencies, initializes submodules, and configures lefthook git hooks. ### Linux / macOS ```bash cd meshmc/ ../bootstrap.sh ``` Supported distributions: Debian, Ubuntu, Fedora, RHEL/CentOS, openSUSE, Arch Linux, macOS (via Homebrew). ### Windows ```cmd cd meshmc\ ..\bootstrap.cmd ``` Uses Scoop for CLI tools and vcpkg for C/C++ libraries. ## Cloning the Repository MeshMC uses git submodules (notably `libnbtplusplus`). Always clone recursively: ```bash git clone --recursive https://github.com/Project-Tick/MeshMC.git cd MeshMC ``` If you already cloned without `--recursive`: ```bash git submodule update --init --recursive ``` The `libnbtplusplus` submodule lives at `../libnbtplusplus` relative to the `meshmc/` directory and is referenced in the root `CMakeLists.txt`: ```cmake add_subdirectory(${CMAKE_SOURCE_DIR}/../libnbtplusplus libnbtplusplus) ``` ## Distro-Specific Package Installation ### Debian / Ubuntu ```bash sudo apt-get install \ cmake ninja-build extra-cmake-modules pkg-config \ qt6-base-dev libquazip1-qt6-dev zlib1g-dev \ libcmark-dev libarchive-dev libqrencode-dev libtomlplusplus-dev \ scdoc ``` ### Fedora ```bash sudo dnf install \ cmake ninja-build extra-cmake-modules pkgconf \ qt6-qtbase-devel quazip-qt6-devel zlib-devel \ cmark-devel libarchive-devel qrencode-devel tomlplusplus-devel \ scdoc ``` ### Arch Linux ```bash sudo pacman -S --needed \ cmake ninja extra-cmake-modules pkgconf \ qt6-base quazip-qt6 zlib \ cmark libarchive qrencode tomlplusplus \ scdoc ``` ### openSUSE ```bash sudo zypper install \ cmake ninja extra-cmake-modules pkg-config \ qt6-base-devel quazip-qt6-devel zlib-devel \ cmark-devel libarchive-devel qrencode-devel tomlplusplus-devel \ scdoc ``` ### macOS (Homebrew) ```bash brew install \ cmake ninja extra-cmake-modules \ qt@6 quazip zlib \ cmark libarchive qrencode tomlplusplus \ scdoc ``` ### Windows On Windows, use vcpkg for C/C++ dependencies and ensure `VCPKG_ROOT` is set: ```cmd set VCPKG_ROOT=C:\path\to\vcpkg vcpkg install qt6 quazip libarchive zlib cmark ``` Or install Qt via the Qt Online Installer for full module support. ## CMake Presets MeshMC ships `CMakePresets.json` with pre-configured presets for each platform. All presets use the **Ninja Multi-Config** generator and output to the `build/` directory. ### Available Configure Presets | Preset | Platform | Notes | |---|---|---| | `linux` | Linux | Available only on Linux hosts | | `macos` | macOS | Uses vcpkg toolchain (`$VCPKG_ROOT`) | | `macos_universal` | macOS (Universal Binary) | Builds for x86_64 + arm64 | | `windows_mingw` | Windows (MinGW) | Available only on Windows hosts | | `windows_msvc` | Windows (MSVC) | Uses vcpkg toolchain (`$VCPKG_ROOT`) | All presets inherit from a hidden `base` preset which sets: - **Generator:** `Ninja Multi-Config` - **Build directory:** `build/` - **Install directory:** `install/` - **LTO:** Enabled by default (`ENABLE_LTO=ON`) ### Environment Variables | Variable | Used By | Purpose | |---|---|---| | `VCPKG_ROOT` | `macos`, `macos_universal`, `windows_msvc` | Path to vcpkg installation | | `ARTIFACT_NAME` | All (via `base`) | Updater artifact identifier | | `BUILD_PLATFORM` | All (via `base`) | Platform identifier string | ## Building on Linux ### Configure ```bash cmake --preset linux ``` ### Build ```bash cmake --build --preset linux --config Release ``` For a debug build: ```bash cmake --build --preset linux --config Debug ``` Since the generator is `Ninja Multi-Config`, you can switch between `Debug`, `Release`, `RelWithDebInfo`, and `MinSizeRel` without re-configuring. ### Install ```bash cmake --install build --config Release --prefix /usr/local ``` The install layout on Linux follows KDE conventions: - Binary: `bin/meshmc` - Libraries: `lib/` - Data: `share/MeshMC/` - Desktop file: `share/applications/org.projecttick.MeshMC.desktop` - Metainfo: `share/metainfo/org.projecttick.MeshMC.metainfo.xml` - Icon: `share/icons/hicolor/scalable/apps/org.projecttick.MeshMC.svg` - MIME type: `share/mime/packages/org.projecttick.MeshMC.xml` ### Full One-Liner ```bash cmake --preset linux && cmake --build --preset linux --config Release ``` ## Building on macOS ### Prerequisites Ensure `VCPKG_ROOT` is set: ```bash export VCPKG_ROOT="$HOME/vcpkg" ``` ### Standard Build (Native Architecture) ```bash cmake --preset macos cmake --build --preset macos --config Release ``` ### Universal Binary (x86_64 + arm64) ```bash cmake --preset macos_universal cmake --build --preset macos_universal --config Release ``` ### Install ```bash cmake --install build --config Release ``` The macOS install layout creates an application bundle: - `MeshMC.app/Contents/MacOS/` — binaries and plugins - `MeshMC.app/Contents/Frameworks/` — frameworks and libraries - `MeshMC.app/Contents/Resources/` — icons, assets ### macOS-Specific Features - **Sparkle updates** — macOS uses the Sparkle framework for native update UI. The public key and feed URL are configured via CMake: ```cmake set(MACOSX_SPARKLE_UPDATE_PUBLIC_KEY "C0eBoyDSoZbzgCMxQH9wH6kmjU2mPRmvhZZd9mHgqZQ=") set(MACOSX_SPARKLE_UPDATE_FEED_URL "https://projecttick.org/product/meshmc/appcast.xml") ``` - **Asset catalog** — Icons are compiled via `actool` when Xcode ≥ 26.0 is available (liquid glass icons) - **Bundle metadata** — Info.plist values are set via `MACOSX_BUNDLE_*` CMake variables ## Building on Windows ### Using MSVC Requires Visual Studio with C++ workload and vcpkg: ```cmd set VCPKG_ROOT=C:\path\to\vcpkg cmake --preset windows_msvc cmake --build --preset windows_msvc --config Release ``` ### Using MinGW ```cmd cmake --preset windows_mingw cmake --build --preset windows_mingw --config Release ``` ### Install ```cmd cmake --install build --config Release ``` Windows install layout places everything in a flat directory structure. ### Windows-Specific Notes - **MSVC C standard** — C11 is used instead of C23 for MSVC compatibility: ```cmake if(MSVC) set(CMAKE_C_STANDARD 11) else() set(CMAKE_C_STANDARD 23) endif() ``` - **NSIS installer** — An NSIS installer script is generated from `branding/win_install.nsi.in` - **Visual C++ Redistributable** — The NSIS installer can download and install the VC++ runtime automatically - **Resource file** — Windows executable metadata is provided via a `.rc` file generated from `branding/meshmc.rc.in` - **Manifest** — A Windows application manifest is generated for DPI awareness and UAC settings ## Building with Nix MeshMC provides a Nix flake for reproducible builds: ### Using the Nix Flake ```bash # Build the package nix build .#meshmc # Enter the development shell nix develop # Inside the dev shell: cd "$cmakeBuildDir" ninjaBuildPhase ninjaInstallPhase ``` ### Without Flakes ```bash nix-build # or nix-shell ``` ### Binary Cache A binary cache is available to speed up builds: ``` https://meshmc.cachix.org ``` Public key: ``` meshmc.cachix.org-1:6ZNLcfqjVDKmN9/XNWGV3kcjBTL51v1v2V+cvanMkZA= ``` These are already configured in the flake's `nixConfig`. ## Building with Container (Podman/Docker) A `Containerfile` (Debian-based) is provided for CI and reproducible builds: ### Build the Container Image ```bash podman build -t meshmc-build . ``` ### Run a Build Inside the Container ```bash podman run --rm -it -v "$(pwd):/work:z" meshmc-build # Inside the container: git submodule update --init --recursive cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release cmake --build build ``` The container comes with Qt 6.10.2 (installed via `aqtinstall`), Clang, LLD, Ninja, CMake, and all required dependencies pre-installed. ## CMake Options These options can be set during configuration with `-D