Skip to content

Commit 3be6809

Browse files
authored
Merge pull request #23217 from selfisekai/cmake-release-safe
* cmake: Add ZIG_RELEASE_SAFE option to build as ReleaseSafe * cmake: Map MinSizeRel to ReleaseSmall.
2 parents dc090e9 + f236362 commit 3be6809

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

CMakeLists.txt

+15-3
Original file line numberDiff line numberDiff line change
@@ -951,12 +951,24 @@ if(ZIG_EXTRA_BUILD_ARGS)
951951
list(APPEND ZIG_BUILD_ARGS ${ZIG_EXTRA_BUILD_ARGS})
952952
endif()
953953

954+
set(ZIG_RELEASE_SAFE OFF CACHE BOOL "Build Zig as ReleaseSafe (with debug assertions on)")
955+
954956
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
955957
list(APPEND ZIG_BUILD_ARGS -Doptimize=Debug)
956-
elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
957-
list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseFast)
958958
else()
959-
list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseFast -Dstrip)
959+
if("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
960+
list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseSmall)
961+
else()
962+
# Release and RelWithDebInfo
963+
if(ZIG_RELEASE_SAFE)
964+
list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseSafe)
965+
else()
966+
list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseFast)
967+
endif()
968+
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
969+
list(APPEND ZIG_BUILD_ARGS -Dstrip)
970+
endif()
971+
endif()
960972
endif()
961973

962974
if(ZIG_STATIC AND NOT MSVC)

0 commit comments

Comments
 (0)