Commit f858d1305a510ef916b50ba781c1a2a954fde08d

Anonymous Maarten 2022-06-03T19:24:20

ci: test installed packages using CMake

diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml
index 04372bf..9380efa 100644
--- a/.github/workflows/emscripten.yml
+++ b/.github/workflows/emscripten.yml
@@ -11,6 +11,21 @@ jobs:
         with:
           version: 2.0.27
       - name: Configure CMake
-        run: emcmake cmake -B build -DCMAKE_VERBOSE_MAKEFILE=ON
+        run: |
+          emcmake cmake -S . -B build \
+            -DCMAKE_BUILD_TYPE=Release \
+            -DCMAKE_INSTALL_PREFIX=prefix
       - name: Build
-        run: cmake --build build/
+        run: cmake --build build/ --verbose
+      - name: Install
+        run: |
+          echo "SDL2_DIR=$(pwd)/prefix" >> $GITHUB_ENV
+          cmake --install build/
+      - name: Verify CMake configuration files
+        if: ${{ false }}  # FIXME: cmake/test/CMakeLists.txt should support emscripten
+        run: |
+          emcmake cmake -S cmake/test -B cmake_config_build \
+            -DCMAKE_BUILD_TYPE=Release \
+            -DTEST_SHARED=FALSE \
+            -DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }}
+          cmake --build cmake_config_build --verbose
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 9f8d83d..1837433 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -17,9 +17,10 @@ jobs:
         platform:
         - { name: Windows (mingw32),      os: windows-latest, shell: 'msys2 {0}', msystem: mingw32, msys-env: mingw-w64-i686 }
         - { name: Windows (mingw64),      os: windows-latest, shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64 }
-        - { name: Linux (CMake),          os: ubuntu-20.04,   shell: sh,   flags: -GNinja }
-        - { name: Linux (autotools),      os: ubuntu-20.04,   shell: sh,   autotools: 'true' }
-        - { name: MacOS,                  os: macos-latest,   shell: sh }
+        - { name: Linux (CMake),          os: ubuntu-20.04,   shell: sh,    flags: true }
+        - { name: Linux (autotools),      os: ubuntu-20.04,   shell: sh,    autotools: true }
+        - { name: MacOS (CMake),          os: macos-latest,   shell: sh }
+        - { name: MacOS (autotools),      os: macos-latest,   shell: sh,    autotools: true }
 
     steps:
     - name: Set up MSYS2
@@ -79,78 +80,105 @@ jobs:
         meson build --buildtype release -Ddemo=false -Ddbus=disabled
         ninja -v -C build
         sudo meson install -C build
+    - name: Setup Macos dependencies
+      if: runner.os == 'macOS'
+      run: |
+        brew install \
+          ninja
     - uses: actions/checkout@v2
     - name: Check that versioning is consistent
       # We only need to run this once: arbitrarily use the Linux/CMake build
       if: "runner.os == 'Linux' && ! matrix.platform.autotools"
       run: ./test/versioning.sh
-    - name: Configure CMake
+    - name: Configure (CMake)
       if: "! matrix.platform.autotools"
-      run: cmake -B build -DSDL_TEST=ON -DCMAKE_VERBOSE_MAKEFILE=ON -DSDL_INSTALL_TESTS=ON ${{ matrix.platform.flags }}
-    - name: Build
+      run: |
+        cmake -S . -B build -G Ninja \
+        -DSDL_TESTS=ON \
+        -DSDL_INSTALL_TESTS=ON \
+        -DCMAKE_INSTALL_PREFIX=cmake_prefix \
+        -DCMAKE_BUILD_TYPE=Release
+    - name: Build (CMake)
       if: "! matrix.platform.autotools"
-      run: cmake --build build/ --config Release
-    - name: Run build-time tests
+      run: |
+        cmake --build build/ --config Release --verbose --parallel
+    - name: Run build-time tests (CMake)
       if: "matrix.platform.shell == 'sh' && ! matrix.platform.autotools"
       run: |
         set -eu
         export SDL_TESTS_QUICK=1
         ctest -VV --test-dir build/
-    - name: Install
-      if: "matrix.platform.shell == 'sh' && ! matrix.platform.autotools"
+    - name: Install (CMake)
+      if: "! matrix.platform.autotools"
       run: |
         set -eu
