CMake: Clean up presets, update the GitHub job to use them

This commit is contained in:
David Hrdlička
2022-07-12 09:08:28 +02:00
parent 30479fc3b9
commit 54e43ad7bc
2 changed files with 198 additions and 313 deletions

View File

@@ -4,28 +4,28 @@ on:
push: push:
paths: paths:
- src/** - src/**
- cmake/** - cmake/**
- "**/CMakeLists.txt" - "**/CMakeLists.txt"
- "CMakePresets.json" - "CMakePresets.json"
- .github/workflows/cmake.yml - .github/workflows/cmake.yml
- vcpkg.json - vcpkg.json
- "!**/Makefile*" - "!**/Makefile*"
pull_request: pull_request:
paths: paths:
- src/** - src/**
- cmake/** - cmake/**
- "**/CMakeLists.txt" - "**/CMakeLists.txt"
- "CMakePresets.json" - "CMakePresets.json"
- .github/workflows/** - .github/workflows/**
- .github/workflows/cmake.yml - .github/workflows/cmake.yml
- vcpkg.json - vcpkg.json
- "!**/Makefile*" - "!**/Makefile*"
jobs: jobs:
msys2: msys2:
name: MSYS2 ${{ matrix.build.name }} build (${{ matrix.environment.msystem }}) name: MSYS2 ${{ matrix.build.name }} ${{ matrix.dynarec.name }} build (${{ matrix.environment.msystem }})
runs-on: windows-2022 runs-on: windows-2022
@@ -37,71 +37,62 @@ jobs:
fail-fast: true fail-fast: true
matrix: matrix:
build: build:
# - name: Regular ODR - name: Debug
# slug: -ODR preset: debug
# preset: regular slug: -Debug
# target: install/strip - name: Dev
- name: Debug ODR preset: experimental
slug: -ODR-Debug slug: -Dev
preset: debug dynarec:
target: install - name: ODR
- name: Dev ODR new: off
slug: -ODR-Dev slug: -ODR
preset: experimental - name: NDR
target: install new: on
# - name: Regular NDR slug: -NDR
# slug: -NDR
# preset: regularndr
# target: install/strip
- name: Debug NDR
slug: -NDR-Debug
preset: debugndr
target: install
- name: Dev NDR
slug: -NDR-Dev
preset: experimentalndr
target: install
environment: environment:
- msystem: MINGW32 - msystem: MINGW32
prefix: mingw-w64-i686 prefix: mingw-w64-i686
toolchain: ./cmake/flags-gcc-i686.cmake
- msystem: MINGW64 - msystem: MINGW64
prefix: mingw-w64-x86_64 prefix: mingw-w64-x86_64
toolchain: ./cmake/flags-gcc-x86_64.cmake
- msystem: UCRT64 - msystem: UCRT64
prefix: mingw-w64-ucrt-x86_64 prefix: mingw-w64-ucrt-x86_64
# - msystem: CLANG32 toolchain: ./cmake/flags-gcc-x86_64.cmake
# prefix: mingw-w64-clang-i686
# - msystem: CLANG64
# prefix: mingw-w64-clang-x86_64
steps: steps:
- uses: msys2/setup-msys2@v2 - uses: msys2/setup-msys2@v2
with: with:
path-type: inherit path-type: inherit
update: true update: true
msystem: ${{ matrix.environment.msystem }} msystem: ${{ matrix.environment.msystem }}
install: >- install: >-
${{ matrix.environment.prefix }}-ninja ${{ matrix.environment.prefix }}-ninja
${{ matrix.environment.prefix }}-cc ${{ matrix.environment.prefix }}-cc
${{ matrix.environment.prefix }}-pkg-config ${{ matrix.environment.prefix }}-pkg-config
${{ matrix.environment.prefix }}-freetype ${{ matrix.environment.prefix }}-freetype
${{ matrix.environment.prefix }}-SDL2 ${{ matrix.environment.prefix }}-SDL2
${{ matrix.environment.prefix }}-zlib ${{ matrix.environment.prefix }}-zlib
${{ matrix.environment.prefix }}-libpng ${{ matrix.environment.prefix }}-libpng
${{ matrix.environment.prefix }}-libvncserver ${{ matrix.environment.prefix }}-libvncserver
${{ matrix.environment.prefix }}-rtmidi ${{ matrix.environment.prefix }}-rtmidi
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Configure CMake - name: Configure CMake
run: >- run: >-
cmake -S . -B build cmake -G Ninja -S . -B build --preset ${{ matrix.build.preset }}
--preset ${{ matrix.build.preset }} --toolchain ${{ matrix.environment.toolchain }}
-D CMAKE_INSTALL_PREFIX=./build/artifacts -D NEW_DYNAREC=${{ matrix.dynarec.new }}
-D QT=OFF -D CMAKE_INSTALL_PREFIX=./build/artifacts
- name: Build -D QT=OFF
run: cmake --build build --target ${{ matrix.build.target }} - name: Build
- uses: actions/upload-artifact@v2 run: cmake --build build
with: - name: Generate package
name: '86Box${{ matrix.build.slug }}-Windows-${{ matrix.environment.msystem }}-gha${{ github.run_number }}' run: cmake --install build
path: build/artifacts/** - uses: actions/upload-artifact@v2
with:
name: '86Box${{ matrix.dynarec.slug }}${{ matrix.build.slug }}-Windows-${{ matrix.environment.msystem }}-gha${{ github.run_number }}'
path: build/artifacts/**
llvm-windows: llvm-windows:
name: "Windows vcpkg/LLVM (${{ matrix.ui.name }}, ${{ matrix.build.name }}, ${{ matrix.dynarec.name }}, ${{ matrix.target.name }})" name: "Windows vcpkg/LLVM (${{ matrix.ui.name }}, ${{ matrix.build.name }}, ${{ matrix.dynarec.name }}, ${{ matrix.target.name }})"
@@ -115,156 +106,144 @@ jobs:
fail-fast: true fail-fast: true
matrix: matrix:
build: build:
- name: Debug - name: Debug
dev: off preset: debug
slug: -Debug slug: -Debug
- name: Dev - name: Dev
dev: on preset: experimental
slug: -Dev slug: -Dev
dynarec: dynarec:
- name: ODR - name: ODR
new: off
slug: -ODR
- name: NDR
new: on
slug: -NDR
ui:
- name: Win32 GUI
qt: off
- name: Qt GUI
qt: on
slug: -Qt
target:
- name: x86
triplet: x86-windows-static
toolchain: cmake/llvm-win32-i686.cmake
vcvars: x64_x86
- name: x64
triplet: x64-windows-static
toolchain: cmake/llvm-win32-x86_64.cmake
vcvars: x64
- name: ARM64
triplet: arm64-windows-static
toolchain: cmake/llvm-win32-aarch64.cmake
vcvars: x64_arm64
exclude:
- dynarec:
new: off new: off
target: slug: -ODR
name: ARM64 - name: NDR
new: on
slug: -NDR
ui:
- name: Win32 GUI
qt: off
- name: Qt GUI
qt: on
slug: -Qt
target:
- name: x86
triplet: x86-windows-static
toolchain: cmake/llvm-win32-i686.cmake
vcvars: x64_x86
- name: x64
triplet: x64-windows-static
toolchain: cmake/llvm-win32-x86_64.cmake
vcvars: x64
- name: ARM64
triplet: arm64-windows-static
toolchain: cmake/llvm-win32-aarch64.cmake
vcvars: x64_arm64
exclude:
- dynarec:
new: off
target:
name: ARM64
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Prepare VS environment - name: Prepare VS environment
uses: ilammy/msvc-dev-cmd@v1 uses: ilammy/msvc-dev-cmd@v1
with: with:
arch: ${{ matrix.target.vcvars }} arch: ${{ matrix.target.vcvars }}
- name: Add LLVM to path - name: Add LLVM to path
run: echo "C:/Program Files/LLVM/bin" >> $env:GITHUB_PATH run: echo "C:/Program Files/LLVM/bin" >> $env:GITHUB_PATH
- name: Download Ninja - name: Download Ninja
run: > run: >
Invoke-WebRequest https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip -OutFile ninja-win.zip && Invoke-WebRequest https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip -OutFile ninja-win.zip &&
Expand-Archive ninja-win.zip -DestinationPath . Expand-Archive ninja-win.zip -DestinationPath .
- name: Setup NuGet Credentials - name: Setup NuGet Credentials
run: > run: >
& (C:/vcpkg/vcpkg fetch nuget | tail -n 2) & (C:/vcpkg/vcpkg fetch nuget | tail -n 2)
sources add sources add
-source "https://nuget.pkg.github.com/86Box/index.json" -source "https://nuget.pkg.github.com/86Box/index.json"
-storepasswordincleartext -storepasswordincleartext
-name "GitHub" -name "GitHub"
-username "86Box" -username "86Box"
-password "${{ secrets.GITHUB_TOKEN }}" -password "${{ secrets.GITHUB_TOKEN }}"
- name: Fix MSVC atomic headers - name: Fix MSVC atomic headers
run: dir "C:/Program Files/Microsoft Visual Studio/2022/*/VC/Tools/MSVC/*/include" -include stdatomic.h -recurse | del run: dir "C:/Program Files/Microsoft Visual Studio/2022/*/VC/Tools/MSVC/*/include" -include stdatomic.h -recurse | del
- name: Configure CMake - name: Configure CMake
run: > run: >
cmake -G Ninja -S . -B build cmake -G Ninja -S . -B build --preset ${{ matrix.build.preset }}
-D DEV_BUILD=${{ matrix.build.dev}} -D NEW_DYNAREC=${{ matrix.dynarec.new }} -D QT=${{ matrix.ui.qt }} --toolchain C:/vcpkg/scripts/buildsystems/vcpkg.cmake
-D CMAKE_BUILD_TYPE=Debug -D NEW_DYNAREC=${{ matrix.dynarec.new }} -D QT=${{ matrix.ui.qt }}
-D CMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -D VCPKG_CHAINLOAD_TOOLCHAIN_FILE=${{ github.workspace }}/${{ matrix.target.toolchain }}
-D VCPKG_CHAINLOAD_TOOLCHAIN_FILE=${{ github.workspace }}/${{ matrix.target.toolchain }} -D VCPKG_TARGET_TRIPLET=${{ matrix.target.triplet }}
-D VCPKG_TARGET_TRIPLET=${{ matrix.target.triplet }} -D VCPKG_HOST_TRIPLET=x64-windows
-D VCPKG_HOST_TRIPLET=x64-windows -D VCPKG_USE_HOST_TOOLS=ON
-D VCPKG_USE_HOST_TOOLS=ON - name: Fix Qt
- name: Fix Qt if: matrix.ui.qt == 'on'
if: matrix.ui.qt == 'on' run: |
run: | $qtTargetsPath = "${{ github.workspace }}/build/vcpkg_installed/${{ matrix.target.triplet }}/share/Qt6/Qt6Targets.cmake"
$qtTargetsPath = "${{ github.workspace }}/build/vcpkg_installed/${{ matrix.target.triplet }}/share/Qt6/Qt6Targets.cmake" (Get-Content $qtTargetsPath) -replace "^.*-Zc:__cplusplus;-permissive-.*$","#$&" | Set-Content $qtTargetsPath
(Get-Content $qtTargetsPath) -replace "^.*-Zc:__cplusplus;-permissive-.*$","#$&" | Set-Content $qtTargetsPath - name: Reconfigure CMake
- name: Reconfigure CMake if: matrix.ui.qt == 'on'
if: matrix.ui.qt == 'on' run: cmake clean build
run: cmake clean build - name: Build
- name: Build run: cmake --build build
run: cmake --build build - name: Generate package
- name: Generate package run: cmake --install build --prefix ./build/artifacts
run: cmake --install build --prefix ./build/artifacts - uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v2 with:
with: name: '86Box${{ matrix.ui.slug }}${{ matrix.dynarec.slug }}${{ matrix.build.slug }}-Windows-LLVM-${{ matrix.target.name }}-gha${{ github.run_number }}'
name: '86Box${{ matrix.ui.slug }}${{ matrix.dynarec.slug }}${{ matrix.build.slug }}-Windows-LLVM-${{ matrix.target.name }}-gha${{ github.run_number }}' path: build/artifacts/**
path: build/artifacts/**
linux: linux:
name: "Linux GCC 11 (${{ matrix.build.name }} x86_64)" name: "Linux GCC 11 (${{ matrix.build.name }} ${{ matrix.dynarec.name }} x86_64)"
runs-on: ubuntu-20.04 runs-on: ubuntu-22.04
strategy: strategy:
fail-fast: true fail-fast: true
matrix: matrix:
build: build:
# - name: Regular ODR - name: Debug
# slug: -ODR preset: debug
# type: Release slug: -Debug
# dev-build: off - name: Dev
# new-dynarec: off preset: experimental
# strip: --strip slug: -Dev
- name: Debug ODR dynarec:
slug: -ODR-Debug - name: ODR
type: Debug new: off
dev-build: off slug: -ODR
new-dynarec: off - name: NDR
- name: Dev ODR new: on
slug: -ODR-Dev slug: -NDR
type: Debug
dev-build: on
new-dynarec: off
# - name: Regular NDR
# slug: -NDR
# type: Release
# strip: --strip
# dev-build: off
# new-dynarec: on
- name: Debug NDR
slug: -NDR-Debug
type: Debug
dev-build: off
new-dynarec: on
- name: Dev NDR
slug: -NDR-Dev
type: Debug
dev-build: on
new-dynarec: on
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Install dependencies - name: Install dependencies
run: sudo apt update && sudo apt install gcc-11 g++-11 libfreetype-dev libsdl2-dev libpng-dev libc6-dev librtmidi-dev qtbase5-dev qttools5-dev libfaudio-dev run: >-
sudo apt update && sudo apt install
build-essential
ninja-build
libfreetype-dev
libsdl2-dev
libpng-dev
libc6-dev
librtmidi-dev
qtbase5-dev
qttools5-dev
libfaudio-dev
- name: Configure CMake - name: Configure CMake
run: >- run: >-
cmake -S . -B build cmake -G Ninja -S . -B build --preset ${{ matrix.build.preset }}
-D CMAKE_INSTALL_PREFIX=./build/artifacts --toolchain ./cmake/flags-gcc-x86_64.cmake
-D DEV_BRANCH=${{ matrix.build.dev-build }} -D NEW_DYNAREC=${{ matrix.dynarec.new }}
-D NEW_DYNAREC=${{ matrix.build.new-dynarec }}
-D CMAKE_BUILD_TYPE=${{ matrix.build.type }}
-D CMAKE_C_COMPILER=gcc-11 -D CMAKE_CXX_COMPILER=g++-11
- name: Build - name: Build
run: cmake --build build run: cmake --build build
- name: Generate package # - name: Generate package
run: cmake --install build --prefix ./build/artifacts ${{ matrix.build.strip }} # run: cmake --install build --prefix ./build/artifacts
- uses: actions/upload-artifact@v2 # - uses: actions/upload-artifact@v2
with: # with:
name: '86Box${{ matrix.build.slug }}-UbuntuFocal-x86_64-gha${{ github.run_number }}' # name: '86Box${{ matrix.build.slug }}-UbuntuJammy-x86_64-gha${{ github.run_number }}'
path: build/artifacts/** # path: build/artifacts/**
macos11: macos11:
name: "macOS 11 (${{ matrix.build.name }} x86_64)" name: "macOS 11 (${{ matrix.build.name }} x86_64)"
@@ -275,56 +254,35 @@ jobs:
fail-fast: true fail-fast: true
matrix: matrix:
build: build:
# - name: Regular ODR - name: Debug
# slug: -ODR preset: debug
# type: Release slug: -Debug
# dev-build: off - name: Dev
# new-dynarec: off preset: experimental
# strip: --strip slug: -Dev
- name: Debug ODR dynarec:
slug: -ODR-Debug - name: ODR
type: Debug new: off
dev-build: off slug: -ODR
new-dynarec: off - name: NDR
- name: Dev ODR new: on
slug: -ODR-Dev slug: -NDR
type: Debug
dev-build: on
new-dynarec: off
# - name: Regular NDR
# slug: -NDR
# type: Release
# strip: --strip
# dev-build: off
# new-dynarec: on
- name: Debug NDR
slug: -NDR-Debug
type: Debug
dev-build: off
new-dynarec: on
- name: Dev NDR
slug: -NDR-Dev
type: Debug
dev-build: on
new-dynarec: on
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Install dependencies - name: Install dependencies
run: brew install freetype sdl2 libpng rtmidi qt@5 faudio run: brew install freetype sdl2 libpng rtmidi qt@5 faudio ninja
- name: Configure CMake - name: Configure CMake
run: >- run: >-
PATH=/usr/local/opt/qt@5/bin:$PATH PATH=/usr/local/opt/qt@5/bin:$PATH
cmake -S . -B build cmake -G Ninja -S . -B build --preset ${{ matrix.build.preset }}
--toolchain cmake/flags-gcc-x86_64.cmake --toolchain cmake/flags-gcc-x86_64.cmake
-D DEV_BRANCH=${{ matrix.build.dev-build }}
-D NEW_DYNAREC=${{ matrix.build.new-dynarec }} -D NEW_DYNAREC=${{ matrix.build.new-dynarec }}
-D CMAKE_BUILD_TYPE=${{ matrix.build.type }}
-D CMAKE_FIND_ROOT_PATH=/usr/local/opt/qt@5 -D CMAKE_FIND_ROOT_PATH=/usr/local/opt/qt@5
- name: Build - name: Build
run: cmake --build build run: cmake --build build
- name: Generate package - name: Generate package
run: cmake --install build --prefix ./build/artifacts ${{ matrix.build.strip }} run: cmake --install build --prefix ./build/artifacts
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
name: '86Box${{ matrix.build.slug }}-macOS-x86_64-gha${{ github.run_number }}' name: '86Box${{ matrix.build.slug }}-macOS-x86_64-gha${{ github.run_number }}'

View File

@@ -2,108 +2,35 @@
"version": 3, "version": 3,
"cmakeMinimumRequired": { "cmakeMinimumRequired": {
"major": 3, "major": 3,
"minor": 21, "minor": 21
"patch": 0
}, },
"configurePresets": [ "configurePresets": [
{
"name": "flags-base",
"cacheVariables": {
"CMAKE_CONFIGURATION_TYPES": "Debug;Release;Optimized"
},
"hidden": true,
"binaryDir": "build"
},
{ {
"name": "regular", "name": "regular",
"inherits": [
"flags-base"
],
"generator": "Ninja",
"cacheVariables": { "cacheVariables": {
"CMAKE_BUILD_TYPE": "Release", "CMAKE_BUILD_TYPE": "Release",
"DEV_BRANCH": "OFF", "DEV_BRANCH": "OFF",
"NEW_DYNAREC": "OFF" "NEW_DYNAREC": "OFF"
} }
}, },
{
"name": "regularndr",
"inherits": [
"flags-base"
],
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"DEV_BRANCH": "OFF",
"NEW_DYNAREC": "ON"
}
},
{ {
"name": "optimized", "name": "optimized",
"inherits": [
"flags-base"
],
"generator": "Ninja",
"cacheVariables": { "cacheVariables": {
"CMAKE_BUILD_TYPE": "Optimized", "CMAKE_BUILD_TYPE": "Optimized",
"DEV_BRANCH": "OFF", "DEV_BRANCH": "OFF",
"NEW_DYNAREC": "OFF" "NEW_DYNAREC": "OFF"
} }
}, },
{
"name": "optimizedndr",
"inherits": [
"flags-base"
],
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Optimized",
"DEV_BRANCH": "OFF",
"NEW_DYNAREC": "ON"
}
},
{ {
"name": "debug", "name": "debug",
"inherits": [
"flags-base"
],
"generator": "Ninja",
"cacheVariables": { "cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug", "CMAKE_BUILD_TYPE": "Debug",
"DEV_BRANCH": "OFF", "DEV_BRANCH": "OFF",
"NEW_DYNAREC": "OFF" "NEW_DYNAREC": "OFF"
} }
}, },
{
"name": "debugndr",
"inherits": [
"flags-base"
],
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"DEV_BRANCH": "OFF",
"NEW_DYNAREC": "ON"
}
},
{ {
"name": "experimental", "name": "experimental",
"inherits": [
"flags-base"
],
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"DEV_BRANCH": "ON",
"NEW_DYNAREC": "OFF"
}
},
{
"name": "experimentalndr",
"inherits": [
"flags-base"
],
"generator": "Ninja",
"cacheVariables": { "cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug", "CMAKE_BUILD_TYPE": "Debug",
"DEV_BRANCH": "ON", "DEV_BRANCH": "ON",