mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-28 01:51:43 +00:00
Add a ghostty_vt_add_target() CMake function that lets downstream projects build libghostty-vt for a specific Zig target triple. The function encapsulates zig discovery, build-type-to-optimize mapping, the zig build invocation, and output path conventions so consumers do not need to duplicate any of that logic. It creates named IMPORTED targets (e.g. ghostty-vt-static-linux-amd64) that work alongside the existing native ghostty-vt and ghostty-vt-static targets. The build-type mapping is factored into a shared _GHOSTTY_ZIG_OPT_FLAG variable used by both the native build and the new function. The static library targets now propagate c++ as a link dependency on non-Windows platforms, fixing link failures when consumers use static linking with the default SIMD-enabled build. A new example/c-vt-cmake-cross/ demonstrates end-to-end cross- compilation using zig cc as the C compiler, auto-detecting a cross target based on the host OS.
22 lines
518 B
Markdown
22 lines
518 B
Markdown
# c-vt-cmake-cross
|
|
|
|
Demonstrates using `ghostty_vt_add_target()` to cross-compile
|
|
libghostty-vt with static linking. The target OS is chosen automatically:
|
|
|
|
| Host | Target |
|
|
| ------- | --------------- |
|
|
| Linux | Windows (MinGW) |
|
|
| Windows | Linux (glibc) |
|
|
| macOS | Linux (glibc) |
|
|
|
|
Override with `-DZIG_TARGET=...` if needed.
|
|
|
|
## Building
|
|
|
|
```shell-session
|
|
cd example/c-vt-cmake-cross
|
|
cmake -B build -DFETCHCONTENT_SOURCE_DIR_GHOSTTY=../..
|
|
cmake --build build
|
|
file build/c_vt_cmake_cross
|
|
```
|