mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-06 07:38:21 +00:00
build: fix Windows cmake example failures
The cmake examples were failing at runtime on Windows CI for two reasons. The static library was installed as "libghostty-vt.a" on all platforms, but on Windows the DLL import library is also placed in zig-out/lib/ as "ghostty-vt.lib". The CMakeLists.txt expected the platform-native name "ghostty-vt.lib" for the static lib, so it picked up the tiny DLL import lib instead, silently producing a dynamically-linked executable. That executable then failed at runtime because the DLL was not on PATH. Fix this by installing the static library as "ghostty-vt-static.lib" on Windows to avoid the name collision, and updating CMakeLists.txt to match. For the shared (DLL) example, add zig-out/bin to PATH in the CI run step so the DLL can be found at runtime.
This commit is contained in:
1
.github/workflows/test.yml
vendored
1
.github/workflows/test.yml
vendored
@@ -294,6 +294,7 @@ jobs:
|
||||
$name = "${{ matrix.dir }}" -replace '-','_'
|
||||
$exe = "example/${{ matrix.dir }}/build/Debug/${name}.exe"
|
||||
if (!(Test-Path $exe)) { $exe = "example/${{ matrix.dir }}/build/${name}.exe" }
|
||||
$env:PATH = "${{ github.workspace }}/zig-out/bin;$env:PATH"
|
||||
& $exe
|
||||
|
||||
build-cmake:
|
||||
|
||||
@@ -95,7 +95,13 @@ else()
|
||||
endif()
|
||||
|
||||
# Static library name.
|
||||
set(GHOSTTY_VT_STATIC_REALNAME "${CMAKE_STATIC_LIBRARY_PREFIX}ghostty-vt${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||
# On Windows, the static lib is named "ghostty-vt-static.lib" to avoid
|
||||
# colliding with the DLL import library "ghostty-vt.lib".
|
||||
if(WIN32)
|
||||
set(GHOSTTY_VT_STATIC_REALNAME "ghostty-vt-static.lib")
|
||||
else()
|
||||
set(GHOSTTY_VT_STATIC_REALNAME "libghostty-vt.a")
|
||||
endif()
|
||||
set(GHOSTTY_VT_STATIC_LIBRARY "${ZIG_OUT_DIR}/lib/${GHOSTTY_VT_STATIC_REALNAME}")
|
||||
|
||||
# Ensure the output directories exist so CMake doesn't reject the
|
||||
|
||||
10
build.zig
10
build.zig
@@ -111,17 +111,21 @@ pub fn build(b: *std.Build) !void {
|
||||
b,
|
||||
&mod,
|
||||
);
|
||||
|
||||
if (config.is_dep) {
|
||||
// If we're a dependency, we need to install everything as-is
|
||||
// so that dep.artifact("ghostty-vt-static") works.
|
||||
libghostty_vt_static.install(b.getInstallStep());
|
||||
} else {
|
||||
// If we're not a dependency, we rename the static lib to
|
||||
// be idiomatic.
|
||||
// be idiomatic. On Windows, we use a distinct name to avoid
|
||||
// colliding with the DLL import library (ghostty-vt.lib).
|
||||
const static_lib_name = if (config.target.result.os.tag == .windows)
|
||||
"ghostty-vt-static.lib"
|
||||
else
|
||||
"libghostty-vt.a";
|
||||
b.getInstallStep().dependOn(&b.addInstallLibFile(
|
||||
libghostty_vt_static.output,
|
||||
"libghostty-vt.a",
|
||||
static_lib_name,
|
||||
).step);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user