Files
ghostty/dist/cmake
Mitchell Hashimoto 5a46e61bee cmake: fix Windows build support
On Windows, shared libraries (DLLs) require an import library (.lib)
for linking, and the DLL itself is placed in bin/ rather than lib/ by
the Zig build. The CMake wrapper was missing IMPORTED_IMPLIB on the
shared imported target, causing link failures, and assumed the shared
library was always in lib/.

Add GHOSTTY_VT_IMPLIB for the import library name, set IMPORTED_IMPLIB
on the ghostty-vt target, and fix the shared library path to use bin/
on Windows. Install the DLL and PDB to bin/ and the import library to
lib/ following standard Windows conventions. Apply the same fixes to
ghostty-vt-config.cmake.in for the find_package path.
2026-03-23 10:31:11 -07:00
..

CMake Support for libghostty-vt

The top-level CMakeLists.txt wraps the Zig build system so that CMake projects can consume libghostty-vt without invoking zig build manually. Running cmake --build triggers zig build -Demit-lib-vt automatically.

This means downstream projects do require a working Zig compiler on PATH to build, but don't need to know any Zig-specific details.

Add the following to your project's CMakeLists.txt:

include(FetchContent)
FetchContent_Declare(ghostty
    GIT_REPOSITORY https://github.com/ghostty-org/ghostty.git
    GIT_TAG main
)
FetchContent_MakeAvailable(ghostty)

add_executable(myapp main.c)
target_link_libraries(myapp PRIVATE ghostty-vt)

This fetches the Ghostty source, builds libghostty-vt via Zig during your CMake build, and links it into your target. Headers are added to the include path automatically.

Using a local checkout

If you already have the Ghostty source checked out, skip the download by pointing CMake at it:

cmake -B build -DFETCHCONTENT_SOURCE_DIR_GHOSTTY=/path/to/ghostty
cmake --build build

Using find_package (install-based)

Build and install libghostty-vt first:

cd /path/to/ghostty
cmake -B build
cmake --build build
cmake --install build --prefix /usr/local

Then in your project:

find_package(ghostty-vt REQUIRED)

add_executable(myapp main.c)
target_link_libraries(myapp PRIVATE ghostty-vt::ghostty-vt)

Files

  • ghostty-vt-config.cmake.in — template for the CMake package config file installed alongside the library, enabling find_package() support.

Example

See example/c-vt-cmake/ for a complete working example.