Skip to content

Commit

Permalink
CMake: Copy FFmpeg dylibs into Mac bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Aug 12, 2024
1 parent 5786f3a commit f48d3b4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
18 changes: 17 additions & 1 deletion CMakeModules/FindFFMPEG.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,23 @@ function (_ffmpeg_find component headername)
PARENT_SCOPE)

set(version_header_path "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h")
if (EXISTS "${version_header_path}")
set(major_version_header_path "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version_major.h")
if (EXISTS "${major_version_header_path}")
string(TOUPPER "${component}" component_upper)
file(STRINGS "${major_version_header_path}" major_version
REGEX "#define *LIB${component_upper}_VERSION_MAJOR ")
file(STRINGS "${version_header_path}" version
REGEX "#define *LIB${component_upper}_VERSION_(MINOR|MICRO) ")
string(REGEX REPLACE ".*_MAJOR *\([0-9]*\).*" "\\1" major "${major_version}")
string(REGEX REPLACE ".*_MINOR *\([0-9]*\).*" "\\1" minor "${version}")
string(REGEX REPLACE ".*_MICRO *\([0-9]*\).*" "\\1" micro "${version}")
if (NOT major STREQUAL "" AND
NOT minor STREQUAL "" AND
NOT micro STREQUAL "")
set("FFMPEG_${component}_VERSION" "${major}.${minor}.${micro}"
PARENT_SCOPE)
endif ()
elseif (EXISTS "${version_header_path}")
string(TOUPPER "${component}" component_upper)
file(STRINGS "${version_header_path}" version
REGEX "#define *LIB${component_upper}_VERSION_(MAJOR|MINOR|MICRO) ")
Expand Down
10 changes: 9 additions & 1 deletion src/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,15 @@ function(add_util_resources target)

# Copy shaderc into the bundle
get_target_property(SPIRV_CROSS_LIBRARY spirv-cross-c-shared IMPORTED_SONAME_RELEASE)
target_sources(duckstation-qt PRIVATE "${SHADERC_LIBRARY}" "${SPIRV_CROSS_LIBRARY}")
target_sources(${target} PRIVATE "${SHADERC_LIBRARY}" "${SPIRV_CROSS_LIBRARY}")
set_source_files_properties("${SHADERC_LIBRARY}" "${SPIRV_CROSS_LIBRARY}" PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks)

# Copy FFmpeg libraries into the bundle
foreach(component avcodec avformat avutil swresample swscale)
string(REGEX REPLACE "\([0-9]+\)\.[0-9]+\.[0-9]+" "\\1" major "${FFMPEG_${component}_VERSION}")
string(REPLACE "lib${component}.dylib" "lib${component}.${major}.dylib" version_lib "${FFMPEG_${component}_LIBRARIES}")
target_sources(${target} PRIVATE ${version_lib})
set_source_files_properties(${target} PRIVATE ${version_lib} PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks)
endforeach()
endif()
endfunction()

0 comments on commit f48d3b4

Please sign in to comment.