Files
faumaray bba5c8a39a initial commit
Signed-off-by: Aleksey Selihov <faumaray@gmail.com>
2026-05-22 02:40:32 +03:00

26 lines
997 B
CMake

# Toolchain: zig cc targeting x86_64-linux-musl (static musl libc)
# Use this file to produce a statically-linked Linux binary with no glibc dep:
#
# cmake -B build-linux -DCMAKE_TOOLCHAIN_FILE=cmake/zigcc/linux-musl.cmake
#
# The resulting binary runs on any x86_64 Linux without any shared library
# dependencies beyond the kernel ABI.
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
find_program(_ZIG_EXE zig REQUIRED)
set(CMAKE_C_COMPILER "${_ZIG_EXE}" CACHE FILEPATH "")
set(CMAKE_CXX_COMPILER "${_ZIG_EXE}" CACHE FILEPATH "")
set(CMAKE_C_COMPILER_ARG1 "cc;-target;x86_64-linux-musl" CACHE STRING "")
set(CMAKE_CXX_COMPILER_ARG1 "c++;-target;x86_64-linux-musl" CACHE STRING "")
# Produce fully-static binaries (no dynamic linking at all).
set(CMAKE_EXE_LINKER_FLAGS_INIT "-static")
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-static")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)