1
0
Fork 0

Workaround cmake's random library order in external_ffmpeg

This commit is contained in:
Ilya Fedin 2022-04-19 15:54:00 +04:00 committed by John Preston
parent b8b517a5e0
commit 2e1d9c80d9

View file

@ -24,15 +24,19 @@ if (DESKTOP_APP_USE_PACKAGED)
PkgConfig::SWSCALE
PkgConfig::SWRESAMPLE
)
else()
return()
endif()
set(ffmpeg_lib_list)
if (LINUX)
target_link_static_libraries(external_ffmpeg
INTERFACE
avformat
avcodec
swresample
swscale
avutil
list(APPEND ffmpeg_lib_list
-lavformat
-lavcodec
-lswresample
-lswscale
-lavutil
)
else()
set(ffmpeg_lib_loc ${libs_loc}/ffmpeg)
@ -42,8 +46,7 @@ else()
${ffmpeg_lib_loc}
)
target_link_libraries(external_ffmpeg
INTERFACE
list(APPEND ffmpeg_lib_list
${ffmpeg_lib_loc}/libavformat/libavformat.a
${ffmpeg_lib_loc}/libavcodec/libavcodec.a
${ffmpeg_lib_loc}/libswresample/libswresample.a
@ -52,17 +55,33 @@ else()
)
endif()
target_link_libraries(external_ffmpeg
INTERFACE
$<LINK_ONLY:desktop-app::external_opus>
list(APPEND ffmpeg_lib_list
$<TARGET_FILE:desktop-app::external_opus>
$<LINK_ONLY:desktop-app::external_vpx>
$<TARGET_FILE:desktop-app::external_vpx>
)
if (APPLE)
target_link_libraries(external_ffmpeg INTERFACE bz2)
list(APPEND ffmpeg_lib_list bz2)
elseif (LINUX)
target_link_static_libraries(external_ffmpeg INTERFACE lzma)
list(APPEND ffmpeg_lib_list -llzma)
endif()
# Workaround cmake's random order on Linux...
if (LINUX)
list(JOIN ffmpeg_lib_list , ffmpeg_lib_link)
target_link_libraries(external_ffmpeg
INTERFACE
-Wl,--push-state,-Bstatic,${ffmpeg_lib_link},--pop-state
)
else()
target_link_libraries(external_ffmpeg
INTERFACE
${ffmpeg_lib_list}
)
endif()
target_link_libraries(external_ffmpeg
INTERFACE
$<LINK_ONLY:desktop-app::external_opus>
$<LINK_ONLY:desktop-app::external_vpx>
)