Seek lib deps via CMake FetchContent

`FetchContent` respects existing installs, and downloads and compiles the libs
if they aren't found.
This is admittedly a little finicky, since this ignores the usual `Find*`
modules provided by CMake, requiring a bit of glue on our side.

But, one upside is that this moves that logic from our CI into the build system,
which can thus benefit other downstream users.
This also opens the door to some improvements in upcoming commits.

Doing this with Bison turned out to be much more painful, however, due to
`FindBISON` providing the specific `bison_target` command; thus, it remains
installed externally, so that it can be picked up by `FindBISON`.

This also bumps our CMake version requirement slightly, though it's
possible that older versions keep working, or could be supported with small patches;
however, our CI doesn't provide anything below 3.31, so we can't check.
This commit is contained in:
ISSOtm
2026-03-18 02:34:30 +01:00
committed by Eldred Habert
parent fd38a3dbc4
commit d6d1844d60
5 changed files with 52 additions and 67 deletions

View File

@@ -28,27 +28,14 @@ jobs:
uses: actions/checkout@v4
- name: Install deps
run: .github/scripts/get_win_deps.ps1
- name: Build zlib
run: | # BUILD_SHARED_LIBS causes the output DLL to be called `z.dll` as of zlib 1.3.2 (formerly `zlib1.dll`)
cmake -S zlib -B zbuild -A ${{ matrix.platform }} -Wno-dev -DCMAKE_INSTALL_PREFIX=install_dir -DBUILD_SHARED_LIBS=ON
cmake --build zbuild --config Release -j
- name: Install zlib
run: |
cmake --install zbuild --config Release
- name: Build libpng
shell: bash
run: |
cmake -S libpng -B pngbuild -A ${{ matrix.platform }} -Wno-dev -DCMAKE_INSTALL_PREFIX=install_dir -DPNG_SHARED=ON -DPNG_STATIC=OFF -DPNG_TESTS=OFF
cmake --build pngbuild --config Release -j
- name: Install libpng
run: |
cmake --install pngbuild --config Release
- name: Build Windows binaries
shell: bash
# We instruct CMake to download and build third-party projects outside of our source tree,
# otherwise they can trigger `-Werror=dev` (from the `develop` preset).
run: |
cmake -S . -B build -A ${{ matrix.platform }} -DCMAKE_INSTALL_PREFIX=install_dir -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release -j --verbose
cmake --install build --config Release --strip
cmake -S . -B build -A ${{ matrix.platform }} -DCMAKE_BUILD_TYPE=Release -DFETCHCONTENT_BASE_DIR="$TEMP/cmake-deps" -DBISON_EXECUTABLE=bison/win_bison.exe
cmake --build build --config Release -j
cmake --install build --config Release --prefix install_dir --verbose
- name: Package binaries
run: |
Compress-Archive -LiteralPath @("install_dir/bin/rgbasm.exe", "install_dir/bin/rgblink.exe", "install_dir/bin/rgbfix.exe", "install_dir/bin/rgbgfx.exe", "install_dir/bin/z.dll", "install_dir/bin/libpng16.dll") "rgbds-win${{ matrix.bits }}.zip"

View File

@@ -30,8 +30,13 @@ jobs:
sudo make install -j Q=
- name: Build & install using CMake
if: matrix.buildsys == 'cmake'
# Since GitHub's runners are basically kitchen sinks,
# the Mono framework exposes a libpng 1.4.x header, breaking everything.
# Searching frameworks last makes Homebrew's libpng be discovered first, which works.
# Note that since this is specific to our CI environment, the workaround is
# better applied here than in our CMakeLists, where it could affect and break someone else.
run: |
cmake -S . -B build --preset develop -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DTESTS_OS_NAME=${{ matrix.os }}
cmake -S . -B build --preset develop -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DTESTS_OS_NAME=${{ matrix.os }}
cmake --build build -j --verbose
sudo cmake --install build --verbose
- name: Package binaries
@@ -147,38 +152,14 @@ jobs:
uses: actions/checkout@v4
- name: Install deps
run: .github/scripts/get_win_deps.ps1
- name: Check libraries cache
id: cache
uses: actions/cache@v4
with:
path: |
zbuild
pngbuild
key: ${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles('zlib/**', 'libpng/**') }}
- name: Build zlib
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
run: | # BUILD_SHARED_LIBS causes the output DLL to be called `z.dll` as of zlib 1.3.2 (formerly `zlib1.dll`)
cmake -S zlib -B zbuild -A ${{ matrix.platform }} -Wno-dev -DCMAKE_INSTALL_PREFIX=install_dir -DBUILD_SHARED_LIBS=ON
cmake --build zbuild --config Debug -j
- name: Install zlib
run: |
cmake --install zbuild --config Debug
- name: Build libpng
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
run: |
cmake -S libpng -B pngbuild -A ${{ matrix.platform }} -Wno-dev -DCMAKE_INSTALL_PREFIX=install_dir -DCMAKE_BUILD_TYPE=Debug -DPNG_SHARED=ON -DPNG_STATIC=OFF -DPNG_TESTS=OFF
cmake --build pngbuild --config Debug -j
- name: Install libpng
run: |
cmake --install pngbuild --config Debug
- name: Build Windows binaries
shell: bash
run: | # ASan seems to be broken on Windows.
cmake -S . -B build -A ${{ matrix.platform }} --preset develop -DCMAKE_INSTALL_PREFIX=install_dir -DSANITIZERS=OFF
cmake --build build --config Debug -j --verbose
cmake --install build --verbose
# We instruct CMake to download and build third-party projects outside of our source tree,
# otherwise they can trigger `-Werror=dev` (from the `develop` preset).
run: | # ASan seems to be broken on Windows, so we disable it.
cmake -S . -B build -A ${{ matrix.platform }} --preset develop -DFETCHCONTENT_BASE_DIR="$TEMP/cmake-deps" -DBISON_EXECUTABLE=bison/win_bison.exe -DSANITIZERS=OFF
cmake --build build --config Debug -j
cmake --install build --config Debug --prefix install_dir --verbose
- name: Package binaries
shell: bash
run: |