cmake: prefer system ffmpeg library (#451)

This commit is contained in:
Alexandre Bouvier 2024-08-16 15:56:47 +00:00 committed by GitHub
parent c1fb5d5bca
commit ad60ae1d40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 2 deletions

View File

@ -67,6 +67,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/common/scm_rev.cpp.in" "${CMAKE_
find_package(Boost 1.84.0 CONFIG) find_package(Boost 1.84.0 CONFIG)
find_package(cryptopp 8.9.0 MODULE) find_package(cryptopp 8.9.0 MODULE)
find_package(FFmpeg 5.1.2 MODULE)
find_package(fmt 10.2.1 CONFIG) find_package(fmt 10.2.1 CONFIG)
find_package(glslang 14.2.0 CONFIG) find_package(glslang 14.2.0 CONFIG)
find_package(magic_enum 0.9.6 CONFIG) find_package(magic_enum 0.9.6 CONFIG)
@ -607,7 +608,7 @@ endif()
create_target_directory_groups(shadps4) create_target_directory_groups(shadps4)
target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt toml11::toml11 tsl::robin_map xbyak::xbyak Tracy::TracyClient RenderDoc::API ffmpeg) target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt toml11::toml11 tsl::robin_map xbyak::xbyak Tracy::TracyClient RenderDoc::API FFmpeg::ffmpeg)
target_link_libraries(shadps4 PRIVATE Boost::headers GPUOpen::VulkanMemoryAllocator sirit Vulkan::Headers xxHash::xxhash Zydis::Zydis glslang::SPIRV glslang::glslang SDL3::SDL3) target_link_libraries(shadps4 PRIVATE Boost::headers GPUOpen::VulkanMemoryAllocator sirit Vulkan::Headers xxHash::xxhash Zydis::Zydis glslang::SPIRV glslang::glslang SDL3::SDL3)
if (APPLE) if (APPLE)

23
cmake/FindFFmpeg.cmake Normal file
View File

@ -0,0 +1,23 @@
# SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later
find_package(PkgConfig QUIET)
pkg_check_modules(FFMPEG QUIET IMPORTED_TARGET libavcodec libavfilter libavformat libavutil libswresample libswscale)
find_file(FFMPEG_VERSION_FILE libavutil/ffversion.h HINTS "${FFMPEG_libavutil_INCLUDEDIR}")
if (FFMPEG_VERSION_FILE)
file(STRINGS "${FFMPEG_VERSION_FILE}" FFMPEG_VERSION_LINE REGEX "FFMPEG_VERSION")
string(REGEX MATCH "[0-9.]+" FFMPEG_VERSION "${FFMPEG_VERSION_LINE}")
unset(FFMPEG_VERSION_LINE)
unset(FFMPEG_VERSION_FILE)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFmpeg
REQUIRED_VARS FFMPEG_LINK_LIBRARIES
VERSION_VAR FFMPEG_VERSION
)
if (FFmpeg_FOUND AND NOT TARGET FFmpeg::ffmpeg)
add_library(FFmpeg::ffmpeg ALIAS PkgConfig::FFMPEG)
endif()

View File

@ -47,9 +47,10 @@ else()
endif() endif()
endif() endif()
if (NOT TARGET ffmpeg) if (NOT TARGET FFmpeg::ffmpeg)
set(ARCHITECTURE "x86_64") set(ARCHITECTURE "x86_64")
add_subdirectory(ffmpeg-core) add_subdirectory(ffmpeg-core)
add_library(FFmpeg::ffmpeg ALIAS ffmpeg)
endif() endif()
# Zlib-Ng # Zlib-Ng