diff options
| author | Alex Rønne Petersen <alex@alexrp.com> | 2025-04-17 04:18:23 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-17 04:18:23 +0200 |
| commit | 3be6809e27e2b7a2beb657f8e20a3a47a1bcfe48 (patch) | |
| tree | 2227fb6ef126fe6e2b5f23cf22864a49a6a3b760 /CMakeLists.txt | |
| parent | dc090e99cf7d438af911e0114b7ffae46c265cab (diff) | |
| parent | f2363623e1eb4c0b12b9a8f795e5ce02053ec1f1 (diff) | |
| download | zig-3be6809e27e2b7a2beb657f8e20a3a47a1bcfe48.tar.gz zig-3be6809e27e2b7a2beb657f8e20a3a47a1bcfe48.zip | |
Merge pull request #23217 from selfisekai/cmake-release-safe
* cmake: Add ZIG_RELEASE_SAFE option to build as ReleaseSafe
* cmake: Map MinSizeRel to ReleaseSmall.
Diffstat (limited to 'CMakeLists.txt')
| -rw-r--r-- | CMakeLists.txt | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e17a8a5953..5f22a2a6f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -951,12 +951,24 @@ if(ZIG_EXTRA_BUILD_ARGS) list(APPEND ZIG_BUILD_ARGS ${ZIG_EXTRA_BUILD_ARGS}) endif() +set(ZIG_RELEASE_SAFE OFF CACHE BOOL "Build Zig as ReleaseSafe (with debug assertions on)") + if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") list(APPEND ZIG_BUILD_ARGS -Doptimize=Debug) -elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo") - list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseFast) else() - list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseFast -Dstrip) + if("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel") + list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseSmall) + else() + # Release and RelWithDebInfo + if(ZIG_RELEASE_SAFE) + list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseSafe) + else() + list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseFast) + endif() + if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo") + list(APPEND ZIG_BUILD_ARGS -Dstrip) + endif() + endif() endif() if(ZIG_STATIC AND NOT MSVC) |
