summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Dyomin <artem.dyomin@qt.io>2023-08-10 09:50:44 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-08-11 16:30:38 +0000
commit8224f487472396184b8efd5d7920c9059d79b5b4 (patch)
tree622183edec99dfe941a1db8d1edbdf0438500b9d
parente78d7d156930a73bbc772f3224fc3b4db9ca2504 (diff)
Fix parsing *.pc file in FindFFmpeg.cmake
The build failure is not reproduced on CI but can be reproduced locally if adding additional deps to the ffmpeg build. In this case, deps may contain '-L:/usr/.../arm64-linux-gnu', the prev regex found -l in the middle of the path and caused a compilation error. Change-Id: I56c229513a1d3752804d3da08e08785738feee0a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> Reviewed-by: Lars Knoll <lars@knoll.priv.no> (cherry picked from commit a6864238d4d4d3ca2764c36829eb2b029d175ff3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--cmake/FindFFmpeg.cmake33
1 files changed, 18 insertions, 15 deletions
diff --git a/cmake/FindFFmpeg.cmake b/cmake/FindFFmpeg.cmake
index 8157091bf..ead6f7690 100644
--- a/cmake/FindFFmpeg.cmake
+++ b/cmake/FindFFmpeg.cmake
@@ -181,26 +181,29 @@ function(__ffmpeg_internal_set_dependencies lib)
if(EXISTS ${PC_FILE})
file(READ ${PC_FILE} pcfile)
+ set(prefix_l "(^| )\\-l")
+ set(suffix_lib "\\.lib($| )")
+
string(REGEX REPLACE ".*Libs:([^\n\r]+).*" "\\1" out "${pcfile}")
- string(REGEX MATCHALL "\\-l[^ ]+" libs_dependency ${out})
- string(REGEX MATCHALL "[^ ]+\\.lib" libs_dependency_lib ${out})
+ 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 "\\-l[^ ]+" libs_private_dependency ${out})
- string(REGEX MATCHALL "[^ ]+\\.lib" libs_private_dependency_lib ${out})
-
- list(APPEND no_suffix ${libs_dependency} ${libs_private_dependency})
- list(APPEND lib_suffix ${libs_dependency_lib} ${libs_private_dependency_lib})
-
- foreach(d ${no_suffix})
- string(REGEX REPLACE "\\-l" "" d ${d})
- if(NOT ${lib} STREQUAL ${d})
- target_link_libraries(FFmpeg::${lib} INTERFACE ${d})
+ string(REGEX MATCHALL "${prefix_l}[^ ]+" libs_private_dependency ${out})
+ string(REGEX MATCHALL "[^ ]+${suffix_lib}" libs_private_dependency_lib ${out})
+
+ list(APPEND deps_no_suffix ${libs_dependency} ${libs_private_dependency})
+ foreach(dependency ${deps_no_suffix})
+ string(REGEX REPLACE ${prefix_l} "" dependency ${dependency})
+ if(NOT ${lib} STREQUAL ${dependency})
+ target_link_libraries(FFmpeg::${lib} INTERFACE ${dependency})
endif()
endforeach()
- foreach(d ${lib_suffix})
- string(REGEX REPLACE "\\.lib" "" d ${d})
- target_link_libraries(FFmpeg::${lib} INTERFACE ${d})
+
+ list(APPEND deps_lib_suffix ${libs_dependency_lib} ${libs_private_dependency_lib})
+ foreach(dependency ${deps_lib_suffix})
+ string(REGEX REPLACE ${suffix_lib} "" dependency ${dependency})
+ target_link_libraries(FFmpeg::${lib} INTERFACE ${dependency})
endforeach()
endif()
endfunction()