SDL_mixer: Add github action and bump CMake to 3.0.0

From d4e30cc4d2f65b4001c6973ea52827f7b8a2760f Mon Sep 17 00:00:00 2001
From: Bensuperpc <[EMAIL REDACTED]>
Date: Sat, 13 Nov 2021 01:01:54 +0100
Subject: [PATCH] Add github action and bump CMake to 3.0.0

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
---
 .github/workflows/linux.yml | 71 +++++++++++++++++++++++++++++++++++++
 CMakeLists.txt              | 11 ++++--
 2 files changed, 79 insertions(+), 3 deletions(-)
 create mode 100644 .github/workflows/linux.yml

diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
new file mode 100644
index 00000000..16dd652c
--- /dev/null
+++ b/.github/workflows/linux.yml
@@ -0,0 +1,71 @@
+name: linux
+
+on:
+  push:
+    branches:
+      - "*"
+    paths-ignore:
+      - "**.md"
+  pull_request:
+    branches:
+      - "*"
+  workflow_dispatch:
+
+jobs:
+  build-cmake:
+    runs-on: ubuntu-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        compiler: ["gcc", "clang"]
+        shared: [YES, NO]
+        build_type: [Release]
+
+    steps:
+      - name: "Checkout Code"
+        uses: actions/checkout@v2
+        with:
+          submodules: "recursive"
+          fetch-depth: 0
+
+      - name: dependencies
+        run: |
+          sudo apt -y update
+          sudo apt -y install ninja-build libsdl2-dev
+
+      - name: Configure CMake
+        env:
+          CC: ${{matrix.compiler}}
+        run: |
+          cmake -S . -B build -D CMAKE_BUILD_TYPE=${{matrix.build_type}} \
+                -G Ninja -D BUILD_SHARED_LIBS=${{matrix.shared}}
+
+      - name: Build CMake
+        run: ninja -C build
+  build-make:
+    runs-on: ubuntu-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        compiler: ["gcc", "clang"]
+
+    steps:
+      - name: "Checkout Code"
+        uses: actions/checkout@v2
+        with:
+          submodules: "recursive"
+          fetch-depth: 0
+
+      - name: dependencies
+        run: |
+          sudo apt -y update
+          sudo apt -y install libsdl2-dev
+
+      - name: Configure make
+        env:
+          CC: ${{matrix.compiler}}
+        run: |
+          ./configure
+
+      - name: Build make
+        run: make -j2
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 283f5889..539949f6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 2.8.12)
+cmake_minimum_required(VERSION 3.0.0)
 project(SDL_mixer C)
 
 # FIXME: make it able build against system codec libraries, too.
@@ -14,9 +14,14 @@ option(SUPPORT_MP3_MPG123 "Support loading MP3 music via MPG123" OFF)
 option(SUPPORT_MOD_MODPLUG "Support loading MOD music via modplug" OFF)
 option(SUPPORT_MID_TIMIDITY "Support TiMidity" OFF)
 
+option(BUILD_SHARED_LIBS "Enable shared library" ON)
+
+find_package(SDL2 REQUIRED)
+include_directories(${SDL2_INCLUDE_DIRS} ${SDL2_INCLUDE_DIR})
+
 include_directories(include src src/codecs)
 
-add_library(SDL2_mixer SHARED)
+add_library(SDL2_mixer)
 
 target_sources(SDL2_mixer PRIVATE
         src/effect_position.c src/effects_internal.c src/effect_stereoreverse.c
@@ -64,5 +69,5 @@ if (SUPPORT_MID_TIMIDITY)
 endif()
 
 target_include_directories(SDL2_mixer PUBLIC include)
-target_link_libraries(SDL2_mixer PRIVATE SDL2)
+target_link_libraries(SDL2_mixer PRIVATE ${SDL2_LIBRARIES} ${SDL2_LIBRARY})