-        rm -fr DESTDIR-cmake
-        DESTDIR=$(pwd)/DESTDIR-cmake cmake --install build/ --config Release
-        ( cd DESTDIR-cmake; find ) | LC_ALL=C sort -u
-    - name: Configure Autotools
+        cmake --install build/ --config Release
+        echo "SDL2_DIR=$(pwd)/cmake_prefix" >> $GITHUB_ENV
+        ( cd cmake_prefix; find ) | LC_ALL=C sort -u
+    - name: Configure (Autotools)
       if: matrix.platform.autotools
       run: |
         set -eu
         rm -fr build-autotools
         mkdir build-autotools
         ./autogen.sh
-        ( cd build-autotools && ../configure )
-        curdir="$(pwd)"
-        multiarch="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
         (
-          mkdir -p build-autotools/test
-          cd build-autotools/test
-          ../../test/configure \
-            --x-includes=/usr/include \
-            --x-libraries="/usr/lib/${multiarch}" \
-            SDL_CFLAGS="-I${curdir}/include" \
-            SDL_LIBS="-L${curdir}/build-autotools/build/.libs -lSDL2" \
-            ac_cv_lib_SDL2_ttf_TTF_Init=no \
-            ${NULL+}
+          cd build-autotools
+          ${{ github.workspace }}/configure \
+            --prefix=${{ github.workspace }}/autotools_prefix \
         )
-    - name: Build with Autotools
+        if test "${{ runner.os }}" != "macOS" ; then
+          curdir="$(pwd)"
+          multiarch="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
+          (
+            mkdir -p build-autotools/test
+            cd build-autotools/test
+            ${{ github.workspace }}/test/configure \
+              --x-includes=/usr/include \
+              --x-libraries="/usr/lib/${multiarch}" \
+              --prefix=${{ github.workspace }}/autotools_prefix \
+              SDL_CFLAGS="-I${curdir}/include" \
+              SDL_LIBS="-L${curdir}/build-autotools/build/.libs -lSDL2" \
+              ac_cv_lib_SDL2_ttf_TTF_Init=no \
+              ${NULL+}
+          )
+        fi
+    - name: Build (Autotools)
       if: matrix.platform.autotools
       run: |
         set -eu
         parallel="$(getconf _NPROCESSORS_ONLN)"
         make -j"${parallel}" -C build-autotools V=1
-        make -j"${parallel}" -C build-autotools/test V=1
-    - name: Run build-time tests with Autotools
-      if: matrix.platform.autotools
+        if test "${{ runner.os }}" != "macOS" ; then
+          make -j"${parallel}" -C build-autotools/test V=1
+        fi
+    - name: Run build-time tests (Autotools)
+      if: ${{ matrix.platform.autotools && (runner.os != 'macOS') }}
       run: |
         set -eu
         curdir="$(pwd)"
         parallel="$(getconf _NPROCESSORS_ONLN)"
         export SDL_TESTS_QUICK=1
         make -j"${parallel}" -C build-autotools/test check LD_LIBRARY_PATH="${curdir}/build-autotools/build/.libs"
-    - name: Install with Autotools
+    - name: Install (Autotools)
       if: matrix.platform.autotools
       run: |
         set -eu
         curdir="$(pwd)"
         parallel="$(getconf _NPROCESSORS_ONLN)"
-        rm -fr DESTDIR-autotools
-        mkdir DESTDIR-autotools
-        make -j"${parallel}" -C build-autotools install DESTDIR="${curdir}/DESTDIR-autotools" V=1
-        make -j"${parallel}" -C build-autotools/test install DESTDIR="${curdir}/DESTDIR-autotools" V=1
-        ( cd DESTDIR-autotools; find ) | LC_ALL=C sort -u
-    - name: Distcheck
+        make -j"${parallel}" -C build-autotools install V=1
+        if test "${{ runner.os }}" != "macOS" ; then
+          make -j"${parallel}" -C build-autotools/test install V=1
+        fi
+        ( cd autotools_prefix; find . ) | LC_ALL=C sort -u
+        echo "SDL2_DIR=$(pwd)/autotools_prefix" >> $GITHUB_ENV
+    - name: Verify CMake configuration files
+      run: |
+        cmake -S cmake/test -B cmake_config_build -G Ninja \
+          -DCMAKE_BUILD_TYPE=Release \
+          -DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }}
+        cmake --build cmake_config_build --verbose
+    - name: Distcheck (Autotools)
       if: matrix.platform.autotools
       run: |
         set -eu
@@ -162,7 +190,7 @@ jobs:
         tar -C distcheck -zxf build-autotools/SDL2-*.tar.gz
         ( cd distcheck/SDL2-* && ./configure )
         make -j"${parallel}" -C distcheck/SDL2-*
-    - name: Run installed-tests from Autotools
+    - name: Run installed-tests (Autotools)
       if: "runner.os == 'Linux' && matrix.platform.autotools"
       run: |
         set -eu
