Build Windows CI builds with vcpkg and Qt 6 (#2112)

If using Qt 6 becomes a problem in terms of compatibility, toggle it off in the CMakePresets.json.
This commit is contained in:
Nadia Holmquist Pedersen 2024-07-27 17:22:35 +02:00 committed by GitHub
parent d31eabb6fa
commit ececf337f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 102 additions and 46 deletions

View File

@ -8,36 +8,30 @@ on:
branches: branches:
- master - master
env:
BUILD_TYPE: Release
jobs: jobs:
build: build:
runs-on: windows-latest runs-on: windows-latest
defaults: defaults:
run: run:
shell: msys2 {0} shell: msys2 {0}
steps: steps:
- uses: actions/checkout@v1 - name: Check out sources
- uses: msys2/setup-msys2@v2 uses: actions/checkout@v3
- name: Set up MSYS2
uses: msys2/setup-msys2@v2
with: with:
msystem: MINGW64 msystem: ucrt64
update: true update: true
pacboy: gcc:p cmake:p ninja:p make:p
- name: Install dependencies - name: Set up vcpkg
run: pacman -Sq --noconfirm git pkgconf mingw-w64-x86_64-{cmake,SDL2,qt5-static,libarchive,toolchain} uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: 53bef8994c541b6561884a8395ea35715ece75db
- name: Configure - name: Configure
working-directory: ${{runner.workspace}} run: cmake --preset=release-mingw-x86_64
run: cmake -B build $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_STATIC=ON -DCMAKE_PREFIX_PATH=C:/tools/msys64/mingw64/qt5-static - name: Build
run: cmake --build --preset=release-mingw-x86_64
- name: Make - uses: actions/upload-artifact@v4
working-directory: ${{runner.workspace}}/build
run: cmake --build .
- uses: actions/upload-artifact@v1
with: with:
name: melonDS-windows-x86_64 name: melonDS-windows-x86_64
path: ${{runner.workspace}}\build\melonDS.exe path: .\build\release-mingw-x86_64\melonDS.exe

View File

@ -20,6 +20,23 @@
} }
} }
}, },
{
"name": "release-mingw-x86_64",
"inherits": "release-vcpkg",
"displayName": "Windows MinGW release (x86_64)",
"binaryDir": "${sourceDir}/build/release-mingw-x86_64",
"generator": "Ninja",
"cacheVariables": {
"USE_QT6": {
"type": "BOOL",
"value": "ON"
},
"BUILD_STATIC": {
"type": "BOOL",
"value": "ON"
}
}
},
{ {
"name": "release-mac-x86_64", "name": "release-mac-x86_64",
"inherits": "release-vcpkg", "inherits": "release-vcpkg",
@ -44,6 +61,10 @@
"name": "release-vcpkg", "name": "release-vcpkg",
"configurePreset": "release-vcpkg" "configurePreset": "release-vcpkg"
}, },
{
"name": "release-mingw-x86_64",
"configurePreset": "release-mingw-x86_64"
},
{ {
"name": "release-mac-x86_64", "name": "release-mac-x86_64",
"configurePreset": "release-mac-x86_64" "configurePreset": "release-mac-x86_64"

View File

@ -4,7 +4,9 @@ set(_DEFAULT_VCPKG_ROOT "${CMAKE_SOURCE_DIR}/vcpkg")
set(VCPKG_ROOT "${_DEFAULT_VCPKG_ROOT}" CACHE STRING "The path to the vcpkg repository") set(VCPKG_ROOT "${_DEFAULT_VCPKG_ROOT}" CACHE STRING "The path to the vcpkg repository")
if (VCPKG_ROOT STREQUAL "${_DEFAULT_VCPKG_ROOT}") if (VCPKG_ROOT STREQUAL "${_DEFAULT_VCPKG_ROOT}")
file(LOCK "${_DEFAULT_VCPKG_ROOT}" DIRECTORY GUARD FILE) if (APPLE) # this doesn't work on non-macOS
file(LOCK "${_DEFAULT_VCPKG_ROOT}" DIRECTORY GUARD FILE)
endif()
FetchContent_Declare(vcpkg FetchContent_Declare(vcpkg
GIT_REPOSITORY "https://github.com/Microsoft/vcpkg.git" GIT_REPOSITORY "https://github.com/Microsoft/vcpkg.git"
GIT_TAG 2024.01.12 GIT_TAG 2024.01.12
@ -16,6 +18,18 @@ set(VCPKG_OVERLAY_TRIPLETS "${CMAKE_SOURCE_DIR}/cmake/overlay-triplets")
option(USE_RECOMMENDED_TRIPLETS "Use the recommended triplets that are used for official builds" ON) option(USE_RECOMMENDED_TRIPLETS "Use the recommended triplets that are used for official builds" ON)
# Duplicated here because it needs to be set before project()
if (NOT WIN32)
option(USE_QT6 "Build using Qt 6 instead of 5" ON)
else()
option(USE_QT6 "Build using Qt 6 instead of 5" OFF)
endif()
if (NOT USE_QT6)
list(APPEND VCPKG_MANIFEST_FEATURES qt5)
set(VCPKG_MANIFEST_NO_DEFAULT_FEATURES ON)
endif()
if (CMAKE_OSX_ARCHITECTURES MATCHES ";") if (CMAKE_OSX_ARCHITECTURES MATCHES ";")
message(FATAL_ERROR "macOS universal builds are not supported. Build them individually and combine afterwards instead.") message(FATAL_ERROR "macOS universal builds are not supported. Build them individually and combine afterwards instead.")
endif() endif()
@ -47,7 +61,7 @@ if (USE_RECOMMENDED_TRIPLETS)
elseif(WIN32) elseif(WIN32)
# TODO Windows arm64 if possible # TODO Windows arm64 if possible
set(_CAN_TARGET_AS_HOST ON) set(_CAN_TARGET_AS_HOST ON)
set(_WANTED_TRIPLET x64-mingw-static) set(_WANTED_TRIPLET x64-mingw-static-release)
endif() endif()
# Don't override it if the user set something else # Don't override it if the user set something else

View File

@ -0,0 +1,7 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_ENV_PASSTHROUGH PATH)
set(VCPKG_BUILD_TYPE release)
set(VCPKG_CMAKE_SYSTEM_NAME MinGW)

View File

@ -1,26 +1,46 @@
{ {
"default-features": ["qt6"],
"dependencies": [ "dependencies": [
"sdl2", "sdl2",
{ "libarchive",
"name": "libarchive", "zstd"
"default-features": false, ],
"features": ["bzip2", "crypto", "lz4", "zstd"] "features": {
"qt6": {
"description": "Use Qt 6 for the frontend.",
"dependencies": [
{
"name": "qtbase",
"default-features": false,
"features": ["gui", "png", "thread", "widgets", "opengl", "zstd"]
},
{
"name": "qtbase",
"host": true,
"default-features": false
},
{
"name": "qtmultimedia",
"default-features": false
},
"qtsvg"
]
}, },
"zstd", "qt5": {
{ "description": "Use Qt 5 for the frontend.",
"name": "qtbase", "dependencies": [
"default-features": false, {
"features": ["gui", "png", "thread", "widgets", "opengl", "zstd"] "name": "qt5-base",
}, "default-features": false
{ },
"name": "qtbase", {
"host": true, "name": "qt5-base",
"default-features": false "host": true,
}, "default-features": false
{ },
"name": "qtmultimedia", "qt5-multimedia",
"default-features": false "qt5-svg"
}, ]
"qtsvg" }
] }
} }