authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-04-17 04:18:23+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-04-17 04:18:23+02:00
log3be6809e27e2b7a2beb657f8e20a3a47a1bcfe48
tree2227fb6ef126fe6e2b5f23cf22864a49a6a3b760
parentdc090e99cf7d438af911e0114b7ffae46c265cab
parentf2363623e1eb4c0b12b9a8f795e5ce02053ec1f1
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #23217 from selfisekai/cmake-release-safe

* cmake: Add ZIG_RELEASE_SAFE option to build as ReleaseSafe * cmake: Map MinSizeRel to ReleaseSmall.

1 files changed, 15 insertions(+), 3 deletions(-)

CMakeLists.txt+15-3
...@@ -951,12 +951,24 @@ if(ZIG_EXTRA_BUILD_ARGS)...@@ -951,12 +951,24 @@ if(ZIG_EXTRA_BUILD_ARGS)
951 list(APPEND ZIG_BUILD_ARGS ${ZIG_EXTRA_BUILD_ARGS})951 list(APPEND ZIG_BUILD_ARGS ${ZIG_EXTRA_BUILD_ARGS})
952endif()952endif()
953953
954set(ZIG_RELEASE_SAFE OFF CACHE BOOL "Build Zig as ReleaseSafe (with debug assertions on)")
955
954if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")956if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
955 list(APPEND ZIG_BUILD_ARGS -Doptimize=Debug)957 list(APPEND ZIG_BUILD_ARGS -Doptimize=Debug)
956elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
957 list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseFast)
958else()958else()
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()
960endif()972endif()
961973
962if(ZIG_STATIC AND NOT MSVC)974if(ZIG_STATIC AND NOT MSVC)