diff --git a/.github/workflows/msvc.yml b/.github/workflows/msvc.yml
index 39e23e4..1db6a39 100644
--- a/.github/workflows/msvc.yml
+++ b/.github/workflows/msvc.yml
@@ -19,14 +19,29 @@ jobs:
         - { name: Windows (clang-cl x86), flags: -T ClangCL -A Win32 }
         - { name: Windows (ARM),          flags: -A ARM }
         - { name: Windows (ARM64),        flags: -A ARM64 }
-        - { name: UWP (x64),              flags: -A x64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION="10.0" -DSDL_TEST=OFF, project: VisualC-WinRT/SDL-UWP.sln, projectflags: '/p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0.17763.0' }
+        - { name: UWP (x64),              flags: -A x64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION="10.0" -DSDL_TESTS=OFF,
+            project: VisualC-WinRT/SDL-UWP.sln, projectflags: '/p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0.17763.0' }
 
     steps:
     - uses: actions/checkout@v2
     - name: Configure CMake
-      run: cmake -B build -DSDL_TEST=ON ${{ matrix.platform.flags }}
+      run: cmake -S . -B build `
+        -DSDL_TESTS=ON `
+        ${{ matrix.platform.flags }} `
+        -DCMAKE_INSTALL_PREFIX=prefix
     - name: Build CMake
       run: cmake --build build/ --config Release --parallel
+    - name: Install CMake
+      run: |
+        echo "SDL2_DIR=$Env:GITHUB_WORKSPACE/prefix" >> $Env:GITHUB_ENV
+        cmake --install build/
+    - name: Verify CMake configuration files
+      if: ${{ !contains(matrix.platform.name, 'UWP') }}  # FIXME: cmake/test/CMakeLists.txt should support UWP
+      run: |
+        cmake -S cmake/test -B cmake_config_build `
+          -DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }} `
+          ${{ matrix.platform.flags }}
+        cmake --build cmake_config_build --config Release
 
     - name: Add msbuild to PATH
       if: ${{ matrix.platform.project != '' }}
diff --git a/.github/workflows/psp.yaml b/.github/workflows/psp.yaml
index b1b470e..bed0a01 100644
--- a/.github/workflows/psp.yaml
+++ b/.github/workflows/psp.yaml
@@ -13,6 +13,24 @@ jobs:
         apk update 
         apk add cmake gmp mpc1 mpfr4 make
     - name: Configure CMake
-      run: cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$PSPDEV/psp/share/pspdev.cmake -DSDL_TEST=ON
+      run: |
+        cmake -S . -B build \
+          -DCMAKE_TOOLCHAIN_FILE=$PSPDEV/psp/share/pspdev.cmake \
+          -DSDL_TESTS=ON \
+          -DCMAKE_BUILD_TYPE=Release \
+          -DCMAKE_INSTALL_PREFIX=prefix
     - name: Build
-      run: cmake --build build
+      run: cmake --build build --config Release
+    - name: Install
+      run: |
+        echo "SDL2_DIR=$(pwd)/prefix" >> $GITHUB_ENV
+        cmake --install build --config Release
+        ( cd prefix; find ) | LC_ALL=C sort -u
+    - name: Verify CMake configuration files
+      run: |
+        cmake -S cmake/test -B cmake_config_build \
+          -DCMAKE_TOOLCHAIN_FILE=$PSPDEV/psp/share/pspdev.cmake \
+          -DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }} \
+          -DTEST_SHARED=FALSE \
+          -DCMAKE_BUILD_TYPE=Release
+        cmake --build cmake_config_build --verbose
diff --git a/.github/workflows/riscos.yml b/.github/workflows/riscos.yml
index 9f33705..7c3340c 100644
--- a/.github/workflows/riscos.yml
+++ b/.github/workflows/riscos.yml
@@ -3,26 +3,63 @@ name: Build (RISC OS)
 on: [push, pull_request]
 
 jobs:
-  autotools:
-    name: autotools
+  Build:
+    name: ${{ matrix.platform.name }}
     runs-on: ubuntu-latest
     container: riscosdotinfo/riscos-gccsdk-4.7:latest
-    steps:
-    - uses: actions/checkout@v2
-    - name: Configure
-      run: ./configure --host=arm-unknown-riscos --disable-gcc-atomics
-    - name: Build
-      run: make -j`nproc` V=1
 
-  cmake:
-    name: CMake
-    runs-on: ubuntu-latest
-    container: riscosdotinfo/riscos-gccsdk-4.7:latest
+    strategy:
+      fail-fast: false
+      matrix:
+        platform:
+          - { name: autotools, test_args: '-DTEST_SHARED=FALSE' } # FIXME: autotools should build and install shared libraries
+          - { name: CMake }
+
     steps:
     - name: Setup dependencies
       run: apt-get update && apt-get install -y cmake ninja-build
     - uses: actions/checkout@v2
-    - name: Configure CMake
-      run: cmake -S. -Bbuild -G Ninja -DCMAKE_TOOLCHAIN_FILE=/home/riscos/env/toolchain-riscos.cmake -DRISCOS=ON -DSDL_GCC_ATOMICS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON
-    - name: Build
-      run: cmake --build build
+    - name: Configure (autotools)
+      if: ${{ contains(matrix.platform.name, 'autotools') }}
+      run: |
+        mkdir build_autotools
+        cd build_autotools
+        ../configure \
+          --host=arm-unknown-riscos \
+          --disable-gcc-atomics \
+          --prefix=${{ github.workspace }}/prefix_autotools
+    - name: Build (autotools)
+      if: ${{ contains(matrix.platform.name, 'autotools') }}
+      run: make -C build_autotools -j`nproc` V=1
+    - name: Install (autotools)
+      if: ${{ contains(matrix.platform.name, 'autotools') }}
+      run: |
+        echo "SDL2_DIR=${{ github.workspace }}/prefix_autotools" >> $GITHUB_ENV
+        make -C build_autotools install
+        ( cd ${{ github.workspace }}/prefix_autotools; find ) | LC_ALL=C sort -u
+    - name: Configure (CMake)
+      if: ${{ contains(matrix.platform.name, 'CMake') }}
+      run: |
+        cmake -S . -B build -G Ninja \
+          -DCMAKE_TOOLCHAIN_FILE=/home/riscos/env/toolchain-riscos.cmake \
+          -DRISCOS=ON \
+          -DSDL_GCC_ATOMICS=OFF \
+          -DCMAKE_BUILD_TYPE=Release \
+          -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/prefix_cmake
+    - name: Build (CMake)
+      if: ${{ contains(matrix.platform.name, 'CMake') }}
+      run: cmake --build build --verbose
+    - name: Install (CMake)
+      if: ${{ contains(matrix.platform.name, 'CMake') }}
+      run: |
+        echo "SDL2_DIR=${{ github.workspace }}/prefix_cmake" >> $GITHUB_ENV
+        cmake --install build/
+        ( cd ${{ github.workspace }}/prefix_cmake; find ) | LC_ALL=C sort -u
+    - name: Verify CMake configuration files
+      run: |
+        cmake -S cmake/test -B cmake_config_build -G Ninja \
+          -DCMAKE_TOOLCHAIN_FILE=/home/riscos/env/toolchain-riscos.cmake \
+          -DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }} \
+          -DCMAKE_BUILD_TYPE=Release \
+          ${{ matrix.platform.test_args }}
+        cmake --build cmake_config_build --verbose
diff --git a/.github/workflows/vita.yaml b/.github/workflows/vita.yaml
index 49d1a2b..792bd5b 100644
--- a/.github/workflows/vita.yaml
+++ b/.github/workflows/vita.yaml
@@ -16,8 +16,25 @@ jobs:
     - name: Install CMake and GNU Make
       run: |
         apk update 
-        apk add cmake make
+        apk add cmake make ninja
     - name: Configure CMake
-      run: cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE=${VITASDK}/share/vita.toolchain.cmake -DCMAKE_BUILD_TYPE=Release
+      run: |
+        cmake -S . -B build -G Ninja \
+          -DCMAKE_TOOLCHAIN_FILE=${VITASDK}/share/vita.toolchain.cmake \
+          -DCMAKE_BUILD_TYPE=Release \
+          -DCMAKE_INSTALL_PREFIX=prefix
     - name: Build
-      run: cmake --build build
+      run: cmake --build build --verbose
+    - name: Install CMake
+      run: |
+        echo "SDL2_DIR=$(pwd)/prefix" >> $GITHUB_ENV
+        cmake --install build/
+        ( cd prefix; find ) | LC_ALL=C sort -u
+    - name: Verify CMake configuration files
+      run: |
+        cmake -S cmake/test -B cmake_config_build -G Ninja \
+          -DCMAKE_TOOLCHAIN_FILE=${VITASDK}/share/vita.toolchain.cmake \
+          -DTEST_SHARED=FALSE \
+          -DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }} \
+          -DCMAKE_BUILD_TYPE=Release
+        cmake --build cmake_config_build --verbose