-
Notifications
You must be signed in to change notification settings - Fork 57
94 lines (84 loc) · 4.26 KB
/
cmake.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: CMake
on:
push:
branches: [master]
pull_request:
jobs:
unix:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
name: ${{ matrix.os }} - ${{ matrix.build_type }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
build_type: [Debug, RelWithDebInfo, Release]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup (apt)
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
sudo apt update -qq
sudo apt install git build-essential cmake ninja-build zip unzip libsdl2-dev libfreetype-dev
- name: Setup (brew)
if: ${{ startsWith(matrix.os, 'macos') }}
run: brew install cmake sdl2 ninja
- name: Setup (windows)
if: ${{ startsWith(matrix.os, 'windows') }}
run: |
$sdl_version = "2.0.16"
$sdl_link = "https://libsdl.org/release/SDL2-devel-$sdl_version-VC.zip"
$sdl_zip = "$env:GITHUB_WORKSPACE/sdl-dev.zip"
(new-object System.Net.WebClient).DownloadFile($sdl_link, $sdl_zip)
Expand-Archive -LiteralPath $sdl_zip -DestinationPath "$env:GITHUB_WORKSPACE/externals"
$sdl_config = @"
set(flavor x86)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(flavor x64)
endif()
set(_SDL2_prefix "`${CMAKE_CURRENT_LIST_DIR}/SDL2-$sdl_version")
add_library(SDL2::SDL2main STATIC IMPORTED)
set_target_properties(SDL2::SDL2main PROPERTIES
IMPORTED_LOCATION "`${_SDL2_prefix}/lib/`${flavor}/SDL2main.lib"
)
add_library(SDL2::SDL2 SHARED IMPORTED)
set_target_properties(SDL2::SDL2 PROPERTIES
IMPORTED_LOCATION "`${_SDL2_prefix}/lib/`${flavor}/SDL2.dll"
IMPORTED_IMPLIB "`${_SDL2_prefix}/lib/`${flavor}/SDL2.lib"
INTERFACE_INCLUDE_DIRECTORIES "`${_SDL2_prefix}/include"
)
target_link_libraries(SDL2::SDL2 INTERFACE SDL2::SDL2main)
"@
Set-Content -Path "$env:GITHUB_WORKSPACE/externals/sdl2-config.cmake" -Value $sdl_config
Get-Content "$env:GITHUB_WORKSPACE/externals/sdl2-config.cmake"
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{runner.workspace}}/build
- name: Configure CMake (windows)
if: ${{ startsWith(matrix.os, 'windows') }}
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
working-directory: ${{runner.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $env:GITHUB_WORKSPACE -G "Visual Studio 17 2022" -A Win32 -DCMAKE_BUILD_TYPE:STRING=${{ matrix.build_type }} -DSDL2_DIR:PATH="$env:GITHUB_WORKSPACE/externals" -DWARNING_IS_ERROR=1
- name: Configure CMake (unix-like)
if: ${{ !startsWith(matrix.os, 'windows') }}
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{runner.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DWARNING_IS_ERROR=1
- name: Build
working-directory: ${{runner.workspace}}/build
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config ${{ matrix.build_type }}