Refactor CMake workflow.
Switches to using Ninja.
Adds jobs for Windows and MacOS.
@@ -4,6 +4,10 @@ on:
push:
pull_request:
+defaults:
+ run:
+ shell: bash
+
jobs:
build:
@@ -11,10 +15,37 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ubuntu-20.04]
- config: [Debug, Release]
- shared: [dynamic, static]
- triplet: [x64-linux]
+ include:
+ - os: ubuntu-20.04
+ triplet: x64-linux
+ shared: dynamic
+ config: Debug
+ - os: ubuntu-20.04
+ triplet: x64-linux
+ shared: static
+ config: Debug
+ - os: ubuntu-20.04
+ triplet: x64-linux
+ shared: dynamic
+ config: Release
+
+ - os: macos-10.15
+ triplet: x64-osx
+ shared: static
+ config: Debug
+ - os: macos-10.15
+ triplet: x64-osx
+ shared: dynamic
+ config: Release
+
+ - os: windows-2019
+ triplet: x64-windows
+ shared: static
+ config: Debug
+ - os: windows-2019
+ triplet: x64-windows
+ shared: dynamic
+ config: Release
env:
CMAKE_BUILD_DIR: build
@@ -45,11 +76,13 @@ jobs:
# Note: given a key, the cache content is immutable. If a cache entry has been created improperly, in order the recreate the right content the key must be changed as well, and it must be brand new (i.e. not existing already).
key: |
${{ hashFiles( 'vcpkg_manifest/vcpkg.json', '.git/modules/vcpkg/HEAD' )}}-${{ matrix.triplet }}-invalidate
+ # On Windows runners, let's ensure to have the Developer Command Prompt environment setup correctly. As used here the Developer Command Prompt created is targeting x64 and using the default the Windows SDK.
+ - uses: ilammy/msvc-dev-cmd@v1
- name: CMake configure
run: |
- cmake -S . -B ${{env.CMAKE_BUILD_DIR}} \
+ cmake -S . -B ${{env.CMAKE_BUILD_DIR}} -GNinja \
+ -DVCPKG_TARGET_TRIPLET="${{ matrix.triplet }}" \
-DCMAKE_BUILD_TYPE=${{matrix.config}} \
- -DCMAKE_TOOLCHAIN_FILE=${{env.VCPKG_ROOT}}/scripts/buildsystems/vcpkg.cmake \
-DLIBTCOD_SDL2=find_package \
-DLIBTCOD_ZLIB=find_package \
-DLIBTCOD_GLAD=find_package \
@@ -60,11 +93,10 @@ jobs:
-DBUILD_SHARED_LIBS=${{ matrix.shared == 'dynamic' && 'TRUE' || 'FALSE' }} \
-DLIBTCOD_SAMPLES=ON \
-DLIBTCOD_TESTS=ON \
- -Wdev \
- --warn-uninitialized
+ -Wdev
- name: CMake build
run: |
- cmake --build ${{env.CMAKE_BUILD_DIR}} --config ${{matrix.config}}
+ cmake --build ${{env.CMAKE_BUILD_DIR}}
- name: List build files
run: find ${{env.CMAKE_BUILD_DIR}}
- name: Run tests
