Skip to content

Commit

Permalink
Cleanup GitHub workflows using CMake presets (#4435)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranisalt committed May 4, 2023
1 parent 37dc2fa commit b57e85a
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 66 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ on:

jobs:
build-ubuntu:
name: ubuntu-${{ matrix.buildtype }}-luajit=${{ matrix.luajit }}
runs-on: ubuntu-latest
strategy:
matrix:
buildtype: [Debug, Release]
luajit: [on, off]

steps:
- uses: actions/checkout@v3

Expand All @@ -39,8 +45,9 @@ jobs:
- name: Build with cmake
uses: lukka/run-cmake@v10
with:
buildPreset: ninja
configurePreset: ninja
buildPreset: default
buildPresetAdditionalArgs: "['--config ${{ matrix.buildtype }}']"
configurePreset: default

- name: Upload artifact binary
uses: actions/upload-artifact@v3
Expand Down
34 changes: 6 additions & 28 deletions .github/workflows/build-vcpkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,13 @@ on:

jobs:
build-vcpkg:
name: ${{ matrix.name }}-${{ matrix.buildtype }}-luajit=${{ matrix.luajit }}
name: ${{ matrix.os }}-${{ matrix.buildtype }}-luajit=${{ matrix.luajit }}
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
name: [ubuntu, ubuntu-clang, macos-clang, windows-msvc]
os: [ubuntu, macos, windows]
buildtype: [Debug, Release]
luajit: [on, off]
include:
- name: ubuntu
os: ubuntu
- name: ubuntu-clang
os: ubuntu
- name: macos-clang
os: macos
- name: windows-msvc
os: windows
exclude:
- name: ubuntu-clang
buildtype: Release
- name: ubuntu-clang
luajit: off
- name: macos-clang
luajit: off
- name: windows-msvc
luajit: off

steps:
- uses: actions/checkout@v3
Expand All @@ -60,12 +42,6 @@ jobs:
if: ${{ matrix.luajit }} == "on"
run: echo "VCPKG_FEATURE_FLAGS=luajit" >> $GITHUB_ENV

- name: Set clang as compiler
if: ${{ endsWith(matrix.name, 'clang') }}
run: |
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
- name: Run vcpkg
uses: lukka/run-vcpkg@v11
with:
Expand All @@ -74,8 +50,10 @@ jobs:
- name: Build with CMake
uses: lukka/run-cmake@v10
with:
buildPreset: ninja-vcpkg
configurePreset: ninja-vcpkg
buildPreset: vcpkg
buildPresetAdditionalArgs: "['--config ${{ matrix.buildtype }}', '--clean-first']"
configurePreset: vcpkg
configurePresetAdditionalArgs: "['-G Ninja']"

- name: Upload artifact binary
uses: actions/upload-artifact@v3
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/release-vcpkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ jobs:
- name: Build with CMake
uses: lukka/run-cmake@v10
with:
buildPreset: ninja-vcpkg
configurePreset: ninja-vcpkg
buildPreset: vcpkg
buildPresetAdditionalArgs: "['--config Release', '--clean-first']"
configurePreset: vcpkg
configurePresetAdditionalArgs: "['-G Ninja']"

- name: Prepare datapack contents
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Build with CMake
uses: lukka/run-cmake@v10
with:
buildPreset: ninja
configurePreset: ninja
configurePresetAdditionalArgs: "['-DENABLE_TESTING=ON']"
testPreset: ninja
buildPreset: default
configurePreset: default
configurePresetAdditionalArgs: "['-G Ninja', '-DENABLE_TESTING=ON']"
testPreset: default
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ if (NOT WIN32)
add_compile_options(-Wall -Werror -pipe -fvisibility=hidden)
endif ()

set(CMAKE_CXX_FLAGS_PERFORMANCE "${CMAKE_CXX_FLAGS_RELEASE} -march=native")

if (CMAKE_COMPILER_IS_GNUCXX)
add_compile_options(-fno-strict-aliasing)
endif ()
Expand Down
44 changes: 16 additions & 28 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,38 @@
{
"version": 2,
"cmakeMinimumRequired": {
"major": 3,
"minor": 20,
"patch": 2
},
"version": 3,
"configurePresets": [
{
"name": "ninja",
"displayName": "Ninja",
"name": "default",
"description": "Generate Ninja project files",
"binaryDir": "${sourceDir}/build",
"generator": "Ninja"
"binaryDir": "${sourceDir}/build"
},
{
"name": "ninja-vcpkg",
"displayName": "Ninja",
"name": "vcpkg",
"inherits": [
"default"
],
"description": "Configure with vcpkg toolchain and generate Ninja project files",
"binaryDir": "${sourceDir}/build",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"type": "FILEPATH",
"value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
}
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
],
"buildPresets": [
{
"name": "ninja",
"configurePreset": "ninja"
"name": "default",
"configurePreset": "default"
},
{
"name": "ninja-vcpkg",
"configurePreset": "ninja-vcpkg"
"name": "vcpkg",
"configurePreset": "vcpkg"
}
],
"testPresets": [
{
"name": "ninja",
"configurePreset": "ninja"
"name": "default",
"configurePreset": "default"
},
{
"name": "ninja-vcpkg",
"configurePreset": "ninja-vcpkg"
"name": "vcpkg",
"configurePreset": "vcpkg"
}
]
}

0 comments on commit b57e85a

Please sign in to comment.