From c46fb824ad3841241e59f50df5508ede95866431 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Thu, 10 Oct 2024 10:13:43 +0700 Subject: [PATCH] Re-add qtmultimedia overlay to fix windows builds --- .../fix_avfoundation_target.patch | 13 +++ vcpkg/ports/qtmultimedia/portfile.cmake | 70 +++++++++++++++ vcpkg/ports/qtmultimedia/private_libs.patch | 19 ++++ .../qtmultimedia/remove-static-ssl-stub.patch | 26 ++++++ .../qtmultimedia/static_find_modules.patch | 82 +++++++++++++++++ vcpkg/ports/qtmultimedia/vcpkg.json | 90 +++++++++++++++++++ 6 files changed, 300 insertions(+) create mode 100644 vcpkg/ports/qtmultimedia/fix_avfoundation_target.patch create mode 100644 vcpkg/ports/qtmultimedia/portfile.cmake create mode 100644 vcpkg/ports/qtmultimedia/private_libs.patch create mode 100644 vcpkg/ports/qtmultimedia/remove-static-ssl-stub.patch create mode 100644 vcpkg/ports/qtmultimedia/static_find_modules.patch create mode 100644 vcpkg/ports/qtmultimedia/vcpkg.json diff --git a/vcpkg/ports/qtmultimedia/fix_avfoundation_target.patch b/vcpkg/ports/qtmultimedia/fix_avfoundation_target.patch new file mode 100644 index 0000000000..83c457821b --- /dev/null +++ b/vcpkg/ports/qtmultimedia/fix_avfoundation_target.patch @@ -0,0 +1,13 @@ +diff --git a/src/plugins/multimedia/darwin/CMakeLists.txt b/src/plugins/multimedia/darwin/CMakeLists.txt +index a1a0cb1..242ceac 100644 +--- a/src/plugins/multimedia/darwin/CMakeLists.txt ++++ b/src/plugins/multimedia/darwin/CMakeLists.txt +@@ -34,7 +34,7 @@ qt_internal_add_plugin(QDarwinMediaPlugin + ${FWMetal} + ${FWQuartzCore} + ${FWAudioToolbox} +- AVFoundation::AVFoundation ++ ${FWAVFoundation} + ) + + qt_internal_extend_target(QDarwinMediaPlugin CONDITION NOT TVOS diff --git a/vcpkg/ports/qtmultimedia/portfile.cmake b/vcpkg/ports/qtmultimedia/portfile.cmake new file mode 100644 index 0000000000..b160fd6c73 --- /dev/null +++ b/vcpkg/ports/qtmultimedia/portfile.cmake @@ -0,0 +1,70 @@ +set(SCRIPT_PATH "${CURRENT_INSTALLED_DIR}/share/qtbase") +include("${SCRIPT_PATH}/qt_install_submodule.cmake") + +set(${PORT}_PATCHES + static_find_modules.patch + fix_avfoundation_target.patch + remove-static-ssl-stub.patch + private_libs.patch +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS +FEATURES + "qml" CMAKE_REQUIRE_FIND_PACKAGE_Qt6Quick + "widgets" CMAKE_REQUIRE_FIND_PACKAGE_Qt6Widgets +INVERTED_FEATURES + "qml" CMAKE_DISABLE_FIND_PACKAGE_Qt6Quick + "widgets" CMAKE_DISABLE_FIND_PACKAGE_Qt6Widgets + "gstreamer" CMAKE_DISABLE_FIND_PACKAGE_GStreamer + "ffmpeg" CMAKE_DISABLE_FIND_PACKAGE_FFmpeg + # Features not yet added in the manifest: + "vaapi" CMAKE_DISABLE_FIND_PACKAGE_VAAPI # not in vpckg +) + +if("gstreamer" IN_LIST FEATURES) + list(APPEND FEATURE_OPTIONS "-DINPUT_gstreamer='yes'") +else() + list(APPEND FEATURE_OPTIONS "-DINPUT_gstreamer='no'") +endif() +list(APPEND FEATURE_OPTIONS "-DINPUT_gstreamer_gl='no'") +list(APPEND FEATURE_OPTIONS "-DINPUT_gstreamer_photography='no'") + +if(VCPKG_TARGET_IS_WINDOWS) + list(APPEND FEATURE_OPTIONS "-DFEATURE_wmf=ON") +else() + list(APPEND FEATURE_OPTIONS "-DFEATURE_wmf=OFF") +endif() + +if("ffmpeg" IN_LIST FEATURES) + # Note: Requires pulsadio on linux and wmfsdk on windows + list(APPEND FEATURE_OPTIONS "-DINPUT_ffmpeg='yes'") + if(VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_OSX OR VCPKG_TARGET_IS_ANDROID) + list(APPEND FEATURE_OPTIONS "-DINPUT_pulseaudio='no'") + else() + list(APPEND FEATURE_OPTIONS "-DINPUT_pulseaudio='yes'") + endif() +else() + list(APPEND FEATURE_OPTIONS "-DINPUT_ffmpeg='no'") + list(APPEND FEATURE_OPTIONS "-DINPUT_pulseaudio='no'") +endif() + +# alsa is not ready +if(NOT "ffmpeg" IN_LIST FEATURES AND NOT "gstreamer" IN_LIST FEATURES AND VCPKG_TARGET_IS_LINUX) + #list(APPEND FEATURE_OPTIONS "-DFEATURE_alsa=ON") # alsa is experimental so don't activate it (also missing the dep on it.) + message(FATAL_ERROR "You need to activate at least one backend.") +else() + list(APPEND FEATURE_OPTIONS "-DFEATURE_alsa=OFF") +endif() + +qt_install_submodule(PATCHES ${${PORT}_PATCHES} + CONFIGURE_OPTIONS + --trace-expand + ${FEATURE_OPTIONS} + -DCMAKE_FIND_PACKAGE_TARGETS_GLOBAL=ON + CONFIGURE_OPTIONS_RELEASE + CONFIGURE_OPTIONS_DEBUG + ) + +if("gstreamer" IN_LIST FEATURES AND VCPKG_LIBRARY_LINKAGE STREQUAL "static") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/Qt6Multimedia/Qt6QGstreamerMediaPluginDependencies.cmake" "GStreamer\;FALSE\;\;\;;GStreamer\;FALSE\;\;App\;;GStreamer\;FALSE\;\;\;Gl" "GStreamer\;FALSE\;\;\;;GStreamer\;FALSE\;\;App\;;GStreamer\;FALSE\;\;\;Gl;EGL\;FALSE\;\;\;" IGNORE_UNCHANGED) +endif() diff --git a/vcpkg/ports/qtmultimedia/private_libs.patch b/vcpkg/ports/qtmultimedia/private_libs.patch new file mode 100644 index 0000000000..3ffc253f4c --- /dev/null +++ b/vcpkg/ports/qtmultimedia/private_libs.patch @@ -0,0 +1,19 @@ +diff --git a/cmake/FindFFmpeg.cmake b/cmake/FindFFmpeg.cmake +index 6316dde..54f807b 100644 +--- a/cmake/FindFFmpeg.cmake ++++ b/cmake/FindFFmpeg.cmake +@@ -264,9 +264,11 @@ function(__ffmpeg_internal_set_dependencies _component) + string(REGEX MATCHALL "${prefix_l}[^ ]+" libs_dependency ${out}) + string(REGEX MATCHALL "[^ ]+${suffix_lib}" libs_dependency_lib ${out}) + +- string(REGEX REPLACE ".*Libs.private:([^\n\r]+).*" "\\1" out "${pcfile}") +- string(REGEX MATCHALL "${prefix_l}[^ ]+" libs_private_dependency ${out}) +- string(REGEX MATCHALL "[^ ]+${suffix_lib}" libs_private_dependency_lib ${out}) ++ if(out MATCHES "Libs.private:") ++ string(REGEX REPLACE ".*Libs.private:([^\n\r]+).*" "\\1" out "${pcfile}") ++ string(REGEX MATCHALL "${prefix_l}[^ ]+" libs_private_dependency ${out}) ++ string(REGEX MATCHALL "[^ ]+${suffix_lib}" libs_private_dependency_lib ${out}) ++ endif() + + list(APPEND deps_no_suffix ${libs_dependency} ${libs_private_dependency}) + foreach(dependency ${deps_no_suffix}) diff --git a/vcpkg/ports/qtmultimedia/remove-static-ssl-stub.patch b/vcpkg/ports/qtmultimedia/remove-static-ssl-stub.patch new file mode 100644 index 0000000000..1bd76b28c2 --- /dev/null +++ b/vcpkg/ports/qtmultimedia/remove-static-ssl-stub.patch @@ -0,0 +1,26 @@ +diff --git a/src/plugins/multimedia/ffmpeg/cmake/QtAddFFmpegStubs.cmake b/src/plugins/multimedia/ffmpeg/cmake/QtAddFFmpegStubs.cmake +index 5778ae4d23..8c0df4b44d 100644 +--- a/src/plugins/multimedia/ffmpeg/cmake/QtAddFFmpegStubs.cmake ++++ b/src/plugins/multimedia/ffmpeg/cmake/QtAddFFmpegStubs.cmake +@@ -70,7 +70,10 @@ macro(qt_internal_multimedia_find_openssl_soversion) + if (NOT OPENSSL_SSL_LIBRARY) + message(FATAL_ERROR "OPENSSL_SSL_LIBRARY is not found") + endif() +- ++ set(openssl_is_shared ON) ++ if(OPENSSL_SSL_LIBRARY MATCHES "${CMAKE_STATIC_LIBRARY_SUFFIX}$") ++ set(openssl_is_shared OFF) ++ endif() + get_filename_component(ssl_lib_realpath "${OPENSSL_SSL_LIBRARY}" REALPATH) + string(REGEX MATCH "[0-9]+(\\.[0-9]+)*$" ssl_soversion "${ssl_lib_realpath}") + string(REGEX REPLACE "^3(\\..*|$)" "3" ssl_soversion "${ssl_soversion}") +@@ -187,6 +190,9 @@ function(qt_internal_multimedia_add_ffmpeg_stubs) + + if (ffmpeg_has_openssl) + qt_internal_multimedia_find_openssl_soversion() ++ if(NOT openssl_is_shared) ++ list(REMOVE_ITEM FFMPEG_STUBS ssl crypto) ++ endif() + endif() + + foreach (stub ${FFMPEG_STUBS}) diff --git a/vcpkg/ports/qtmultimedia/static_find_modules.patch b/vcpkg/ports/qtmultimedia/static_find_modules.patch new file mode 100644 index 0000000000..68957566f6 --- /dev/null +++ b/vcpkg/ports/qtmultimedia/static_find_modules.patch @@ -0,0 +1,82 @@ +diff --git a/cmake/FindFFmpeg.cmake b/cmake/FindFFmpeg.cmake +index 47d8769..46a5c9b 100644 +--- a/cmake/FindFFmpeg.cmake ++++ b/cmake/FindFFmpeg.cmake +@@ -215,7 +215,7 @@ foreach (_component ${FFmpeg_FIND_COMPONENTS}) + find_component(${_component} "lib${library}" ${library} "lib${library}/${library}.h") + + if (${_component}_FOUND) +- list(APPEND FFMPEG_LIBRARIES ${${_component}_LIBRARY_NAME}) ++ list(APPEND FFMPEG_LIBRARIES ${${_component}_LIBRARY}) + list(APPEND FFMPEG_DEFINITIONS ${${_component}_DEFINITIONS}) + list(APPEND FFMPEG_INCLUDE_DIRS ${${_component}_INCLUDE_DIR}) + list(APPEND FFMPEG_LIBRARY_DIRS ${${_component}_LIBRARY_DIR}) +@@ -306,18 +306,19 @@ endfunction() + string(TOLOWER ${_component} _lowerComponent) + if (NOT TARGET FFmpeg::${_lowerComponent}) +- add_library(FFmpeg::${_lowerComponent} INTERFACE IMPORTED) ++ add_library(FFmpeg::${_lowerComponent} UNKNOWN IMPORTED) + set_target_properties(FFmpeg::${_lowerComponent} PROPERTIES + INTERFACE_COMPILE_OPTIONS "${${_component}_DEFINITIONS}" + INTERFACE_INCLUDE_DIRECTORIES ${${_component}_INCLUDE_DIR} +- INTERFACE_LINK_LIBRARIES "${${_component}_LIBRARY_NAME}" +- INTERFACE_LINK_DIRECTORIES "${${_component}_LIBRARY_DIR}" ++ IMPORTED_LOCATION "${${_component}_LIBRARY}" + ) + + __ffmpeg_internal_set_dependencies(${_component}) +- target_link_libraries(FFmpeg::${_lowerComponent} INTERFACE "${${_component}_LIBRARY_NAME}") ++ if(WIN32 AND _lowerComponent STREQUAL "avutil") ++ target_link_libraries(FFmpeg::${_lowerComponent} INTERFACE "Bcrypt.lib") ++ endif() + if (UNIX AND NOT APPLE) + target_link_options(FFmpeg::${_lowerComponent} INTERFACE "-Wl,--exclude-libs=lib${_lowerComponent}") + endif () + endif() + endif() + endforeach () +@@ -361,14 +364,18 @@ if (shared_libs_desired AND NOT FFMPEG_SHARED_COMPONENTS) + endif() + + if (NOT TARGET FFmpeg::FFmpeg) +- add_library(FFmpeg INTERFACE) ++ add_library(FFmpeg INTERFACE IMPORTED) + set_target_properties(FFmpeg PROPERTIES + INTERFACE_COMPILE_OPTIONS "${FFMPEG_DEFINITIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${FFMPEG_INCLUDE_DIRS}" +- INTERFACE_LINK_LIBRARIES "${FFMPEG_LIBRARIES}" + INTERFACE_LINK_DIRECTORIES "${FFMPEG_LIBRARY_DIRS}" + ) ++ target_link_libraries(FFmpeg INTERFACE ${FFMPEG_LIBRARIES}) +- add_library(FFmpeg::FFmpeg ALIAS FFmpeg) ++ if(WIN32) ++ target_link_libraries(FFmpeg INTERFACE "Bcrypt.lib") ++ endif() ++ add_library(FFmpeg::FFmpeg INTERFACE IMPORTED) ++ target_link_libraries(FFmpeg::FFmpeg INTERFACE FFmpeg) + endif() + + # Compile the list of required vars +diff --git a/cmake/FindGObject.cmake b/cmake/FindGObject.cmake +index 19a8a67..09e95d1 100644 +--- a/cmake/FindGObject.cmake ++++ b/cmake/FindGObject.cmake +@@ -13,8 +13,8 @@ + # ``GObject::GObject`` + # The gobject-2.0 library + +-include(CMakeFindDependencyMacro) +-find_dependency(GLIB2) ++find_package(GLIB2) ++find_package(libffi) + qt_internal_disable_find_package_global_promotion(GLIB2::GLIB2) + + if(NOT TARGET GObject::GObject) +@@ -40,6 +40,7 @@ if(NOT TARGET GObject::GObject) + target_link_libraries(GObject::GObject INTERFACE + ${GObject_LIBRARY} + GLIB2::GLIB2 ++ libffi + ) + endif() + include(FindPackageHandleStandardArgs) diff --git a/vcpkg/ports/qtmultimedia/vcpkg.json b/vcpkg/ports/qtmultimedia/vcpkg.json new file mode 100644 index 0000000000..1f0bd38348 --- /dev/null +++ b/vcpkg/ports/qtmultimedia/vcpkg.json @@ -0,0 +1,90 @@ +{ + "name": "qtmultimedia", + "version": "6.7.3", + "description": "Qt Multimedia is an add-on module that provides a rich set of QML types and C++ classes to handle multimedia content.", + "homepage": "https://www.qt.io/", + "license": null, + "dependencies": [ + { + "name": "qtbase", + "default-features": false, + "features": [ + "concurrent", + "gui", + "network" + ] + }, + { + "name": "qtshadertools", + "default-features": false + } + ], + "default-features": [ + { + "name": "gstreamer", + "platform": "linux" + }, + "widgets" + ], + "features": { + "ffmpeg": { + "description": "Build with ffmpeg", + "dependencies": [ + { + "name": "ffmpeg", + "default-features": false, + "features": [ + "avcodec", + "avdevice", + "avformat", + "swresample", + "swscale" + ] + }, + { + "name": "pulseaudio", + "platform": "linux" + }, + { + "name": "qtdeclarative", + "default-features": false + } + ] + }, + "gstreamer": { + "description": "Build with gstreamer", + "supports": "linux", + "dependencies": [ + "egl", + { + "name": "gstreamer", + "default-features": false, + "features": [ + "plugins-base" + ] + } + ] + }, + "qml": { + "description": "Build QML imports", + "dependencies": [ + { + "name": "qtdeclarative", + "default-features": false + } + ] + }, + "widgets": { + "description": "Build Multimedia Widgets", + "dependencies": [ + { + "name": "qtbase", + "default-features": false, + "features": [ + "widgets" + ] + } + ] + } + } +}