diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f3d51a48..dbc02c4c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -326,6 +326,7 @@ jobs: "-DCMAKE_TOOLCHAIN_FILE=$toolchain", "-DVCPKG_TARGET_TRIPLET=x64-windows-static", "-DVCPKG_MANIFEST_MODE=ON", + "-DVCPKG_OVERLAY_PORTS=${{ github.workspace }}/cmake/overlays", "-DYAZE_BUILD_TESTS=ON", "-DYAZE_BUILD_EMU=ON", "-DYAZE_BUILD_Z3ED=ON", diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5f00f6a3..65e4f1ec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,6 +55,7 @@ jobs: -DCMAKE_BUILD_TYPE=Release ` -DCMAKE_TOOLCHAIN_FILE=$toolchain ` -DVCPKG_TARGET_TRIPLET=x64-windows-static ` + -DVCPKG_OVERLAY_PORTS="${{ github.workspace }}/cmake/overlays" ` -DYAZE_BUILD_TESTS=OFF ` -DYAZE_BUILD_EMU=ON ` -DYAZE_BUILD_Z3ED=ON ` diff --git a/cmake/overlays/README.md b/cmake/overlays/README.md new file mode 100644 index 00000000..8ad08d47 --- /dev/null +++ b/cmake/overlays/README.md @@ -0,0 +1,37 @@ +# vcpkg Port Overlays + +This directory contains custom vcpkg port overlays that modify the behavior of specific packages during installation. + +## Purpose + +vcpkg overlays allow us to patch specific ports without forking the entire vcpkg repository. These overlays are automatically used when `VCPKG_OVERLAY_PORTS` is set in the CMake configuration. + +## Current Overlays + +### sdl2/ + +**Problem**: The official SDL2 vcpkg port runs `vcpkg_fixup_pkgconfig()` on Windows, which attempts to download `pkgconf` from MSYS2 mirrors. These URLs frequently return 404 errors, causing build failures. + +**Solution**: Patched portfile that skips pkgconfig fixup on Windows platforms while maintaining it for Linux/macOS where it's needed. + +**Impact**: Prevents SDL2 installation failures on Windows without affecting functionality (pkgconfig isn't needed for Windows static builds). + +## Usage + +The overlays are automatically applied via the GitHub Actions workflows: + +```cmake +-DVCPKG_OVERLAY_PORTS=${github.workspace}/cmake/overlays +``` + +For local development on Windows: +```bash +cmake -B build -DVCPKG_OVERLAY_PORTS=cmake/overlays ... +``` + +## Maintenance + +- Overlays are version-specific (currently SDL2 2.30.9) +- When updating SDL2 version in vcpkg.json, check if the overlay needs updating +- Monitor upstream vcpkg for fixes that would allow removing these overlays + diff --git a/cmake/overlays/sdl2/portfile.cmake b/cmake/overlays/sdl2/portfile.cmake new file mode 100644 index 00000000..7e895dd5 --- /dev/null +++ b/cmake/overlays/sdl2/portfile.cmake @@ -0,0 +1,83 @@ +# Patched SDL2 portfile that skips pkgconfig fixup on Windows +# This prevents MSYS2 download failures during vcpkg installation +# Based on official SDL2 port with pkgconfig fixup removed + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO libsdl-org/SDL + REF "release-${VERSION}" + SHA512 bbf9e35dc1cb1b47d1e452ef23bd3b49bdfd83c6e291e7e7f61c45fb07b33e01cc77811c8c854a599bcdafc2e98b03015fc5e9c6e4c1db8ec61a9e90ff17ed83 + HEAD_REF main + PATCHES + deps.patch + alsa-dep-fix.patch + cxx-linkage-pkgconfig.diff +) + +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" SDL_STATIC) +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" SDL_SHARED) +string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" FORCE_STATIC_VCRT) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + alsa SDL_ALSA + ibus SDL_IBUS + samplerate SDL_LIBSAMPLERATE + wayland SDL_WAYLAND + x11 SDL_X11 +) + +if(VCPKG_TARGET_IS_UWP) + set(configure_opts WINDOWS_USE_MSBUILD) +endif() + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + ${configure_opts} + OPTIONS ${FEATURE_OPTIONS} + -DSDL_STATIC=${SDL_STATIC} + -DSDL_SHARED=${SDL_SHARED} + -DSDL_FORCE_STATIC_VCRT=${FORCE_STATIC_VCRT} + -DSDL_LIBC=ON + -DSDL_TEST=OFF + -DSDL_INSTALL_CMAKEDIR=share/sdl2 + MAYBE_UNUSED_VARIABLES + SDL_FORCE_STATIC_VCRT +) + +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(CONFIG_PATH share/sdl2) + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" + "${CURRENT_PACKAGES_DIR}/bin/sdl2-config" + "${CURRENT_PACKAGES_DIR}/debug/bin/sdl2-config" + "${CURRENT_PACKAGES_DIR}/share/licenses" + "${CURRENT_PACKAGES_DIR}/share/aclocal" +) + +# Skip pkgconfig fixup on Windows to avoid MSYS2 download issues +if(NOT VCPKG_TARGET_IS_WINDOWS) + vcpkg_fixup_pkgconfig() +endif() + +if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_UWP) + if(NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib/manual-link") + file(RENAME "${CURRENT_PACKAGES_DIR}/lib/SDL2main.lib" "${CURRENT_PACKAGES_DIR}/lib/manual-link/SDL2main.lib") + endif() + if(NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib/manual-link") + file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/SDL2maind.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/manual-link/SDL2maind.lib") + endif() + + file(GLOB SHARE_FILES "${CURRENT_PACKAGES_DIR}/share/sdl2/*.cmake") + foreach(SHARE_FILE ${SHARE_FILES}) + vcpkg_replace_string("${SHARE_FILE}" "lib/SDL2main" "lib/manual-link/SDL2main") + endforeach() +endif() + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt") + diff --git a/cmake/overlays/sdl2/usage b/cmake/overlays/sdl2/usage new file mode 100644 index 00000000..5475be7a --- /dev/null +++ b/cmake/overlays/sdl2/usage @@ -0,0 +1,8 @@ +SDL2 provides CMake targets: + + find_package(SDL2 CONFIG REQUIRED) + target_link_libraries(main PRIVATE $,SDL2::SDL2,SDL2::SDL2-static>) + + # SDL2::SDL2main may be optionally added manually to provide a main() function wrapper. + # If you use this, don't use SDL_MAIN_HANDLED. + diff --git a/cmake/overlays/sdl2/vcpkg.json b/cmake/overlays/sdl2/vcpkg.json new file mode 100644 index 00000000..78004417 --- /dev/null +++ b/cmake/overlays/sdl2/vcpkg.json @@ -0,0 +1,68 @@ +{ + "name": "sdl2", + "version": "2.30.9", + "description": "Simple DirectMedia Layer (patched to skip pkgconfig on Windows)", + "homepage": "https://www.libsdl.org/", + "license": "Zlib", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "default-features": [], + "features": { + "alsa": { + "description": "Support for alsa audio", + "dependencies": [ + { + "name": "alsa", + "platform": "linux" + } + ] + }, + "ibus": { + "description": "Build with support for IBus", + "dependencies": [ + { + "name": "ibus", + "platform": "linux" + } + ] + }, + "samplerate": { + "description": "Use libsamplerate for audio rate conversion", + "dependencies": [ + "libsamplerate" + ] + }, + "wayland": { + "description": "Build with support for Wayland", + "dependencies": [ + { + "name": "wayland", + "platform": "linux" + }, + { + "name": "wayland-protocols", + "host": true, + "platform": "linux" + } + ] + }, + "x11": { + "description": "Build with support for X11", + "dependencies": [ + { + "name": "libxext", + "platform": "linux" + } + ] + } + } +} +