Skip to content

Commit 19888f7

Browse files
committed
cmake: Add ZIG_RELEASE_SAFE option to build as ReleaseSafe
1 parent d091178 commit 19888f7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

CMakeLists.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -938,12 +938,19 @@ if(ZIG_EXTRA_BUILD_ARGS)
938938
list(APPEND ZIG_BUILD_ARGS ${ZIG_EXTRA_BUILD_ARGS})
939939
endif()
940940

941+
set(ZIG_RELEASE_SAFE OFF CACHE BOOL "Build Zig as ReleaseSafe (with debug assertions on)")
942+
941943
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
942944
list(APPEND ZIG_BUILD_ARGS -Doptimize=Debug)
943-
elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
944-
list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseFast)
945945
else()
946-
list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseFast -Dstrip)
946+
if(ZIG_RELEASE_SAFE)
947+
list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseSafe)
948+
else()
949+
list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseFast)
950+
endif()
951+
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
952+
list(APPEND ZIG_BUILD_ARGS -Dstrip)
953+
endif()
947954
endif()
948955

949956
if(ZIG_STATIC AND NOT MSVC)

0 commit comments

Comments
 (0)