Add support for vcpkg (#3742)

This commit is contained in:
Seth Flynn 2025-07-09 06:50:41 -04:00 committed by GitHub
commit af73cfa20f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 66 additions and 1 deletions

View File

@ -25,6 +25,31 @@ runs:
arch: ${{ inputs.vcvars-arch }}
vsversion: 2022
- name: Setup vcpkg cache (MSVC)
if: ${{ inputs.msystem == '' && inputs.build-type == 'Debug' }}
shell: pwsh
env:
USERNAME: ${{ github.repository_owner }}
FEED_URL: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
run: |
.$(vcpkg fetch nuget) `
sources add `
-Source "$env:FEED_URL" `
-StorePasswordInClearText `
-Name GitHubPackages `
-UserName "$env:USERNAME" `
-Password "$env:GITHUB_TOKEN"
.$(vcpkg fetch nuget) `
setapikey "$env:GITHUB_TOKEN" `
-Source "$env:FEED_URL"
Write-Output "VCPKG_BINARY_SOURCES=clear;nuget,$env:FEED_URL,readwrite" >> "$GITHUB_ENV"
- name: Setup vcpkg environment (MSVC)
if: ${{ inputs.msystem == '' }}
shell: bash
run: |
echo "CMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" >> "$GITHUB_ENV"
- name: Setup MSYS2 (MinGW)
if: ${{ inputs.msystem != '' }}
uses: msys2/setup-msys2@v2

View File

@ -69,6 +69,10 @@ jobs:
build:
name: Build (${{ matrix.artifact-name }})
permissions:
# Required for vcpkg binary cache
packages: write
strategy:
fail-fast: false
matrix:

View File

@ -348,6 +348,14 @@ endif()
if(NOT Launcher_FORCE_BUNDLED_LIBS)
# Find toml++
find_package(tomlplusplus 3.2.0 QUIET)
# Fallback to pkg-config (if available) if CMake files aren't found
if(NOT tomlplusplus_FOUND)
find_package(PkgConfig)
if(PkgConfig_FOUND)
pkg_check_modules(tomlplusplus IMPORTED_TARGET tomlplusplus>=3.2.0)
endif()
endif()
# Find cmark
find_package(cmark QUIET)

View File

@ -1309,12 +1309,16 @@ target_link_libraries(Launcher_logic
Launcher_murmur2
nbt++
${ZLIB_LIBRARIES}
tomlplusplus::tomlplusplus
qdcss
BuildConfig
Qt${QT_VERSION_MAJOR}::Widgets
qrcodegenerator
)
if(TARGET PkgConfig::tomlplusplus)
target_link_libraries(Launcher_logic PkgConfig::tomlplusplus)
else()
target_link_libraries(Launcher_logic tomlplusplus::tomlplusplus)
endif()
if (UNIX AND NOT CYGWIN AND NOT APPLE)
target_link_libraries(Launcher_logic

14
vcpkg-configuration.json Normal file
View File

@ -0,0 +1,14 @@
{
"default-registry": {
"kind": "git",
"baseline": "0c4cf19224a049cf82f4521e29e39f7bd680440c",
"repository": "https://github.com/microsoft/vcpkg"
},
"registries": [
{
"kind": "artifact",
"location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip",
"name": "microsoft"
}
]
}

10
vcpkg.json Normal file
View File

@ -0,0 +1,10 @@
{
"dependencies": [
"bzip2",
"cmark",
{ "name": "ecm", "host": true },
{ "name": "pkgconf", "host": true },
"tomlplusplus",
"zlib"
]
}