SDL: ci: add NetBSD to test matrix

From e548044a82c8ae6ffd2605ceef285598adbe6bd0 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Sat, 11 Nov 2023 21:52:07 +0100
Subject: [PATCH] ci: add NetBSD to test matrix

Co-authored-by: Ozkan Sezer <sezeroz@gmail.com>
---
 .github/workflows/cpactions.yml | 64 ++++++++++++++-------------------
 CMakeLists.txt                  |  2 +-
 2 files changed, 27 insertions(+), 39 deletions(-)

diff --git a/.github/workflows/cpactions.yml b/.github/workflows/cpactions.yml
index 4a11b81686ad..7591c0dc2a66 100644
--- a/.github/workflows/cpactions.yml
+++ b/.github/workflows/cpactions.yml
@@ -9,53 +9,41 @@ concurrency:
 jobs:
   freebsd:
     runs-on: ubuntu-latest
-    name: FreeBSD
+    name: '${{ matrix.platform.name }} ${{ matrix.platform.os-version }}'
     timeout-minutes: 30
+    strategy:
+      fail-fast: false
+      matrix:
+        platform:
+          - { name: FreeBSD,  os: freebsd,  os-version: 13.2, os-arch: x86-64,  artifact: SDL-freebsd-x64,
+              sdl-cmake-configure-arguments: '-DSDL_CHECK_REQUIRED_INCLUDES="/usr/local/include" -DSDL_CHECK_REQUIRED_LINK_OPTIONS="-L/usr/local/lib"',
+              setup-cmd: 'sudo pkg update',
+              install-cmd: 'sudo pkg install -y cmake ninja pkgconf libXcursor libXext libXinerama libXi libXfixes libXrandr libXScrnSaver libXxf86vm wayland wayland-protocols libxkbcommon mesa-libs libglvnd evdev-proto libinotify alsa-lib jackit pipewire pulseaudio sndio dbus zh-fcitx ibus libudev-devd',
+            }
+          - { name: NetBSD,   os: netbsd,   os-version: 9.3,  os-arch: x86-64,  artifact: SDL-netbsd-x64,
+              sdl-cmake-configure-arguments: '',
+              setup-cmd: 'export PATH="/usr/pkg/sbin:/usr/pkg/bin:/sbin:$PATH";export PKG_CONFIG_PATH="/usr/pkg/lib/pkgconfig";export PKG_PATH="https://cdn.netBSD.org/pub/pkgsrc/packages/NetBSD/$(uname -p)/$(uname -r|cut -f "1 2" -d.)/All/";echo "PKG_PATH=$PKG_PATH";echo "uname -a -> \"$(uname -a)\"";sudo -E sysctl -w security.pax.aslr.enabled=0;sudo -E sysctl -w security.pax.aslr.global=0;sudo -E pkgin clean;sudo -E pkgin update',
+              install-cmd: 'sudo -E pkgin -y install cmake dbus pkgconf ninja-build pulseaudio libxkbcommon wayland wayland-protocols libinotify libusb1',
+            }
     steps:
     - uses: actions/checkout@v3
     - name: Build
-      uses: cross-platform-actions/action@v0.19.1
+      uses: cross-platform-actions/action@v0.21.1
       with:
-        operating_system: freebsd
-        version: '13.2'
+        operating_system: ${{ matrix.platform.os }}
+        architecture: ${{ matrix.platform.os-arch }}
+        version: ${{ matrix.platform.os-version }}
         run: |
-          sudo pkg update
-          sudo pkg install -y \
-              cmake \
-              ninja \
-              pkgconf \
-              libXcursor \
-              libXext \
-              libXinerama \
-              libXi \
-              libXfixes \
-              libXrandr \
-              libXScrnSaver \
-              libXxf86vm \
-              wayland \
-              wayland-protocols \
-              libxkbcommon \
-              mesa-libs \
-              libglvnd \
-              evdev-proto \
-              libinotify \
-              alsa-lib \
-              jackit \
-              pipewire \
-              pulseaudio \
-              sndio \
-              dbus \
-              zh-fcitx \
-              ibus \
-              libudev-devd
+          ${{ matrix.platform.setup-cmd }}
+          ${{ matrix.platform.install-cmd }}
           cmake -S . -B build -GNinja  \
             -Wdeprecated -Wdev -Werror \
             -DCMAKE_BUILD_TYPE=Release \
-            -DSDL_CHECK_REQUIRED_INCLUDES="/usr/local/include" \
-            -DSDL_CHECK_REQUIRED_LINK_OPTIONS="-L/usr/local/lib"
-          cmake --build build/ --config Release --verbose -- -j`sysctl -n hw.ncpu`
+            -DSDL_WERROR=ON \
+            ${{ matrix.platform.sdl-cmake-configure-arguments }}
+          cmake --build build/ --config Release --verbose
           cmake --build build/ --config Release --target package
-          
+
           cmake --build build/ --config Release --target clean
           rm -rf build/dist/_CPack_Packages
           rm -rf build/CMakeFiles
@@ -64,5 +52,5 @@ jobs:
     - uses: actions/upload-artifact@v3
       with:
         if-no-files-found: error
-        name: SDL-freebsd
+        name: ${{ matrix.platform.artifact }}
         path: build/dist/SDL3*
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ba5451015020..52e3f900591c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1590,7 +1590,7 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
         set(SDL_USE_IME 1)
       endif()
 
-      if(FREEBSD AND NOT HAVE_INOTIFY)
+      if((FREEBSD OR NETBSD) AND NOT HAVE_INOTIFY)
         set(LibInotify_PKG_CONFIG_SPEC libinotify)
         pkg_check_modules(PC_LIBINOTIFY IMPORTED_TARGET ${LibInotify_PKG_CONFIG_SPEC})
         if(PC_LIBINOTIFY_FOUND)