Files
voice-cat/cmake/voicecat-toolchain.cmake
Talon 4f89d2d32d
Some checks failed
Build Linux Binaries / linux/amd64 (push) Has been cancelled
Build Linux Binaries / linux/arm64 (push) Has been cancelled
feat(deploy): Docker + Linux server deployment
Multi-stage Dockerfile (builder → export → runtime) producing a 149 MB
Ubuntu 24.04 image, verified booting end-to-end on Docker Desktop.  vcpkg
fetched via shallow git fetch at the pinned baseline, release-only overlay
triplets (x64-linux, arm64-linux) to halve intermediate disk usage, and
buildtrees deleted within the RUN layer so they never land in the image or
the BuildKit cache.  Binary cache mount (VCPKG_BINARY_SOURCES) makes
subsequent rebuilds restore pre-built packages instead of recompiling.

Also adds:
- docker-compose.yml for one-command local deploy
- .dockerignore (excludes clients/, build/, .git/)
- .github/workflows/build-linux.yml — CI cross-build for amd64 + arm64
  with downloadable artifacts (primary path for building from Windows)
- scripts/build-linux-binaries.sh — local Docker binary extraction fallback
- deploy/linux/voicecat.service — hardened systemd unit for bare-metal
- cmake/voicecat-toolchain.cmake now auto-wires VCPKG_OVERLAY_TRIPLETS

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-21 19:51:43 +02:00

83 lines
3.9 KiB
CMake

# cmake/voicecat-toolchain.cmake — vcpkg toolchain wrapper with auto-triplet.
#
# Wraps vcpkg's toolchain to auto-resolve VCPKG_HOST_TRIPLET and VCPKG_TARGET_TRIPLET
# from the host platform, so the main presets (dev, release, server-release) build on
# Windows/MinGW, Linux, and macOS without per-OS preset variants.
#
# Triplet mapping (auto):
# Windows → x64-mingw-static (the project's toolchain is MSYS2/UCRT64 — see
# clients/windows/README.md; MSVC users must set
# VCPKG_TARGET_TRIPLET=x64-windows explicitly)
# Linux x64 → x64-linux
# Linux arm64 → arm64-linux
# macOS arm64 → arm64-osx (Apple Silicon)
# macOS x64 → x64-osx (Intel)
#
# Cross-compile presets (apple-ios, apple-ios-sim) set VCPKG_TARGET_TRIPLET explicitly
# in their cacheVariables; the DEFINED guards below preserve those. VCPKG_HOST_TRIPLET
# is always the host's (e.g. arm64-osx when cross-compiling iOS on Apple Silicon).
#
# Requires VCPKG_ROOT in the environment (set by the inheriting preset).
# ── Host triplet (the platform running vcpkg / the build) ─────────────────────
if(NOT DEFINED VCPKG_HOST_TRIPLET)
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set(_voicecat_host "x64-mingw-static")
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64|arm64")
set(_voicecat_host "arm64-linux")
else()
set(_voicecat_host "x64-linux")
endif()
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64|arm64")
set(_voicecat_host "arm64-osx")
else()
set(_voicecat_host "x64-osx")
endif()
endif()
if(_voicecat_host)
set(VCPKG_HOST_TRIPLET "${_voicecat_host}" CACHE STRING "vcpkg host triplet (auto-resolved)")
endif()
unset(_voicecat_host)
endif()
# ── Target triplet (the platform being built for) ─────────────────────────────
# Auto-resolve only when not explicitly set. Cross-compile presets (apple-ios,
# apple-ios-sim) set VCPKG_TARGET_TRIPLET in their cacheVariables; the DEFINED
# guard preserves those so they win over the auto-detection.
if(NOT DEFINED VCPKG_TARGET_TRIPLET)
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set(_voicecat_target "x64-mingw-static")
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64|arm64")
set(_voicecat_target "arm64-linux")
else()
set(_voicecat_target "x64-linux")
endif()
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64|arm64")
set(_voicecat_target "arm64-osx")
else()
set(_voicecat_target "x64-osx")
endif()
endif()
if(_voicecat_target)
set(VCPKG_TARGET_TRIPLET "${_voicecat_target}" CACHE STRING "vcpkg target triplet (auto-resolved)")
endif()
unset(_voicecat_target)
endif()
# ── Overlay triplets — project-local overrides take precedence ────────────────
# Enables custom triplets (e.g. release-only x64-linux/arm64-linux, iOS slices)
# without needing to fork vcpkg's built-in ones. Cross-compile presets that
# already set VCPKG_OVERLAY_TRIPLETS explicitly (apple-ios, apple-ios-sim) keep
# their own value via the DEFINED guard.
if(NOT DEFINED VCPKG_OVERLAY_TRIPLETS)
set(VCPKG_OVERLAY_TRIPLETS "${CMAKE_CURRENT_LIST_DIR}/vcpkg-overlays/triplets"
CACHE STRING "vcpkg overlay triplets directory")
endif()
# ── Hand off to the real vcpkg toolchain ──────────────────────────────────────
include("$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")