Skip to content

Commit b66e0b9

Browse files
Appolonniusclaude
andcommitted
CI: build macOS x86_64 by cross-compiling on the arm64 runner
Intel (macos-13) runners queue indefinitely on GitHub capacity, so build the x86_64 macOS binary on the reliable Apple-Silicon runner instead: compile a static x86_64 SDL2 from source (release-2.30.x) and build the app with CMAKE_OSX_ARCHITECTURES=x86_64 (deployment target 10.13), producing a self-contained Intel binary. CMake now also accepts the SDL2::SDL2-static target. arm64 stays native (brew SDL2). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 6c8b703 commit b66e0b9

2 files changed

Lines changed: 32 additions & 8 deletions

File tree

.github/workflows/build.yml

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ jobs:
1515
matrix:
1616
include:
1717
- { os: ubuntu-latest, name: linux }
18-
- { os: macos-13, name: macos-x86_64 } # Intel runner
19-
- { os: macos-14, name: macos-arm64 } # Apple Silicon runner
18+
# Both macOS builds run on the reliable Apple-Silicon runner: one native
19+
# arm64, one cross-compiled to x86_64 (static SDL2 from source), so the
20+
# Intel build no longer depends on scarce Intel-runner capacity.
21+
- { os: macos-14, name: macos-arm64, mac_arch: arm64 }
22+
- { os: macos-14, name: macos-x86_64, mac_arch: x86_64 }
2023
- { os: windows-latest, name: windows }
2124
steps:
2225
- uses: actions/checkout@v4
@@ -25,20 +28,39 @@ jobs:
2528
if: runner.os == 'Linux'
2629
run: sudo apt-get update && sudo apt-get install -y cmake build-essential libsdl2-dev libgl1-mesa-dev
2730

28-
- name: Install deps (macOS)
29-
if: runner.os == 'macOS'
31+
- name: Install deps (macOS arm64, native)
32+
if: matrix.mac_arch == 'arm64'
3033
run: brew install sdl2
3134

35+
- name: Build x86_64 SDL2 from source (macOS cross)
36+
if: matrix.mac_arch == 'x86_64'
37+
run: |
38+
git clone --depth 1 -b release-2.30.x https://github.com/libsdl-org/SDL SDLsrc
39+
cmake -S SDLsrc -B sdlbuild -DCMAKE_BUILD_TYPE=Release \
40+
-DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \
41+
-DSDL_SHARED=OFF -DSDL_STATIC=ON -DSDL_TEST=OFF \
42+
-DCMAKE_INSTALL_PREFIX="$PWD/sdlx86"
43+
cmake --build sdlbuild -j3 --target install
44+
3245
- name: Configure
33-
run: cmake -B build -DCMAKE_BUILD_TYPE=Release
46+
shell: bash
47+
run: |
48+
if [ "${{ matrix.mac_arch }}" = "x86_64" ]; then
49+
cmake -B build -DCMAKE_BUILD_TYPE=Release \
50+
-DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \
51+
-DCMAKE_PREFIX_PATH="$PWD/sdlx86"
52+
else
53+
cmake -B build -DCMAKE_BUILD_TYPE=Release
54+
fi
3455
3556
- name: Build
36-
run: cmake --build build --config Release -j 2
57+
shell: bash
58+
run: cmake --build build --config Release -j 3
3759

3860
- name: Verify arch (macOS)
3961
if: runner.os == 'macOS'
4062
run: |
41-
echo "runner arch: $(uname -m)"
63+
echo "runner arch: $(uname -m) target: ${{ matrix.name }}"
4264
file build/msxforge-gui
4365
lipo -archs build/msxforge-gui || true
4466

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ else()
4848
# Linux / macOS: use the system SDL2 (apt install libsdl2-dev / brew install sdl2).
4949
find_package(SDL2 REQUIRED)
5050
if(TARGET SDL2::SDL2)
51-
target_link_libraries(msxforge-gui PRIVATE SDL2::SDL2)
51+
target_link_libraries(msxforge-gui PRIVATE SDL2::SDL2) # shared (brew/apt)
52+
elseif(TARGET SDL2::SDL2-static)
53+
target_link_libraries(msxforge-gui PRIVATE SDL2::SDL2-static) # static (cross build)
5254
else()
5355
target_include_directories(msxforge-gui PRIVATE ${SDL2_INCLUDE_DIRS})
5456
target_link_libraries(msxforge-gui PRIVATE ${SDL2_LIBRARIES})

0 commit comments

Comments
 (0)