summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArtem Dyomin <artem.dyomin@qt.io>2023-12-06 13:08:09 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-12-22 10:25:41 +0000
commit6290ad911e4eafd255b86606d2edd6de2fa2846d (patch)
tree69869c07317c3017ab29b320f5a3e2fbd7732970 /src
parent24a43429e215a7bfc9c6cecf8f236fdec945dccf (diff)
Implement shipping of dynamic ffmpeg together with the ffmpeg plugin
This is the first patch that implements ffmpeg shipping for both cases, building and installation. * deploy ffmpeg to plugins/multimedia/ffmpeg, as it should go together with the ffmpeg plugin. * ffmpeg deployment should be explicitly enquired via the option: -DQT_DEPLOY_FFMPEG=TRUE. The idea is to turn it on only when we or users need it, as users might have other compilation environments (e.g. it's so with boot2qt). Setting the flag for static qt builds is to be implemented later on. * Tested on Windows, Linux, macOS, some platform-specific details - On Unix platforms, ffmpeg libs might be put to plugins/multimedia/ffmpeg, closer to the ffmpeg plugin. However, on the current step, it was decided to deploy to the library directory. - On Windows, ffmpeg shared libs are linked through auxiliary static ones, it's handled in cmake scripts in the patch. - On Linux and Android, we will compile openssl and maybe vaapi stub shared libs and deploy the together with ffmpeg. - For Unix platforms, we will need to implement fixing of rpaths e.g. set 'ORIGIN' and hardcoded dylib deps (macOS). It will be done on the level of ffmpeg building on CI (install-ffmpeg.sh). Pick-to: 6.6 6.5 Change-Id: Ib7ce480b5412302f5d7ae9b247d5a5e87406a806 Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 545ffc25a7d8b544c6257892c24fe4f433c1e5cf) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/multimedia/ffmpeg/CMakeLists.txt17
-rw-r--r--src/plugins/multimedia/ffmpeg/cmake/QtDeployFFmpeg.cmake43
2 files changed, 58 insertions, 2 deletions
diff --git a/src/plugins/multimedia/ffmpeg/CMakeLists.txt b/src/plugins/multimedia/ffmpeg/CMakeLists.txt
index 1be16e268..806d31635 100644
--- a/src/plugins/multimedia/ffmpeg/CMakeLists.txt
+++ b/src/plugins/multimedia/ffmpeg/CMakeLists.txt
@@ -57,7 +57,6 @@ qt_internal_add_plugin(QFFmpegMediaPlugin
LIBRARIES
Qt::MultimediaPrivate
Qt::CorePrivate
- FFmpeg::avformat FFmpeg::avcodec FFmpeg::swresample FFmpeg::swscale FFmpeg::avutil
)
if(DYNAMIC_RESOLVE_OPENSSL_SYMBOLS)
@@ -75,7 +74,7 @@ qt_internal_extend_target(QFFmpegMediaPlugin CONDITION DYNAMIC_RESOLVE_OPENSSL_S
if (ENABLE_DYNAMIC_RESOLVE_VAAPI_SYMBOLS)
if (QT_FEATURE_vaapi AND NOT DYNAMIC_RESOLVE_VAAPI_SYMBOLS)
- if (FFMPEG_IS_STATIC)
+ if (NOT FFMPEG_SHARED_LIBRARIES)
message(WARNING
"QT_FEATURE_vaapi is found but statically built ffmpeg doesn't include vaapi,"
"however dynamic symbols resolve is possible.")
@@ -242,3 +241,17 @@ if (ANDROID)
android.permission.MODIFY_AUDIO_SETTINGS
)
endif()
+
+# TODO: get libs from FindFFmpeg.cmake
+set(ffmpeg_libs FFmpeg::avformat FFmpeg::avcodec FFmpeg::swresample FFmpeg::swscale FFmpeg::avutil)
+
+if (QT_DEPLOY_FFMPEG AND NOT BUILD_SHARED_LIBS)
+ message(FATAL_ERROR "QT_DEPLOY_FFMPEG is not implemented yet for static builds")
+endif()
+
+if (QT_DEPLOY_FFMPEG AND FFMPEG_SHARED_LIBRARIES AND BUILD_SHARED_LIBS)
+ include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtDeployFFmpeg.cmake")
+ qt_internal_multimedia_copy_or_install_ffmpeg()
+endif()
+
+qt_internal_extend_target(QFFmpegMediaPlugin LIBRARIES ${ffmpeg_libs})
diff --git a/src/plugins/multimedia/ffmpeg/cmake/QtDeployFFmpeg.cmake b/src/plugins/multimedia/ffmpeg/cmake/QtDeployFFmpeg.cmake
new file mode 100644
index 000000000..5e7d4b552
--- /dev/null
+++ b/src/plugins/multimedia/ffmpeg/cmake/QtDeployFFmpeg.cmake
@@ -0,0 +1,43 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+function(qt_internal_multimedia_set_ffmpeg_link_directory directory)
+ foreach (lib ${ffmpeg_libs} FFmpeg)
+ set_target_properties(${lib} PROPERTIES INTERFACE_LINK_DIRECTORIES ${directory})
+ endforeach()
+endfunction()
+
+function(qt_internal_multimedia_copy_or_install_ffmpeg)
+ if (WIN32)
+ set(install_dir ${INSTALL_BINDIR})
+ else()
+ set(install_dir ${INSTALL_LIBDIR})
+ endif()
+
+ if (QT_WILL_INSTALL)
+ qt_install(FILES "${FFMPEG_SHARED_LIBRARIES}" DESTINATION ${install_dir})
+ else()
+ # elseif(NOT WIN32) actually we can just drop the coping for unix platforms
+ # However, it makes sense to copy anyway for consistency:
+ # in order to have the same configuration for developer builds.
+
+ set(ffmpeg_output_dir "${QT_BUILD_DIR}/${install_dir}")
+ file(MAKE_DIRECTORY ${ffmpeg_output_dir})
+
+ foreach(lib_path ${FFMPEG_SHARED_LIBRARIES})
+ get_filename_component(lib_name ${lib_path} NAME)
+ if(NOT EXISTS "${ffmpeg_output_dir}/${lib_name}")
+ file(COPY ${lib_path} DESTINATION ${ffmpeg_output_dir})
+ endif()
+ endforeach()
+
+ # On Windows, shared linking goes through 'integration' static libs,
+ # otherwise we should link the directory with copied libs
+ if (NOT WIN32)
+ qt_internal_multimedia_set_ffmpeg_link_directory(${ffmpeg_output_dir})
+ endif()
+ endif()
+
+ # Should we set the compile definition for the plugin or for the QtMM module?
+ # target_compile_definitions(QFFmpegMediaPlugin PRIVATE FFMPEG_DEPLOY_FOLDER="${FFMPEG_DEPLOY_FOLDER}")
+endfunction()