summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorArtem Dyomin <artem.dyomin@qt.io>2024-02-19 11:26:57 +0100
committerArtem Dyomin <artem.dyomin@qt.io>2024-02-26 15:52:48 +0000
commit8172efe2a7246cbb55b2306837bf3705734c89b3 (patch)
tree9d4cdde7c25447741f33b510edb76c5fdf49f6a1 /cmake
parent6f004bc9a492418c494a4ccdacb594c3f1f46282 (diff)
Fix finding dynamic ffmpeg on Windows/arm/llvm-mingw
Handle the corner case on Windows/arm/llvm-mingw compiler: The compiler generates auxiliary static libs in the 'lib' folder and cmake finds those instead of *.lib in the 'bin' folder. The libs look like lib/libavutil.dll.a. The previous approach didn't find the matching dll. Let's handle the corner case even though we don't have it on CI. The message with dumping found shared libs helps easily check on CI whether the libs are found. Pick-to: 6.7 6.6 6.5 Change-Id: Idc5b4aba0f9c60361336321138b1c078526075d4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/FindFFmpeg.cmake29
1 files changed, 25 insertions, 4 deletions
diff --git a/cmake/FindFFmpeg.cmake b/cmake/FindFFmpeg.cmake
index 9d24acde8..fbb2bca81 100644
--- a/cmake/FindFFmpeg.cmake
+++ b/cmake/FindFFmpeg.cmake
@@ -73,6 +73,30 @@ if (QT_DEPLOY_FFMPEG AND BUILD_SHARED_LIBS)
set(shared_libs_required TRUE)
endif()
+# finds ffmpeg libs, including symlinks, for the specified component.
+macro(find_shared_libs_for_component _component)
+ # the searching pattern is pretty rough but it seems to be sufficient to gather dynamic libs
+ get_filename_component(name_we ${${_component}_LIBRARY} NAME_WE)
+
+ if (WIN32)
+ get_filename_component(dir_name ${${_component}_LIBRARY_DIR} NAME)
+ if (${dir_name} STREQUAL "lib" AND EXISTS "${${_component}_LIBRARY_DIR}/../bin")
+ # llvm-mingv builds aux ffmpeg static libs like lib/libavutil.dll.a and cmake finds
+ # only them even though the folder bin/ contains proper *.dll and *.lib.
+
+ string(REGEX REPLACE "^lib" "" name_we "${name_we}")
+ set(shared_lib_pattern "../bin/${name_we}*${CMAKE_SHARED_LIBRARY_SUFFIX}")
+ else()
+ set(shared_lib_pattern "${name_we}*${CMAKE_SHARED_LIBRARY_SUFFIX}")
+ endif()
+
+ else()
+ set(shared_lib_pattern "${name_we}*${CMAKE_SHARED_LIBRARY_SUFFIX}*")
+ endif()
+
+ file(GLOB ${_component}_SHARED_LIBRARIES "${${_component}_LIBRARY_DIR}/${shared_lib_pattern}")
+endmacro()
+
#
### Macro: set_component_found
#
@@ -167,10 +191,7 @@ macro(find_component _component _pkgconfig _library _header)
# On Windows, shared linking goes through 'integration' static libs, so we should look for shared ones anyway
# On Unix, we gather symlinks as well so that we could install them.
if (WIN32 OR ${${_component}_LIBRARY_NAME} MATCHES "\\${CMAKE_SHARED_LIBRARY_SUFFIX}$")
- # the searching pattern is pretty rough but it seems to be sufficient to gather dynamic libs
- get_filename_component(name_we ${${_component}_LIBRARY} NAME_WE)
-
- file(GLOB ${_component}_SHARED_LIBRARIES "${${_component}_LIBRARY_DIR}/${name_we}*${CMAKE_SHARED_LIBRARY_SUFFIX}*")
+ find_shared_libs_for_component(${_component})
endif()
endif()