Skip to content

Commit

Permalink
Build Windows CI builds with vcpkg and Qt 6 (#2112)
Browse files Browse the repository at this point in the history
If using Qt 6 becomes a problem in terms of compatibility, toggle it off in the CMakePresets.json.
  • Loading branch information
nadiaholmquist authored Jul 27, 2024
1 parent d31eabb commit ececf33
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 46 deletions.
38 changes: 16 additions & 22 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,30 @@ on:
branches:
- master

env:
BUILD_TYPE: Release

jobs:
build:

runs-on: windows-latest

defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v1
- uses: msys2/setup-msys2@v2
- name: Check out sources
uses: actions/checkout@v3
- name: Set up MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true

- name: Install dependencies
run: pacman -Sq --noconfirm git pkgconf mingw-w64-x86_64-{cmake,SDL2,qt5-static,libarchive,toolchain}

msystem: ucrt64
update: true
pacboy: gcc:p cmake:p ninja:p make:p
- name: Set up vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: 53bef8994c541b6561884a8395ea35715ece75db
- name: Configure
working-directory: ${{runner.workspace}}
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: Make
working-directory: ${{runner.workspace}}/build
run: cmake --build .

- uses: actions/upload-artifact@v1
run: cmake --preset=release-mingw-x86_64
- name: Build
run: cmake --build --preset=release-mingw-x86_64
- uses: actions/upload-artifact@v4
with:
name: melonDS-windows-x86_64
path: ${{runner.workspace}}\build\melonDS.exe
path: .\build\release-mingw-x86_64\melonDS.exe
23 changes: 22 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"inherits": "release-vcpkg",
Expand All @@ -44,6 +61,10 @@
"name": "release-vcpkg",
"configurePreset": "release-vcpkg"
},
{
"name": "release-mingw-x86_64",
"configurePreset": "release-mingw-x86_64"
},
{
"name": "release-mac-x86_64",
"configurePreset": "release-mac-x86_64"
Expand Down Expand Up @@ -85,4 +106,4 @@
]
}
]
}
}
18 changes: 16 additions & 2 deletions cmake/ConfigureVcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")

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
GIT_REPOSITORY "https://github.com/Microsoft/vcpkg.git"
GIT_TAG 2024.01.12
Expand All @@ -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)

# 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 ";")
message(FATAL_ERROR "macOS universal builds are not supported. Build them individually and combine afterwards instead.")
endif()
Expand Down Expand Up @@ -47,7 +61,7 @@ if (USE_RECOMMENDED_TRIPLETS)
elseif(WIN32)
# TODO Windows arm64 if possible
set(_CAN_TARGET_AS_HOST ON)
set(_WANTED_TRIPLET x64-mingw-static)
set(_WANTED_TRIPLET x64-mingw-static-release)
endif()

# Don't override it if the user set something else
Expand Down
7 changes: 7 additions & 0 deletions cmake/overlay-triplets/x64-mingw-static-release.cmake
Original file line number Diff line number Diff line change
@@ -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)
62 changes: 41 additions & 21 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,46 @@
{
"default-features": ["qt6"],
"dependencies": [
"sdl2",
{
"name": "libarchive",
"default-features": false,
"features": ["bzip2", "crypto", "lz4", "zstd"]
"libarchive",
"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",
{
"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"
]
"qt5": {
"description": "Use Qt 5 for the frontend.",
"dependencies": [
{
"name": "qt5-base",
"default-features": false
},
{
"name": "qt5-base",
"host": true,
"default-features": false
},
"qt5-multimedia",
"qt5-svg"
]
}
}
}

0 comments on commit ececf33

Please sign in to comment.