Skip to content

Commit c044d85

Browse files
authored
Merge pull request #1 from tillt/till/universal-macos-releases
feat: creates universal (fat) binary releases for macos
2 parents 6c83f45 + fc2be65 commit c044d85

2 files changed

Lines changed: 20 additions & 17 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ jobs:
2929
- os: ubuntu-latest
3030
- os: windows-latest
3131
- os: macos-latest
32-
arch: x86_64
33-
- os: macos-latest
34-
arch: arm64
3532
runs-on: ${{ matrix.os }}
3633
steps:
3734
- name: Checkout
@@ -85,11 +82,11 @@ jobs:
8582
- name: Configure
8683
shell: bash
8784
run: |
88-
ARCH_FLAG=""
89-
if [[ -n "${{ matrix.arch || '' }}" ]]; then
90-
ARCH_FLAG="-DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }}"
85+
UNIVERSAL_FLAG=""
86+
if [[ "${{ matrix.os }}" == "macos-latest" ]]; then
87+
UNIVERSAL_FLAG="-DCHAPTERFORGE_UNIVERSAL=ON"
9188
fi
92-
cmake -S . -B build -DENABLE_OUTPUT_TOOL_TESTS=ON -DCMAKE_BUILD_TYPE=Release ${ARCH_FLAG}
89+
cmake -S . -B build -DENABLE_OUTPUT_TOOL_TESTS=ON -DCMAKE_BUILD_TYPE=Release ${UNIVERSAL_FLAG}
9390
9491
- name: Build
9592
shell: bash
@@ -114,9 +111,6 @@ jobs:
114111
- os: ubuntu-latest
115112
- os: windows-latest
116113
- os: macos-latest
117-
arch: x86_64
118-
- os: macos-latest
119-
arch: arm64
120114
runs-on: ${{ matrix.os }}
121115
steps:
122116
- name: Checkout
@@ -128,11 +122,11 @@ jobs:
128122
- name: Configure
129123
shell: bash
130124
run: |
131-
ARCH_FLAG=""
132-
if [[ -n "${{ matrix.arch || '' }}" ]]; then
133-
ARCH_FLAG="-DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }}"
125+
UNIVERSAL_FLAG=""
126+
if [[ "${{ matrix.os }}" == "macos-latest" ]]; then
127+
UNIVERSAL_FLAG="-DCHAPTERFORGE_UNIVERSAL=ON"
134128
fi
135-
cmake -S . -B build -DENABLE_OUTPUT_TOOL_TESTS=OFF -DCMAKE_BUILD_TYPE=Release ${ARCH_FLAG}
129+
cmake -S . -B build -DENABLE_OUTPUT_TOOL_TESTS=OFF -DCMAKE_BUILD_TYPE=Release ${UNIVERSAL_FLAG}
136130
137131
- name: Build
138132
shell: bash
@@ -187,8 +181,8 @@ jobs:
187181
run: |
188182
mkdir -p dist
189183
suffix="-${{ matrix.os }}"
190-
if [[ -n "${{ matrix.arch || '' }}" ]]; then
191-
suffix="${suffix}-${{ matrix.arch }}"
184+
if [[ "${{ matrix.os }}" == "macos-latest" ]]; then
185+
suffix="${suffix}-universal"
192186
fi
193187
ver="${GITHUB_REF##*/}"
194188
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.dry_run }}" == "true" ]]; then
@@ -217,7 +211,7 @@ jobs:
217211
- name: Upload artifact
218212
uses: actions/upload-artifact@v4
219213
with:
220-
name: chapterforge-${{ matrix.os }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }}
214+
name: chapterforge-${{ matrix.os }}${{ matrix.os == 'macos-latest' && '-universal' || '' }}
221215
path: dist/*
222216

223217
publish:

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ set(CMAKE_CXX_STANDARD 20)
5757
set(CMAKE_CXX_STANDARD_REQUIRED ON)
5858
set(CMAKE_CXX_EXTENSIONS OFF)
5959

60+
# macOS universal helper (opt-in).
61+
if(APPLE)
62+
option(CHAPTERFORGE_UNIVERSAL "Build arm64 + x86_64 universal binaries on macOS" OFF)
63+
if(CHAPTERFORGE_UNIVERSAL)
64+
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "macOS architectures" FORCE)
65+
message(STATUS "CHAPTERFORGE_UNIVERSAL=ON -> CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}")
66+
endif()
67+
endif()
68+
6069
option(ENABLE_ASAN "Enable AddressSanitizer for ChapterForge" OFF)
6170
if(ENABLE_ASAN)
6271
add_compile_options(-fsanitize=address -fno-omit-frame-pointer -fno-common)

0 commit comments

Comments
 (0)