From 268c4f14c194b72ced33f520688fb0d3d096fad5 Mon Sep 17 00:00:00 2001 From: Nadia Holmquist Pedersen Date: Fri, 6 Sep 2024 22:50:12 +0200 Subject: [PATCH] vcpkg: support building on Linux --- cmake/ConfigureVcpkg.cmake | 13 +++++++++++++ src/frontend/qt_sdl/CMakeLists.txt | 7 ++++++- vcpkg.json | 27 ++++++++++++++++++++++++++- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/cmake/ConfigureVcpkg.cmake b/cmake/ConfigureVcpkg.cmake index bd256d91..f8c33fd4 100644 --- a/cmake/ConfigureVcpkg.cmake +++ b/cmake/ConfigureVcpkg.cmake @@ -25,6 +25,11 @@ else() option(USE_QT6 "Build using Qt 6 instead of 5" OFF) endif() +# Since the Linux build pulls in glib anyway, we can just use upstream libslirp +if (UNIX AND NOT APPLE) + option(USE_SYSTEM_LIBSLIRP "Use system libslirp instead of the bundled version" ON) +endif() + if (NOT USE_QT6) list(APPEND VCPKG_MANIFEST_FEATURES qt5) set(VCPKG_MANIFEST_NO_DEFAULT_FEATURES ON) @@ -62,6 +67,14 @@ if (USE_RECOMMENDED_TRIPLETS) # TODO Windows arm64 if possible set(_CAN_TARGET_AS_HOST ON) set(_WANTED_TRIPLET x64-mingw-static-release) + elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux) + # Can't really detect cross compiling here. + set(_CAN_TARGET_AS_HOST ON) + if (_HOST_PROCESSOR STREQUAL x86_64) + set(_WANTED_TRIPLET x64-linux-release) + elseif(_HOST_PROCESSOR STREQUAL "aarch64") + set(_WANTED_TRIPLET arm64-linux-release) + endif() endif() # Don't override it if the user set something else diff --git a/src/frontend/qt_sdl/CMakeLists.txt b/src/frontend/qt_sdl/CMakeLists.txt index 9cd784aa..524fa13d 100644 --- a/src/frontend/qt_sdl/CMakeLists.txt +++ b/src/frontend/qt_sdl/CMakeLists.txt @@ -160,7 +160,12 @@ if (BUILD_STATIC) if (WIN32 AND USE_QT6) qt_import_plugins(melonDS INCLUDE Qt::QModernWindowsStylePlugin) endif() - target_link_options(melonDS PRIVATE -static) + if (USE_VCPKG AND UNIX AND NOT APPLE) + pkg_check_modules(ALSA REQUIRED IMPORTED_TARGET alsa) + target_link_libraries(melonDS PRIVATE PkgConfig::ALSA) + else() + target_link_options(melonDS PRIVATE -static) + endif() endif() target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/vcpkg.json b/vcpkg.json index eb8790c8..cd734cce 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -2,9 +2,22 @@ "default-features": ["qt6"], "dependencies": [ "sdl2", + { + "name": "sdl2", + "platform": "linux", + "features": [ "alsa" ] + }, "libarchive", "zstd", - "enet" + "enet", + { + "name": "ecm", + "platform": "linux" + }, + { + "name": "libslirp", + "platform": "linux" + } ], "features": { "qt6": { @@ -15,6 +28,12 @@ "default-features": false, "features": ["gui", "png", "thread", "widgets", "opengl", "zstd", "harfbuzz"] }, + { + "name": "qtbase", + "platform": "linux", + "default-features": false, + "features": ["dbus", "xcb", "xkb", "xcb-xlib", "freetype", "fontconfig"] + }, { "name": "qtbase", "host": true, @@ -24,6 +43,12 @@ "name": "qtmultimedia", "default-features": false }, + { + "name": "qtmultimedia", + "platform": "linux", + "features": ["gstreamer"], + "default-features": false + }, "qtsvg" ] },