build: set zig optimize flag for CMake release builds (#11707)

Map CMake release build types (Release, MinSizeRel, RelWithDebInfo) to
-Doptimize=ReleaseFast so that zig build automatically produces
optimized builds when CMake is configured for a release variant. Debug
builds remain unaffected, letting Zig use its default Debug optimization
level.
pull/11717/head
Mitchell Hashimoto 2026-03-20 15:41:48 -07:00 committed by GitHub
commit e8fb7eabad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 0 deletions

View File

@ -52,6 +52,15 @@ project(ghostty-vt VERSION 0.1.0 LANGUAGES C)
set(GHOSTTY_ZIG_BUILD_FLAGS "" CACHE STRING "Additional flags to pass to zig build")
# Map CMake build types to Zig optimization levels.
if(CMAKE_BUILD_TYPE)
string(TOUPPER "${CMAKE_BUILD_TYPE}" _bt)
if(_bt STREQUAL "RELEASE" OR _bt STREQUAL "MINSIZEREL" OR _bt STREQUAL "RELWITHDEBINFO")
list(APPEND GHOSTTY_ZIG_BUILD_FLAGS "-Doptimize=ReleaseFast")
endif()
unset(_bt)
endif()
# --- Find Zig ----------------------------------------------------------------
find_program(ZIG_EXECUTABLE zig REQUIRED)